Forums / Templates, Stylesheets, Page Layout / How to get cPath from a product id?

How to get cPath from a product id?

Views: 1,200

Results 1 to 2 of 2
18 Jan 2012, 1:14 AM
#1
cindy2010 avatar

cindy2010

Zen Follower

Join Date:
Apr 2010
Posts:
100
Plugin Contributions:
0

How to get cPath from a product id?

Hello,

Is there a function that returns the cPath value given the product ID? -- I know the cPath is simply like A_B_C, where A, B, C are its (parent) category IDs. But instead writing a code to get the IDs from db, just wonder whether such function is already there.

Thanks.

18 Jan 2012, 1:32 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How to get cPath from a product id?

I don't think there is a single function that does that, but you can use
zen_get_products_category_id($products_id) for the product's master category,
with
zen_get_path($current_category_id = '')

like this:

zen_get_path(zen_get_products_category_id($products_id))

Oops, nevermind, here it is:```php
zen_get_product_path($products_id)