Commit 1a71dde2 by lmf

恢复接口

parent e2e35062
...@@ -88,8 +88,6 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -88,8 +88,6 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
return $entry->getId(); return $entry->getId();
} }
} }
return true;
throw new StateException(__('The new media gallery entry failed to save.')); throw new StateException(__('The new media gallery entry failed to save.'));
} }
...@@ -102,7 +100,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -102,7 +100,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
$existingMediaGalleryEntries = $product->getMediaGalleryEntries(); $existingMediaGalleryEntries = $product->getMediaGalleryEntries();
if ($existingMediaGalleryEntries == null) { if ($existingMediaGalleryEntries == null) {
throw new NoSuchEntityException( throw new NoSuchEntityException(
__('No image with the provided ID was found. Verify the ID and try again 1.') __('No image with the provided ID was found. Verify the ID and try again.')
); );
} }
$found = false; $found = false;
...@@ -110,15 +108,15 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -110,15 +108,15 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
foreach ($existingMediaGalleryEntries as $key => $existingEntry) { foreach ($existingMediaGalleryEntries as $key => $existingEntry) {
$existingEntryTypes = (array)$existingEntry->getTypes(); $existingEntryTypes = (array)$existingEntry->getTypes();
$existingEntry->setTypes(array_diff($existingEntryTypes, $entryTypes)); $existingEntry->setTypes(array_diff($existingEntryTypes, $entryTypes));
$this->remove($sku,$entry->getId());
// if ($existingEntry->getId() == $entry->getId()) { if ($existingEntry->getId() == $entry->getId()) {
// $found = true; $found = true;
// $existingMediaGalleryEntries[$key] = $entry; $existingMediaGalleryEntries[$key] = $entry;
// } }
} }
if (!$found) { if (!$found) {
throw new NoSuchEntityException( throw new NoSuchEntityException(
__('No image with the provided ID was found. Verify the ID and try again 2.') __('No image with the provided ID was found. Verify the ID and try again.')
); );
} }
$product->setMediaGalleryEntries($existingMediaGalleryEntries); $product->setMediaGalleryEntries($existingMediaGalleryEntries);
...@@ -128,8 +126,6 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -128,8 +126,6 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
} catch (\Exception $exception) { } catch (\Exception $exception) {
throw new StateException(__("The product can't be saved.")); throw new StateException(__("The product can't be saved."));
} }
return $this->create($sku,$entry);
return true; return true;
} }
...@@ -142,7 +138,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -142,7 +138,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
$existingMediaGalleryEntries = $product->getMediaGalleryEntries(); $existingMediaGalleryEntries = $product->getMediaGalleryEntries();
if ($existingMediaGalleryEntries == null) { if ($existingMediaGalleryEntries == null) {
throw new NoSuchEntityException( throw new NoSuchEntityException(
__('No image with the provided ID was found. Verify the ID and try again 3.') __('No image with the provided ID was found. Verify the ID and try again.')
); );
} }
$found = false; $found = false;
...@@ -155,7 +151,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -155,7 +151,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
} }
if (!$found) { if (!$found) {
throw new NoSuchEntityException( throw new NoSuchEntityException(
__('No image with the provided ID was found. Verify the ID and try again 4.') __('No image with the provided ID was found. Verify the ID and try again.')
); );
} }
$product->setMediaGalleryEntries($existingMediaGalleryEntries); $product->setMediaGalleryEntries($existingMediaGalleryEntries);
......
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