当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractModel::load方法代码示例

本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::load方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::load方法的具体用法?PHP AbstractModel::load怎么用?PHP AbstractModel::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::load方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testIsModelSavingDataToDatabase

 /**
  * Checking that test data is saving to database
  *
  * @magentoDbIsolation enabled
  */
 public function testIsModelSavingDataToDatabase()
 {
     $modelId = $this->saveTestData();
     $newModel = $this->model->load($modelId);
     $testData = $this->getTestData();
     $newModelData = [];
     foreach (array_keys($testData) as $key) {
         $newModelData[$key] = $newModel->getData($key);
     }
     $this->assertEquals($testData, $newModelData);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:PasswordResetRequestEventTest.php

示例2: load

 /**
  * Load object data
  *
  * @param int|null $id
  * @param string $field
  * @return $this
  */
 public function load($id, $field = null)
 {
     if ($id === null) {
         return $this->noRoutePage();
     }
     return parent::load($id, $field);
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:14,代码来源:Page.php

示例3: load

 /**
  * @param int $modelId
  * @param null|string $field
  * @return \Ess\M2ePro\Model\ActiveRecord\AbstractModel
  * @throws \Ess\M2ePro\Model\Exception\Logic
  */
 public function load($modelId, $field = null)
 {
     parent::load($modelId, $field);
     if (is_null($this->getId())) {
         throw new \Ess\M2ePro\Model\Exception\Logic('Instance does not exist.', array('id' => $modelId, 'field' => $field, 'model' => $this->_resourceName));
     }
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:AbstractModel.php

示例4: load

 public function load($modelId, $field = null)
 {
     parent::load($modelId, $field);
     $this->setId($modelId);
     // array_filter to remove empty items caused by non-magento modules requirements
     $this->setDepends(array_filter($this->packageInfo->getRequire($this->getCode())));
     $this->setVersion($this->packageInfo->getVersion($this->getCode()));
     $this->setPackageName($this->packageInfo->getPackageName($this->getCode()));
     return $this;
 }
开发者ID:swissup,项目名称:core,代码行数:10,代码来源:Module.php

示例5: _getModel

 /**
  * Retrieve model object
  * @return \Magento\Framework\Model\AbstractModel
  */
 protected function _getModel($load = true)
 {
     if (is_null($this->_model)) {
         $this->_model = $this->_objectManager->create($this->_modelClass);
         $id = (int) $this->getRequest()->getParam($this->_idKey);
         if ($id && $load) {
             $this->_model->load($id);
         }
     }
     return $this->_model;
 }
开发者ID:samitrimal,项目名称:Blog-Extension-for-Magento-2,代码行数:15,代码来源:Actions.php

示例6: aggregate

 /**
  * Aggregate
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return void
  */
 public function aggregate($object)
 {
     $readAdapter = $this->_getReadAdapter();
     $writeAdapter = $this->_getWriteAdapter();
     if (!$object->getEntityPkValue() && $object->getId()) {
         $object->load($object->getReviewId());
     }
     $ratingModel = $this->_ratingFactory->create();
     $ratingSummaries = $ratingModel->getEntitySummary($object->getEntityPkValue(), false);
     foreach ($ratingSummaries as $ratingSummaryObject) {
         if ($ratingSummaryObject->getCount()) {
             $ratingSummary = round($ratingSummaryObject->getSum() / $ratingSummaryObject->getCount());
         } else {
             $ratingSummary = $ratingSummaryObject->getSum();
         }
         $reviewsCount = $this->getTotalReviews($object->getEntityPkValue(), true, $ratingSummaryObject->getStoreId());
         $select = $readAdapter->select()->from($this->_aggregateTable)->where('entity_pk_value = :pk_value')->where('entity_type = :entity_type')->where('store_id = :store_id');
         $bind = [':pk_value' => $object->getEntityPkValue(), ':entity_type' => $object->getEntityId(), ':store_id' => $ratingSummaryObject->getStoreId()];
         $oldData = $readAdapter->fetchRow($select, $bind);
         $data = new \Magento\Framework\Object();
         $data->setReviewsCount($reviewsCount)->setEntityPkValue($object->getEntityPkValue())->setEntityType($object->getEntityId())->setRatingSummary($ratingSummary > 0 ? $ratingSummary : 0)->setStoreId($ratingSummaryObject->getStoreId());
         $writeAdapter->beginTransaction();
         try {
             if ($oldData['primary_id'] > 0) {
                 $condition = ["{$this->_aggregateTable}.primary_id = ?" => $oldData['primary_id']];
                 $writeAdapter->update($this->_aggregateTable, $data->getData(), $condition);
             } else {
                 $writeAdapter->insert($this->_aggregateTable, $data->getData());
             }
             $writeAdapter->commit();
         } catch (\Exception $e) {
             $writeAdapter->rollBack();
         }
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:41,代码来源:Review.php

示例7: validate

 /**
  * @param \Magento\Framework\Model\AbstractModel $model
  * @return bool
  */
 public function validate(\Magento\Framework\Model\AbstractModel $model)
 {
     if (!$model->hasData($this->getAttribute())) {
         $model->load($model->getId());
     }
     $attributeValue = $model->getData($this->getAttribute());
     return $this->validateAttribute($attributeValue);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:AbstractCondition.php

示例8: load

 /**
  * Loading store data
  *
  * @param   mixed $key
  * @param   string $field
  * @return  $this
  */
 public function load($key, $field = null)
 {
     if (!is_numeric($key) && $field === null) {
         $this->_getResource()->load($this, $key, 'code');
         return $this;
     }
     return parent::load($key, $field);
 }
开发者ID:kid17,项目名称:magento2,代码行数:15,代码来源:Store.php

示例9: loadByMerchantTransactionId

 public function loadByMerchantTransactionId($mt_id)
 {
     return parent::load($mt_id, self::MERCHANT_TRANSACTION_ID);
 }
开发者ID:smart2pay,项目名称:magento20,代码行数:4,代码来源:Transaction.php

示例10: load

 /**
  * Custom load
  *
  * @param int|string $id
  * @param string $field
  * @return $this
  */
 public function load($id, $field = null)
 {
     if (!is_numeric($id) && is_null($field)) {
         $this->_getResource()->load($this, $id, 'code');
         return $this;
     }
     return parent::load($id, $field);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:Website.php

示例11: load

 /**
  * load info multistore.
  *
  * @param mixed  $id
  * @param string $field
  *
  * @return $this
  */
 public function load($id, $field = null)
 {
     parent::load($id, $field);
     if ($this->getStoreViewId()) {
         $this->getStoreViewValue();
     }
     return $this;
 }
开发者ID:JakeSharp,项目名称:Bannerslider-Magento2,代码行数:16,代码来源:Banner.php

示例12: aggregate

 /**
  * Aggregate
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return void
  */
 public function aggregate($object)
 {
     if (!$object->getEntityPkValue() && $object->getId()) {
         $object->load($object->getReviewId());
     }
     $ratingModel = $this->_ratingFactory->create();
     $ratingSummaries = $ratingModel->getEntitySummary($object->getEntityPkValue(), false);
     foreach ($ratingSummaries as $ratingSummaryObject) {
         $this->aggregateReviewSummary($object, $ratingSummaryObject);
     }
 }
开发者ID:nja78,项目名称:magento2,代码行数:17,代码来源:Review.php

示例13: load

 /**
  * @param int $modelId
  * @param null $field
  * @return $this
  */
 public function load($modelId, $field = null)
 {
     return parent::load($modelId, $field);
     // TODO: Change the autogenerated stub
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:Theme.php


注:本文中的Magento\Framework\Model\AbstractModel::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。