Skip to content

Commit a57768e

Browse files
author
Oleksandr Iegorov
committed
MAGETWO-69496: Impossible specify Bundle option title on store view level with changes to more than one store view
1 parent be6c09b commit a57768e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ public function __construct(
4747
*/
4848
public function execute($entity, $arguments = [])
4949
{
50-
if ($entity->getTypeId() !== Type::TYPE_CODE) {
50+
$bundleProductOptions = $entity->getExtensionAttributes()->getBundleProductOptions();
51+
if ($entity->getTypeId() !== Type::TYPE_CODE || empty($bundleProductOptions)) {
5152
return $entity;
5253
}
5354

5455
$existingBundleProductOptions = $this->optionRepository->getList($entity->getSku());
55-
$bundleProductOptions = $entity->getExtensionAttributes()->getBundleProductOptions();
56-
57-
if (empty($existingBundleProductOptions) && empty($bundleProductOptions)) {
58-
return $entity;
59-
}
6056

61-
$existingOptionsIds = $this->getOptionIds($existingBundleProductOptions);
62-
$optionIds = $this->getOptionIds($bundleProductOptions);
57+
$existingOptionsIds = !empty($existingBundleProductOptions)
58+
? $this->getOptionIds($existingBundleProductOptions)
59+
: [];
60+
$optionIds = !empty($bundleProductOptions)
61+
? $this->getOptionIds($bundleProductOptions)
62+
: [];
6363

6464
$options = $bundleProductOptions ?: [];
6565

@@ -116,6 +116,11 @@ private function saveOptions($entity, $options)
116116
private function getOptionIds($options)
117117
{
118118
$optionIds = [];
119+
120+
if (empty($options)) {
121+
return $optionIds;
122+
}
123+
119124
/** @var \Magento\Bundle\Api\Data\OptionInterface $option */
120125
foreach ($options as $option) {
121126
if ($option->getOptionId()) {

0 commit comments

Comments
 (0)