I want to add a new section with my own links to the customer account page (see pic) This section should be visible based on my custom extension of the customer entity.
How can I do that?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI want to add a new section with my own links to the customer account page (see pic) This section should be visible based on my custom extension of the customer entity.
How can I do that?
Create your own extension.
Let's call it StackExchange_Customer
.
You will need these files:
app/code/StackExchange/Customer/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'StackExchange_Customer',
__DIR__
);
app/code/StackExchange/Customer/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="StackExchange_Customer" setup_version="1.0.0">
<sequence>
<module name="Magento_Customer"/>
</sequence>
</module>
</config>
app/code/StackExchange/Customer/view/frontend/layout/customer_account.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Customer My Account (All Pages)" design_abstraction="custom">
<body>
<attribute name="class" value="account"/>
<referenceContainer name="sidebar.main">
<block class="Magento\Framework\View\Element\Html\Links" name="customer_account_navigation_secondary" after="customer_account_navigation" template="Magento_Customer::account/navigation.phtml">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-account-link-secondary"> <!-- duplicate this as many times as you need, just make sure the name is unique -->
<arguments>
<argument name="label" xsi:type="string" translate="true">Some link here</argument>
<argument name="path" xsi:type="string">module/controller/action</argument>
</arguments>
</block>
</block>
</referenceContainer>
</body>
</page>
then run in the console php bin/magento setup:upgrade
.
customer_account.xml
. Thank you
Jun 23, 2019 at 20:18