Online multi-channel retailing can be interpreted as an approach to sale online store products on additional platforms like Instagram, Facebook, relevant marketplaces, etc.
For Magento 2 stores going for this approach needs to offer an excellent shopping experience. For example, a visitor checks your product on a Facebook shop and decides to buy it. On clicking it, he should be redirected to your store, and the product must be added to the cart for checkout.
However, Magento 2 needs to identify the product that is to be added to the cart. And to do so, you need to pass parameter to URL in Magento 2.
Implement the below method to identify the particular product by passing a parameter through URL:
Method To Pass Parameter To URL In Magento 2:
class Data extends AbstractHelper
public function __construct(
$this->urlBuilder = $urlBuilder;
public function GetParamUrl()
$queryParams = [
'param_1' => value1, // value for parameter
'param_2' => value2
return $this->urlBuilder->getUrl('route/controller/action', ['_current' => true,'_use_rewrite' => true, '_query' => $queryParams]);
//Ex: $this->urlBuilder->getUrl('custom/addcart/index', ['_current' => true,'_use_rewrite' => true, '_query' => $queryParams]);
I would be happy to help with any doubts on the topic mentioned in the Comments section below.
Do share the solution with the fellow developers via social media.