/** * @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; }
/** * @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; }
/** * @param CustomerInterface $entity * @param array $arguments * @return CustomerInterface * @throws \Exception * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute($entity, $arguments = []) { $metadata = $this->metadataPool->getMetadata(ExtensionAttributeInterface::class); $connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName()); $id = $connection->fetchOne($connection->select()->from($metadata->getEntityTable(), [$metadata->getIdentifierField()])->where('customer_id = ?', $entity->getId())->limit(1)); $extensionAttribute = $this->extensionAttributeFactory->create(); $extensionAttribute = $this->entityManager->load($extensionAttribute, $id); $customerExtension = $this->customerExtensionFactory->create(['data' => ['extension_attribute' => $extensionAttribute]]); $entity->setExtensionAttributes($customerExtension); return $entity; }
/** * {@inheritdoc} */ public function delete($id) { /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */ $customer = $this->customerDataFactory->create(); $customer = $this->entityManager->load($customer, $id); try { $this->entityManager->delete($customer); } catch (\Exception $e) { return false; } return true; }
/** * @inheritDoc */ public function delete(AbstractModel $object) { $this->entityManager->delete($object, PageInterface::class); return $this; }
/** * @inheritDoc */ public function delete(AbstractModel $object) { $this->entityManager->delete($object); return $this; }
/** * Delete the object * * @param \Magento\Framework\Model\AbstractModel $object * @return $this * @throws \Exception */ public function delete(AbstractModel $object) { $this->entityManager->delete($object, \Magento\CatalogRule\Api\Data\RuleInterface::class); return $this; }
public function testSave() { $this->entityManagerMock->expects($this->once())->method('save')->with($this->pageMock, [])->willReturn(true); $this->assertInstanceOf(PageResourceModel::class, $this->model->save($this->pageMock)); }
/** * @param CustomerInterface $entity * @return CustomerInterface * @throws \Exception * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute($entity, $arguments = []) { $searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $entity->getId())->create(); $addressesResult = $this->addressRepository->getList($searchCriteria); $entity->setAddresses($addressesResult->getItems()); return $entity; }