/**
  * @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;
 }
Exemple #3
0
 /**
  * Load an object
  *
  * @param \Magento\Cms\Model\Block|AbstractModel $object
  * @param mixed $value
  * @param string $field field to load by (defaults to model id)
  * @return $this
  */
 public function load(AbstractModel $object, $value, $field = null)
 {
     $blockId = $this->getBlockId($object, $value, $field);
     if ($blockId) {
         $this->entityManager->load($object, $blockId);
     }
     return $this;
 }
Exemple #4
0
 /**
  * Load an object
  *
  * @param CmsPage|AbstractModel $object
  * @param mixed $value
  * @param string $field field to load by (defaults to model id)
  * @return $this
  */
 public function load(AbstractModel $object, $value, $field = null)
 {
     $pageId = $this->getPageId($object, $value, $field);
     if ($pageId) {
         $this->entityManager->load($object, $pageId, PageInterface::class, []);
     }
     return $this;
 }
Exemple #5
0
 /**
  * Load an object
  *
  * @param CmsPage|AbstractModel $object
  * @param mixed $value
  * @param string $field field to load by (defaults to model id)
  * @return $this
  */
 public function load(AbstractModel $object, $value, $field = null)
 {
     $entityMetadata = $this->metadataPool->getMetadata(PageInterface::class);
     if (!is_numeric($value) && $field === null) {
         $field = 'identifier';
     } elseif (!$field) {
         $field = $entityMetadata->getIdentifierField();
     }
     $isId = true;
     if ($field != $entityMetadata->getIdentifierField() || $object->getStoreId()) {
         $select = $this->_getLoadSelect($field, $value, $object);
         $select->reset(Select::COLUMNS)->columns($this->getMainTable() . '.' . $entityMetadata->getIdentifierField())->limit(1);
         $result = $this->getConnection()->fetchCol($select);
         $value = count($result) ? $result[0] : $value;
         $isId = count($result);
     }
     if ($isId) {
         $this->entityManager->load($object, $value, PageInterface::class);
     }
     return $this;
 }
Exemple #6
0
 /**
  * @param \Magento\Framework\Model\AbstractModel $object
  * @param mixed $value
  * @param string $field
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null)
 {
     $this->entityManager->load($object, $value, \Magento\CatalogRule\Api\Data\RuleInterface::class);
     return $this;
 }
Exemple #7
0
 /**
  * Load an object
  *
  * @param SalesRule|AbstractModel $object
  * @param mixed $value
  * @param string $field field to load by (defaults to model id)
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function load(AbstractModel $object, $value, $field = null)
 {
     $this->entityManager->load($object, $value, RuleInterface::class);
     return $this;
 }