protected function setUp() { $this->productMock = $this->getMock('\\Magento\\Catalog\\Model\\Product', [], [], '', false); $objectManager = new ObjectManager($this); $this->model = $objectManager->getObject('Magento\\Catalog\\Model\\Product\\Option'); $this->model->setProduct($this->productMock); }
/** * Retrieve option instance * * @return Product\Option */ public function getOptionInstance() { if (!isset($this->optionInstance)) { $this->optionInstance = $this->optionFactory->create(); $this->optionInstance->setProduct($this); } return $this->optionInstance; }
/** * Add option to array of product options * * @param Product\Option $option * @return \Magento\Catalog\Model\Product */ public function addOption(Product\Option $option) { $options = (array) $this->getData('options'); $options[] = $option; $option->setProduct($this); $this->setData('options', $options); return $this; }