0

I want to change the URL of the "create An account" link that is on the top right of the site. I want the link to instead of being customer/account/create/ I want it to be customer/account/login

I believe I have to edit the default xml file that is

app/design/frontend/Smartwave/porto_child/Magento_Customer/layout

here is the file just not sure how to edit it

<?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="header.links">
        <block class="Magento\Customer\Block\Account\Customer" name="customer" template="account/customer.phtml" before="-"/>
        <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link-login" template="account/link/authorization.phtml"/>
    </referenceBlock>
    <block class="Magento\Theme\Block\Html\Header" name="header" as="header">
        <arguments>
            <argument name="show_part" xsi:type="string">welcome</argument>
        </arguments>
    </block>
    <move element="header" destination="header.links" before="-"/>
    <move element="register-link" destination="header.links"/>
    <move element="top.links" destination="customer"/>
    <move element="authorization-link" destination="top.links" after="-"/>
  </body>
</page>
1

Change class of block register-link to Magento\Framework\View\Element\Html\Link

Now you can pass the parameter path to change link

So your final default.xml should look like this:

app/design/frontend/Smartwave/porto_child/Magento_Customer/layout/default.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="top.links">
        <block class="Magento\Framework\View\Element\Html\Link" name="register-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
                <argument name="path" xsi:type="string" translate="true">customer/account/login</argument>
            </arguments>
        </block>
    </referenceBlock>

    ....
    ....
</page>
0

You can remove existing Create an Account link and add a custom link. You need to edit following file:

mage2Root/app/design/frontend/{Package}/{theme}/Magento_Theme/layout/default.xml

Add below code inside body tag:

<referenceBlock name="register-link" remove="true"/>
<referenceBlock name="top.links">
    <block class="Magento\Framework\View\Element\Html\Link" name="add-new-header-link">
        <arguments>
             <argument name="label" xsi:type="string" translate="true">Create an Account@</argument>
             <argument name="path" xsi:type="string" translate="true">customer/account/login</argument>
        </arguments>
    </block>
</referenceBlock>

If needed you can use after,before for adjust position of link.

Hope above will help!

  • 1
    We don't need to remove existing register-link link – Prince Patel Dec 12 '18 at 5:34
  • Yes, you are right! great.. – Pawan Dec 13 '18 at 3:41

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.