Homefeatured, problems with the cache module to select random products
Homefeatured, problems with the cache module to select random products in the module configuration
Homefeatured module allows us to visualize a number of products on our website and also for each load, having activated the option Randomly display products, load these products randomly. Or that should be.
The problem lies when we enabled the cache and can be observed that, for each page load, this randomness does not exist. This has been proven and happens in the module versions 1.5-1.6 for prestashop version 1.6 homefeatured. X (discupad if I have not tried it in more versions: and, for the more autodidacts, I write the code that you put it in the module homefeatured.
I think it does lack explanation, has been bolded lines to be considered for modification. Although, if you sustituís the methods by these it will work guaranteed. Basically, it checks whether enabled or not randomness in products to collect cache or otherwise, go back to view the products.
public function _cacheProducts)
{
$israndom = configure: get ('HOME_FEATURED_RANDOMIZE');
If (! isset(HomeFeatured::$cache_products) | $israndom)
{
$category = new Category ((int) Configuration:get('HOME_FEATURED_CAT'), (int) Context:getContext ()-> language-> id);
$nb = (int) Configuration:get('HOME_FEATURED_NBR');
If ($israndom)
HomeFeatured: $cache_products = $category-> getProducts ((int) Context:getContext ()-> language-> id, 1, (do $nb? $nb: 8), null, null, false, true, true, (do $nb? $nb: 8));
else
HomeFeatured: $cache_products = $category-> getProducts ((int) Context:getContext ()-> language-> id, 1, (do $nb? $nb: 8), 'position');
}
If (HomeFeatured:$ cache_products = false | empty(HomeFeatured::$cache_products))))
return false;
}
public function hookDisplayHome ($params)
{
$retorno = "";
$israndom = Configuration:get('HOME_FEATURED_RANDOMIZE');
$this-> _cacheProducts ();
$this-> smarty-> assign)
array)
'products' => HomeFeatured:$ cache_products,
'add_prod_display' => Configuration:get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image:getSize (ImageType:getFormatedName('home')),
)
);
If ($israndom) {}
$retorno = $this-> display(__FILE__, 'homefeatured.tpl');
} else {}
$retorno = $this-> display (__FILE__, 'homefeatured.tpl', $this-> getCacheId());
}
return $retorno;
}
This code is certainly improved, but now I leave you and your comments.
I hope to have served as support.
A greeting,
Escribe un comentario