【问题标题】:How to get category name by category id in Magento如何在 Magento 中按类别 ID 获取类别名称
【发布时间】:2017-04-20 12:31:38
【问题描述】:

如何在类别页面上的 magento 中通过类别 id 获取类别名称? 提前谢谢请给我建议。

【问题讨论】:

    标签: magento categories


    【解决方案1】:

    请按类别 ID 使用以下代码作为类别名称。还可以获取缩略图等。

    $categoryId = 5;    // Change category id according to you or use dynamic category variable
    
    // display name and other detail of all category                                   
    
    $_category = Mage::getModel('catalog/category')->load($categoryId); 
    
    echo $categoryName = $_category->getName();  
    
    echo $categoryDescription = $_category->getDescription(); 
    
    echo $categoryUrl = $_category->getUrl();   
    
    echo $categoryThumbnail = $_category->getThumbnail(); 
    
    echo $categoryLevel = $_category->getLevel();  
    
    echo $parentCategoryId = $_category->getParentId();
    

    【讨论】:

      【解决方案2】:

      在分类页面,你可以得到这样的信息:

      $category = Mage::registry('current_category');
      echo $category->getName();
      

      【讨论】:

        【解决方案3】:

        它适用于类别模型。

            $Category=Mage::getModel('catalog/category')->load($cat);
            $cat_name=$Category->getName();
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-12-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-08-02
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多