/** * Delete bundle-related attributes of product. * * @param Product $product * @return void */ public function delete(Product $product) { if ($product->getTypeId() != ProductType::TYPE_BUNDLE) { return; } /** * @var string $productSku */ $productSku = $product->getSku(); /** * @var Option[] $bundleProductOptions */ /** * @var AttributeValue $bundleProductOptionsAttrValue */ $bundleProductOptionsAttrValue = $product->getCustomAttribute('bundle_product_options'); if (is_null($bundleProductOptionsAttrValue) || !is_array($bundleProductOptionsAttrValue->getValue())) { $bundleProductOptions = array(); } else { $bundleProductOptions = $bundleProductOptionsAttrValue->getValue(); } foreach ($bundleProductOptions as $option) { $this->optionWriteService->remove($productSku, $option->getId()); } }