From d866b18757ca50bc97df4038a874a4bddf465a4c Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Fri, 6 Jul 2018 15:07:14 +0300 Subject: [PATCH] magento/magento2#7372: Product images gets removed from "Images And Videos" after validation alert. - Add check for product in case of not initialized product. --- .../Magento/Catalog/Controller/Adminhtml/Product/Save.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php index 15154b02dbf8a..03fd93080ee77 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php @@ -147,13 +147,13 @@ public function execute() } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addExceptionMessage($e); - $data = $this->persistMediaData($product, $data); + $data = isset($product) ? $this->persistMediaData($product, $data) : $data; $this->getDataPersistor()->set('catalog_product', $data); $redirectBack = $productId ? true : 'new'; } catch (\Exception $e) { $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); $this->messageManager->addErrorMessage($e->getMessage()); - $data = $this->persistMediaData($product, $data); + $data = isset($product) ? $this->persistMediaData($product, $data) : $data; $this->getDataPersistor()->set('catalog_product', $data); $redirectBack = $productId ? true : 'new'; }