I have set a new page in the customer area with link that links to my new controller with below code:

            <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-address-link">
                    <argument name="label" xsi:type="string" translate="true">Address Book</argument>
                    <argument name="path" xsi:type="string">customer/index/products</argument>

My controller is like below:

namespace Vendor\Module\Controller\Customer\Index;

class Products extends \Magento\Framework\App\Action\Action

protected $resultPageFactory;

public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
    $this->resultPageFactory = $resultPageFactory;

public function execute()
    $resultPage = $this->resultPageFactory->create();
    return $this->resultPageFactory->create();

This creates a link fine and can visit my controller URL however the link within navigation is not set as "current".

Upon investigating vendor/magento/framework/view/element/html/link/current.php where the isCurrent function works out if this is the current page i can see that my controller does not seem to be given a controller name.


Does return the controller name however but the getMCA function does not seem to build it into the full path.

return $this->getCurrent() || $this->getUrl($this->getPath()) == $this->getUrl($this->getMca());

So for my controller it's showing that /customer/contract/products != /customer/contract and so not current however it is and just want to know why this function is not working as expected here.

So I was wondering if anyone knows where i am going wrong?


After some debugging i think i have figured out that this is due to the use of the word index in any of the module / controller / action getting ripped out in the getMCA() function and so if it's its also present in URL it should not be as index will be used by default:

 if (!empty($value) && $value != $this->_defaultPath->getPart($key)) {
            $parts[] = $value;

I changed my controller name to contract and set the action name to index. Then set the url within customer navigation to /customer/contract these now match, however setting url to /customer/contract/index although works, does not match.

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.