CustomerLogoutObserver.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Reports\Observer;
  7. use Magento\Framework\Event\ObserverInterface;
  8. /**
  9. * Reports Event observer model
  10. */
  11. class CustomerLogoutObserver implements ObserverInterface
  12. {
  13. /**
  14. * @var \Magento\Reports\Model\Product\Index\ComparedFactory
  15. */
  16. protected $_productCompFactory;
  17. /**
  18. * @var \Magento\Reports\Model\Product\Index\ViewedFactory
  19. */
  20. protected $_productIndxFactory;
  21. /**
  22. * @param \Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory
  23. * @param \Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory
  24. */
  25. public function __construct(
  26. \Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory,
  27. \Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory
  28. ) {
  29. $this->_productCompFactory = $productCompFactory;
  30. $this->_productIndxFactory = $productIndxFactory;
  31. }
  32. /**
  33. * Customer logout processing
  34. *
  35. * @param \Magento\Framework\Event\Observer $observer
  36. * @return void
  37. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  38. */
  39. public function execute(\Magento\Framework\Event\Observer $observer)
  40. {
  41. $this->_productCompFactory->create()->purgeVisitorByCustomer()->calculate();
  42. $this->_productIndxFactory->create()->purgeVisitorByCustomer()->calculate();
  43. }
  44. }