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


PHP AbstractModel::getEntityId方法代码示例

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


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

示例1: aroundDelete

 /**
  * Reindex on product delete
  *
  * @param \Magento\Catalog\Model\ResourceModel\Product $productResource
  * @param \Closure $proceed
  * @param \Magento\Framework\Model\AbstractModel $product
  * @return \Magento\Catalog\Model\ResourceModel\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDelete(\Magento\Catalog\Model\ResourceModel\Product $productResource, \Closure $proceed, \Magento\Framework\Model\AbstractModel $product)
 {
     $productResource->addCommitCallback(function () use($product) {
         $this->reindexRow($product->getEntityId());
     });
     return $proceed($product);
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:16,代码来源:Product.php

示例2: 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

示例3: aggregateReviewSummary

 /**
  * Aggregate review summary
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @param \Magento\Review\Model\Rating $ratingSummaryObject
  * @return void
  */
 protected function aggregateReviewSummary($object, $ratingSummaryObject)
 {
     $readAdapter = $this->_getReadAdapter();
     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());
     $this->writeReviewSummary($oldData, $data);
 }
开发者ID:nja78,项目名称:magento2,代码行数:23,代码来源:Review.php


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