获取magento产品类别 [英] Get magento product categories
问题描述
我是magento的新手,所以这对于大多数经验丰富的开发人员来说都是显而易见的
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?
我有一个产品模型,正在使用$ product = Mage :: getModel('catalog/product')-> load()并将产品ID作为参数提供给load()
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
请帮助
推荐答案
假设使用集合是正确的.幸运的是,产品模型为此提供了一种便捷的方法:
You are correct in assuming the use of collections. Luckily for you, the product model exposes a convenient method precisely for this: getCategoryCollection()
您将使用以下方式:
$categoryCollection = $product->getCategoryCollection();
这篇关于获取magento产品类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!