Commit e2e35062 by lmf

断点

parent 15b3dfaf
...@@ -88,6 +88,8 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -88,6 +88,8 @@ 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.'));
} }
...@@ -100,7 +102,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -100,7 +102,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.') __('No image with the provided ID was found. Verify the ID and try again 1.')
); );
} }
$found = false; $found = false;
...@@ -108,18 +110,15 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -108,18 +110,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;
// } // }
unset($existingMediaGalleryEntries[$key]);
$found = true;
break;
} }
if (!$found) { if (!$found) {
throw new NoSuchEntityException( throw new NoSuchEntityException(
__('No image with the provided ID was found. Verify the ID and try again.') __('No image with the provided ID was found. Verify the ID and try again 2.')
); );
} }
$product->setMediaGalleryEntries($existingMediaGalleryEntries); $product->setMediaGalleryEntries($existingMediaGalleryEntries);
...@@ -130,9 +129,8 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -130,9 +129,8 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
throw new StateException(__("The product can't be saved.")); throw new StateException(__("The product can't be saved."));
} }
return $this->create($sku,$entry); return $this->create($sku,$entry);
//return true; return true;
} }
/** /**
...@@ -144,7 +142,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -144,7 +142,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.') __('No image with the provided ID was found. Verify the ID and try again 3.')
); );
} }
$found = false; $found = false;
...@@ -157,7 +155,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -157,7 +155,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.') __('No image with the provided ID was found. Verify the ID and try again 4.')
); );
} }
$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