How can i display the Category of Products in "product/search.tpl" and in "product/product.tpl"
See Image Attachment:
on the default it display the:
1. Product Name
2.Product Description
3.Price
4.Tax
i also want to display the Category of the product because i want to do if the product is equal on a certain category do a certain condition.. hope someone could help me.. thanks
See Image Attachment:
on the default it display the:
1. Product Name
2.Product Description
3.Price
4.Tax
i also want to display the Category of the product because i want to do if the product is equal on a certain category do a certain condition.. hope someone could help me.. thanks
Attachments
Capture.PNG (186.75 KiB) Viewed 17985 times
You would need to add some code in to the controllers for both of those templates that looks up and adds the category name to the products array which is created here (products.php line 440):
Then you would have to output this in the .tpls.
Code: Select all
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])
);
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Guru Member
Unfortunately, this may require a more advanced tweaking to make this working. Followed is a working example: http://forum.opencart.com/viewtopic.php ... me#p630228 . Working on the latest module. It can definitely fit to display the category of products.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
hi paulfeakins that's what im trying to do since yesterday but still no luck im new into open cart and im not used to OOP php im more familiar in procedural php my bad but still thanks thou...
hi straightlight thanks for the link i have another question.. it is possible to put a query in template?
example
im new in open cart and OOP but still im learing bit by bit... thanks
hi straightlight thanks for the link i have another question.. it is possible to put a query in template?
example
Code: Select all
$query = mysql_query("SELECT * FROM tbl_product WHERE product_no='$product_no'");
$row = mysql_fetch_assoc($query);
echo $row['product_name'];
Last edited by straightlight on Fri Aug 05, 2016 7:11 pm, edited 1 time in total.
Reason: Added code tags.
Reason: Added code tags.
Opencart does use its own Object Registry to call the database. However, since your enquiry is about gathering a specific product from the database, I would rather suggest to build a new module rather than making generic database calls compared to the above.
Followed is the documentation on how to build a new module: http://docs.opencart.com/developer/module/ . Take note that if you're using or about to use the latest Opencart release, this topic will also be useful for new extensions / modules development: http://forum.opencart.com/viewtopic.php?f=183&t=165958
As for the Opencart Object Registry, in order to call the database as the above, you could simply use into your module as an example:
which the:
would need to originate from your URL.
Followed is the documentation on how to build a new module: http://docs.opencart.com/developer/module/ . Take note that if you're using or about to use the latest Opencart release, this topic will also be useful for new extensions / modules development: http://forum.opencart.com/viewtopic.php?f=183&t=165958
As for the Opencart Object Registry, in order to call the database as the above, you could simply use into your module as an example:
Code: Select all
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
echo html_entity_decode($product_info['name'], ENT_QUOTES, 'UTF-8');
Code: Select all
$this->request->get['product_id']
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: Bing [Bot] and 242 guests