Beispiel #1
0
 /**
  * @param string $entityType
  * @param object $entity
  * @param array $arguments
  * @return \Magento\Catalog\Api\Data\ProductInterface|object
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entityType, $entity, $arguments = [])
 {
     $options = [];
     /** @var $entity \Magento\Catalog\Api\Data\ProductInterface */
     foreach ($this->optionRepository->getProductOptions($entity) as $option) {
         $option->setProduct($entity);
         $options[] = $option;
     }
     $entity->setOptions($options);
     return $entity;
 }
Beispiel #2
0
 /**
  * @param object $entity
  * @param array $arguments
  * @return \Magento\Catalog\Api\Data\ProductInterface|object
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     /** @var \Magento\Catalog\Api\Data\ProductInterface $entity */
     foreach ($this->optionRepository->getProductOptions($entity) as $option) {
         $this->optionRepository->delete($option);
     }
     if ($entity->getOptions()) {
         foreach ($entity->getOptions() as $option) {
             $this->optionRepository->save($option);
         }
     }
     return $entity;
 }