// add color list to some controllers

This commit is contained in:
Rémi Gaillard
2013-10-08 15:39:06 +02:00
parent 53748c3119
commit 0db2372724
6 changed files with 60 additions and 36 deletions
+2 -31
View File
@@ -199,45 +199,16 @@ 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', $this->getColorsListCacheId($product['id_product'])))
$products_need_cache[] = (int)$product['id_product'];
}
unset($product);
$colors = false;
if (count($products_need_cache))
$colors = Product::getAttributesColorList($products_need_cache);
Tools::enableCache();
foreach ($this->cat_products as &$product)
{
$tpl = $this->context->smarty->createTemplate(_PS_THEME_DIR_.'product-list-colors.tpl');
if (isset($colors[$product['id_product']]))
$tpl->assign(array(
'id_product' => $product['id_product'],
'colors_list' => $colors[$product['id_product']]
));
if (!in_array($product['id_product'], $products_need_cache) || isset($colors[$product['id_product']]))
$product['color_list'] = $tpl->fetch(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']));
else
$product['color_list'] = '';
}
Tools::restoreCacheSettings();
$this->addColorsToProductList($this->cat_products);
$this->context->smarty->assign('nb_products', $this->nbProducts);
}
protected function getColorsListCacheId($id_product)
{
return 'productlist_colors|'.(int)$id_product.'|'.$this->context->shop->id;
}
/**
* Get instance of current category
*/