Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AggregateSalesReportOrderData.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $localeResolver;
17 
21  protected $localeDate;
22 
26  protected $orderFactory;
27 
33  public function __construct(
34  \Magento\Framework\Locale\ResolverInterface $localeResolver,
35  \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
36  \Magento\Sales\Model\ResourceModel\Report\OrderFactory $orderFactory
37  ) {
38  $this->localeResolver = $localeResolver;
39  $this->localeDate = $timezone;
40  $this->orderFactory = $orderFactory;
41  }
42 
48  public function execute()
49  {
50  $this->localeResolver->emulate(0);
51  $currentDate = $this->localeDate->date();
52  $date = $currentDate->sub(new \DateInterval('PT25H'));
53  $this->orderFactory->create()->aggregate($date);
54  $this->localeResolver->revert();
55  }
56 }
__construct(\Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, \Magento\Sales\Model\ResourceModel\Report\OrderFactory $orderFactory)