Reputation:
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
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