Skip to content

Commit ab3d0f7

Browse files
committed
MAGETWO-90927: Fix warning with count function on product save
1 parent 1d469f8 commit ab3d0f7

File tree

1 file changed

+7
-4
lines changed
  • app/code/Magento/Catalog/Controller/Adminhtml/Product

1 file changed

+7
-4
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public function execute()
194194
*/
195195
private function handleImageRemoveError($postData, $productId)
196196
{
197+
197198
if (isset($postData['product']['media_gallery']['images'])) {
198199
$removedImagesAmount = 0;
199200
foreach ($postData['product']['media_gallery']['images'] as $image) {
@@ -204,10 +205,12 @@ private function handleImageRemoveError($postData, $productId)
204205
if ($removedImagesAmount) {
205206
$expectedImagesAmount = count($postData['product']['media_gallery']['images']) - $removedImagesAmount;
206207
$product = $this->productRepository->getById($productId);
207-
if ($expectedImagesAmount != count($product->getMediaGallery('images'))) {
208-
$this->messageManager->addNoticeMessage(
209-
__('The image cannot be removed as it has been assigned to the other image role')
210-
);
208+
if (is_array($product->getMediaGallery('images'))) {
209+
if ($expectedImagesAmount != count($product->getMediaGallery('images'))) {
210+
$this->messageManager->addNoticeMessage(
211+
__('The image cannot be removed as it has been assigned to the other image role')
212+
);
213+
}
211214
}
212215
}
213216
}

0 commit comments

Comments
 (0)