Fix count and handle issues

This commit is contained in:
Abhishek Kumar
2023-12-07 18:52:06 +05:30
parent 890fb7af60
commit 09d4e10b22
4 changed files with 54 additions and 13 deletions

View File

@@ -0,0 +1,36 @@
{**
* 2010-2023 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2023 Webkul IN
* @license LICENSE.txt
*}
{extends file='helpers/list/list_content.tpl'}
{block name='td_content'}
{if isset($tr.$key) && isset($params.position)}
{if $order_by == 'position' && $order_way != 'DESC'}
<div class="dragGroup">
<div class="positions">
{$tr.$key.position + 1}
</div>
</div>
{else}
{$tr.$key.position + 1}
{/if}
{else}
{$smarty.block.parent}
{/if}
{/block}

View File

@@ -649,12 +649,12 @@ class ProductCore extends ObjectModel
* @param int $position
* return boolean Update result
*/
public function updatePosition($way, $position)
public function updatePosition($way, $position, $id_category = null)
{
if (!$res = Db::getInstance()->executeS('
SELECT cp.`id_product`, cp.`position`, cp.`id_category`
FROM `'._DB_PREFIX_.'category_product` cp
WHERE cp.`id_category` = '.(int)Tools::getValue('id_category', 1).'
WHERE cp.`id_category` = '.(int) ($id_category ? $id_category: Tools::getValue('id_category', 1)).'
ORDER BY cp.`position` ASC')
) {
return false;

View File

@@ -144,14 +144,19 @@ class AdminProductsControllerCore extends AdminController
}
}
if (Shop::isFeatureActive() && $this->context->cookie->id_category_products_filter) {
$category = new Category((int)$this->context->cookie->id_category_products_filter);
if (Tools::getValue('productFilter_a!id_category_default') === '') {
$this->context->cookie->id_category_room_types_filter = false;
}
if (Shop::isFeatureActive() && $this->context->cookie->id_category_room_types_filter) {
$category = new Category((int)$this->context->cookie->id_category_room_types_filter);
if (!$category->inShop()) {
$this->context->cookie->id_category_products_filter = false;
$this->context->cookie->id_category_room_types_filter = false;
Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts'));
}
}
// to support filter URLs with 'id_category' parameter
if ($id_category = (int)Tools::getValue('id_category')) {
$_POST['submitFilter'] = '1';
$_POST['productFilter_a!id_category_default'] = $id_category;
@@ -161,12 +166,13 @@ class AdminProductsControllerCore extends AdminController
|| ($id_category = (int) Tools::getValue('productFilter_a!id_category_default'))
) {
$this->id_current_category = $id_category;
$this->context->cookie->id_category_products_filter = $id_category;
} elseif ($id_category = $this->context->cookie->id_category_products_filter) {
$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;
}
if ($this->id_current_category) {
$this->_category = new Category((int)$this->id_current_category);
$this->position_group_identifier = (int) $this->id_current_category;
} else {
$this->_category = new Category();
}
@@ -213,7 +219,6 @@ class AdminProductsControllerCore extends AdminController
// show the list of the product according to the booking or service products
$this->_where .= ' AND a.`booking_product` = 1';
$this->_use_found_rows = false;
$this->_group = ' GROUP BY a.`id_product`';
$this->fields_list = array();
@@ -468,7 +473,7 @@ class AdminProductsControllerCore extends AdminController
parent::processResetFilters($list_id);
// reset category filter
$this->context->cookie->id_category_products_filter = false;
$this->context->cookie->id_category_room_types_filter = false;
}
/**
@@ -3530,7 +3535,7 @@ class AdminProductsControllerCore extends AdminController
$product = $obj;
// Prepare Categories tree for display in Associations tab
$root = Category::getRootCategory();
$default_category = $this->context->cookie->id_category_products_filter ? $this->context->cookie->id_category_products_filter : Context::getContext()->shop->id_category;
$default_category = $this->context->cookie->id_category_room_types_filter ? $this->context->cookie->id_category_room_types_filter : Context::getContext()->shop->id_category;
if (!$product->id || !$product->isAssociatedToShop()) {
$selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
} else {
@@ -4694,7 +4699,7 @@ class AdminProductsControllerCore extends AdminController
if ($this->tabAccess['edit'] === '1') {
$way = (int)(Tools::getValue('way'));
$id_product = (int)Tools::getValue('id_product');
$id_category = (int)Tools::getValue('id_category');
$id_category = (int)Tools::getValue('id_category_hotel');
$positions = Tools::getValue('product');
$page = (int)Tools::getValue('page');
$selected_pagination = (int)Tools::getValue('selected_pagination');
@@ -4709,7 +4714,7 @@ class AdminProductsControllerCore extends AdminController
}
if ($product = new Product((int)$pos[2])) {
if (isset($position) && $product->updatePosition($way, $position)) {
if (isset($position) && $product->updatePosition($way, $position, $id_category)) {
$category = new Category((int)$id_category);
if (Validate::isLoadedObject($category)) {
hook::Exec('categoryUpdate', array('category' => $category));

View File

@@ -112,7 +112,7 @@ function initTableDnD(table)
else if (tableId == 'product') {
params = {
action: 'updatePositions',
id_category: ids[1],
id_category_hotel: ids[1],
id_product: ids[2],
way: way
};