Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Promotion.php
Go to the documentation of this file.
1 <?php
7 
10 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
11 
13 {
20 
25 
35  public function __construct(
36  \Magento\Catalog\Block\Product\Context $context,
37  \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
38  \Magento\Catalog\Model\Layer\Resolver $layerResolver,
40  \Magento\Framework\Url\Helper\Data $urlHelper,
41  CollectionFactory $productCollectionFactory,
42  array $data = []
43  ) {
44  $this->_productCollectionFactory = $productCollectionFactory;
45  parent::__construct(
46  $context,
47  $postDataHelper,
48  $layerResolver,
50  $urlHelper,
51  $data
52  );
53  }
54 
58  protected function _getProductCollection()
59  {
60  if ($this->_productCollection === null) {
62  $collection = $this->_productCollectionFactory->create();
63  $this->_catalogLayer->prepareProductCollection($collection);
64 
65  $collection->addAttributeToFilter('promotion', 1)->addStoreFilter();
66 
67  $this->_productCollection = $collection;
68  }
70  }
71 }
Definition: PostHelper.php:15
__construct(\Magento\Catalog\Block\Product\Context $context, \Magento\Framework\Data\Helper\PostHelper $postDataHelper, \Magento\Catalog\Model\Layer\Resolver $layerResolver, CategoryRepositoryInterface $categoryRepository, \Magento\Framework\Url\Helper\Data $urlHelper, CollectionFactory $productCollectionFactory, array $data=[])
Definition: Promotion.php:35