/** * {@inheritdoc} */ public function deleteById($sku, $id) { $product = $this->getProduct($sku); $attributeCollection = $this->configurableType->getConfigurableAttributeCollection($product); /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $option */ $option = $attributeCollection->getItemById($id); if ($option === null) { throw new NoSuchEntityException(__('Requested option doesn\'t exist')); } return $this->delete($option); }
/** * {@inheritdoc} */ public function remove($productSku, $optionId) { $product = $this->getProduct($productSku); $attributeCollection = $this->productType->getConfigurableAttributeCollection($product); /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $option */ $option = $attributeCollection->getItemById($optionId); if ($option === null) { throw new NoSuchEntityException('Requested option doesn\'t exist'); } $option->delete(); return true; }
public function testGetConfigurableAttributeCollection() { $collection = $this->_model->getConfigurableAttributeCollection($this->_product); $this->assertInstanceOf('Magento\\ConfigurableProduct\\Model\\Resource\\Product\\Type\\Configurable\\Attribute\\Collection', $collection); }
/** * Retrieve configurable attribute collection through product object * * @param \Magento\Catalog\Model\Product $product * @return \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection */ private function getConfigurableAttributesCollection(\Magento\Catalog\Model\Product $product) { return $this->configurableType->getConfigurableAttributeCollection($product); }