Skip to content

Commit 7be9173

Browse files
ENGCOM-2670: Save configurable product options after validation error #16597
- Merge Pull Request #16597 from swnsma/magento2-1:Save-Configurable-Product-Options-After-Validation-Error - Merged commits: 1. d866b18 2. bc00d8e
2 parents 5a04525 + bc00d8e commit 7be9173

File tree

2 files changed

+12
-10
lines changed
  • app/code/Magento
    • Catalog/Controller/Adminhtml/Product
    • ConfigurableProduct/view/adminhtml/web/js/variations

2 files changed

+12
-10
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
}

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,17 @@ define([
407407
* - associated_product_ids_serialized.
408408
*/
409409
serializeData: function () {
410-
this.source.data['configurable-matrix-serialized'] =
411-
JSON.stringify(this.source.data['configurable-matrix']);
412-
413-
delete this.source.data['configurable-matrix'];
414-
415-
this.source.data['associated_product_ids_serialized'] =
416-
JSON.stringify(this.source.data['associated_product_ids']);
410+
if (this.source.data['configurable-matrix']) {
411+
this.source.data['configurable-matrix-serialized'] =
412+
JSON.stringify(this.source.data['configurable-matrix']);
413+
delete this.source.data['configurable-matrix'];
414+
}
417415

418-
delete this.source.data['associated_product_ids'];
416+
if (this.source.data['associated_product_ids']) {
417+
this.source.data['associated_product_ids_serialized'] =
418+
JSON.stringify(this.source.data['associated_product_ids']);
419+
delete this.source.data['associated_product_ids'];
420+
}
419421
},
420422

421423
/**

0 commit comments

Comments
 (0)