Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Discounts.php
Go to the documentation of this file.
1 <?php
7 
12 class Discounts
13 {
17  protected $collectionFactory;
18 
22  protected $dateTime;
23 
28  public function __construct(
29  \Magento\Framework\Stdlib\DateTime $dateTime,
30  \Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory $collectionFactory
31  ) {
32  $this->dateTime = $dateTime;
33  $this->collectionFactory = $collectionFactory;
34  }
35 
41  public function getDiscountCollection($websiteId, $customerGroupId)
42  {
44  $collection = $this->collectionFactory->create();
45  $collection->addWebsiteGroupDateFilter(
46  $websiteId,
47  $customerGroupId,
48  (new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)
49  )
50  ->addFieldToFilter('is_rss', 1)
51  ->setOrder('from_date', 'desc');
52  $collection->load();
53  return $collection;
54  }
55 }
__construct(\Magento\Framework\Stdlib\DateTime $dateTime, \Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory $collectionFactory)
Definition: Discounts.php:28