【问题标题】:MAGENTO - get category name in product.info.extrahint reference pageMAGENTO - 在 product.info.extrahint 参考页面中获取类别名称
【发布时间】:2013-01-30 13:07:30
【问题描述】:

我创建了一个 product.info.extraint 页面。 这是我的前端布局:

    <catalog_product_view>
       <reference name="product.info.extrahint">
         <block type="***_***/product" name="***_product" template="***/***/product.phtml" />
       </reference>
    </catalog_product_view>

我的 product.php 扩展自 Mage_Catalog_Block_Product_Abstract

如何在product.php中获取分类名称?

【问题讨论】:

标签: magento categories product


【解决方案1】:

加载产品模型,然后获取类别列表并呼出您想要的?

$product = Mage::getModel('catalog/product')->load($id);

$categories = $product->getCategoryIds();
    foreach ($categories as $catid) {
    echo Mage::getModel('catalog/category')->load($catid)->getName();
} 

【讨论】:

  • 感谢您的回答.. 但它不起作用。当我 var_dump ($categories);,我得到空数组 array(0) { }
  • 我已经在 1.7.0.2 中测试成功 - 你的产品模型加载正确吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多