Commit cc735d1d by lmf

断点

parent 05106c46
......@@ -100,7 +100,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
$existingMediaGalleryEntries = $product->getMediaGalleryEntries();
if ($existingMediaGalleryEntries == null) {
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;
......@@ -108,25 +108,27 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
foreach ($existingMediaGalleryEntries as $key => $existingEntry) {
$existingEntryTypes = (array)$existingEntry->getTypes();
$existingEntry->setTypes(array_diff($existingEntryTypes, $entryTypes));
if ($existingEntry->getId() == $entry->getId()) {
$found = true;
$existingMediaGalleryEntries[$key] = $entry;
}
$this->remove($sku,$entry->getId());
// if ($existingEntry->getId() == $entry->getId()) {
// $found = true;
// $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 {
$this->productRepository->save($product);
} catch (\Exception $exception) {
throw new StateException(__("The product can't be saved."));
}
return true;
return $this->create($sku,$entry);
// if (!$found) {
// throw new NoSuchEntityException(
// __('No image with the provided ID was found. Verify the ID and try again.')
// );
// }
// $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