Skip to content

Commit 48555da

Browse files
committed
ACP2E-3770: No information when deleting last option from bundle
1 parent 5beb093 commit 48555da

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

app/code/Magento/Bundle/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Bundle.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Bundle\Api\Data\OptionInterfaceFactory as OptionFactory;
99
use Magento\Bundle\Api\Data\LinkInterfaceFactory as LinkFactory;
1010
use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory;
11+
use Magento\Catalog\Api\Data\ProductInterface;
1112
use Magento\Catalog\Api\ProductRepositoryInterface as ProductRepository;
1213
use Magento\Store\Model\StoreManagerInterface as StoreManager;
1314
use Magento\Framework\App\RequestInterface;
@@ -108,18 +109,13 @@ public function afterInitialize(
108109
}
109110

110111
if (!$result['bundle_selections']) {
111-
$extension = $product->getExtensionAttributes();
112-
$extension->setBundleProductOptions([]);
113-
$product->setExtensionAttributes($extension);
114-
$product->setDropOptions(true);
112+
$this->resetBundleProductOptions($product);
115113
}
116114

117115
$this->processBundleOptionsData($product);
118116
$this->processDynamicOptionsData($product);
119117
} elseif (!$compositeReadonly) {
120-
$extension = $product->getExtensionAttributes();
121-
$extension->setBundleProductOptions([]);
122-
$product->setExtensionAttributes($extension);
118+
$this->resetBundleProductOptions($product);
123119
}
124120

125121
$affectProductSelections = (bool)$this->request->getPost('affect_bundle_product_selections');
@@ -240,4 +236,18 @@ private function buildLink(
240236

241237
return $link;
242238
}
239+
240+
/**
241+
* Resets bundle product options inside product extension attributes
242+
*
243+
* @param ProductInterface $product
244+
* @return void
245+
*/
246+
private function resetBundleProductOptions(ProductInterface $product) : void
247+
{
248+
$extension = $product->getExtensionAttributes();
249+
$extension->setBundleProductOptions([]);
250+
$product->setExtensionAttributes($extension);
251+
$product->setDropOptions(true);
252+
}
243253
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ public function execute($entity, $arguments = [])
9797
$bundleProductOptions = $entity->getExtensionAttributes()->getBundleProductOptions() ?: [];
9898
//Only processing bundle products.
9999
if ($entity->getTypeId() !== Type::TYPE_CODE
100-
|| empty($bundleProductOptions)
101-
&& !$entity->getDropOptions()
100+
|| (empty($bundleProductOptions) && !$entity->getDropOptions())
102101
) {
103102
return $entity;
104103
}

0 commit comments

Comments
 (0)