Page 1 of 1

[Solved] Journal 2 Product Grid changes disappear after interaction

Posted: Thu Nov 08, 2018 8:00 pm
by patrickbozic
Working with OC 2.0.1.1 and the Journal 2 template.
I want to display bulk order discounts in the product grid, so I modified controller/product/category.php and view/.../product/category.tpl.

When looking at a product category, it works fine at first. Then when I change anything in the product filter of the grid, the grid reloads and all bulk discounts are gone. Does anyone have a solution for this?

Here's my code:

controller/product/category.php

Code: Select all

$discounts_data = $this->model_catalog_product->getProductDiscounts($result['product_id']);
$discounts = array();
	foreach ($discounts_data as $discount) {
		$discounts[$discount['product_id']] = array(
			'quantity' => $discount['quantity'],
			'price'    => $this->currency->format($this->tax->calculate($discount['price'], $result['tax_class_id'], $this->config->get('config_tax')))
		);
	}
				
$data['products'][] = array(
	'product_id'  => $result['product_id'],
	'thumb'       => $image,
	'discount'    => (!empty($discounts[$result['product_id']]) ? $discounts[$result['product_id']] : array()),
	'name'        => $result['name'],
	'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
	'price'       => $price,
	'special'     => $special,
	'tax'         => $tax,
	'rating'      => $result['rating'],
	'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
view/.../product/category.tpl

Code: Select all

<?php echo "<b>" . $product['product_id'] . "</b> | ";
								
if ($product['discount']['price']) {
	echo "<span style='color: red;'>" . $text_bulk_discount . $product['discount']['price'] . "</span>";
}
else {
	echo $product['price'];
}
?>

Re: Journal 2 Product Grid changes disappear after interaction

Posted: Thu Nov 08, 2018 11:53 pm
by patrickbozic
I just solved it myself.
I'm fairly new to OC and didn't know that each module has its own controller.
So, after I applied the modifications of category.php in journal2_super_filter.php, it all worked out.
Cheers.