设置客户仪表板自定义选项卡的排序顺序

时间:2014-07-30 14:00:46

标签: php magento

我在客户帐户信息中心创建了一个自定义标签。使用我的自定义模块布局文件。

<customer_account>
        <reference name="customer_account_navigation">
            <action method="addLink" translate="label" module="customer">
                <name>custom page</name>
                    <path>orders/accountpage/</path>
                    <label>View Old Orders</label>
            </action>
    </reference>
</customer_account>

现在我想设置此创建标签的排序顺序。任何人都可以告诉我,我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

Karan,Magento没有have this type of function,所以你需要customization

课程Mage_Customer_Block_Account_Navigation上的

goto function addLik修改代码,......

public function addLink($name, $path, $label, $urlParams=array(),$sort=50)
{
    $this->_links[$name] = new Varien_Object(array(
        'name' => $name,
        'path' => $path,
        'label' => $label,
        'url' => $this->getUrl($path, $urlParams),
        'sort'=> $sort
    ));
    return $this;
}

添加

public function getLinks()
{


$people=$this->_links;

$sortArray = array();

foreach($people as $person){
    foreach($person as $key=>$value){
        if(!isset($sortArray[$key])){
            $sortArray[$key] = array();
        }
        $sortArray[$key][] = $value;
    }
}

$orderby = "sort"; //change this to whatever key you want from the array

array_multisort($sortArray[$orderby],SORT_DESC,$people);
return $people;

}

XML

<customer_account>
        <reference name="customer_account_navigation">
            <action method="addLink" translate="label" module="customer">
                <name>custom page</name>
                    <path>orders/accountpage/</path>
                    <label>View Old Orders</label>
            <sort>15</sort>
            </action>
    </reference>
</customer_account>