Question

I want to move my custom tab from bottom to top in customer dashboard left sidebar.

I tried below thing

    <referenceBlock name="customer-account-navigation-account-link" remove="true"/>
    <referenceBlock name="customer_account_navigation">
                    <block class="Training\Msg\Block\Current" name="customer-account-navigation-account-customlink">
                        <arguments>
                            <argument name="label" xsi:type="string">Dashboard</argument>
                            <argument name="path" xsi:type="string">customer/account</argument>
                            <argument name="sortOrder" xsi:type="number">210</argument>
                        </arguments>
                    </block>
                </referenceBlock>
<move element="customer-account-navigation-account-customlink" destination="customer_account_navigation" before="customer-account-navigation-orders-link"/>

enter image description here

What I actually need is I want to change My Account tab name according to the customer group, all set well but the tab is display at the bottom.

Was it helpful?

Solution

Hope you doing well.

I'm also facing this issue but after some time have solved this.

Follow mentioned steps.

create file at view/frontend/layout/customer_account.xml.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_account_navigation">
                <block class="Magento\Customer\Block\Account\Delimiter" name="customer-account-navigation-delimiter-4" template="Vendor_Module::account/navigation-delimiter.phtml">
                    <arguments>
                        <argument name="sortOrder" xsi:type="number">1200</argument>
                    </arguments>
                    <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-custom-link">
                        <arguments>
                            <argument name="label" xsi:type="string" translate="true">Custom Link Title</argument>
                            <argument name="path" xsi:type="string">route/module/controller</argument>
                            <argument name="sortOrder" xsi:type="number">180</argument>
                        </arguments>
                    </block>
                </block>
        </referenceBlock>
    </body>
</page>

Now create Phtml file for customer-account-navigation-delimiter-4 block.

view/frontend/templates/account/navigation-delimiter.phtml

<?php echo $block->getChildHtml(); ?>

Hope you have the result you want. :-)

OTHER TIPS

Try below code :

<referenceBlock name="customer_account_navigation">
    <block class="Training\Msg\Block\Current" name="customer-account-navigation-account-customlink" before="-">
        <arguments>
            <argument name="label" xsi:type="string">Dashboard</argument>
            <argument name="path" xsi:type="string">customer/account</argument>
            <argument name="sortOrder" xsi:type="number">210</argument>
        </arguments>
    </block>
</referenceBlock>

Change

<argument name="sortOrder" xsi:type="number">210</argument>

to

<argument name="sortOrder" xsi:type="number">500</argument>

Greater the number in sortOrder higher will be the link in the customer sidebar account navigation.

You need to use block class Magento\Customer\Block\Account\SortLinkInterface and change sortOrder value.

Use this below code :

<referenceBlock name="customer_account_navigation">
        <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-orders-link">
            <arguments>
                <argument name="path" xsi:type="string">customer/account</argument>
                <argument name="label" xsi:type="string" translate="true">Testing</argument>
                <argument name="sortOrder" xsi:type="number">500</argument>
            </arguments>
        </block>
    </referenceBlock>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top