Fixed: filter related issues in the Back office

This commit is contained in:
vishalsingh.qlo325
2025-06-04 12:08:01 +05:30
parent 5da60bb913
commit d79ef4963c
5 changed files with 56 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

@@ -878,9 +878,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

@@ -139,6 +139,7 @@ class AdminNormalProductsControllerCore extends AdminController
}
}
$catFitlerKey = $this->table.'Filter_a!id_category_default';
if (Tools::getValue('reset_filter_category')) {
$this->context->cookie->id_category_products_filter = false;
}
@@ -149,6 +150,9 @@ class AdminNormalProductsControllerCore extends AdminController
Tools::redirectAdmin($this->context->link->getAdminLink('AdminNormalProducts'));
}
}
if (!Tools::getValue($catFitlerKey)) {
$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);
@@ -160,6 +164,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($catFitlerKey)) {
$prefix = $this->getCookieFilterPrefix();
$idFilterCategory = $this->context->cookie->{$prefix.$catFitlerKey};
}
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 {
@@ -550,8 +569,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';
@@ -2560,9 +2580,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

@@ -161,14 +161,32 @@ class AdminProductsControllerCore extends AdminController
$_POST['productFilter_a!id_category_default'] = $id_category;
}
$catFitlerKey = $this->table.'Filter_a!id_category_default';
if (!Tools::getValue($catFitlerKey)) {
$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($catFitlerKey))
) {
$this->id_current_category = $id_category;
$this->context->cookie->id_category_room_types_filter = $id_category;
} elseif ($id_category = $this->context->cookie->id_category_room_types_filter) {
$this->id_current_category = $id_category;
} else {
$idFilterCategory = false;
if (!Tools::isSubmit($catFitlerKey)) {
$prefix = $this->getCookieFilterPrefix();
$idFilterCategory = $this->context->cookie->{$prefix.$catFitlerKey};
}
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;
@@ -631,8 +649,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';
@@ -2524,9 +2543,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',
),