コード例 #1
0
 public function testPrepareProductCollection()
 {
     $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->will($this->returnValue($this->category));
     $this->collectionFilter->expects($this->once())->method('filter')->with($this->equalTo($this->collection), $this->equalTo($this->category));
     $result = $this->model->prepareProductCollection($this->collection);
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Layer', $result);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function prepareProductCollection($collection)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'prepareProductCollection');
     if (!$pluginInfo) {
         return parent::prepareProductCollection($collection);
     } else {
         return $this->___callPlugins('prepareProductCollection', func_get_args(), $pluginInfo);
     }
 }
コード例 #3
0
 /**
  * Retrieve child categories of current category
  *
  * @return \Magento\Framework\Data\Tree\Node\Collection
  */
 public function getCurrentChildCategories()
 {
     $categories = $this->_catalogLayer->getCurrentCategory()->getChildrenCategories();
     /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
     $productCollection = $this->_productCollectionFactory->create();
     $this->_catalogLayer->prepareProductCollection($productCollection);
     $productCollection->addCountToCategories($categories);
     return $categories;
 }