Loxx Posted April 20, 2016 Share Posted April 20, 2016 I am trying to tweak the home featured module as follows: I want to present 3 randomly chosen products of a category on each category site. Here is what I did: I hooked the homefeatured Module into the category.tpl and set it to randomly chose products to display in the backend. I rewrote the hook function in the homefeatured.php as follows: public function hookDisplayInCategories($params) { Configuration::updateValue('HOME_FEATURED_CAT', Tools::getValue('id_category')); if (!$this->isCached('homefeatured.tpl', $this->getCacheId())) { $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')), ) ); } return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId()); } Interesting is this part: Configuration::updateValue('HOME_FEATURED_CAT', Tools::getValue('id_category')); Here I reuse the function used to configure homefeatured and set the HOME_FEATURED_CAT with the value of the actual category ID. Now it works in the dev shop, where caching is off and forced compiling is on. E.G.: http://blickfang.pinguinweb.de/18-schmuck When I move it to life where caching is on and forced compiling is still on, it doesn't work any more. The category is always stuck with the last chosen Category and doesnt adapt to each category ID where displayed... I am not so familiar with how caching works.. I guess the error is somewhere there.. Any possibilty to force the module to always get the HOME_FEATURED_CAT value from the database and not used a cached one? Thank you for any help! Link to comment Share on other sites More sharing options...
Loxx Posted April 20, 2016 Author Share Posted April 20, 2016 Solved it with the very good remarks about caching here: https://www.prestashop.com/forums/topic/316661-random-home-featured-in-v16/ Thanks guys! Link to comment Share on other sites More sharing options...
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