Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
OptionManagement Class Reference
Inheritance diagram for OptionManagement:
ProductOptionManagementInterface

Public Member Functions

 __construct (\Magento\Bundle\Api\ProductOptionRepositoryInterface $optionRepository, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository)
 
 save (\Magento\Bundle\Api\Data\OptionInterface $option)
 
- Public Member Functions inherited from ProductOptionManagementInterface
 save (\Magento\Bundle\Api\Data\OptionInterface $option)
 

Protected Attributes

 $optionRepository
 
 $productRepository
 

Detailed Description

Definition at line 12 of file OptionManagement.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Bundle\Api\ProductOptionRepositoryInterface  $optionRepository,
\Magento\Catalog\Api\ProductRepositoryInterface  $productRepository 
)
Parameters
\Magento\Bundle\Api\ProductOptionRepositoryInterface$optionRepository
\Magento\Catalog\Api\ProductRepositoryInterface$productRepository

Definition at line 28 of file OptionManagement.php.

31  {
32  $this->optionRepository = $optionRepository;
33  $this->productRepository = $productRepository;
34  }

Member Function Documentation

◆ save()

{}

Definition at line 39 of file OptionManagement.php.

40  {
41  $product = $this->productRepository->get($option->getSku(), true);
42  if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
43  throw new InputException(__('This is implemented for bundle products only.'));
44  }
45  return $this->optionRepository->save($product, $option);
46  }
__()
Definition: __.php:13

Field Documentation

◆ $optionRepository

$optionRepository
protected

Definition at line 17 of file OptionManagement.php.

◆ $productRepository

$productRepository
protected

Definition at line 22 of file OptionManagement.php.


The documentation for this class was generated from the following file: