Magento 2: How to pass custom params with url?magento parameter url of currencyCustom URL rewrite for reviews in MagentoChanging product prices based on the current currencygetVisitorData() returns NULL on Category Page only in magento-1.9.2.2Change magento url structure for better Google indexNeed pass dynamic url param value in massAction url of ui-component gridHow to remove direct product url in magento 2?How can I pass a URL parameter to admin grid data provider?Magento2 : How to make a redirect with paramsGet current category or current product and then get its url in the other store store view

My mother co-signed for my car. Can she take it away from me if I am the one making car payments?

Are the plates of a battery really charged?

What verb goes with "coup"?

Can I have a forest in the rain shadow of a mountain range?

How long had Bertha Mason been in the attic at the point of the events in Jane Eyre

Sleepy tired vs physically tired

What is the meaning of "stock" dilution on the Massive Dev Chart website?

A grammar issue?

Why did my leaking pool light trip the circuit breaker, but not the GFCI?

Contributing to a candidate as a Foreign National US Resident?

Can you move between the attacks of a Twinned Booming Blade?

Pandas merge and fillna

Go function to test whether a file exists

Who pays for increased security measures on flights to the US?

Should I hide my travel history to the UK when I apply for an Australian visa?

Can I deep fry food in butter instead of vegetable oil?

administrative duties kill the research spirit?

Sum of Max terms maximization

Is よう an adjective or a noun?

What are the differences of checking a self-signed certificate vs ignore it?

Bypass with wrong cvv of debit card and getting OTP

Did Stalin kill all Soviet officers involved in the Winter War?

PhD: When to quit and move on?

Versicle and response symbols



Magento 2: How to pass custom params with url?


magento parameter url of currencyCustom URL rewrite for reviews in MagentoChanging product prices based on the current currencygetVisitorData() returns NULL on Category Page only in magento-1.9.2.2Change magento url structure for better Google indexNeed pass dynamic url param value in massAction url of ui-component gridHow to remove direct product url in magento 2?How can I pass a URL parameter to admin grid data provider?Magento2 : How to make a redirect with paramsGet current category or current product and then get its url in the other store store view






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















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










