1

Hi I new to magento so this may be obvious to most experienced devs

How do i find get all the categories that a product is in. Do i need to use collections?

I have a product model which am using like $product = Mage::getModel('catalog/product')->load() and giving the product id as parameter to load()

Now i need the category objects a product is in

please help

asked Jul 29, 2012 at 10:13

1 Answer 1

1

You are correct in assuming the use of collections. Luckily for you, the product model exposes a convenient method precisely for this: getCategoryCollection()

You would use as follows:

$categoryCollection = $product->getCategoryCollection();
answered Jul 29, 2012 at 10:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.