Skip to content

Commit 1c62936

Browse files
MC-18472: Product with different custom option prices in different scope overrides to default on import
1 parent 3f24171 commit 1c62936

File tree

1 file changed

+23
-17
lines changed
  • app/code/Magento/CatalogImportExport/Model/Import/Product

1 file changed

+23
-17
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@ protected function _collectOptionTypeData(
15041504
$specificTypeData = $this->_getSpecificTypeData($rowData, 0, false);
15051505
//For others stores
15061506
if ($specificTypeData) {
1507+
$typePrices[$nextValueId][$this->_rowStoreId] = $specificTypeData['price'];
15071508
$typeTitles[$nextValueId++][$this->_rowStoreId] = $specificTypeData['title'];
15081509
}
15091510
}
@@ -1788,29 +1789,30 @@ protected function _getPriceData(array $rowData, $optionId, $type)
17881789
*/
17891790
protected function _getSpecificTypeData(array $rowData, $optionTypeId, $defaultStore = true)
17901791
{
1792+
$data = false;
1793+
$priceData = false;
1794+
$customOptionRowPrice = $rowData[self::COLUMN_ROW_PRICE];
1795+
if (!empty($customOptionRowPrice) || $customOptionRowPrice === '0') {
1796+
$priceData = [
1797+
'price' => (double)rtrim($rowData[self::COLUMN_ROW_PRICE], '%'),
1798+
'price_type' => 'fixed',
1799+
];
1800+
if ('%' == substr($rowData[self::COLUMN_ROW_PRICE], -1)) {
1801+
$priceData['price_type'] = 'percent';
1802+
}
1803+
}
17911804
if (!empty($rowData[self::COLUMN_ROW_TITLE]) && $defaultStore && empty($rowData[self::COLUMN_STORE])) {
17921805
$valueData = [
17931806
'option_type_id' => $optionTypeId,
17941807
'sort_order' => empty($rowData[self::COLUMN_ROW_SORT]) ? 0 : abs($rowData[self::COLUMN_ROW_SORT]),
17951808
'sku' => !empty($rowData[self::COLUMN_ROW_SKU]) ? $rowData[self::COLUMN_ROW_SKU] : '',
17961809
];
1797-
1798-
$priceData = false;
1799-
$customOptionRowPrice = $rowData[self::COLUMN_ROW_PRICE];
1800-
if (!empty($customOptionRowPrice) || $customOptionRowPrice === '0') {
1801-
$priceData = [
1802-
'price' => (double)rtrim($rowData[self::COLUMN_ROW_PRICE], '%'),
1803-
'price_type' => 'fixed',
1804-
];
1805-
if ('%' == substr($rowData[self::COLUMN_ROW_PRICE], -1)) {
1806-
$priceData['price_type'] = 'percent';
1807-
}
1808-
}
1809-
return ['value' => $valueData, 'title' => $rowData[self::COLUMN_ROW_TITLE], 'price' => $priceData];
1810+
$data = ['value' => $valueData, 'title' => $rowData[self::COLUMN_ROW_TITLE], 'price' => $priceData];
18101811
} elseif (!empty($rowData[self::COLUMN_ROW_TITLE]) && !$defaultStore && !empty($rowData[self::COLUMN_STORE])) {
1811-
return ['title' => $rowData[self::COLUMN_ROW_TITLE]];
1812+
$data = ['title' => $rowData[self::COLUMN_ROW_TITLE], 'price' => $priceData];
18121813
}
1813-
return false;
1814+
1815+
return $data;
18141816
}
18151817

18161818
/**
@@ -1868,7 +1870,9 @@ protected function _saveTitles(array $titles)
18681870
{
18691871
$titleRows = [];
18701872
foreach ($titles as $optionId => $storeInfo) {
1871-
foreach ($storeInfo as $storeId => $title) {
1873+
//for use default
1874+
$uniqStoreInfo = array_unique($storeInfo);
1875+
foreach ($uniqStoreInfo as $storeId => $title) {
18721876
$titleRows[] = ['option_id' => $optionId, 'store_id' => $storeId, 'title' => $title];
18731877
}
18741878
}
@@ -1963,7 +1967,9 @@ protected function _saveSpecificTypeTitles(array $typeTitles)
19631967
{
19641968
$optionTypeTitleRows = [];
19651969
foreach ($typeTitles as $optionTypeId => $storesData) {
1966-
foreach ($storesData as $storeId => $title) {
1970+
//for use default
1971+
$uniqStoresData = array_unique($storesData);
1972+
foreach ($uniqStoresData as $storeId => $title) {
19671973
$optionTypeTitleRows[] = [
19681974
'option_type_id' => $optionTypeId,
19691975
'store_id' => $storeId,

0 commit comments

Comments
 (0)