In template I try to get url link but it doesn't work correct. I try to use this code:


But it always return http://abcs.com/aloha/product/view/, Is this a bug?

  • What you want here? ulr looks good. – Sohel Rana Jul 19 '19 at 3:54
  • The result should I expect is abcs.com/aloha/product/view/id/ – David Duong Jul 19 '19 at 4:25


This is the wrong approach. Try following way:

$block->getUrl('aloha/product/view', ['id' => 22])


According to your comment you need url using id. GetUrl will return route/contoller/actionclass and ignore remaining string. In your case, try following way:

| improve this answer | |
  • The issue is I don't have id when I use this function(I will add id in Jquery). Do you know why Magento remove id in last? – David Duong Jul 19 '19 at 4:02
  • Check updated answer – Sohel Rana Jul 19 '19 at 4:29
  • It work. Thank you! – David Duong Jul 19 '19 at 4:32

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.