I want to add an "id"/"parameter" to a front-end route in the following way:


where 213 is the parameter I want to pass.

I have been looking at the Magento 2 dev docs, but I can't seem to find anything regarding adding this parameter.

And I can't seem to find anything that adds the "id" to the existing product route (catalog/product/view/id/:id) in magento/module-catalog. I'm probably missing something.


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="blogpost" frontName="blogpost">
            <module name="MyModule_BlogPost" />



namespace MyModule\BlogPost\Controller\Search;

class Index extends \Magento\Framework\App\Action\Action
    public function execute()
        // This only includes url query parameters ?param1=123&param2=active
        $params = $this->getRequest->getParams();

        // But I'd like to do this like the catalog/product/view/id/:id route ...

Do I need to make a custom router for this, or is there another way?

  • Is that custom route you have created is for grid? does this controller gets triggered on button click?
    – aravind
    Feb 13, 2020 at 10:51
  • It's for when I make a request to store.example.com/blogpost/view/213 as a frontend page.
    – Toine H
    Feb 13, 2020 at 10:58
  • have you checked this url magento.stackexchange.com/questions/226602/…
    – aravind
    Feb 13, 2020 at 11:02
  • Yes, but that question is about making a "pretty" url for an existing route.
    – Toine H
    Feb 13, 2020 at 11:27


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.

Browse other questions tagged or ask your own question.