Post by developer » Mon Feb 28, 2011 9:17 pm

Hello everyone. I'm using OC 1.4.8b

I need a mysql query to get product's category name. I'm using this one but as you may see it doesn't retrieve category name. How can I get category name of a product in the query below?Thanks.

Code: Select all

SELECT * FROM product p, product_description pd, product_to_category pc WHERE p.product_id=pd.product_id AND pd.product_id=pc.product_id

$price = $row['price'];
$image = $row['image'];
$weight = $row['weight'];

User avatar
New member

Posts

Joined
Tue Jul 27, 2010 8:06 pm

Post by developer » Mon Feb 28, 2011 11:52 pm

any ideas?

User avatar
New member

Posts

Joined
Tue Jul 27, 2010 8:06 pm

Post by Xsecrets » Tue Mar 01, 2011 12:51 am

the category name is stored in the category_description table, so you would have to join that table as well with the category_id you pulled from the product_to_category table and the language. And even then there is the problem that a product can be related to any number of categories.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Chones » Tue Mar 01, 2011 2:55 am

I posted a solution here ages ago, before I fully understood how Opencart worked - it works but it's not pretty and needs updating. It should get you started though.
http://forum.opencart.com/viewtopic.php?t=13347

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London
Who is online

Users browsing this forum: No registered users and 304 guests