I can't figure it out how to add links dynamically to customer navigation.
this is my xml:
<referenceBlock name="customer_account_navigation">
<block class="Vendor\Module\Block\Custom\Link\" name="block">
<action method="addCustomLink">
<!-- HERE DYNAMICALLY NEEDS TO ADD ARGUMENTS e.g label, path etc..-->
</action>
</block>
</referenceContainer>
Block:
class Link extends \Magento\Framework\View\Element\Html\Link\Current
{
public function addCustomLink()
{
$parent = $this->getParentBlock();
$parent->addLink(
'Dynamic Label goes here',
'Dynamic Url goes here',
'Dynamic title goes here'
);
}
}
This is giving me error: Invalid method Magento\Customer\Block\Account\Navigation::addLink
.
Anybody have any suggestion how could one do this?
Thanks in advance.
protected function _toHtml() { return '<li class="nav item"><a href="test">TEST</a></li>'; }