Skip to content

Commit d866b18

Browse files
author
al.kravchuk
committed
#7372: Product images gets removed from "Images And Videos" after validation alert.
- Add check for product in case of not initialized product.
1 parent 78ca274 commit d866b18

File tree

1 file changed

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

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ public function execute()
147147
} catch (\Magento\Framework\Exception\LocalizedException $e) {
148148
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
149149
$this->messageManager->addExceptionMessage($e);
150-
$data = $this->persistMediaData($product, $data);
150+
$data = isset($product) ? $this->persistMediaData($product, $data) : $data;
151151
$this->getDataPersistor()->set('catalog_product', $data);
152152
$redirectBack = $productId ? true : 'new';
153153
} catch (\Exception $e) {
154154
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
155155
$this->messageManager->addErrorMessage($e->getMessage());
156-
$data = $this->persistMediaData($product, $data);
156+
$data = isset($product) ? $this->persistMediaData($product, $data) : $data;
157157
$this->getDataPersistor()->set('catalog_product', $data);
158158
$redirectBack = $productId ? true : 'new';
159159
}

0 commit comments

Comments
 (0)