Commit 222c5b16 by liumengfei

修复bug

parent 887c45c5
......@@ -79,7 +79,10 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
$ids = [];
$sku = $content[0]['sku'];
foreach ($content as $entry){
$entry_id = 0;
if (key_exists("id",$entry)){
$entry_id= (int)$entry["id"];
}
$this->entry->setMediaType($entry['media_type']);
$this->entry->setDisabled($entry['disabled']);
$this->entry->setFile($entry['file']);
......@@ -93,11 +96,21 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
$imageContent->setType($entry['content']['type']);
$this->entry->setContent($imageContent);
$id = $this->create($sku,$this->entry);
if ($entry_id){
$this->entry->setId($entry_id);
$result = $this->update($sku,$this->entry);
if ($result){
$id = $entry_id;
}else{
throw new StateException(__("$entry_id update failed"));
}
}else{
$id = $this->create($sku,$this->entry);
}
if (is_numeric((int)$id)){
$ids []= (int)$id;
}
$this->entry->setData([]);
}
if (!$ids){
throw new StateException(__('Batch upload of product images failed'));
......@@ -204,7 +217,7 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
}
/**
* @inheritdoc
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment