Get rewritten URL for custom link in customer account dashboard
-
19-12-2019 - |
Question
To my customer account dashboard (and index) I want to add a custom (direct) link to a product category. This product category is only visible to logged in customers, that's why I want to have it here, too (not just in the basic store category view /listing)
I managed to list the link with adding
<action method="addLink" translate="label" module="customer">
<name>downloads_category</name>
<url>catalog/category/view/id/93</url>
<label>Downloads Category</label>
</action>
to the <customer_account>
block in my customer.xml
file.
But I struggle on getting the rewritten URL (downloads.html, as set in rewrite management). The rewrite-URL works fine in the frontend.
Using downloads.html
as the <url></url>
parameter will end up adding a link to /.../downloads.html/
(with that unwanted trailing slash).
Edit: I'm running Magento CE 1.9.2.2
Solution 2
I managed to get the rewritten URL as href
with using the urlParams
as follows:
<action method="addLink" translate="label" module="customer">
<name>downloads-category</name>
<url>catalog/category/view/id/101</url>
<label>Downloads</label>
<urlParams>
<_direct>downloads.html</_direct>
</urlParams>
</action>
It's not dynamic but at least it is not a non-SEF-URL.
OTHER TIPS
You can use a helper in your layout to generate the URL.
Take a look at this subject, it may help you : Use a helper in a layout