Fix tree view selection and add entity-specific sort options
- Fix validation mixin not being merged in _core.js which broke tree item selection - Add data-entities attribute to sort options for entity-specific filtering - Improve event handlers and filter panel updates Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1467,7 +1467,9 @@
|
|||||||
var name = $item.data('name');
|
var name = $item.data('name');
|
||||||
var isSelected = $item.hasClass('selected');
|
var isSelected = $item.hasClass('selected');
|
||||||
|
|
||||||
if (!self.activeGroup) return;
|
if (!self.activeGroup) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!self.pendingSelections) self.pendingSelections = [];
|
if (!self.pendingSelections) self.pendingSelections = [];
|
||||||
|
|
||||||
var $allItems = self.$dropdown.find('.tree-item');
|
var $allItems = self.$dropdown.find('.tree-item');
|
||||||
@@ -2166,14 +2168,22 @@
|
|||||||
html += '<i class="icon-square-o"></i> ' + (trans.clear || 'Clear') + ' <kbd>Ctrl+D</kbd>';
|
html += '<i class="icon-square-o"></i> ' + (trans.clear || 'Clear') + ' <kbd>Ctrl+D</kbd>';
|
||||||
html += '</button>';
|
html += '</button>';
|
||||||
|
|
||||||
// Sort controls
|
// Sort controls - options with data-entities attribute for entity-specific filtering
|
||||||
html += '<div class="sort-controls">';
|
html += '<div class="sort-controls">';
|
||||||
html += '<select class="sort-field-select" title="Sort by">';
|
html += '<select class="sort-field-select" title="Sort by">';
|
||||||
|
// Universal options (all entities)
|
||||||
html += '<option value="name">' + (trans.sort_name || 'Name') + '</option>';
|
html += '<option value="name">' + (trans.sort_name || 'Name') + '</option>';
|
||||||
html += '<option value="id">' + (trans.sort_id || 'ID') + '</option>';
|
html += '<option value="id">' + (trans.sort_id || 'ID') + '</option>';
|
||||||
html += '<option value="position">' + (trans.sort_position || 'Position') + '</option>';
|
|
||||||
html += '<option value="popularity">' + (trans.sort_popularity || 'Popularity') + '</option>';
|
|
||||||
html += '<option value="selected">' + (trans.sort_selected || 'Selected') + '</option>';
|
html += '<option value="selected">' + (trans.sort_selected || 'Selected') + '</option>';
|
||||||
|
// Product-specific
|
||||||
|
html += '<option value="price" data-entities="products">' + (trans.sort_price || 'Price') + '</option>';
|
||||||
|
html += '<option value="stock" data-entities="products">' + (trans.sort_stock || 'Stock') + '</option>';
|
||||||
|
html += '<option value="popularity" data-entities="products">' + (trans.sort_popularity || 'Sales') + '</option>';
|
||||||
|
html += '<option value="reference" data-entities="products">' + (trans.sort_reference || 'Reference') + '</option>';
|
||||||
|
// Position-based entities (categories, cms, cms_categories, attributes)
|
||||||
|
html += '<option value="position" data-entities="categories,cms,cms_categories,attributes">' + (trans.sort_position || 'Position') + '</option>';
|
||||||
|
// Product count (categories, manufacturers, suppliers)
|
||||||
|
html += '<option value="product_count" data-entities="categories,manufacturers,suppliers">' + (trans.sort_product_count || 'Products') + '</option>';
|
||||||
html += '</select>';
|
html += '</select>';
|
||||||
html += '<button type="button" class="btn-sort-dir" data-dir="ASC" title="Sort direction">';
|
html += '<button type="button" class="btn-sort-dir" data-dir="ASC" title="Sort direction">';
|
||||||
html += '<i class="icon-sort-alpha-asc"></i>';
|
html += '<i class="icon-sort-alpha-asc"></i>';
|
||||||
@@ -3518,6 +3528,53 @@
|
|||||||
this.$dropdown.find('.view-mode-select').val('list');
|
this.$dropdown.find('.view-mode-select').val('list');
|
||||||
this.$dropdown.removeClass('view-tree view-cols-2 view-cols-3 view-cols-4 view-cols-5 view-cols-6 view-cols-7 view-cols-8').addClass('view-list');
|
this.$dropdown.removeClass('view-tree view-cols-2 view-cols-3 view-cols-4 view-cols-5 view-cols-6 view-cols-7 view-cols-8').addClass('view-list');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update sort options for entity type
|
||||||
|
this.updateSortOptionsForEntity(entityType);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show/hide sort options based on entity type
|
||||||
|
* Options with data-entities attribute are only shown for matching entities
|
||||||
|
*/
|
||||||
|
updateSortOptionsForEntity: function(entityType) {
|
||||||
|
if (!this.$dropdown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $select = this.$dropdown.find('.sort-field-select');
|
||||||
|
var currentValue = $select.val();
|
||||||
|
var hasCurrentOption = false;
|
||||||
|
|
||||||
|
$select.find('option').each(function() {
|
||||||
|
var $option = $(this);
|
||||||
|
var entities = $option.data('entities');
|
||||||
|
|
||||||
|
// Options without data-entities are universal (always shown)
|
||||||
|
if (!entities) {
|
||||||
|
$option.show();
|
||||||
|
if ($option.val() === currentValue) {
|
||||||
|
hasCurrentOption = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if this entity type is in the allowed list
|
||||||
|
var allowedEntities = entities.split(',');
|
||||||
|
var isAllowed = allowedEntities.indexOf(entityType) !== -1;
|
||||||
|
|
||||||
|
$option.toggle(isAllowed);
|
||||||
|
|
||||||
|
if (isAllowed && $option.val() === currentValue) {
|
||||||
|
hasCurrentOption = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// If current sort field is not available for this entity, reset to 'name'
|
||||||
|
if (!hasCurrentOption) {
|
||||||
|
$select.val('name');
|
||||||
|
this.currentSort.field = 'name';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
loadFilterableData: function() {
|
loadFilterableData: function() {
|
||||||
@@ -9845,6 +9902,11 @@
|
|||||||
$.extend(instance, mixins.tree);
|
$.extend(instance, mixins.tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merge validation mixin
|
||||||
|
if (mixins.validation) {
|
||||||
|
$.extend(instance, mixins.validation);
|
||||||
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
assets/js/admin/entity-selector.min.js
vendored
2
assets/js/admin/entity-selector.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -209,6 +209,11 @@
|
|||||||
$.extend(instance, mixins.tree);
|
$.extend(instance, mixins.tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merge validation mixin
|
||||||
|
if (mixins.validation) {
|
||||||
|
$.extend(instance, mixins.validation);
|
||||||
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,14 +32,22 @@
|
|||||||
html += '<i class="icon-square-o"></i> ' + (trans.clear || 'Clear') + ' <kbd>Ctrl+D</kbd>';
|
html += '<i class="icon-square-o"></i> ' + (trans.clear || 'Clear') + ' <kbd>Ctrl+D</kbd>';
|
||||||
html += '</button>';
|
html += '</button>';
|
||||||
|
|
||||||
// Sort controls
|
// Sort controls - options with data-entities attribute for entity-specific filtering
|
||||||
html += '<div class="sort-controls">';
|
html += '<div class="sort-controls">';
|
||||||
html += '<select class="sort-field-select" title="Sort by">';
|
html += '<select class="sort-field-select" title="Sort by">';
|
||||||
|
// Universal options (all entities)
|
||||||
html += '<option value="name">' + (trans.sort_name || 'Name') + '</option>';
|
html += '<option value="name">' + (trans.sort_name || 'Name') + '</option>';
|
||||||
html += '<option value="id">' + (trans.sort_id || 'ID') + '</option>';
|
html += '<option value="id">' + (trans.sort_id || 'ID') + '</option>';
|
||||||
html += '<option value="position">' + (trans.sort_position || 'Position') + '</option>';
|
|
||||||
html += '<option value="popularity">' + (trans.sort_popularity || 'Popularity') + '</option>';
|
|
||||||
html += '<option value="selected">' + (trans.sort_selected || 'Selected') + '</option>';
|
html += '<option value="selected">' + (trans.sort_selected || 'Selected') + '</option>';
|
||||||
|
// Product-specific
|
||||||
|
html += '<option value="price" data-entities="products">' + (trans.sort_price || 'Price') + '</option>';
|
||||||
|
html += '<option value="stock" data-entities="products">' + (trans.sort_stock || 'Stock') + '</option>';
|
||||||
|
html += '<option value="popularity" data-entities="products">' + (trans.sort_popularity || 'Sales') + '</option>';
|
||||||
|
html += '<option value="reference" data-entities="products">' + (trans.sort_reference || 'Reference') + '</option>';
|
||||||
|
// Position-based entities (categories, cms, cms_categories, attributes)
|
||||||
|
html += '<option value="position" data-entities="categories,cms,cms_categories,attributes">' + (trans.sort_position || 'Position') + '</option>';
|
||||||
|
// Product count (categories, manufacturers, suppliers)
|
||||||
|
html += '<option value="product_count" data-entities="categories,manufacturers,suppliers">' + (trans.sort_product_count || 'Products') + '</option>';
|
||||||
html += '</select>';
|
html += '</select>';
|
||||||
html += '<button type="button" class="btn-sort-dir" data-dir="ASC" title="Sort direction">';
|
html += '<button type="button" class="btn-sort-dir" data-dir="ASC" title="Sort direction">';
|
||||||
html += '<i class="icon-sort-alpha-asc"></i>';
|
html += '<i class="icon-sort-alpha-asc"></i>';
|
||||||
|
|||||||
@@ -1302,7 +1302,9 @@
|
|||||||
var name = $item.data('name');
|
var name = $item.data('name');
|
||||||
var isSelected = $item.hasClass('selected');
|
var isSelected = $item.hasClass('selected');
|
||||||
|
|
||||||
if (!self.activeGroup) return;
|
if (!self.activeGroup) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!self.pendingSelections) self.pendingSelections = [];
|
if (!self.pendingSelections) self.pendingSelections = [];
|
||||||
|
|
||||||
var $allItems = self.$dropdown.find('.tree-item');
|
var $allItems = self.$dropdown.find('.tree-item');
|
||||||
|
|||||||
@@ -132,6 +132,53 @@
|
|||||||
this.$dropdown.find('.view-mode-select').val('list');
|
this.$dropdown.find('.view-mode-select').val('list');
|
||||||
this.$dropdown.removeClass('view-tree view-cols-2 view-cols-3 view-cols-4 view-cols-5 view-cols-6 view-cols-7 view-cols-8').addClass('view-list');
|
this.$dropdown.removeClass('view-tree view-cols-2 view-cols-3 view-cols-4 view-cols-5 view-cols-6 view-cols-7 view-cols-8').addClass('view-list');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update sort options for entity type
|
||||||
|
this.updateSortOptionsForEntity(entityType);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show/hide sort options based on entity type
|
||||||
|
* Options with data-entities attribute are only shown for matching entities
|
||||||
|
*/
|
||||||
|
updateSortOptionsForEntity: function(entityType) {
|
||||||
|
if (!this.$dropdown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $select = this.$dropdown.find('.sort-field-select');
|
||||||
|
var currentValue = $select.val();
|
||||||
|
var hasCurrentOption = false;
|
||||||
|
|
||||||
|
$select.find('option').each(function() {
|
||||||
|
var $option = $(this);
|
||||||
|
var entities = $option.data('entities');
|
||||||
|
|
||||||
|
// Options without data-entities are universal (always shown)
|
||||||
|
if (!entities) {
|
||||||
|
$option.show();
|
||||||
|
if ($option.val() === currentValue) {
|
||||||
|
hasCurrentOption = true;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if this entity type is in the allowed list
|
||||||
|
var allowedEntities = entities.split(',');
|
||||||
|
var isAllowed = allowedEntities.indexOf(entityType) !== -1;
|
||||||
|
|
||||||
|
$option.toggle(isAllowed);
|
||||||
|
|
||||||
|
if (isAllowed && $option.val() === currentValue) {
|
||||||
|
hasCurrentOption = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// If current sort field is not available for this entity, reset to 'name'
|
||||||
|
if (!hasCurrentOption) {
|
||||||
|
$select.val('name');
|
||||||
|
this.currentSort.field = 'name';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
loadFilterableData: function() {
|
loadFilterableData: function() {
|
||||||
|
|||||||
@@ -1147,6 +1147,13 @@ trait EntitySelector
|
|||||||
$limit = (int) Tools::getValue('limit', 20);
|
$limit = (int) Tools::getValue('limit', 20);
|
||||||
$offset = (int) Tools::getValue('offset', 0);
|
$offset = (int) Tools::getValue('offset', 0);
|
||||||
|
|
||||||
|
// Sorting parameters
|
||||||
|
$sortBy = Tools::getValue('sort_by', 'name');
|
||||||
|
$sortDir = strtoupper(Tools::getValue('sort_dir', 'ASC'));
|
||||||
|
if (!in_array($sortDir, ['ASC', 'DESC'])) {
|
||||||
|
$sortDir = 'ASC';
|
||||||
|
}
|
||||||
|
|
||||||
$idLang = (int) $this->context->language->id;
|
$idLang = (int) $this->context->language->id;
|
||||||
$idShop = (int) $this->context->shop->id;
|
$idShop = (int) $this->context->shop->id;
|
||||||
|
|
||||||
@@ -1217,6 +1224,9 @@ trait EntitySelector
|
|||||||
'is_color' => $filterIsColor,
|
'is_color' => $filterIsColor,
|
||||||
'is_custom' => $filterIsCustom,
|
'is_custom' => $filterIsCustom,
|
||||||
'indexable' => $filterIndexable,
|
'indexable' => $filterIndexable,
|
||||||
|
// Sorting
|
||||||
|
'sort_by' => $sortBy,
|
||||||
|
'sort_dir' => $sortDir,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Delegate to EntitySearchEngine
|
// Delegate to EntitySearchEngine
|
||||||
|
|||||||
@@ -126,6 +126,29 @@ class EntitySearchEngine
|
|||||||
return str_replace(['%', '_'], ['\\%', '\\_'], pSQL($pattern));
|
return str_replace(['%', '_'], ['\\%', '\\_'], pSQL($pattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build ORDER BY clause based on entity type and sort field
|
||||||
|
*
|
||||||
|
* @param string $entityType Entity type (products, categories, etc.)
|
||||||
|
* @param array $filters Filters containing sort_by and sort_dir
|
||||||
|
* @param array $columnMap Mapping of sort field names to SQL columns
|
||||||
|
* @return string ORDER BY clause
|
||||||
|
*/
|
||||||
|
protected function buildOrderBy($entityType, array $filters, array $columnMap)
|
||||||
|
{
|
||||||
|
$sortBy = $filters['sort_by'] ?? 'name';
|
||||||
|
$sortDir = strtoupper($filters['sort_dir'] ?? 'ASC');
|
||||||
|
|
||||||
|
if (!in_array($sortDir, ['ASC', 'DESC'])) {
|
||||||
|
$sortDir = 'ASC';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the column for sorting
|
||||||
|
$column = $columnMap[$sortBy] ?? $columnMap['name'] ?? 'name';
|
||||||
|
|
||||||
|
return $column . ' ' . $sortDir;
|
||||||
|
}
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// PRODUCTS
|
// PRODUCTS
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
@@ -187,7 +210,17 @@ class EntitySearchEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('pl.name ASC');
|
// Sorting
|
||||||
|
// Note: Products don't have a global position - only per-category positions in ps_category_product
|
||||||
|
$productSortMap = [
|
||||||
|
'name' => 'pl.name',
|
||||||
|
'id' => 'p.id_product',
|
||||||
|
'price' => 'ps.price',
|
||||||
|
'reference' => 'p.reference',
|
||||||
|
'popularity' => 'sales_qty',
|
||||||
|
'stock' => 'stock_qty',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('products', $filters, $productSortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -546,7 +579,14 @@ class EntitySearchEngine
|
|||||||
$sql->where('c.active = 1');
|
$sql->where('c.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('cl.name ASC');
|
// Sorting
|
||||||
|
$categorySortMap = [
|
||||||
|
'name' => 'cl.name',
|
||||||
|
'id' => 'c.id_category',
|
||||||
|
'position' => 'c.position',
|
||||||
|
'product_count' => 'product_count',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('categories', $filters, $categorySortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -876,7 +916,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('m.active = 1');
|
$sql->where('m.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('m.name ASC');
|
// Sorting
|
||||||
|
$manufacturerSortMap = [
|
||||||
|
'name' => 'm.name',
|
||||||
|
'id' => 'm.id_manufacturer',
|
||||||
|
'product_count' => 'product_count',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('manufacturers', $filters, $manufacturerSortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -1002,7 +1048,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('s.active = 1');
|
$sql->where('s.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('s.name ASC');
|
// Sorting
|
||||||
|
$supplierSortMap = [
|
||||||
|
'name' => 's.name',
|
||||||
|
'id' => 's.id_supplier',
|
||||||
|
'product_count' => 'product_count',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('suppliers', $filters, $supplierSortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -1128,7 +1180,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('c.active = 1');
|
$sql->where('c.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('cl.meta_title ASC');
|
// Sorting
|
||||||
|
$cmsSortMap = [
|
||||||
|
'name' => 'cl.meta_title',
|
||||||
|
'id' => 'c.id_cms',
|
||||||
|
'position' => 'c.position',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('cms', $filters, $cmsSortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -1258,7 +1316,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('cc.active = 1');
|
$sql->where('cc.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('ccl.name ASC');
|
// Sorting
|
||||||
|
$cmsCategorySortMap = [
|
||||||
|
'name' => 'ccl.name',
|
||||||
|
'id' => 'cc.id_cms_category',
|
||||||
|
'position' => 'cc.position',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('cms_categories', $filters, $cmsCategorySortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -1388,7 +1452,12 @@ class EntitySearchEngine
|
|||||||
$sql->where('e.active = 1');
|
$sql->where('e.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('e.lastname ASC, e.firstname ASC');
|
// Sorting
|
||||||
|
$employeeSortMap = [
|
||||||
|
'name' => 'e.lastname',
|
||||||
|
'id' => 'e.id_employee',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('employees', $filters, $employeeSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -1515,7 +1584,12 @@ class EntitySearchEngine
|
|||||||
$sql->where('c.active = 1');
|
$sql->where('c.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('c.lastname ASC, c.firstname ASC');
|
// Sorting
|
||||||
|
$customerSortMap = [
|
||||||
|
'name' => 'c.lastname',
|
||||||
|
'id' => 'c.id_customer',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('customers', $filters, $customerSortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -1644,7 +1718,12 @@ class EntitySearchEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('gl.name ASC');
|
// Sorting
|
||||||
|
$customerGroupSortMap = [
|
||||||
|
'name' => 'gl.name',
|
||||||
|
'id' => 'g.id_group',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('customer_groups', $filters, $customerGroupSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -1768,7 +1847,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('c.active = 1');
|
$sql->where('c.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('c.name ASC');
|
// Sorting
|
||||||
|
$carrierSortMap = [
|
||||||
|
'name' => 'c.name',
|
||||||
|
'id' => 'c.id_carrier',
|
||||||
|
'position' => 'c.position',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('carriers', $filters, $carrierSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -1895,7 +1980,12 @@ class EntitySearchEngine
|
|||||||
$sql->where('z.active = 1');
|
$sql->where('z.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('z.name ASC');
|
// Sorting
|
||||||
|
$zoneSortMap = [
|
||||||
|
'name' => 'z.name',
|
||||||
|
'id' => 'z.id_zone',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('zones', $filters, $zoneSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -2022,7 +2112,14 @@ class EntitySearchEngine
|
|||||||
$sql->where('c.active = 1');
|
$sql->where('c.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('cl.name ASC');
|
// Sorting
|
||||||
|
$countrySortMap = [
|
||||||
|
'name' => 'cl.name',
|
||||||
|
'id' => 'c.id_country',
|
||||||
|
'zone' => 'z.name',
|
||||||
|
'iso_code' => 'c.iso_code',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('countries', $filters, $countrySortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -2154,7 +2251,14 @@ class EntitySearchEngine
|
|||||||
$sql->where('c.active = 1');
|
$sql->where('c.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('cl.name ASC');
|
// Sorting
|
||||||
|
$currencySortMap = [
|
||||||
|
'name' => 'cl.name',
|
||||||
|
'id' => 'c.id_currency',
|
||||||
|
'iso_code' => 'c.iso_code',
|
||||||
|
'conversion_rate' => 'c.conversion_rate',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('currencies', $filters, $currencySortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -2285,7 +2389,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('l.active = 1');
|
$sql->where('l.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('l.name ASC');
|
// Sorting
|
||||||
|
$languageSortMap = [
|
||||||
|
'name' => 'l.name',
|
||||||
|
'id' => 'l.id_lang',
|
||||||
|
'iso_code' => 'l.iso_code',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('languages', $filters, $languageSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -2414,7 +2524,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('s.active = 1');
|
$sql->where('s.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('s.name ASC');
|
// Sorting
|
||||||
|
$shopSortMap = [
|
||||||
|
'name' => 's.name',
|
||||||
|
'id' => 's.id_shop',
|
||||||
|
'group' => 'sg.name',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('shops', $filters, $shopSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -2534,7 +2650,12 @@ class EntitySearchEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('pl.name ASC');
|
// Sorting
|
||||||
|
$profileSortMap = [
|
||||||
|
'name' => 'pl.name',
|
||||||
|
'id' => 'p.id_profile',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('profiles', $filters, $profileSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -2650,7 +2771,12 @@ class EntitySearchEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('osl.name ASC');
|
// Sorting
|
||||||
|
$orderStateSortMap = [
|
||||||
|
'name' => 'osl.name',
|
||||||
|
'id' => 'os.id_order_state',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('order_states', $filters, $orderStateSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -2776,7 +2902,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('t.active = 1');
|
$sql->where('t.active = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('tl.name ASC');
|
// Sorting
|
||||||
|
$taxSortMap = [
|
||||||
|
'name' => 'tl.name',
|
||||||
|
'id' => 't.id_tax',
|
||||||
|
'rate' => 't.rate',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('taxes', $filters, $taxSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -2911,7 +3043,14 @@ class EntitySearchEngine
|
|||||||
$sql->where('ag.is_color_group = 1');
|
$sql->where('ag.is_color_group = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('agl.name ASC, a.position ASC');
|
// Sorting
|
||||||
|
$attributeSortMap = [
|
||||||
|
'name' => 'al.name',
|
||||||
|
'id' => 'a.id_attribute',
|
||||||
|
'position' => 'a.position',
|
||||||
|
'group' => 'agl.name',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('attributes', $filters, $attributeSortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -3056,7 +3195,13 @@ class EntitySearchEngine
|
|||||||
$sql->where('fv.custom = 1');
|
$sql->where('fv.custom = 1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('fl.name ASC, fvl.value ASC');
|
// Sorting
|
||||||
|
$featureSortMap = [
|
||||||
|
'name' => 'fvl.value',
|
||||||
|
'id' => 'fv.id_feature_value',
|
||||||
|
'feature' => 'fl.name',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('features', $filters, $featureSortMap));
|
||||||
$sql->limit((int) $limit, (int) $offset);
|
$sql->limit((int) $limit, (int) $offset);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
@@ -3189,7 +3334,13 @@ class EntitySearchEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql->orderBy('t.name ASC');
|
// Sorting
|
||||||
|
$tagSortMap = [
|
||||||
|
'name' => 't.name',
|
||||||
|
'id' => 't.id_tag',
|
||||||
|
'popularity' => 'product_count',
|
||||||
|
];
|
||||||
|
$sql->orderBy($this->buildOrderBy('tags', $filters, $tagSortMap));
|
||||||
$sql->limit($limit);
|
$sql->limit($limit);
|
||||||
|
|
||||||
$results = Db::getInstance()->executeS($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
|
|||||||
Reference in New Issue
Block a user