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;
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¤cy=GBP
Need help
magento2 url-rewrite currency parameter id
add a comment |
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¤cy=GBP
Need help
magento2 url-rewrite currency parameter id
add a comment |
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¤cy=GBP
Need help
magento2 url-rewrite currency parameter id
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¤cy=GBP
Need help
magento2 url-rewrite currency parameter id
magento2 url-rewrite currency parameter id
asked Jun 25 at 6:44
Shoaib SaleemShoaib Saleem
9611 bronze badges
9611 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Use below code to Pass parameter
$id=123
$currency = 'GBP';
$parameter = ['id' => $id, 'currency' => $currency];
$resultRedirect->setPath('frontname/path/controllername', ['params' => $parameter]);
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
add a comment |
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)
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
|
show 1 more comment
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Use below code to Pass parameter
$id=123
$currency = 'GBP';
$parameter = ['id' => $id, 'currency' => $currency];
$resultRedirect->setPath('frontname/path/controllername', ['params' => $parameter]);
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
add a comment |
Use below code to Pass parameter
$id=123
$currency = 'GBP';
$parameter = ['id' => $id, 'currency' => $currency];
$resultRedirect->setPath('frontname/path/controllername', ['params' => $parameter]);
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
add a comment |
Use below code to Pass parameter
$id=123
$currency = 'GBP';
$parameter = ['id' => $id, 'currency' => $currency];
$resultRedirect->setPath('frontname/path/controllername', ['params' => $parameter]);
Use below code to Pass parameter
$id=123
$currency = 'GBP';
$parameter = ['id' => $id, 'currency' => $currency];
$resultRedirect->setPath('frontname/path/controllername', ['params' => $parameter]);
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
add a comment |
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
add a comment |
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)
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
|
show 1 more comment
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)
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
|
show 1 more comment
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)
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)
edited Jun 25 at 8:22
answered Jun 25 at 8:03
Amit Bera♦Amit 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
|
show 1 more comment
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
|
show 1 more comment
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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