Esempio n. 1
0
 public function testSaveProductsForDuplicate()
 {
     $mainProduct = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->setMethods(['getIsDuplicate', '__sleep', '__wakeup', 'getTypeInstance', '_getWriteAdapter'])->disableOriginalConstructor()->getMock();
     $mainProduct->expects($this->once())->method('getIsDuplicate')->will($this->returnValue(true));
     $mainProduct->expects($this->never())->method('getTypeInstance')->will($this->returnSelf());
     $this->configurable->saveProducts($mainProduct, [1, 2, 3]);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function delete(OptionInterface $option)
 {
     $product = $this->getProductById($option->getProductId());
     try {
         $this->configurableTypeResource->saveProducts($product, []);
     } catch (\Exception $exception) {
         throw new StateException(__('Cannot delete variations from product: %1', $option->getProductId()));
     }
     try {
         $this->optionResource->delete($option);
     } catch (\Exception $exception) {
         throw new StateException(__('Cannot delete option with id: %1', $option->getId()));
     }
     return true;
 }