Post by RemarkLima » Mon Oct 12, 2015 4:04 pm

Hi all,

This is driving me crazy, and I'm sure it should be a simple thing! I'm a .NET C# dev usually so PHP is a little alien to me, but the concepts all generally translate.

I'm using the Journal2 template, which seems to add a slight layer of complexity and I'm finding it hard to find what calls what and when! Anyway, I'm trying to add a label to the category template (here: "/catalog/view/theme/journal2/template/product/category.tpl") based on a condition, the number of options.

So I can edit "/catalog/model/product.php" and add a value to the "getProduct" array after "'viewed' => $query->row['viewed']". No errors, and if I edit the existing values, it's reflected in the view template without any problems.

However the new value, "no_of_options" I can't get to the template... And if I edit either of the controllers "$products[]" array it's not reflected in the template, by adding the value from the model or just hard-coding a value.

Where am I going wrong here!?

Newbie

Posts

Joined
Fri Nov 11, 2011 1:30 am

Post by andrei.bogdan » Fri Nov 27, 2015 10:54 pm

Hi,

The field 'viewed' works because it already exists in the table and the model: http://take.ms/qrDLq
If you want to add a new field, you must add it to:
1. database table
2. product model SQL query in catalog/model/catalog/product.php > getProducts() and in the returned array also
3. add it in the category controller catalog/controller/product/category.php around line 215, where the products fields are set. after this it will be available in the theme, to be 'echoed' with $product['no_of_options'], for example.

Andrei
andrei.opencart[at]yahoo.com
Themes and Extensions


Active Member

Posts

Joined
Mon Mar 25, 2013 4:52 am
Who is online

Users browsing this forum: No registered users and 9 guests