Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WishlistAddProductObserver.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  protected $eventSaver;
20 
24  private $reportStatus;
25 
29  public function __construct(
31  \Magento\Reports\Model\ReportStatus $reportStatus
32  ) {
33  $this->eventSaver = $eventSaver;
34  $this->reportStatus = $reportStatus;
35  }
36 
43  public function execute(\Magento\Framework\Event\Observer $observer)
44  {
45  if (!$this->reportStatus->isReportEnabled(Event::EVENT_PRODUCT_TO_WISHLIST)) {
46  return;
47  }
48 
49  $this->eventSaver->save(
51  $observer->getEvent()->getProduct()->getId()
52  );
53  }
54 }
__construct(EventSaver $eventSaver, \Magento\Reports\Model\ReportStatus $reportStatus)
execute(\Magento\Framework\Event\Observer $observer)