Job.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\Cron;
  22. use Mageplaza\Search\Helper\Data;
  23. use Mageplaza\Search\Model\Config\Source\Reindex;
  24. /**
  25. * Class Job
  26. * @package Mageplaza\Search\Cron
  27. */
  28. class Job
  29. {
  30. /**
  31. * @var \Mageplaza\Search\Helper\Data
  32. */
  33. protected $helperData;
  34. /**
  35. * Job constructor.
  36. * @param \Mageplaza\Search\Helper\Data $helperData
  37. */
  38. public function __construct(Data $helperData)
  39. {
  40. $this->helperData = $helperData;
  41. }
  42. /**
  43. * execute cron job
  44. */
  45. public function execute()
  46. {
  47. $reindexConfig = $this->helperData->getConfigGeneral('reindex_search');
  48. if ($reindexConfig == Reindex::TYPE_CRON_JOB) {
  49. $this->helperData->createJsonFile();
  50. }
  51. return $this;
  52. }
  53. }