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); }
/** * {@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); } }
/** * 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; }