如果有人可以幫助我,我嘗試在我的產品中添加影像,但沒有出現影像!
我的代碼:
$xml = simplexml_load_file('php://input');
$product = new Product($xml->id);
$product->id_category_default = (int)$xml->id_category_default; //categories
$product->name = $xml->name; //nom produit
$product->price = $xml->price; //prix
$product->id_tax_rules_group = (int)$xml->id_tax_rules_group; //1=20%; 2=10%; 3=5.5%; 4=2.1%; 5=EU VAT For Virtual Products
$product->ean13 = $xml->ean13; //code barre
$product->description = $xml->description; //description
$product->description_short = $xml->description_short; //petite description
$product->reference = $xml->reference; //reference
$product->weight = $xml->weight; //poids
$product->height = $xml->height; //hauteur
$product->width = $xml->width; //largeur
$product->depth = $xml->depth; //profondeur
$url = "https://www.google.com/logos/doodles/2014/first-day-of-school-2014-5475863151771648-hp.jpg";
$image = new Image();
$image->id_product = (int)$product->id;
$image->position = Image::getHighestPosition($product->id) 1;
$image->cover = true; // or false;
$image->add();
AdminImportControllerCore::copyImg((int)$product->id, (int)$image->id, $url, 'products', false);
$product->active = true;
$product->save();
謝謝 !
uj5u.com熱心網友回復:
AdminImportControllerCore::copyImg()是受保護的方法,不能在AdminImportController范圍之外呼叫。
考慮將copyImg()方法移動到您的腳本中。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/489245.html
標籤:php xml prestashop
上一篇:如何序列化完整串列而不是逐行
