コード例 #1
0
 /**
  * @param string $name
  * @param string $primaryFieldName
  * @param string $requestFieldName
  * @param CollectionFactory $collectionFactory
  * @param RequestInterface $request
  * @param array $meta
  * @param array $data
  */
 public function __construct($name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, RequestInterface $request, array $meta = [], array $data = [])
 {
     parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
     $this->collectionFactory = $collectionFactory;
     $this->collection = $this->collectionFactory->create();
     $this->request = $request;
 }
コード例 #2
0
 /**
  * Return collection of reviews
  *
  * @return array|\Magento\Review\Model\ResourceModel\Review\Product\Collection
  */
 public function getReviews()
 {
     if (!($customerId = $this->currentCustomer->getCustomerId())) {
         return [];
     }
     if (!$this->_collection) {
         $this->_collection = $this->_collectionFactory->create();
         $this->_collection->addStoreFilter($this->_storeManager->getStore()->getId())->addCustomerFilter($customerId)->setDateOrder()->setPageSize(5)->load()->addReviewSummary();
     }
     return $this->_collection;
 }
コード例 #3
0
ファイル: Grid.php プロジェクト: pradeep-wagento/magento2
 /**
  * Prepare collection
  *
  * @return \Magento\Review\Block\Adminhtml\Grid
  */
 protected function _prepareCollection()
 {
     /** @var $model \Magento\Review\Model\Review */
     $model = $this->_reviewFactory->create();
     /** @var $collection \Magento\Review\Model\ResourceModel\Review\Product\Collection */
     $collection = $this->_productsFactory->create();
     if ($this->getProductId() || $this->getRequest()->getParam('productId', false)) {
         $productId = $this->getProductId();
         if (!$productId) {
             $productId = $this->getRequest()->getParam('productId');
         }
         $this->setProductId($productId);
         $collection->addEntityFilter($this->getProductId());
     }
     if ($this->getCustomerId() || $this->getRequest()->getParam('customerId', false)) {
         $customerId = $this->getCustomerId();
         if (!$customerId) {
             $customerId = $this->getRequest()->getParam('customerId');
         }
         $this->setCustomerId($customerId);
         $collection->addCustomerFilter($this->getCustomerId());
     }
     if ($this->_coreRegistry->registry('usePendingFilter') === true) {
         $collection->addStatusFilter($model->getPendingStatus());
     }
     $collection->addStoreData();
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
コード例 #4
0
 /**
  * Get product collection
  *
  * @return ProductCollection
  */
 public function getProductCollection()
 {
     return $this->productCollectionFactory->create();
 }