Commit e2e35062 by lmf

断点

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