Skip to content

Commit b39774c

Browse files
committed
MAGETWO-90789: [Magento cloud] Custom options should be cleared if custom options in import file is empty
1 parent 5b7e6c3 commit b39774c

File tree

1 file changed

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

1 file changed

+11
-17
lines changed

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ protected function _importData()
12351235
$multiRowData = $this->_getMultiRowFormat($rowData);
12361236
if (!empty($rowData[self::COLUMN_SKU]) && isset($this->_productsSkuToId[$rowData[self::COLUMN_SKU]])) {
12371237
$this->_rowProductId = $this->_productsSkuToId[$rowData[self::COLUMN_SKU]];
1238-
if (array_key_exists('custom_options', $rowData) && trim($rowData['custom_options']) === "") {
1238+
if (array_key_exists('custom_options', $rowData) && trim($rowData['custom_options']) === '') {
12391239
$optionsToRemove[] = $this->_rowProductId;
12401240
}
12411241
}
@@ -1273,15 +1273,18 @@ protected function _importData()
12731273

12741274
$this->removeExistingOptions($products, $optionsToRemove);
12751275

1276+
$types = [
1277+
'values' => $typeValues,
1278+
'prices' => $typePrices,
1279+
'titles' => $typeTitles,
1280+
];
12761281
//Save prepared custom options data.
12771282
$this->savePreparedCustomOptions(
12781283
$products,
12791284
$options,
12801285
$titles,
12811286
$prices,
1282-
$typeValues,
1283-
$typePrices,
1284-
$typeTitles
1287+
$types
12851288
);
12861289
}
12871290

@@ -1546,7 +1549,7 @@ private function getExistingOptionTypeId($optionId, $storeId, $optionTypeTitle)
15461549
*/
15471550
protected function _parseRequiredData(array $rowData)
15481551
{
1549-
if (!isset($this->_rowProductId)) {
1552+
if ($this->_rowProductId === null) {
15501553
return false;
15511554
}
15521555

@@ -2006,9 +2009,7 @@ private function getProductIdentifierField()
20062009
* @param array $options
20072010
* @param array $titles
20082011
* @param array $prices
2009-
* @param array $typeValues
2010-
* @param array $typePrices
2011-
* @param array $typeTitles
2012+
* @param array $types
20122013
*
20132014
* @return void
20142015
*/
@@ -2017,16 +2018,9 @@ private function savePreparedCustomOptions(
20172018
array $options,
20182019
array $titles,
20192020
array $prices,
2020-
array $typeValues,
2021-
array $typePrices,
2022-
array $typeTitles
2021+
array $types
20232022
): void {
2024-
if ($this->_isReadyForSaving($options, $titles, $typeValues)) {
2025-
$types = [
2026-
'values' => $typeValues,
2027-
'prices' => $typePrices,
2028-
'titles' => $typeTitles,
2029-
];
2023+
if ($this->_isReadyForSaving($options, $titles, $types['values'])) {
20302024
if ($this->getBehavior() == \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) {
20312025
$this->_compareOptionsWithExisting($options, $titles, $prices, $types['values']);
20322026
$this->restoreOriginalOptionTypeIds($types['values'], $types['prices'], $types['titles']);

0 commit comments

Comments
 (0)