ProductSearchUpdate.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Mageplaza
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Mageplaza.com license that is
  8. * available through the world-wide-web at this URL:
  9. * https://www.mageplaza.com/LICENSE.txt
  10. *
  11. * DISCLAIMER
  12. *
  13. * Do not edit or add to this file if you wish to upgrade this extension to newer
  14. * version in the future.
  15. *
  16. * @category Mageplaza
  17. * @package Mageplaza_Search
  18. * @copyright Copyright (c) 2017 Mageplaza (http://www.mageplaza.com/)
  19. * @license https://www.mageplaza.com/LICENSE.txt
  20. */
  21. namespace Mageplaza\Search\Observer;
  22. use Magento\Framework\Event\Observer;
  23. use Magento\Framework\Event\ObserverInterface;
  24. use Mageplaza\Search\Helper\Data;
  25. use Mageplaza\Search\Model\Config\Source\Reindex;
  26. /**
  27. * Class ProductSearchUpdate
  28. * @package Mageplaza\Search\Observer
  29. */
  30. class ProductSearchUpdate implements ObserverInterface
  31. {
  32. /**
  33. * @var Data
  34. */
  35. protected $_helper;
  36. /**
  37. * ProductSearchUpdate constructor.
  38. * @param \Mageplaza\Search\Helper\Data $helper
  39. */
  40. public function __construct(Data $helper)
  41. {
  42. $this->_helper = $helper;
  43. }
  44. /**
  45. * @param \Magento\Framework\Event\Observer $observer
  46. * @return $this
  47. */
  48. public function execute(Observer $observer)
  49. {
  50. if(!$this->_helper->isEnabled()){
  51. return $this;
  52. }
  53. $reindexConfig = $this->_helper->getConfigGeneral('reindex_search');
  54. if ($reindexConfig == Reindex::TYPE_PRODUCT_SAVE) {
  55. $this->_helper->getMediaHelper()->removeJsPath();
  56. }
  57. return $this;
  58. }
  59. }