Commit 9bdab0d2 by liumengfei

Y优化数据结构

parent 674ecee7
...@@ -76,9 +76,10 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal ...@@ -76,9 +76,10 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal
if (empty($content)) { if (empty($content)) {
return 0; return 0;
} }
$ids = true; $ids = [];
$sku = $content[0]['sku']; $sku = $content[0]['sku'];
foreach ($content as $entry){ foreach ($content as $entry){
$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']);
...@@ -92,15 +93,24 @@ class GalleryManagement implements \Joshine\Catalog\Api\ProductAttributeMediaGal ...@@ -92,15 +93,24 @@ 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);
$id = $this->create($sku,$this->entry); $id = $this->create($sku,$this->entry);
if (!is_numeric((int)$id)){ if (is_numeric((int)$id)){
$ids = false; $ids []= (int)$id;
} }
} }
if (!$ids){ if (!$ids){
throw new StateException(__('Batch upload of product images failed')); throw new StateException(__('Batch upload of product images failed'));
} }
return $this->getList($sku);
$list = $this->getList($sku);
foreach ($list as $key => $v) {
if (!in_array($v->getId(),$ids)) {
unset($list[$key]);
}
}
array_multisort($list);
return $list;
} }
......
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