2

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

$block->getUrl('aloha/product/view/id/')

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

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

1 Answer 1

3

$block->getUrl('aloha/product/view/id/')

This is the wrong approach. Try following way:

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

[Update]

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:

$block->getUrl('aloha/product/view').'/id'
3
  • 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? Jul 19, 2019 at 4:02
  • Check updated answer
    – Sohel Rana
    Jul 19, 2019 at 4:29
  • It work. Thank you! Jul 19, 2019 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.