Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CatalogProductCompareClearObserver.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
19 
23  private $reportStatus;
24 
28  public function __construct(
29  \Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory,
30  \Magento\Reports\Model\ReportStatus $reportStatus
31  ) {
32  $this->_productCompFactory = $productCompFactory;
33  $this->reportStatus = $reportStatus;
34  }
35 
45  public function execute(\Magento\Framework\Event\Observer $observer)
46  {
47  if (!$this->reportStatus->isReportEnabled(\Magento\Reports\Model\Event::EVENT_PRODUCT_VIEW)) {
48  return;
49  }
50 
51  $this->_productCompFactory->create()->calculate();
52  }
53 }
__construct(\Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory, \Magento\Reports\Model\ReportStatus $reportStatus)