Jump to content

Cannot get override to work


sshare

Recommended Posts

Hi everyone,

I'm trying to get the an override to work for the CategoryController, but whatever I put in the CategoryController file the category pages on my site go blank.

 

Here's the code I'm using, what am I doing wrong? I'm running 1.5.0.17 btw.

<?php

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);
}
}
}
}



}
Edited by sshare (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...