Commit cc735d1d by lmf

断点

parent 05106c46
...@@ -100,7 +100,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -100,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 11111111111.') __('No image with the provided ID was found. Verify the ID and try again.')
); );
} }
$found = false; $found = false;
...@@ -108,25 +108,27 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal ...@@ -108,25 +108,27 @@ 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) {
throw new NoSuchEntityException(
__('No image with the provided ID was found. Verify the ID and try again 22222222222.')
);
}
$product->setMediaGalleryEntries($existingMediaGalleryEntries);
try { return $this->create($sku,$entry);
$this->productRepository->save($product); // if (!$found) {
} catch (\Exception $exception) { // throw new NoSuchEntityException(
throw new StateException(__("The product can't be saved.")); // __('No image with the provided ID was found. Verify the ID and try again.')
} // );
return true; // }
// $product->setMediaGalleryEntries($existingMediaGalleryEntries);
//
// try {
// $this->productRepository->save($product);
// } catch (\Exception $exception) {
// throw new StateException(__("The product can't be saved."));
// }
// return true;
} }
/** /**
......
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