Reindex.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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\Model\Config\Source;
  22. use Magento\Framework\Option\ArrayInterface;
  23. /**
  24. * Class Reindex
  25. * @package Mageplaza\Search\Model\Config\Source
  26. */
  27. class Reindex implements ArrayInterface
  28. {
  29. const TYPE_CRON_JOB = 'cronjob';
  30. const TYPE_PRODUCT_SAVE = 'product_save';
  31. const TYPE_MANUAL = 'manual';
  32. /**
  33. * Options getter
  34. *
  35. * @return array
  36. */
  37. public function toOptionArray()
  38. {
  39. $options = [];
  40. foreach ($this->toArray() as $value => $label) {
  41. $options[] = [
  42. 'value' => $value,
  43. 'label' => $label
  44. ];
  45. }
  46. return $options;
  47. }
  48. /**
  49. * Get options in "key-value" format
  50. *
  51. * @return array
  52. */
  53. public function toArray()
  54. {
  55. return [
  56. self::TYPE_CRON_JOB => __('Cron job'),
  57. self::TYPE_PRODUCT_SAVE => __('After Product Save'),
  58. self::TYPE_MANUAL => __('Manually (used reindex button bellow)')
  59. ];
  60. }
  61. }