How do I get categories for a product in Magento

后端 未结 6 2130
情书的邮戳
情书的邮戳 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:41

    Get all Categories of the Product

    load( PRODUCT_ID );
        $categoryIds = $_Product->getCategoryIds();//array of product categories
    
        foreach($categoryIds as $categoryId) {
          $category = Mage::getModel('catalog/category')->load($categoryId);
          $this->_setAttribute('product_type', $category->getName(), 'text' );
       } 
    ?>
    

提交回复
热议问题