user1560805
user1560805

Reputation:

Get magento product categories

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

Upvotes: 1

Views: 411

Answers (1)

Drew Hunter
Drew Hunter

Reputation: 10114

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();

Upvotes: 1

Related Questions