This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
61
61
/**
62
62
* @var string|null
63
63
*/
64
- private $ order = null ;
64
+ private $ relevanceOrderDirection = null ;
65
65
66
66
/**
67
67
* @var string
@@ -361,13 +361,16 @@ protected function _renderFiltersBefore()
361
361
[]
362
362
);
363
363
364
- if ($ this ->order && 'relevance ' === $ this ->order ['field ' ]) {
365
- $ this ->getSelect ()->order ('search_result. ' . TemporaryStorage::FIELD_SCORE . ' ' . $ this ->order ['dir ' ]);
364
+ if ($ this ->relevanceOrderDirection ) {
365
+ $ this ->getSelect ()->order (
366
+ 'search_result. ' . TemporaryStorage::FIELD_SCORE . ' ' . $ this ->relevanceOrderDirection
367
+ );
366
368
}
367
369
368
370
/*
369
371
* This order is required to force search results be the same
370
372
* for the same requests and products with the same relevance
373
+ * NOTE: this does not replace existing orders but ADDs one more
371
374
*/
372
375
$ this ->setOrder ('entity_id ' );
373
376
@@ -392,10 +395,12 @@ protected function _renderFilters()
392
395
*/
393
396
public function setOrder ($ attribute , $ dir = Select::SQL_DESC )
394
397
{
395
- $ this ->order = ['field ' => $ attribute , 'dir ' => $ dir ];
396
- if ($ attribute !== 'relevance ' ) {
398
+ if ($ attribute === 'relevance ' ) {
399
+ $ this ->relevanceOrderDirection = $ dir ;
400
+ } else {
397
401
parent ::setOrder ($ attribute , $ dir );
398
402
}
403
+
399
404
return $ this ;
400
405
}
401
406
You can’t perform that action at this time.
0 commit comments