Jump to content

Same Products On Every Category After File System Cache Enabled


Recommended Posts

Hi.

 

If I enable the file system cache in my prestashop configuration, on the front-end just one category appears.

For each and every category the same products are appearing.

 

I am on shared hosting so i cannot activate another type of caching.

Can I debug this somehow, or what the problem might be?

 

Thank you!

Link to comment
Share on other sites

Hi, 

that is because of several queries in blocklayered return sama data from the cache.

Quick fix is to force these queries not to use cache:

 

blocklayered.php:

public function getProductByFilters($selected_filters = array()):
{
....
// $this->nbr_products = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'cat_filter_restriction');      <---- this line needs to be changed
$this->nbr_products = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'cat_filter_restriction', false);

....


               $this->products = Db::getInstance()->executeS('
                SELECT 
                    p.*,
                    '.($alias_where == 'p' ? '' : 'product_shop.*,' ).'
                    '.$alias_where.'.id_category_default,
                    pl.*,
                    image_shop.`id_image` id_image,
                    il.legend,
                    m.name manufacturer_name,
                    '.(Combination::isFeatureActive() ? 'product_attribute_shop.id_product_attribute id_product_attribute,' : '').'
                    DATEDIFF('.$alias_where.'.`date_add`, DATE_SUB("'.date('Y-m-d').' 00:00:00", INTERVAL '.(int)$nb_day_new_product.' DAY)) > 0 AS new,
                    stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity'.(Combination::isFeatureActive() ? ', product_attribute_shop.minimal_quantity AS product_att
                FROM '._DB_PREFIX_.'cat_filter_restriction cp
                LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
                '.Shop::addSqlAssociation('product', 'p').
                (Combination::isFeatureActive() ?
                ' LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` product_attribute_shop
                    ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`default_on` = 1 AND product_attribute_shop.id_shop='.(int)$contex
                LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.Shop::addSqlRestrictionOnLang('pl').' AND pl.id_lang = '.(int)$cookie->id_lang.')
                LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop
                    ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop='.(int)$context->shop->id.')
                LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$cookie->id_lang.')
                LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
                '.Product::sqlStock('p', 0).'
                WHERE '.$alias_where.'.`active` = 1 AND '.$alias_where.'.`visibility` IN ("both", "catalog")
                ORDER BY '.Tools::getProductsOrder('by', Tools::getValue('orderby'), true).' '.Tools::getProductsOrder('way', Tools::getValue('orderway')).' , cp.id_product'.

//                ' LIMIT '.(((int)$this->page - 1) * $n.','.$n)); <-------------- this line needs to be changed                
                  ' LIMIT '.(((int)$this->page - 1) * $n.','.$n), true, false);
Edited by markych (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...