コード例 #1
0
ファイル: OptionRepository.php プロジェクト: opexsw/magento2
 /**
  * {@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);
 }
コード例 #2
0
ファイル: WriteService.php プロジェクト: aiesh/magento2
 /**
  * {@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;
 }
コード例 #3
0
ファイル: ConfigurableTest.php プロジェクト: nja78/magento2
 public function testGetConfigurableAttributeCollection()
 {
     $collection = $this->_model->getConfigurableAttributeCollection($this->_product);
     $this->assertInstanceOf('Magento\\ConfigurableProduct\\Model\\Resource\\Product\\Type\\Configurable\\Attribute\\Collection', $collection);
 }
コード例 #4
0
 /**
  * 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);
 }