Пример #1
1
 /**
  * @param CustomerInterface $entity
  * @param array $arguments
  * @return CustomerInterface
  * @throws \Exception
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     $extensionAttribute = $entity->getExtensionAttributes()->getExtensionAttribute();
     $extensionAttribute->setCustomerId($entity->getId());
     $extensionAttribute = $this->entityManager->save($extensionAttribute);
     $entity->getExtensionAttributes()->setExtensionAttribute($extensionAttribute);
     return $entity;
 }
Пример #2
0
 /**
  * @param CustomerInterface $entity
  * @param array $arguments
  * @return CustomerInterface
  * @throws \Exception
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     $newAddresses = [];
     foreach ($entity->getAddresses() as $address) {
         $address->setCustomerId($entity->getId());
         $newAddresses[] = $this->entityManager->save($address);
     }
     $entity->setAddresses($newAddresses);
     return $entity;
 }
Пример #3
0
 /**
  * @inheritDoc
  */
 public function save(AbstractModel $object)
 {
     if ($object->isDeleted()) {
         return $this->delete($object);
     }
     $this->beginTransaction();
     try {
         if (!$this->isModified($object)) {
             $this->processNotModifiedSave($object);
             $this->commit();
             $object->setHasDataChanges(false);
             return $this;
         }
         $object->validateBeforeSave();
         $object->beforeSave();
         if ($object->isSaveAllowed()) {
             $this->_serializeFields($object);
             $this->_beforeSave($object);
             $this->_checkUnique($object);
             $this->objectRelationProcessor->validateDataIntegrity($this->getMainTable(), $object->getData());
             $this->entityManager->save(PageInterface::class, $object);
             $this->unserializeFields($object);
             $this->processAfterSaves($object);
         }
         $this->addCommitCallback([$object, 'afterCommitCallback'])->commit();
         $object->setHasDataChanges(false);
     } catch (\Exception $e) {
         $this->rollBack();
         $object->setHasDataChanges(true);
         throw $e;
     }
     return $this;
 }
Пример #4
0
 /**
  * @param AbstractModel $object
  * @return $this
  * @throws \Exception
  */
 public function save(AbstractModel $object)
 {
     $this->entityManager->save($object);
     return $this;
 }
Пример #5
0
 /**
  * @param AbstractModel $object
  * @return $this
  * @throws \Exception
  */
 public function save(\Magento\Framework\Model\AbstractModel $object)
 {
     $this->entityManager->save($object, \Magento\CatalogRule\Api\Data\RuleInterface::class);
     return $this;
 }
Пример #6
0
 /**
  * @param AbstractModel $object
  * @return $this
  * @throws \Exception
  */
 public function save(AbstractModel $object)
 {
     $this->entityManager->save($object, BlockInterface::class, []);
     return $this;
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function save(\Magento\Customer\Api\Data\CustomerInterface $customer)
 {
     return $this->entityManager->save($customer);
 }