示例#1
0
 /**
  * {@inheritdoc}
  */
 public function add($productSku, Option $option)
 {
     $product = $this->getProduct($productSku);
     $optionModel = $this->optionConverter->createModelFromData($option, $product);
     $optionModel->setStoreId($this->storeManager->getStore()->getId());
     try {
         $optionModel->save();
     } catch (\Exception $e) {
         throw new CouldNotSaveException('Could not save option', [], $e);
     }
     return $optionModel->getId();
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function add($productSku, Option $option)
 {
     $product = $this->getProduct($productSku);
     $optionModel = $this->optionConverter->createModelFromData($option, $product);
     $optionModel->setStoreId($this->storeManager->getStore()->getId());
     try {
         $optionModel->save();
     } catch (\Exception $e) {
         throw new CouldNotSaveException('Could not save option', [], $e);
     }
     $optionId = $optionModel->getId();
     if (is_array($option->getProductLinks())) {
         foreach ($option->getProductLinks() as $link) {
             $this->linkWriteService->addChild($productSku, $optionId, $link);
         }
     }
     return $optionId;
 }