[-] BO: product listing should call Product::getPriceStatic() with the product default shop in the context when it is not a shop context

This commit is contained in:
Rémi Gaillard
2013-10-23 15:08:02 +02:00
parent 747ec9a2c4
commit 554ab9414f
@@ -174,7 +174,7 @@ class AdminProductsControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')';
$this->_select .= 'shop.name as shopname, ';
$this->_select .= 'shop.name as shopname, a.id_shop_default, ';
$this->_select .= 'MAX('.$alias_image.'.id_image) id_image, cl.name `name_category`, '.$alias.'.`price`, 0 AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
if ($join_category)
@@ -331,12 +331,17 @@ class AdminProductsControllerCore extends AdminController
$nb = count($this->_list);
if ($this->_list)
{
$context = $this->context->cloneContext();
$context->shop = clone($context->shop);
/* update product final price */
for ($i = 0; $i < $nb; $i++)
{
if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP)
$context->shop = new Shop((int)$this->_list[$i]['id_shop_default']);
// convert price with the currency from context
$this->_list[$i]['price'] = Tools::convertPrice($this->_list[$i]['price'], $this->context->currency, true, $this->context);
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, null, 2, null, false, true, 1, true);
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, null, 2, null, false, true, 1, true, null, null, null, $nothing, true, true, $context);
}
}