2016-03-02 29 views
0

我有一个问题添加链接类别名称为了这个,我有下面的代码添加在Magento的类别的超链接

$sports = Mage::getModel('catalog/category') 
        ->getCollection() 
        ->addAttributeToSelect('*') 
        ->addIsActiveFilter(); 

我的问题是我怎么可以添加类别链接。下面是后

foreach($sports as $key => $value) 
{ 
    $data = $value->getData(); 
} 

输出我的输出:

Array (
    [entity_id] => 2 
    [entity_type_id] => 3 
    [attribute_set_id] => 3 
    [parent_id] => 1 
    [created_at] => 2016-02-29 13:39:10 
    [updated_at] => 2016-03-02 12:32:37 
    [path] => 1/2 
    [position] => 1 
    [level] => 1 
    [children_count] => 5 
    [is_active] => 1 
    [include_in_menu] => 1 
    [landing_page] => 4 
    [is_anchor] => 1 
    [custom_apply_to_products] => 0 
    [name] => Default Category 
    [meta_title] => 
    [custom_design] => 
    [page_layout] => 
    [display_mode] => PRODUCTS_AND_PAGE 
    [available_sort_by] => 
    [description] => 
    [meta_keywords] => 
    [meta_description] => 
    [custom_layout_update] => 
    [custom_design_from] => 
    [custom_design_to] => 
    [filter_price_range] => 
) 

链接:

<li><a href="product.html"><?php echo strtoupper($data['name']);?></a></li> 
+0

你能改说这个问题吗?我不确定你在问什么。 –

回答

0

尝试这种解决方案。

<?php 
$sports = Mage::getModel('catalog/category') 
        ->getCollection() 
        ->addAttributeToSelect('*') 
        ->addIsActiveFilter(); 

$_helper = Mage::helper('catalog/category'); //category helper    
foreach($sports as $sport) 
{ 
    $_currentCat = Mage::getModel('catalog/category')->load($sport->getId()); //load current category 
    echo $_helper->getCategoryUrl($_currentCat); //Category URL 
} 
?> 

你可以把这个代码放在product.html的地方,但一定要检查代码并相应放置。

<?php echo $_helper->getCategoryUrl($_currentCat); ?> 

希望这可以帮助你!