您好我需要使用PHP cURL发送图像,尝试这样做:
$this->ch = curl_init();
curl_setopt($this->ch, CURLOPT_URL, $URL);
$postValues = array(
'utf8' => $utf8,
'authenticity_token' => $auth_token,
'media_object[title]' => 'something',
'media_object[source]' => '',
'media_object[object_type]' => 0,
'media_object[image]'=>'@/home/me/images/something.jpg',
'captcha' => $captcha,
);
$n = 0;
$postStr = '';
foreach ($postValues as $name => $value) {
if ($n == 0)
$postStr .= $name . '=' . $value;
else
$postStr .= '&' . $name . '=' . $value;
$n++;
}
curl_setopt($this->ch, CURLOPT_URL, $url);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $postStr);
curl_setopt($this->ch, CURLOPT_POST,1);
curl_setopt($this->ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT …Run Code Online (Sandbox Code Playgroud) 正如主题所说,我有添加产品的问题(通过使用产品类).一切正常,但即使我指定$ product-> id = 1234; 它用这个id保存它,它只是自动增加数据库中的产品.但我真的需要将我自己的product_id插入数据库(因为我从地面strone数据库导入产品,他们需要经常更新)
这是我的代码:
$langId = (int) (Configuration::get('PS_LANG_DEFAULT'));
$p = new Product($prod['towar_id']);
$p->id = $prod['towar_id'];
$p->name = array($langId => $prod['nazwa']);
$p->ean13 = $prod['kod'];
$p->id_category_default = 6;
$p->category = array(6);
$p->link_rewrite = array($langId => Tools::link_rewrite($prod['nazwa']));
$p->weight = $prod['ile_kg_litrow'];
$p->quantity = $prod['magazyny']['magazyn']['stan_magazynu'];
$p->price = $prod['cena_detal'];
$p->add();
Run Code Online (Sandbox Code Playgroud)
那么有没有办法插入我自己的产品ID?