Skip to content

Commit

Permalink
Implement option to use feature value position as ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ks129 authored Oct 2, 2024
1 parent c5fd245 commit 4506630
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Filters/DataAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace PrestaShop\Module\FacetedSearch\Filters;

use Configuration;
use Combination;
use Db;
use Shop;
Expand Down Expand Up @@ -191,6 +192,13 @@ public function getFeatureValues($idFeature, $idLang)
{
if (!isset($this->featureValues[$idLang][$idFeature])) {
$this->featureValues[$idLang] = [$idFeature => []];

if ((bool) Configuration::get('PS_LAYERED_FILTER_FEATURE_VALUES_USE_POSITION')) {
$order = 'ORDER BY v.`position` ASC';
} else {
$order = 'ORDER BY vl.`value` ASC';
}

$tempFeatureValues = $this->database->executeS(
'SELECT v.*, vl.*, ' .
'IF(lifvlv.`url_name` IS NULL OR lifvlv.`url_name` = "", NULL, lifvlv.`url_name`) AS url_name, ' .
Expand All @@ -201,7 +209,7 @@ public function getFeatureValues($idFeature, $idLang)
'LEFT JOIN `' . _DB_PREFIX_ . 'layered_indexable_feature_value_lang_value` lifvlv ' .
'ON (v.`id_feature_value` = lifvlv.`id_feature_value` AND lifvlv.`id_lang` = ' . (int) $idLang . ') ' .
'WHERE v.`id_feature` = ' . (int) $idFeature . ' ' .
'ORDER BY v.`position` ASC'
$order
);

foreach ($tempFeatureValues as $feature) {
Expand Down

0 comments on commit 4506630

Please sign in to comment.