|
36 | 36 | use Magento\Framework\Api\SearchCriteriaInterface; |
37 | 37 | use Magento\Framework\Api\SearchResultsInterface; |
38 | 38 | use Magento\GraphQl\Model\Query\ContextInterface; |
| 39 | +use Magento\Customer\Api\Data\OptionInterfaceFactory; |
39 | 40 |
|
40 | 41 | /** |
41 | 42 | * Product field data provider for product search, used for GraphQL resolver processing. |
@@ -72,28 +73,36 @@ class ProductSearch |
72 | 73 | */ |
73 | 74 | private $searchCriteriaBuilder; |
74 | 75 |
|
| 76 | + /** |
| 77 | + * @var OptionInterfaceFactory |
| 78 | + */ |
| 79 | + private $optionFactory; |
| 80 | + |
75 | 81 | /** |
76 | 82 | * @param CollectionFactory $collectionFactory |
77 | 83 | * @param ProductSearchResultsInterfaceFactory $searchResultsFactory |
78 | 84 | * @param CollectionProcessorInterface $collectionPreProcessor |
79 | 85 | * @param CollectionPostProcessor $collectionPostProcessor |
80 | 86 | * @param SearchResultApplierFactory $searchResultsApplierFactory |
81 | 87 | * @param ProductCollectionSearchCriteriaBuilder $searchCriteriaBuilder |
| 88 | + * @param OptionInterfaceFactory $optionFactory |
82 | 89 | */ |
83 | 90 | public function __construct( |
84 | 91 | CollectionFactory $collectionFactory, |
85 | 92 | ProductSearchResultsInterfaceFactory $searchResultsFactory, |
86 | 93 | CollectionProcessorInterface $collectionPreProcessor, |
87 | 94 | CollectionPostProcessor $collectionPostProcessor, |
88 | 95 | SearchResultApplierFactory $searchResultsApplierFactory, |
89 | | - ProductCollectionSearchCriteriaBuilder $searchCriteriaBuilder |
| 96 | + ProductCollectionSearchCriteriaBuilder $searchCriteriaBuilder, |
| 97 | + OptionInterfaceFactory $optionFactory |
90 | 98 | ) { |
91 | 99 | $this->collectionFactory = $collectionFactory; |
92 | 100 | $this->searchResultsFactory = $searchResultsFactory; |
93 | 101 | $this->collectionPreProcessor = $collectionPreProcessor; |
94 | 102 | $this->collectionPostProcessor = $collectionPostProcessor; |
95 | 103 | $this->searchResultApplierFactory = $searchResultsApplierFactory; |
96 | 104 | $this->searchCriteriaBuilder = $searchCriteriaBuilder; |
| 105 | + $this->optionFactory = $optionFactory; |
97 | 106 | } |
98 | 107 |
|
99 | 108 | /** |
@@ -129,7 +138,10 @@ public function getList( |
129 | 138 | if (get_class($_item) == "Smile\\ElasticsuiteCore\\Search\\Adapter\\Elasticsuite\\Response\\Document") { |
130 | 139 | $score = $_item->getCustomAttribute('score'); |
131 | 140 | if (!$score) { |
132 | | - $_item->setCustomAttribute('score', ''); |
| 141 | + $scoreOption = $this->optionFactory->create(); |
| 142 | + $scoreOption->setLabel("score"); |
| 143 | + $scoreOption->setValue(1); |
| 144 | + $_item->setCustomAttribute('score', $scoreOption); |
133 | 145 | } |
134 | 146 | $items[] = $_item; |
135 | 147 | } |
|
0 commit comments