muynck Posted March 27, 2015 Share Posted March 27, 2015 In short, homefeatured.php is fixed, but the vars don't occur in homefeatured.tpl. I've got a similar code working for product-list.tpl through changing the override of the CategoryController. public function hookDisplayHome($params) { $producten = HomeFeatured::$cache_products; foreach($producten as $k=>$v) { $quantity_discounts = SpecificPrice::getQuantityDiscounts($v['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true, $id_customer); foreach($quantity_discounts as $r) { $discount_value[$k][$r['reduction']] = $r['reduction']; } $price[$k] = $v['price_tax_exc']; $rate[$k] = $v['rate']; $discounts_nb = array(); foreach ($quantity_discounts as $quantity_info) { $reduction[$quantity_info['reduction']] = $quantity_info['reduction']; } } foreach($discount_value as $k => $v) { $producten[$k]['price_with_highest_qty_discount'] = (int)$price[$k]-(max($v)/(100+$rate[$k])*100); } if (!$this->isCached('homefeatured.tpl', $this->getCacheId())) { $this->_cacheProducts(); echo '<pre>'; var_dump($producten); echo '</pre>'; $this->smarty->assign( array( 'products' => $producten, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } return $this->display(__FILE__, 'homefeatured.tpl'); } When I dump all the variables, it has everything it needs, the 'price_with_highest_qty_discount' variable. Here's a small example output: ["nopackprice"]=> int(0) ["rate"]=> float(21) ["tax_name"]=> string(10) "BTW NL 21%" ["price_with_highest_qty_discount"]=> float(47.5) But in the tpl in the $products foreach loop $product.price_with_highest_qty_discount doesn't give anything. {$products|@print_r} also doesn't contain my variable. My guess is that it has something to do with the fact that the variables come from the HomeFeatured::$cache_products, with emphasis on CACHE If anyone could put me in the right direction I would be very grateful. And I will be also willing to share all of my code to as I'm trying to show the lowest price possible all over the website. Thanks in advance! Link to comment Share on other sites More sharing options...
PascalVG Posted March 30, 2015 Share Posted March 30, 2015 Hello Muynck (Hallo), Just double checking, but did you ( temporarily) turn off smarty caching and set compilation of smarty to force compile? (Advanced Parameters->Optimization? After done so, reload the page and see if that helped. My 2 cents, pascal 1 Link to comment Share on other sites More sharing options...
muynck Posted May 7, 2015 Author Share Posted May 7, 2015 Hi Pascal, Thanks for your answer! Although it was not the solution, I solved it. I must say not the most beautiful solution, but it works. I first cached the products with $this->_cacheProducts(); Then I get the products, and make it ready for my calculation. I put the extra var into $producten.. $producten = HomeFeatured::$cache_products; Then at the end I assign the array with Smarty: $this->smarty->assign( array( 'products' => $producten, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); It is not the most effecient/fast way, but it works. Thanks for the support! 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