Magento – Magento 2: How to pass custom params with url

currencyidmagento2parameterurl-rewrite

I want to pass custom params( product id and currency) with product page url dynamically.
Example url:

https://example.com/boys-5-piece-blue-suit-eric.html?id=123&currency=GBP

Need help

Best Answer

Use below code to Pass parameter

$id=123
$currency = 'GBP';
$parameter = ['id' => $id, 'currency' => $currency];
$resultRedirect->setPath('frontname/path/controllername', ['params' => $parameter]);
Related Topic