[-] BugFix : Bad count in request for admin stock instant states
This commit is contained in:
@@ -203,34 +203,46 @@ class AdminStockInstantStateControllerCore extends AdminController
|
|||||||
$order_way = $this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderway') : 'ASC';
|
$order_way = $this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderway') : 'ASC';
|
||||||
|
|
||||||
$query = 'SELECT SQL_CALC_FOUND_ROWS
|
$query = 'SELECT SQL_CALC_FOUND_ROWS
|
||||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as designation,
|
id_stock,
|
||||||
id_stock, p.id_product, s.id_product_attribute, ean13, p.reference,
|
id_product,
|
||||||
IF((count(DISTINCT id_stock)=1), s.price_te, \'--\') as price_te,
|
id_product_attribute,
|
||||||
IF((count(DISTINCT id_stock)=1), 0, 1) as need_details,
|
designation,
|
||||||
CAST((SUM(physical_quantity) / (count(id_stock) - count(DISTINCT id_stock) + 1)) AS SIGNED INTEGER) AS physical_quantity,
|
IF((count(id_stock)=1), s.price_te, \'--\') as price_te,
|
||||||
CAST((SUM(usable_quantity) / (count(id_stock) - count(DISTINCT id_stock) + 1)) AS SIGNED INTEGER) AS usable_quantity
|
SUM(physical_quantity) physical_quantity,
|
||||||
FROM '._DB_PREFIX_.'stock s
|
SUM(usable_quantity) usable_quantity,
|
||||||
INNER JOIN '._DB_PREFIX_.'product p
|
ean13,
|
||||||
ON (p.id_product = s.id_product)
|
reference,
|
||||||
INNER JOIN '._DB_PREFIX_.'product_lang pl
|
IF((count(id_stock)=1), 0, 1) as need_details
|
||||||
ON (pl.id_product = p.id_product AND pl.id_lang = '.$id_lang.')
|
FROM (SELECT
|
||||||
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac
|
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.`name`, \' - \', al.name SEPARATOR \', \')), pl.name) as designation,
|
||||||
ON (pac.id_product_attribute = s.id_product_attribute)
|
id_stock, p.id_product, s.id_product_attribute, ean13, p.reference,
|
||||||
LEFT JOIN '._DB_PREFIX_.'attribute a
|
s.price_te,
|
||||||
ON (a.id_attribute = pac.id_attribute)
|
physical_quantity,
|
||||||
LEFT JOIN '._DB_PREFIX_.'attribute_lang al
|
usable_quantity
|
||||||
ON (al.id_attribute = a.id_attribute AND al.id_lang = '.$id_lang.')
|
FROM '._DB_PREFIX_.'stock s
|
||||||
LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl
|
INNER JOIN '._DB_PREFIX_.'product p
|
||||||
ON (agl.id_attribute_group = a.id_attribute_group AND agl.id_lang = '.$id_lang.')
|
ON (p.id_product = s.id_product)
|
||||||
WHERE id_warehouse = '.$this->getCurrentWarehouseId().' '.(isset($this->_where) ? $this->_where.' ' : '').
|
INNER JOIN '._DB_PREFIX_.'product_lang pl
|
||||||
($this->deleted ? 'AND a.`deleted` = 0 ' : '').
|
ON (pl.id_product = p.id_product AND pl.id_lang = '.$id_lang.')
|
||||||
(isset($this->_filter) ? $this->_filter : '').'
|
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac
|
||||||
GROUP BY pac.id_product_attribute, p.id_product
|
ON (pac.id_product_attribute = s.id_product_attribute)
|
||||||
'.((isset($this->_filterHaving) || isset($this->_having)) ? 'HAVING ' : '').
|
LEFT JOIN '._DB_PREFIX_.'attribute a
|
||||||
(isset($this->_filterHaving) ? ltrim($this->_filterHaving, ' AND ') : '').
|
ON (a.id_attribute = pac.id_attribute)
|
||||||
(isset($this->_having) ? $this->_having.' ' : '').'
|
LEFT JOIN '._DB_PREFIX_.'attribute_lang al
|
||||||
ORDER BY `'.pSQL($order_by).'` '.pSQL($order_way).'
|
ON (al.id_attribute = a.id_attribute AND al.id_lang = '.$id_lang.')
|
||||||
LIMIT '.(int)$start.','.(int)$limit;
|
LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl
|
||||||
|
ON (agl.id_attribute_group = a.id_attribute_group AND agl.id_lang = '.$id_lang.')
|
||||||
|
WHERE id_warehouse = '.$this->getCurrentWarehouseId().' '.(isset($this->_where) ? $this->_where.' ' : '').
|
||||||
|
($this->deleted ? 'AND a.`deleted` = 0 ' : '').
|
||||||
|
(isset($this->_filter) ? $this->_filter : '').'
|
||||||
|
GROUP BY id_stock
|
||||||
|
'.((isset($this->_filterHaving) || isset($this->_having)) ? 'HAVING ' : '').
|
||||||
|
(isset($this->_filterHaving) ? ltrim($this->_filterHaving, ' AND ') : '').
|
||||||
|
(isset($this->_having) ? $this->_having.' ' : '').'
|
||||||
|
) s
|
||||||
|
GROUP BY id_product_attribute, id_product
|
||||||
|
ORDER BY `'.pSQL($order_by).'` '.pSQL($order_way).'
|
||||||
|
LIMIT '.(int)$start.','.(int)$limit;
|
||||||
|
|
||||||
$this->_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
$this->_list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||||
$manager = StockManagerFactory::getManager();
|
$manager = StockManagerFactory::getManager();
|
||||||
|
|||||||
Reference in New Issue
Block a user