How do I get categories for a product in Magento

后端 未结 6 2202
情书的邮戳
情书的邮戳 2021-01-31 16:12

I\'m trying to add product_type to my Magento Google Base output based on the product\'s categories, but I seem to be unable to. I have the following code:

// Ge         


        
6条回答
  •  甜味超标
    2021-01-31 16:21

    This is utterly not tested..

    //load the product 
    
    $product = Mage::getModel('catalog/product')->load($productId);
    
    //load the categories of this product 
    
    $categoryCollection = $product->getCategoryCollection();
    

    You can then loop through $categoryCollection like through an array.

    source

提交回复
热议问题