|
8 | 8 | use Magento\Bundle\Api\Data\OptionInterfaceFactory as OptionFactory; |
9 | 9 | use Magento\Bundle\Api\Data\LinkInterfaceFactory as LinkFactory; |
10 | 10 | use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory; |
| 11 | +use Magento\Catalog\Api\Data\ProductInterface; |
11 | 12 | use Magento\Catalog\Api\ProductRepositoryInterface as ProductRepository; |
12 | 13 | use Magento\Store\Model\StoreManagerInterface as StoreManager; |
13 | 14 | use Magento\Framework\App\RequestInterface; |
@@ -108,18 +109,13 @@ public function afterInitialize( |
108 | 109 | } |
109 | 110 |
|
110 | 111 | if (!$result['bundle_selections']) { |
111 | | - $extension = $product->getExtensionAttributes(); |
112 | | - $extension->setBundleProductOptions([]); |
113 | | - $product->setExtensionAttributes($extension); |
114 | | - $product->setDropOptions(true); |
| 112 | + $this->resetBundleProductOptions($product); |
115 | 113 | } |
116 | 114 |
|
117 | 115 | $this->processBundleOptionsData($product); |
118 | 116 | $this->processDynamicOptionsData($product); |
119 | 117 | } elseif (!$compositeReadonly) { |
120 | | - $extension = $product->getExtensionAttributes(); |
121 | | - $extension->setBundleProductOptions([]); |
122 | | - $product->setExtensionAttributes($extension); |
| 118 | + $this->resetBundleProductOptions($product); |
123 | 119 | } |
124 | 120 |
|
125 | 121 | $affectProductSelections = (bool)$this->request->getPost('affect_bundle_product_selections'); |
@@ -240,4 +236,18 @@ private function buildLink( |
240 | 236 |
|
241 | 237 | return $link; |
242 | 238 | } |
| 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 | + } |
243 | 253 | } |
0 commit comments