Quant Posted April 26, 2019 Posted April 26, 2019 There is a bug with displaying colors on the categories page when SmartyCache is enabled. It is not fixed in TB and PS (1.6.x). Here is an example of how to fix it. public function addColorsToProductList(&$products) { if (!is_array($products) || !count($products) || !file_exists(_PS_THEME_DIR_.'product-list-colors.tpl')) { return; } $productsNeedCache = []; foreach ($products as &$product) { if (!$this->isCached(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']))) { $productsNeedCache[] = (int) $product['id_product']; } else { $product['color_list'] = $this->context->smarty->fetch(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product'])); } } unset($product); $colors = false; if (count($productsNeedCache)) { $colors = Product::getAttributesColorList($productsNeedCache); } else { return; } Tools::enableCache(); foreach ($products as &$product) { if (isset($colors[$product['id_product']])) { $tpl = $this->context->smarty->createTemplate(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product'])); $tpl->assign( [ 'id_product' => $product['id_product'], 'colors_list' => $colors[$product['id_product']], 'link' => $this->context->link, 'img_col_dir' => _THEME_COL_DIR_, 'col_img_dir' => _PS_COL_IMG_DIR_, ] ); $product['color_list'] = $tpl->fetch(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product'])); } if (in_array($product['id_product'], $productsNeedCache) && !isset($colors[$product['id_product']])) { $product['color_list'] = ''; } } Tools::restoreCacheSettings(); } 1
0 Traumflug Posted April 27, 2019 Posted April 27, 2019 Thanks for reporting! Filed in the issue tracker to not forget this: https://github.com/thirtybees/thirtybees/issues/914
0 the.rampage.rado Posted April 27, 2019 Posted April 27, 2019 And what exactly is the bug? Screenshot or description at least?
0 datakick Posted May 19, 2019 Posted May 19, 2019 Thanks for bug report and proposed fix. I was able to reproduce the caching problem, and the fix indeed works correctly
Question
Quant
There is a bug with displaying colors on the categories page when SmartyCache is enabled.
It is not fixed in TB and PS (1.6.x).
Here is an example of how to fix it.
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now