// add color list on product listing

This commit is contained in:
Rémi Gaillard
2013-09-30 17:19:02 +02:00
parent a6d8ffa293
commit c2857add42
5 changed files with 82 additions and 1 deletions
+28
View File
@@ -199,10 +199,38 @@ class CategoryControllerCore extends FrontController
// Pagination must be call after "getProducts"
$this->pagination($this->nbProducts);
$products_need_cache = array();
foreach ($this->cat_products as &$product)
{
if ($product['id_product_attribute'] && isset($product['product_attribute_minimal_quantity']))
$product['minimal_quantity'] = $product['product_attribute_minimal_quantity'];
if (!$this->isCached(_PS_THEME_DIR_.'product-list-colors.tpl', 'productlist_colors|'.$product['id_product']))
$products_need_cache[] = (int)$product['id_product'];
}
unset($product);
$colors = array();
if (count($products_need_cache))
$colors = Product::getAttributesColorList($products_need_cache);
if (count($colors))
{
Tools::enableCache();
foreach ($this->cat_products as &$product)
if (isset($colors[$product['id_product']]) && count($colors[$product['id_product']]))
{
$data = $this->context->smarty->createData();
$data->assign(array(
'id_product' => $product['id_product'],
'colors_list' => $colors[$product['id_product']]
));
$product['color_list'] = $this->context->smarty->createTemplate(_PS_THEME_DIR_.'product-list-colors.tpl', $data)->fetch(_PS_THEME_DIR_.'product-list-colors.tpl', 'productlist_colors|'.(int)$product['id_product']);
}
else
$product['color_list'] = '';
Tools::restoreCacheSettings();
}
$this->context->smarty->assign('nb_products', $this->nbProducts);