share|improve this question




























    1















    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










    share|improve this question
























      1












      1








      1








      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










      share|improve this question














      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







      magento2 url-rewrite currency parameter id






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 25 at 6:44









      Shoaib SaleemShoaib Saleem

      9611 bronze badges




      9611 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          1














          Use below code to Pass parameter



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





          share|improve this answer























          • In which file this code should be place?

            – Shoaib Saleem
            Jun 25 at 7:10











          • Where you want add redirect code . like block or controller file

            – Shorabh
            Jun 25 at 7:13











          • I am new in magento 2, don't know where should be add this code to get example url.

            – Shoaib Saleem
            Jun 25 at 7:14











          • I think you want add parameter on product details page . I am write ?

            – Shorabh
            Jun 25 at 7:23











          • Yes.ID and currency(both) params on product detail page and just currency on all others pages.

            – Shoaib Saleem
            Jun 25 at 7:28


















          0














          As you want to add id and currency then you have to work on MagentoCatalogModelProductUrl::getUrl()



          Create Before plugin on the method getUrl and add currency add one of an index of parameter $params.



          Declare the Plugin from di.xml and it code is below



          <?xml version="1.0" ?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogModelProductUrl">
          <plugin disabled="false" name="StackExchange_MagentoAddress_Plugin_Magento_Catalog_Model_Product_Url"
          sortOrder="10" type="StackExchangeMagentoPluginProductUrl"/>
          </type>
          </config>


          Plugin Class



          <?php
          namespace StackExchangeMagentoPlugin;

          class ProductUrl


          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          private $storeManager;

          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )

          $this->storeManager = $storeManager;

          public function beforeGetUrl(
          MagentoCatalogModelProductUrl $subject,
          MagentoCatalogModelProduct $product,
          $params = []
          )

          if(empty($params)






          share|improve this answer

























          • I tried but not getting any result.

            – Shoaib Saleem
            Jun 25 at 8:13











          • hmm i have checked that , seems it is not working. I will check again and will post answer

            – Amit Bera
            Jun 25 at 8:14











          • @shoaib-saleem,abve solution is worked

            – Amit Bera
            Jun 25 at 8:23











          • How to pass params in getUrl()?Can you describe a proper way?I am not good in Mag2.

            – Shoaib Saleem
            Jun 25 at 8:25












          • using before plugin, i have changes the parameter of this function

            – Amit Bera
            Jun 25 at 8:41













          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279481%2fmagento-2-how-to-pass-custom-params-with-url%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Use below code to Pass parameter



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





          share|improve this answer























          • In which file this code should be place?

            – Shoaib Saleem
            Jun 25 at 7:10











          • Where you want add redirect code . like block or controller file

            – Shorabh
            Jun 25 at 7:13











          • I am new in magento 2, don't know where should be add this code to get example url.

            – Shoaib Saleem
            Jun 25 at 7:14











          • I think you want add parameter on product details page . I am write ?

            – Shorabh
            Jun 25 at 7:23











          • Yes.ID and currency(both) params on product detail page and just currency on all others pages.

            – Shoaib Saleem
            Jun 25 at 7:28















          1














          Use below code to Pass parameter



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





          share|improve this answer























          • In which file this code should be place?

            – Shoaib Saleem
            Jun 25 at 7:10











          • Where you want add redirect code . like block or controller file

            – Shorabh
            Jun 25 at 7:13











          • I am new in magento 2, don't know where should be add this code to get example url.

            – Shoaib Saleem
            Jun 25 at 7:14











          • I think you want add parameter on product details page . I am write ?

            – Shorabh
            Jun 25 at 7:23











          • Yes.ID and currency(both) params on product detail page and just currency on all others pages.

            – Shoaib Saleem
            Jun 25 at 7:28













          1












          1








          1







          Use below code to Pass parameter



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





          share|improve this answer













          Use below code to Pass parameter



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






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 25 at 6:56









          ShorabhShorabh

          1,0616 silver badges15 bronze badges




          1,0616 silver badges15 bronze badges












          • In which file this code should be place?

            – Shoaib Saleem
            Jun 25 at 7:10











          • Where you want add redirect code . like block or controller file

            – Shorabh
            Jun 25 at 7:13











          • I am new in magento 2, don't know where should be add this code to get example url.

            – Shoaib Saleem
            Jun 25 at 7:14











          • I think you want add parameter on product details page . I am write ?

            – Shorabh
            Jun 25 at 7:23











          • Yes.ID and currency(both) params on product detail page and just currency on all others pages.

            – Shoaib Saleem
            Jun 25 at 7:28

















          • In which file this code should be place?

            – Shoaib Saleem
            Jun 25 at 7:10











          • Where you want add redirect code . like block or controller file

            – Shorabh
            Jun 25 at 7:13











          • I am new in magento 2, don't know where should be add this code to get example url.

            – Shoaib Saleem
            Jun 25 at 7:14











          • I think you want add parameter on product details page . I am write ?

            – Shorabh
            Jun 25 at 7:23











          • Yes.ID and currency(both) params on product detail page and just currency on all others pages.

            – Shoaib Saleem
            Jun 25 at 7:28
















          In which file this code should be place?

          – Shoaib Saleem
          Jun 25 at 7:10





          In which file this code should be place?

          – Shoaib Saleem
          Jun 25 at 7:10













          Where you want add redirect code . like block or controller file

          – Shorabh
          Jun 25 at 7:13





          Where you want add redirect code . like block or controller file

          – Shorabh
          Jun 25 at 7:13













          I am new in magento 2, don't know where should be add this code to get example url.

          – Shoaib Saleem
          Jun 25 at 7:14





          I am new in magento 2, don't know where should be add this code to get example url.

          – Shoaib Saleem
          Jun 25 at 7:14













          I think you want add parameter on product details page . I am write ?

          – Shorabh
          Jun 25 at 7:23





          I think you want add parameter on product details page . I am write ?

          – Shorabh
          Jun 25 at 7:23













          Yes.ID and currency(both) params on product detail page and just currency on all others pages.

          – Shoaib Saleem
          Jun 25 at 7:28





          Yes.ID and currency(both) params on product detail page and just currency on all others pages.

          – Shoaib Saleem
          Jun 25 at 7:28













          0














          As you want to add id and currency then you have to work on MagentoCatalogModelProductUrl::getUrl()



          Create Before plugin on the method getUrl and add currency add one of an index of parameter $params.



          Declare the Plugin from di.xml and it code is below



          <?xml version="1.0" ?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogModelProductUrl">
          <plugin disabled="false" name="StackExchange_MagentoAddress_Plugin_Magento_Catalog_Model_Product_Url"
          sortOrder="10" type="StackExchangeMagentoPluginProductUrl"/>
          </type>
          </config>


          Plugin Class



          <?php
          namespace StackExchangeMagentoPlugin;

          class ProductUrl


          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          private $storeManager;

          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )

          $this->storeManager = $storeManager;

          public function beforeGetUrl(
          MagentoCatalogModelProductUrl $subject,
          MagentoCatalogModelProduct $product,
          $params = []
          )

          if(empty($params)






          share|improve this answer

























          • I tried but not getting any result.

            – Shoaib Saleem
            Jun 25 at 8:13











          • hmm i have checked that , seems it is not working. I will check again and will post answer

            – Amit Bera
            Jun 25 at 8:14











          • @shoaib-saleem,abve solution is worked

            – Amit Bera
            Jun 25 at 8:23











          • How to pass params in getUrl()?Can you describe a proper way?I am not good in Mag2.

            – Shoaib Saleem
            Jun 25 at 8:25












          • using before plugin, i have changes the parameter of this function

            – Amit Bera
            Jun 25 at 8:41















          0














          As you want to add id and currency then you have to work on MagentoCatalogModelProductUrl::getUrl()



          Create Before plugin on the method getUrl and add currency add one of an index of parameter $params.



          Declare the Plugin from di.xml and it code is below



          <?xml version="1.0" ?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogModelProductUrl">
          <plugin disabled="false" name="StackExchange_MagentoAddress_Plugin_Magento_Catalog_Model_Product_Url"
          sortOrder="10" type="StackExchangeMagentoPluginProductUrl"/>
          </type>
          </config>


          Plugin Class



          <?php
          namespace StackExchangeMagentoPlugin;

          class ProductUrl


          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          private $storeManager;

          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )

          $this->storeManager = $storeManager;

          public function beforeGetUrl(
          MagentoCatalogModelProductUrl $subject,
          MagentoCatalogModelProduct $product,
          $params = []
          )

          if(empty($params)






          share|improve this answer

























          • I tried but not getting any result.

            – Shoaib Saleem
            Jun 25 at 8:13











          • hmm i have checked that , seems it is not working. I will check again and will post answer

            – Amit Bera
            Jun 25 at 8:14











          • @shoaib-saleem,abve solution is worked

            – Amit Bera
            Jun 25 at 8:23











          • How to pass params in getUrl()?Can you describe a proper way?I am not good in Mag2.

            – Shoaib Saleem
            Jun 25 at 8:25












          • using before plugin, i have changes the parameter of this function

            – Amit Bera
            Jun 25 at 8:41













          0












          0








          0







          As you want to add id and currency then you have to work on MagentoCatalogModelProductUrl::getUrl()



          Create Before plugin on the method getUrl and add currency add one of an index of parameter $params.



          Declare the Plugin from di.xml and it code is below



          <?xml version="1.0" ?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogModelProductUrl">
          <plugin disabled="false" name="StackExchange_MagentoAddress_Plugin_Magento_Catalog_Model_Product_Url"
          sortOrder="10" type="StackExchangeMagentoPluginProductUrl"/>
          </type>
          </config>


          Plugin Class



          <?php
          namespace StackExchangeMagentoPlugin;

          class ProductUrl


          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          private $storeManager;

          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )

          $this->storeManager = $storeManager;

          public function beforeGetUrl(
          MagentoCatalogModelProductUrl $subject,
          MagentoCatalogModelProduct $product,
          $params = []
          )

          if(empty($params)






          share|improve this answer















          As you want to add id and currency then you have to work on MagentoCatalogModelProductUrl::getUrl()



          Create Before plugin on the method getUrl and add currency add one of an index of parameter $params.



          Declare the Plugin from di.xml and it code is below



          <?xml version="1.0" ?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCatalogModelProductUrl">
          <plugin disabled="false" name="StackExchange_MagentoAddress_Plugin_Magento_Catalog_Model_Product_Url"
          sortOrder="10" type="StackExchangeMagentoPluginProductUrl"/>
          </type>
          </config>


          Plugin Class



          <?php
          namespace StackExchangeMagentoPlugin;

          class ProductUrl


          /**
          * @var MagentoStoreModelStoreManagerInterface
          */
          private $storeManager;

          public function __construct(
          MagentoStoreModelStoreManagerInterface $storeManager
          )

          $this->storeManager = $storeManager;

          public function beforeGetUrl(
          MagentoCatalogModelProductUrl $subject,
          MagentoCatalogModelProduct $product,
          $params = []
          )

          if(empty($params)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 25 at 8:22

























          answered Jun 25 at 8:03









          Amit BeraAmit Bera

          61.7k16 gold badges84 silver badges183 bronze badges




          61.7k16 gold badges84 silver badges183 bronze badges












          • I tried but not getting any result.

            – Shoaib Saleem
            Jun 25 at 8:13











          • hmm i have checked that , seems it is not working. I will check again and will post answer

            – Amit Bera
            Jun 25 at 8:14











          • @shoaib-saleem,abve solution is worked

            – Amit Bera
            Jun 25 at 8:23











          • How to pass params in getUrl()?Can you describe a proper way?I am not good in Mag2.

            – Shoaib Saleem
            Jun 25 at 8:25












          • using before plugin, i have changes the parameter of this function

            – Amit Bera
            Jun 25 at 8:41

















          • I tried but not getting any result.

            – Shoaib Saleem
            Jun 25 at 8:13











          • hmm i have checked that , seems it is not working. I will check again and will post answer

            – Amit Bera
            Jun 25 at 8:14











          • @shoaib-saleem,abve solution is worked

            – Amit Bera
            Jun 25 at 8:23











          • How to pass params in getUrl()?Can you describe a proper way?I am not good in Mag2.

            – Shoaib Saleem
            Jun 25 at 8:25












          • using before plugin, i have changes the parameter of this function

            – Amit Bera
            Jun 25 at 8:41
















          I tried but not getting any result.

          – Shoaib Saleem
          Jun 25 at 8:13





          I tried but not getting any result.

          – Shoaib Saleem
          Jun 25 at 8:13













          hmm i have checked that , seems it is not working. I will check again and will post answer

          – Amit Bera
          Jun 25 at 8:14





          hmm i have checked that , seems it is not working. I will check again and will post answer

          – Amit Bera
          Jun 25 at 8:14













          @shoaib-saleem,abve solution is worked

          – Amit Bera
          Jun 25 at 8:23





          @shoaib-saleem,abve solution is worked

          – Amit Bera
          Jun 25 at 8:23













          How to pass params in getUrl()?Can you describe a proper way?I am not good in Mag2.

          – Shoaib Saleem
          Jun 25 at 8:25






          How to pass params in getUrl()?Can you describe a proper way?I am not good in Mag2.

          – Shoaib Saleem
          Jun 25 at 8:25














          using before plugin, i have changes the parameter of this function

          – Amit Bera
          Jun 25 at 8:41





          using before plugin, i have changes the parameter of this function

          – Amit Bera
          Jun 25 at 8:41

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279481%2fmagento-2-how-to-pass-custom-params-with-url%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form