Jump to content

1.6.1.1 (1.6.1.2) do not display color attributes in the category.


Recommended Posts

Same problem here. When the built in prestashop smarty cache is enabled, and the blocklayered module us used on frontend for color filtering, the small color boxes are not shown or are showed randomly in the product list. I also have third party pagecache module, with that there is no problem. But if I turn off prestashop smarty cache the admin is slow, so this is not the proper solution.

The problem appeared after updating from 1.6.0.14 to 1.6.1.1 and is still there in 1.6.1.2.

Edited by programmer85 (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...

hello,please test this,thanks

 

 

https://github.com/PrestaShop/PrestaShop/pull/7876

 public function addColorsToProductList(&$products)
    {
        if (!is_array($products) || !count($products) || !file_exists(_PS_THEME_DIR_.'product-list-colors.tpl')) {
            return;
        }

        $products_need_cache = array();
        foreach ($products as &$product) {
            if (!$this->isCached(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']))) {
                $products_need_cache[] = (int)$product['id_product'];
            }else{
                $product['color_list'] = $this->context->smarty->createTemplate(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']))->fetch();
            }
        }
      
        unset($product);

        $colors = false;
        if (count($products_need_cache)) {
            var_dump($products_need_cache);
             $colors = Product::getAttributesColorList($products_need_cache);
             Tools::enableCache();
            foreach ($products as &$product) {
                if (in_array($product['id_product'], $products_need_cache)){
                        $tpl = $this->context->smarty->createTemplate(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']));
                        if (isset($colors[$product['id_product']])) {
                            $tpl->assign(array(
                                'id_product'  => $product['id_product'],
                                'colors_list' => $colors[$product['id_product']],
                                'link'        => Context::getContext()->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']));
                        } else {
                            $product['color_list'] = '';
                        }
                 }
                    
            }
            Tools::restoreCacheSettings();
        }
    }

this code can fix the bug ,but i don't know why  :ph34r:

 

Edited by Irder (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...