2016-03-02 34 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); ?> 

希望這可以幫助你!