Merge pull request #1467 from vishal-singh-webkul/gli-2609

Fixed: Filter related issues in the Back office
This commit is contained in:
Rohit Jain
2025-06-17 17:32:13 +05:30
committed by GitHub
5 changed files with 60 additions and 15 deletions

View File

@@ -455,7 +455,7 @@
<p class="help-block">{l s='Please note that position numbering starts from 0. A position of 0 means room type will be displayed at the topmost position.'}</p>
<div class="alert alert-info">
{l s='You can manage positions of the room types of this hotel from'}
<a href="{$link->getAdminLink('AdminProducts')}&id_category={$htl_full_info['id_category']}">{l s='here.'}</a>
<a href="{$link->getAdminLink('AdminProducts')}&submitResetproduct&submitFilterproduct=1&productFilter_a!id_category_default={$htl_full_info['id_category']}">{l s='here.'}</a>
</div>
</div>
</div>

View File

@@ -907,9 +907,8 @@ class AdminControllerCore extends Controller
}
}
if (empty($filters)) {
$filters = $this->context->cookie->getFamily($prefix.$this->list_id.'Filter_');
}
// To merge the older filters with the new ones, and replace if new data is added to filter.
$filters = array_merge($this->context->cookie->getFamily($prefix.$this->list_id.'Filter_'), $filters);
foreach ($filters as $key => $value) {
$key_org = $key;

View File

@@ -146,6 +146,7 @@ class AdminNormalProductsControllerCore extends AdminController
}
}
$catFilterKey = $this->table.'Filter_a!id_category_default';
if (Tools::getValue('reset_filter_category')) {
$this->context->cookie->id_category_products_filter = false;
}
@@ -156,6 +157,9 @@ class AdminNormalProductsControllerCore extends AdminController
Tools::redirectAdmin($this->context->link->getAdminLink('AdminNormalProducts'));
}
}
if (!Tools::getValue($catFilterKey)) {
$this->context->cookie->id_category_products_filter = false;
}
/* Join categories table */
if ($id_category = (int)Tools::getValue('productFilter_cl!name')) {
$this->_category = new Category((int)$id_category);
@@ -167,6 +171,21 @@ class AdminNormalProductsControllerCore extends AdminController
} elseif ($id_category = $this->context->cookie->id_category_products_filter) {
$this->id_current_category = $id_category;
}
$idFilterCategory = false;
if (!Tools::isSubmit($catFilterKey)) {
$prefix = $this->getCookieFilterPrefix();
$idFilterCategory = $this->context->cookie->{$prefix.$catFilterKey};
}
if ($idFilterCategory) {
$this->id_current_category = $idFilterCategory;
$this->context->cookie->id_category_products_filter = $idFilterCategory;
} else {
$this->id_current_category = false;
$this->context->cookie->id_category_products_filter = false;
}
if ($this->id_current_category) {
$this->_category = new Category((int)$this->id_current_category);
} else {
@@ -557,8 +576,9 @@ class AdminNormalProductsControllerCore extends AdminController
public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = null)
{
$orderByPriceFinal = (empty($orderBy) ? ($this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : 'id_'.$this->table) : $orderBy);
$orderWayPriceFinal = (empty($orderWay) ? ($this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderby') : 'ASC') : $orderWay);
$prefix = $this->getCookieFilterPrefix();
$orderByPriceFinal = (empty($orderBy) ? ($this->context->cookie->__get($prefix.$this->table.'Orderby') ? $this->context->cookie->__get($prefix.$this->table.'Orderby') : 'id_'.$this->table) : $orderBy);
$orderWayPriceFinal = (empty($orderWay) ? ($this->context->cookie->__get($prefix.$this->table.'Orderway') ? $this->context->cookie->__get($prefix.$this->table.'Orderby') : 'ASC') : $orderWay);
if ($orderByPriceFinal == 'price_final') {
$orderBy = 'id_'.$this->table;
$orderWay = 'ASC';
@@ -2567,9 +2587,10 @@ class AdminNormalProductsControllerCore extends AdminController
// If products from all categories are displayed, we don't want to use sorting by position
if (!$id_category) {
$this->_defaultOrderBy = $this->identifier;
if ($this->context->cookie->{$this->table.'Orderby'} == 'position') {
unset($this->context->cookie->{$this->table.'Orderby'});
unset($this->context->cookie->{$this->table.'Orderway'});
$prefix = $this->getCookieFilterPrefix();
if ($this->context->cookie->{$prefix.$this->table.'Orderby'} == 'position') {
unset($this->context->cookie->{$prefix.$this->table.'Orderby'});
unset($this->context->cookie->{$prefix.$this->table.'Orderway'});
}
}
if (!$id_category) {

View File

@@ -169,14 +169,36 @@ class AdminProductsControllerCore extends AdminController
$_POST['productFilter_a!id_category_default'] = $id_category;
}
$catFilterKey = $this->table.'Filter_a!id_category_default';
if (!Tools::getValue($catFilterKey)) {
$this->context->cookie->id_category_room_types_filter = false;
}
if (($id_category = (int)Tools::getValue('id_category'))
|| ($id_category = (int) Tools::getValue('productFilter_a!id_category_default'))
|| ($id_category = (int)Tools::getValue($catFilterKey))
) {
$this->id_current_category = $id_category;
$this->context->cookie->id_category_room_types_filter = $id_category;
if (Tools::isSubmit('submitResetproduct')) {
$this->id_current_category = false;
$this->context->cookie->id_category_room_types_filter = false;
}
} elseif ($id_category = $this->context->cookie->id_category_room_types_filter) {
$this->id_current_category = $id_category;
} else {
$idFilterCategory = false;
if (!Tools::isSubmit($catFilterKey)) {
$prefix = $this->getCookieFilterPrefix();
$idFilterCategory = $this->context->cookie->{$prefix.$catFilterKey};
}
if ($idFilterCategory) {
$this->id_current_category = $idFilterCategory;
$this->context->cookie->id_category_room_types_filter = $idFilterCategory;
} else {
$this->context->cookie->id_category_room_types_filter = false;
}
}
if ($this->id_current_category) {
$this->_category = new Category((int)$this->id_current_category);
$this->position_group_identifier = (int) $this->id_current_category;
@@ -639,8 +661,9 @@ class AdminProductsControllerCore extends AdminController
public function getList($id_lang, $orderBy = null, $orderWay = null, $start = 0, $limit = null, $id_lang_shop = null)
{
$orderByPriceFinal = (empty($orderBy) ? ($this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : 'id_'.$this->table) : $orderBy);
$orderWayPriceFinal = (empty($orderWay) ? ($this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderby') : 'ASC') : $orderWay);
$prefix = $this->getCookieFilterPrefix();
$orderByPriceFinal = (empty($orderBy) ? ($this->context->cookie->__get($prefix.$this->table.'Orderby') ? $this->context->cookie->__get($prefix.$this->table.'Orderby') : 'id_'.$this->table) : $orderBy);
$orderWayPriceFinal = (empty($orderWay) ? ($this->context->cookie->__get($prefix.$this->table.'Orderway') ? $this->context->cookie->__get($prefix.$this->table.'Orderby') : 'ASC') : $orderWay);
if ($orderByPriceFinal == 'price_final') {
$orderBy = 'id_'.$this->table;
$orderWay = 'ASC';
@@ -2532,9 +2555,10 @@ class AdminProductsControllerCore extends AdminController
// If products from all categories are displayed, we don't want to use sorting by position
if (!(int) $this->id_current_category) {
$this->_defaultOrderBy = $this->identifier;
if ($this->context->cookie->{$this->table.'Orderby'} == 'position') {
unset($this->context->cookie->{$this->table.'Orderby'});
unset($this->context->cookie->{$this->table.'Orderway'});
$prefix = $this->getCookieFilterPrefix();
if ($this->context->cookie->{$prefix.$this->table.'Orderby'} == 'position') {
unset($this->context->cookie->{$prefix.$this->table.'Orderby'});
unset($this->context->cookie->{$prefix.$this->table.'Orderway'});
}
}
}

View File

@@ -106,6 +106,7 @@ class AdminHotelRoomModuleSettingController extends ModuleAdminController
),
'date_add' => array(
'title' => $this->l('Date Add'),
'filter_key' => 'a!date_add',
'align' => 'center',
'type' => 'datetime',
),