Skip to content

Commit 1001a7c

Browse files
author
Alexey Yakimovich
committed
MAGETWO-70232: [GITHUB] Import customizable options adds it to another product if same SKU is filled#9457
- Fixed static test;
1 parent e80b162 commit 1001a7c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

app/code/Magento/Catalog/Model/Product/Option/SaveHandler.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,25 @@ public function execute($entity, $arguments = [])
5959
}
6060
if ($options) {
6161
$hasChangedSku = ($entity->getOrigData('sku') !== null && $entity->dataHasChangedFor('sku'));
62-
foreach ($options as $option) {
63-
if ($hasChangedSku && $option->hasData('product_sku')) {
64-
$option->setProductSku($entity->getSku());
65-
}
66-
$this->optionRepository->save($option);
67-
}
62+
$this->processOptionsSaving($options, $hasChangedSku, $entity->getSku());
6863
}
6964

7065
return $entity;
7166
}
67+
68+
/**
69+
* Save custom options
70+
*
71+
* @param array $options
72+
* @param bool $hasChangedSku
73+
* @param string $newSku
74+
*/
75+
private function processOptionsSaving($options, $hasChangedSku, $newSku) {
76+
foreach ($options as $option) {
77+
if ($hasChangedSku && $option->hasData('product_sku')) {
78+
$option->setProductSku($newSku);
79+
}
80+
$this->optionRepository->save($option);
81+
}
82+
}
7283
}

0 commit comments

Comments
 (0)