Skip to content

Commit 2c910f4

Browse files
Sergii Kovalenkodanielrenaud
authored andcommitted
MAGETWO-62310: Product "Use Default Value" checkbox for an attributes are unchecked for the new website scope
1 parent f8b3385 commit 2c910f4

File tree

1 file changed

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

1 file changed

+15
-9
lines changed

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ private function handleImageRemoveError($postData, $productId)
216216
/**
217217
* Do copying data to stores
218218
*
219+
* In case when 'copy_from' didnt specified we suppose, that data should be taken
220+
* from default values (from admin store). For this we have fallback, and there is no need
221+
* to copy data between 0 store and some speficic store
222+
*
219223
* @param array $data
220224
* @param int $productId
221225
* @return void
@@ -227,15 +231,17 @@ protected function copyToStores($data, $productId)
227231
if (isset($data['product']['website_ids'][$websiteId])
228232
&& (bool)$data['product']['website_ids'][$websiteId]) {
229233
foreach ($group as $store) {
230-
$copyFrom = (isset($store['copy_from'])) ? $store['copy_from'] : 0;
231-
$copyTo = (isset($store['copy_to'])) ? $store['copy_to'] : 0;
232-
if ($copyTo) {
233-
$this->_objectManager->create(\Magento\Catalog\Model\Product::class)
234-
->setStoreId($copyFrom)
235-
->load($productId)
236-
->setStoreId($copyTo)
237-
->setCopyFromView(true)
238-
->save();
234+
if (isset($store['copy_from'])) {
235+
$copyFrom = $store['copy_from'];
236+
$copyTo = (isset($store['copy_to'])) ? $store['copy_to'] : 0;
237+
if ($copyTo) {
238+
$this->_objectManager->create(\Magento\Catalog\Model\Product::class)
239+
->setStoreId($copyFrom)
240+
->load($productId)
241+
->setStoreId($copyTo)
242+
->setCopyFromView(true)
243+
->save();
244+
}
239245
}
240246
}
241247
}

0 commit comments

Comments
 (0)