Commit 1a71dde2 by lmf

恢复接口

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