Plexy89 Posted September 24, 2016 Share Posted September 24, 2016 Hi guys, I am overriding CategoryControllerCore with a functionality which shows the "Lowest price" on the product list - e.g. if having quantity discounts. However, this override does not seem to cover the homenewproducts module - even if this one is using the product-list. And I can't get my head around it. Anyone who can help me out? Here's the CategoryController override I use. Thanks a lot in advance! class CategoryController extends CategoryControllerCore { public function initContent() { parent::initContent(); if($this->cat_products) { $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0); $id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_); $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'); $id_currency = (int)$this->context->cookie->id_currency; $id_shop = $this->context->shop->id; foreach ($this->cat_products as $key => $product) { $prices_array = array(); /* For each product, grab quantity discounts */ $quantity_discounts = SpecificPrice::getQuantityDiscounts($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true); /* Process quantity discounts to get the real price */ if ($quantity_discounts) { foreach ($quantity_discounts as $qkey => $discount) { if (!(float)$discount['reduction']) $price = $discount['price']; else { if ($discount['reduction_type'] == 'percentage') { $price = $product['price_without_reduction'] - ($product['price_without_reduction'] * $discount['reduction']); } else { $price = $product['price_without_reduction'] - $discount['reduction']; } } $prices_array[] = $price; } $this->cat_products[$key]['price'] = min($prices_array); $this->cat_products[$key]['qt_disc'] = true; } // end if quantity discounts $this->context->smarty->assign('products', $this->cat_products); } } } } Link to comment Share on other sites More sharing options...
Plexy89 Posted September 26, 2016 Author Share Posted September 26, 2016 Anyone got any clue? Any help is appreciated, thanks! Link to comment Share on other sites More sharing options...
Plexy89 Posted September 27, 2016 Author Share Posted September 27, 2016 No one? Any ideas? 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