コード例 #1
0
ファイル: Layer.php プロジェクト: pavelnovitsky/magento2
 /**
  * Retrieve current layer product collection
  *
  * @return \Magento\Catalog\Model\Resource\Product\Collection
  */
 public function getProductCollection()
 {
     if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
         $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
     } else {
         $collection = $this->collectionProvider->getCollection($this->getCurrentCategory());
         $this->prepareProductCollection($collection);
         $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
     }
     return $collection;
 }
コード例 #2
0
 public function testGetProductCollection()
 {
     $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->will($this->returnValue($this->category));
     $this->category->expects($this->any())->method('getId')->will($this->returnValue(333));
     $this->collectionFilter->expects($this->once())->method('filter')->with($this->equalTo($this->collection), $this->equalTo($this->category));
     $this->collectionProvider->expects($this->once())->method('getCollection')->with($this->equalTo($this->category))->will($this->returnValue($this->collection));
     $result = $this->model->getProductCollection();
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', $result);
     $result = $this->model->getProductCollection();
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', $result);
 }