【发布时间】:2022-06-11 03:19:24
【问题描述】:
我在创建图像时遇到问题,当我运行代码时会创建一个图像,但它不想显示在我的主页中,但它在我的管理页面中显示得很好
我不明白这个问题,因为它在管理页面中显示得很好,如果有人可以帮助我!
我的代码:
$xml = simplexml_load_file('php://input');
$product = new Product($xml->id);
$product->category = [2, 7];
$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
$product->indexed = 1;
$product->active = true;
$product->save();
$product->updateCategories($product->category);
$e = $product->getDefaultIdProductAttribute();
StockAvailable::setQuantity($product->id, $e, $xml->quantity);
$image = new Image();
$image->id_product = $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = true;
$image->save();
AdminImportControllerCore::copyImg((int)$product->id, (int)$image->id, $xml->urlImage, 'products', false);
在我的主页上:
在我的管理页面上:
谢谢!
【问题讨论】:
标签: php xml prestashop