public function testLoad() { $readOperation = $this->getMockForAbstractClass('Magento\\Framework\\Model\\Operation\\ReadInterface', [], '', false, false, true, []); $readOperation->expects($this->once())->method('execute')->with('Test\\Entity\\Type', $this->abstractEntity, '100000001')->willReturn($this->abstractEntity); $this->orchestratorPool->expects($this->once())->method('getReadOperation')->with('Test\\Entity\\Type')->willReturn($readOperation); $result = $this->subject->load('Test\\Entity\\Type', $this->abstractEntity, '100000001'); $this->assertEquals($this->abstractEntity, $result); }
/** * Reset firstly loaded attributes * * @param \Magento\Framework\DataObject $object * @param integer $entityId * @param array|null $attributes * @return $this */ public function load($object, $entityId, $attributes = []) { $this->loadAttributesMetadata($attributes); $this->entityManager->load('Magento\\Catalog\\Api\\Data\\ProductInterface', $object, $entityId); $this->_afterLoad($object); return $this; }
/** * @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('Magento\\CatalogRule\\Api\\Data\\RuleInterface', $object, $value); $this->unserializeFields($object); $this->_afterLoad($object); return $this; }
/** * 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(RuleInterface::class, $object, $value); $this->unserializeFields($object); $this->_afterLoad($object); return $this; }
/** * Reset firstly loaded attributes * * @param \Magento\Framework\Model\AbstractModel $object * @param integer $entityId * @param array|null $attributes * @return $this */ public function load($object, $entityId, $attributes = []) { \Magento\Framework\Profiler::start('EAV:load_entity'); /** * Load object base row data */ $this->entityManager->load(CategoryInterface::class, $object, $entityId); if (!$this->entityManager->has(\Magento\Catalog\Api\Data\CategoryInterface::class, $entityId)) { $object->isObjectNew(true); } $this->loadAttributesMetadata($attributes); $this->_loadModelAttributes($object); $object->setOrigData(); $this->_afterLoad($object); \Magento\Framework\Profiler::stop('EAV:load_entity'); return $this; }
/** * 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(PageInterface::class, $object, $value); $this->_afterLoad($object); } return $this; }