本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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);
}
示例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);
}
示例9: loadByMerchantTransactionId
public function loadByMerchantTransactionId($mt_id)
{
return parent::load($mt_id, self::MERCHANT_TRANSACTION_ID);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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
}