Engine.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Elasticsearch\Model\ResourceModel;
  7. use Magento\CatalogSearch\Model\ResourceModel\EngineInterface;
  8. use Magento\Catalog\Model\Product\Visibility;
  9. use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver;
  10. /**
  11. * Search engine resource model
  12. */
  13. class Engine implements EngineInterface
  14. {
  15. /**
  16. * Catalog product visibility
  17. *
  18. * @var Visibility
  19. */
  20. protected $catalogProductVisibility;
  21. /**
  22. * @var IndexScopeResolver
  23. */
  24. private $indexScopeResolver;
  25. /**
  26. * Construct
  27. *
  28. * @param Visibility $catalogProductVisibility
  29. * @param IndexScopeResolver $indexScopeResolver
  30. */
  31. public function __construct(
  32. Visibility $catalogProductVisibility,
  33. IndexScopeResolver $indexScopeResolver
  34. ) {
  35. $this->catalogProductVisibility = $catalogProductVisibility;
  36. $this->indexScopeResolver = $indexScopeResolver;
  37. }
  38. /**
  39. * Retrieve allowed visibility values for current engine
  40. *
  41. * @return int[]
  42. */
  43. public function getAllowedVisibility()
  44. {
  45. return $this->catalogProductVisibility->getVisibleInSiteIds();
  46. }
  47. /**
  48. * Define if current search engine supports advanced index
  49. *
  50. * @return bool
  51. */
  52. public function allowAdvancedIndex()
  53. {
  54. return false;
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function processAttributeValue($attribute, $value)
  60. {
  61. return $value;
  62. }
  63. /**
  64. * Prepare index array as a string glued by separator
  65. * Support 2 level array gluing
  66. *
  67. * @param array $index
  68. * @param string $separator
  69. * @return string
  70. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  71. */
  72. public function prepareEntityIndex($index, $separator = ' ')
  73. {
  74. return $index;
  75. }
  76. /**
  77. * {@inheritdoc}
  78. */
  79. public function isAvailable()
  80. {
  81. return true;
  82. }
  83. }