Esempio n. 1
0
 /**
  * Return collection of reviews
  *
  * @return array|\Magento\Review\Model\Resource\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;
 }
Esempio n. 2
0
 protected function setUp()
 {
     $this->storeManager = $this->getMock('\\Magento\\Framework\\StoreManagerInterface');
     $this->context = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', array(), array(), '', false);
     $this->context->expects($this->any())->method('getStoreManager')->will($this->returnValue($this->storeManager));
     $this->collection = $this->getMock('Magento\\Review\\Model\\Resource\\Review\\Product\\Collection', array(), array(), '', false);
     $this->collectionFactory = $this->getMock('Magento\\Review\\Model\\Resource\\Review\\Product\\CollectionFactory', array('create'), array(), '', false);
     $this->collectionFactory->expects($this->once())->method('create')->will($this->returnValue($this->collection));
     $this->currentCustomer = $this->getMock('Magento\\Customer\\Helper\\Session\\CurrentCustomer', array(), array(), '', false);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->object = $this->objectManagerHelper->getObject('Magento\\Review\\Block\\Customer\\Recent', array('context' => $this->context, 'collectionFactory' => $this->collectionFactory, 'currentCustomer' => $this->currentCustomer));
 }
Esempio n. 3
0
 /**
  * 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\Resource\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();
 }
Esempio n. 4
0
 /**
  * Get product collection
  *
  * @return ProductCollection
  */
 public function getProductCollection()
 {
     return $this->productCollectionFactory->create();
 }
Esempio n. 5
0
 /**
  * Initialize review collection
  *
  * @return $this
  */
 protected function _initCollection()
 {
     $this->_collection = $this->_collectionFactory->create();
     $this->_collection->addStoreFilter($this->_storeManager->getStore()->getId())->addCustomerFilter($this->currentCustomer->getCustomerId())->setDateOrder();
     return $this;
 }