Commit fe6802e3 by liumengfei

优化批量上传产品图片接口

parent 94b8b160
......@@ -74,7 +74,7 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
public function add($content)
{
if (empty($content)) {
return 0;
throw new StateException(__("request update date is null ,so failed"));
}
$ids = [];
$sku = $content[0]['sku'];
......@@ -85,17 +85,10 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
}
$this->entry->setMediaType($entry['media_type']);
$this->entry->setDisabled($entry['disabled']);
$this->entry->setFile($entry['file']);
$this->entry->setPosition($entry['position']);
$this->entry->setLabel($entry['label']);
$this->entry->setTypes($entry['types']);
$imageContent = new ImageContent();
$imageContent->setBase64EncodedData($entry['content']['base64_encoded_data']);
$imageContent->setName($entry['content']['name']);
$imageContent->setType($entry['content']['type']);
$this->entry->setContent($imageContent);
if ($entry_id){
$this->entry->setId($entry_id);
$result = $this->update($sku,$this->entry);
......@@ -105,6 +98,12 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
throw new StateException(__("$entry_id update failed"));
}
}else{
$this->entry->setFile($entry['file']);
$imageContent = new ImageContent();
$imageContent->setBase64EncodedData($entry['content']['base64_encoded_data']);
$imageContent->setName($entry['content']['name']);
$imageContent->setType($entry['content']['type']);
$this->entry->setContent($imageContent);
$id = $this->create($sku,$this->entry);
}
if (is_numeric((int)$id)){
......
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