Skip to content

Commit 8b202f1

Browse files
author
Sergii Kovalenko
committed
Merge remote-tracking branch 'origin/MAGETWO-58651' into BUGS
2 parents c9ae935 + 9f1c19d commit 8b202f1

File tree

2 files changed

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

2 files changed

+26
-31
lines changed

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ public function execute()
9797
$productTypeId = $this->getRequest()->getParam('type');
9898
if ($data) {
9999
try {
100-
$this->unserializeProductData($data);
101100
$product = $this->initializationHelper->initialize(
102101
$this->productBuilder->build($this->getRequest())
103102
);
@@ -181,30 +180,6 @@ public function execute()
181180
return $resultRedirect;
182181
}
183182

184-
/**
185-
* Unserialize product data for configurable products
186-
*
187-
* @param array $postData
188-
* @return void
189-
*/
190-
private function unserializeProductData($postData)
191-
{
192-
if (isset($postData["configurable-matrix-serialized"])) {
193-
$configurableMatrixSerialized = $postData["configurable-matrix-serialized"];
194-
if ($configurableMatrixSerialized != null && !empty($configurableMatrixSerialized)) {
195-
$postData["configurable-matrix"] = json_decode($configurableMatrixSerialized, true);
196-
unset($postData["configurable-matrix-serialized"]);
197-
}
198-
}
199-
if (isset($postData["associated_product_ids_serialized"])) {
200-
$associatedProductIdsSerialized = $postData["associated_product_ids_serialized"];
201-
if ($associatedProductIdsSerialized != null && !empty($associatedProductIdsSerialized)) {
202-
$postData["associated_product_ids"] = json_decode($associatedProductIdsSerialized, true);
203-
unset($postData["associated_product_ids_serialized"]);
204-
}
205-
}
206-
}
207-
208183
/**
209184
* Notify customer when image was not deleted in specific case.
210185
* TODO: temporary workaround must be eliminated in MAGETWO-45306

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,7 @@ define([
383383
* Chose action for the form save button
384384
*/
385385
saveFormHandler: function () {
386-
this.source.data['configurable-matrix-serialized'] =
387-
JSON.stringify(this.source.data['configurable-matrix']);
388-
delete this.source.data['configurable-matrix'];
389-
this.source.data['associated_product_ids_serialized'] =
390-
JSON.stringify(this.source.data['associated_product_ids']);
391-
delete this.source.data['associated_product_ids'];
386+
this.serializeData();
392387

393388
if (this.checkForNewAttributes()) {
394389
this.formSaveParams = arguments;
@@ -398,6 +393,31 @@ define([
398393
}
399394
},
400395

396+
/**
397+
* Serialize data for specific form fields
398+
*
399+
* Get data from outdated fields, serialize it and produce new form fields.
400+
*
401+
* Outdated fields:
402+
* - configurable-matrix;
403+
* - associated_product_ids.
404+
*
405+
* New fields:
406+
* - configurable-matrix-serialized;
407+
* - associated_product_ids_serialized.
408+
*/
409+
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']);
417+
418+
delete this.source.data['associated_product_ids'];
419+
},
420+
401421
/**
402422
* Check for newly added attributes
403423
* @returns {Boolean}

0 commit comments

Comments
 (0)