I’m using Opencart am trying to call a variable to be displayed just under the product name in the featured module. This featured module is displayed on the frontpage.
I’ve already added a new column in the database and was able to add data into the db through the admin page. Verified by going through PHPmyadmin.
I can’t however, display the variable on the main page. I’ve edited catalog/view/theme/*/template/module/featured.tpl to include the following code but with no success. If i remove the isset it throws an Notice: Undefined variable: product_description in … error
Addded the following line
<div class="secondtitle"><?php echo isset($product_description['secondtitle']); ?></a></div>
Before
<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
VQmod
<file name="catalog/view/theme/*/template/module/featured.tpl">
<operation>
<search position="after"><![CDATA[
<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
]]></search>
<add><![CDATA[
<div class="secondtitle"><?php echo isset($product_description['secondtitle']); ?></a></div>
]]></add>
</operation>
</file>
Can anyone please guide me on how to resolve this? Thanks in advance.
You need to be more specific, it is hard to guess where did you add the extra field in the database. Is it in the ‘product’ table?
Then, based on your previous comment, looks like you’re on the right track.
You need to edit model/catalog/product.php Edit function getProduct()
You’ll see an array being populated like:
Add your custom field there:
Can you please show where in the DB you are adding this custom variable?
[EDITED: 2012-12-13 in response to the comment #1]
If your custom field is in ‘product_description’ table then follow the above example to edit model/catalog/product.php
Edit controller featured.php, add your variable to the products array. Look for
Add your field
Then in view featured.tpl echo it where you want it with
This works, I just tested it.
You were doing the right thing as I said before, probably just missed a step or two..