Commit 222c5b16 by liumengfei

修复bug

parent 887c45c5
...@@ -79,7 +79,10 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal ...@@ -79,7 +79,10 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
$ids = []; $ids = [];
$sku = $content[0]['sku']; $sku = $content[0]['sku'];
foreach ($content as $entry){ 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->setMediaType($entry['media_type']);
$this->entry->setDisabled($entry['disabled']); $this->entry->setDisabled($entry['disabled']);
$this->entry->setFile($entry['file']); $this->entry->setFile($entry['file']);
...@@ -93,11 +96,21 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal ...@@ -93,11 +96,21 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
$imageContent->setType($entry['content']['type']); $imageContent->setType($entry['content']['type']);
$this->entry->setContent($imageContent); $this->entry->setContent($imageContent);
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); $id = $this->create($sku,$this->entry);
}
if (is_numeric((int)$id)){ if (is_numeric((int)$id)){
$ids []= (int)$id; $ids []= (int)$id;
} }
$this->entry->setData([]);
} }
if (!$ids){ if (!$ids){
throw new StateException(__('Batch upload of product images failed')); throw new StateException(__('Batch upload of product images failed'));
......
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