prestalearn Posted January 28, 2014 Share Posted January 28, 2014 (edited) Ive been struggling for almost 2 hours with getting 2 override files merged. I have this code right now in my override/controllers/front/CategoryController.php: <?php class CategoryController extends CategoryControllerCore { public function initContent() { parent::initContent(); $this->context->smarty->assign(array( 'display_x_products_default' => Configuration::get('PWDESIGNER_DISPLAY_X_PRODUCTS'), )); } } To this I must add the code described by Nemops here: http://nemops.com/lowest-price-prestashop-product-list/#.UugxtncRksk Wich is: 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; } } // end if quantity discounts $this->cat_products[$key]['price'] = min($prices_array); $this->cat_products[$key]['qt_disc'] = true; $this->context->smarty->assign('products', $this->cat_products); But no matter How I try my category pages just render blank :/ I really cant understand how to merge these two together. Any help on how to put the code together would be sooo appriciated! TIA! // Edited: Sorry think I solved it: <?php class CategoryController extends CategoryControllerCore { public function initContent() { parent::initContent(); $this->context->smarty->assign(array( 'display_x_products_default' => Configuration::get('PWDESIGNER_DISPLAY_X_PRODUCTS'), )); 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; } } // end if quantity discounts $this->cat_products[$key]['price'] = min($prices_array); $this->cat_products[$key]['qt_disc'] = true; $this->context->smarty->assign('products', $this->cat_products); } } But it doesnt render any discounted price in the product-list.tpl even though I edited that file aswell. If someone have gotten it to work in 1.5.6.2 i would really appriciate some advice. have a wonderfull evening, thanks! Edited January 29, 2014 by prestalearn (see edit history) 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