How to pass store code to custom URL in magento 2How to get Magento 2 base URL?Custom URL for magento extensionRemoving Magento Store URLs Param ?__store=How to get Magento root url properly?module pass custom url parametersMagento 2.1.1: How can we add Payment Information (custom payment) to an order?Getting URL for Products only works for first storeMagento 2: How to get secure category URL programmatically?How to know if module's output is disabled in magento 2?Magento 2.2.3 How to change validation message Or add new custom rule in system config fieldMagento 2.3.0 How to add store filter in searchCriteriaBuilder
What would a Dragon have to exhale to cause rain?
Five Powers of Fives Produce Unique Pandigital Number...Solve for X..Tell me Y
How long do Aarakocra live?
Roman Numerals Equation 2
What color to choose as "danger" if the main color of my app is red
Is there an academic word that means "to split hairs over"?
How does the Heat Metal spell interact with a follow-up Frostbite spell?
Could a space colony 1g from the sun work?
Physically unpleasant work environment
How to continually and organically let my readers know what time it is in my story?
Who is frowning in the sentence "Daisy looked at Tom frowning"?
Working hours and productivity expectations for game artists and programmers
How to pass store code to custom URL in magento 2
Given 0s on Assignments with suspected and dismissed cheating?
AD: OU for system administrator accounts
Does a non-singular matrix have a large minor with disjoint rows and columns and full rank?
Is Precocious Apprentice enough for Mystic Theurge?
Why is so much ransomware breakable?
Quadratic/polynomial problem
What kind of environment would favor hermaphroditism in a sentient species over regular, old sexes?
What technology would Dwarves need to forge titanium?
Iterate lines of string variable in bash
What are the effects of eating many berries from the Goodberry spell per day?
Why does string strummed with finger sound different from the one strummed with pick?
How to pass store code to custom URL in magento 2
How to get Magento 2 base URL?Custom URL for magento extensionRemoving Magento Store URLs Param ?__store=How to get Magento root url properly?module pass custom url parametersMagento 2.1.1: How can we add Payment Information (custom payment) to an order?Getting URL for Products only works for first storeMagento 2: How to get secure category URL programmatically?How to know if module's output is disabled in magento 2?Magento 2.2.3 How to change validation message Or add new custom rule in system config fieldMagento 2.3.0 How to add store filter in searchCriteriaBuilder
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I would like to add store code to a custom URL in Magento 2.3.0
Actually, I want to pass store code to a custom URL in my custom module based on relevant store order.
Let's take an example:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->urlInterface->getUrl($this->emailHelper->dynamicUrl()).'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->urlInterface->getUrl('route/controller/index/'.'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
In the above code
$orderData = order object i can get storeId in this object
$this->emailHelper->dynamicUrl() = get custom string from system config
$orderData->getIncrementId() = pass orderId to url params
$this->getFollowUpId() = module custom table ID pass to url params.
Above code, the result is http://example.com/default/seo/oId/000000112/fId/179
where /default/
is store code. I would like to pass /store2Code/ instead of
/default/where
/store2Code/` is order placed on store 2.
So in short pass store code based on the placed order store.
Note : I have enabled pass store code to URL from system config. so the reason for this store code is showing in URL.
Any help would be appreciated! Thanks.
module url helper magento2.3.0
add a comment |
I would like to add store code to a custom URL in Magento 2.3.0
Actually, I want to pass store code to a custom URL in my custom module based on relevant store order.
Let's take an example:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->urlInterface->getUrl($this->emailHelper->dynamicUrl()).'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->urlInterface->getUrl('route/controller/index/'.'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
In the above code
$orderData = order object i can get storeId in this object
$this->emailHelper->dynamicUrl() = get custom string from system config
$orderData->getIncrementId() = pass orderId to url params
$this->getFollowUpId() = module custom table ID pass to url params.
Above code, the result is http://example.com/default/seo/oId/000000112/fId/179
where /default/
is store code. I would like to pass /store2Code/ instead of
/default/where
/store2Code/` is order placed on store 2.
So in short pass store code based on the placed order store.
Note : I have enabled pass store code to URL from system config. so the reason for this store code is showing in URL.
Any help would be appreciated! Thanks.
module url helper magento2.3.0
Maybe you can try like this$this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
– magefms
1 hour ago
It is working fine when you use this in frontend but when you use for backend operation like cron or admin area it is not working.
– Chirag Patel
1 hour ago
haven't tried it before but maybe setting the current store first usingsetCurrentStore($storeId);
will make it work?
– magefms
1 hour ago
add a comment |
I would like to add store code to a custom URL in Magento 2.3.0
Actually, I want to pass store code to a custom URL in my custom module based on relevant store order.
Let's take an example:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->urlInterface->getUrl($this->emailHelper->dynamicUrl()).'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->urlInterface->getUrl('route/controller/index/'.'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
In the above code
$orderData = order object i can get storeId in this object
$this->emailHelper->dynamicUrl() = get custom string from system config
$orderData->getIncrementId() = pass orderId to url params
$this->getFollowUpId() = module custom table ID pass to url params.
Above code, the result is http://example.com/default/seo/oId/000000112/fId/179
where /default/
is store code. I would like to pass /store2Code/ instead of
/default/where
/store2Code/` is order placed on store 2.
So in short pass store code based on the placed order store.
Note : I have enabled pass store code to URL from system config. so the reason for this store code is showing in URL.
Any help would be appreciated! Thanks.
module url helper magento2.3.0
I would like to add store code to a custom URL in Magento 2.3.0
Actually, I want to pass store code to a custom URL in my custom module based on relevant store order.
Let's take an example:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->urlInterface->getUrl($this->emailHelper->dynamicUrl()).'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->urlInterface->getUrl('route/controller/index/'.'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
In the above code
$orderData = order object i can get storeId in this object
$this->emailHelper->dynamicUrl() = get custom string from system config
$orderData->getIncrementId() = pass orderId to url params
$this->getFollowUpId() = module custom table ID pass to url params.
Above code, the result is http://example.com/default/seo/oId/000000112/fId/179
where /default/
is store code. I would like to pass /store2Code/ instead of
/default/where
/store2Code/` is order placed on store 2.
So in short pass store code based on the placed order store.
Note : I have enabled pass store code to URL from system config. so the reason for this store code is showing in URL.
Any help would be appreciated! Thanks.
module url helper magento2.3.0
module url helper magento2.3.0
asked 2 hours ago
Chirag PatelChirag Patel
2,950524
2,950524
Maybe you can try like this$this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
– magefms
1 hour ago
It is working fine when you use this in frontend but when you use for backend operation like cron or admin area it is not working.
– Chirag Patel
1 hour ago
haven't tried it before but maybe setting the current store first usingsetCurrentStore($storeId);
will make it work?
– magefms
1 hour ago
add a comment |
Maybe you can try like this$this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
– magefms
1 hour ago
It is working fine when you use this in frontend but when you use for backend operation like cron or admin area it is not working.
– Chirag Patel
1 hour ago
haven't tried it before but maybe setting the current store first usingsetCurrentStore($storeId);
will make it work?
– magefms
1 hour ago
Maybe you can try like this
$this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
– magefms
1 hour ago
Maybe you can try like this
$this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
– magefms
1 hour ago
It is working fine when you use this in frontend but when you use for backend operation like cron or admin area it is not working.
– Chirag Patel
1 hour ago
It is working fine when you use this in frontend but when you use for backend operation like cron or admin area it is not working.
– Chirag Patel
1 hour ago
haven't tried it before but maybe setting the current store first using
setCurrentStore($storeId);
will make it work?– magefms
1 hour ago
haven't tried it before but maybe setting the current store first using
setCurrentStore($storeId);
will make it work?– magefms
1 hour ago
add a comment |
3 Answers
3
active
oldest
votes
Use store emulation (MagentoStoreModelAppEmulation)
to set store for backend operation and Try below code.
return $this->storeManagerInterface->getStore()->getBaseUrl().$this->emailHelper->dynamicUrl().'/oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
It should work.
1
Try this but it will return without store code like thishttp://example.com/oId/2000000058/fId/192
– Chirag Patel
1 hour ago
add a comment |
I guess this can help you https://magento.stackexchange.com/a/84982/45214 .
In the above link, the BaseUrl is already obtained from storemanager and it will return the store's baseurl. If you have enabled the configuration from the backend to display store_code (for ex. en_US) along with the BaseUrl in the URL, then it will return the BaseUrl/store_code/ as Base Url.
Hope this will be helpful.
I have already seen this reference url but it's not relevant what i want.
– Chirag Patel
1 hour ago
+1 for your efforts :)
– Chirag Patel
1 hour ago
add a comment |
You can try using MagentoStoreModelStoreManagerInterface
/**
* @var MagentoStoreModelStoreManagerInterface
*/
protected $storeManager;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
parent::__construct($context);
And you can get current store url and code in your function:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
add a 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%2f274787%2fhow-to-pass-store-code-to-custom-url-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use store emulation (MagentoStoreModelAppEmulation)
to set store for backend operation and Try below code.
return $this->storeManagerInterface->getStore()->getBaseUrl().$this->emailHelper->dynamicUrl().'/oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
It should work.
1
Try this but it will return without store code like thishttp://example.com/oId/2000000058/fId/192
– Chirag Patel
1 hour ago
add a comment |
Use store emulation (MagentoStoreModelAppEmulation)
to set store for backend operation and Try below code.
return $this->storeManagerInterface->getStore()->getBaseUrl().$this->emailHelper->dynamicUrl().'/oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
It should work.
1
Try this but it will return without store code like thishttp://example.com/oId/2000000058/fId/192
– Chirag Patel
1 hour ago
add a comment |
Use store emulation (MagentoStoreModelAppEmulation)
to set store for backend operation and Try below code.
return $this->storeManagerInterface->getStore()->getBaseUrl().$this->emailHelper->dynamicUrl().'/oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
It should work.
Use store emulation (MagentoStoreModelAppEmulation)
to set store for backend operation and Try below code.
return $this->storeManagerInterface->getStore()->getBaseUrl().$this->emailHelper->dynamicUrl().'/oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
It should work.
edited 29 mins ago
Chirag Patel
2,950524
2,950524
answered 2 hours ago
Yash ShahYash Shah
1,05629
1,05629
1
Try this but it will return without store code like thishttp://example.com/oId/2000000058/fId/192
– Chirag Patel
1 hour ago
add a comment |
1
Try this but it will return without store code like thishttp://example.com/oId/2000000058/fId/192
– Chirag Patel
1 hour ago
1
1
Try this but it will return without store code like this
http://example.com/oId/2000000058/fId/192
– Chirag Patel
1 hour ago
Try this but it will return without store code like this
http://example.com/oId/2000000058/fId/192
– Chirag Patel
1 hour ago
add a comment |
I guess this can help you https://magento.stackexchange.com/a/84982/45214 .
In the above link, the BaseUrl is already obtained from storemanager and it will return the store's baseurl. If you have enabled the configuration from the backend to display store_code (for ex. en_US) along with the BaseUrl in the URL, then it will return the BaseUrl/store_code/ as Base Url.
Hope this will be helpful.
I have already seen this reference url but it's not relevant what i want.
– Chirag Patel
1 hour ago
+1 for your efforts :)
– Chirag Patel
1 hour ago
add a comment |
I guess this can help you https://magento.stackexchange.com/a/84982/45214 .
In the above link, the BaseUrl is already obtained from storemanager and it will return the store's baseurl. If you have enabled the configuration from the backend to display store_code (for ex. en_US) along with the BaseUrl in the URL, then it will return the BaseUrl/store_code/ as Base Url.
Hope this will be helpful.
I have already seen this reference url but it's not relevant what i want.
– Chirag Patel
1 hour ago
+1 for your efforts :)
– Chirag Patel
1 hour ago
add a comment |
I guess this can help you https://magento.stackexchange.com/a/84982/45214 .
In the above link, the BaseUrl is already obtained from storemanager and it will return the store's baseurl. If you have enabled the configuration from the backend to display store_code (for ex. en_US) along with the BaseUrl in the URL, then it will return the BaseUrl/store_code/ as Base Url.
Hope this will be helpful.
I guess this can help you https://magento.stackexchange.com/a/84982/45214 .
In the above link, the BaseUrl is already obtained from storemanager and it will return the store's baseurl. If you have enabled the configuration from the backend to display store_code (for ex. en_US) along with the BaseUrl in the URL, then it will return the BaseUrl/store_code/ as Base Url.
Hope this will be helpful.
answered 2 hours ago
Kazim NooraniKazim Noorani
1,0871723
1,0871723
I have already seen this reference url but it's not relevant what i want.
– Chirag Patel
1 hour ago
+1 for your efforts :)
– Chirag Patel
1 hour ago
add a comment |
I have already seen this reference url but it's not relevant what i want.
– Chirag Patel
1 hour ago
+1 for your efforts :)
– Chirag Patel
1 hour ago
I have already seen this reference url but it's not relevant what i want.
– Chirag Patel
1 hour ago
I have already seen this reference url but it's not relevant what i want.
– Chirag Patel
1 hour ago
+1 for your efforts :)
– Chirag Patel
1 hour ago
+1 for your efforts :)
– Chirag Patel
1 hour ago
add a comment |
You can try using MagentoStoreModelStoreManagerInterface
/**
* @var MagentoStoreModelStoreManagerInterface
*/
protected $storeManager;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
parent::__construct($context);
And you can get current store url and code in your function:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
add a comment |
You can try using MagentoStoreModelStoreManagerInterface
/**
* @var MagentoStoreModelStoreManagerInterface
*/
protected $storeManager;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
parent::__construct($context);
And you can get current store url and code in your function:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
add a comment |
You can try using MagentoStoreModelStoreManagerInterface
/**
* @var MagentoStoreModelStoreManagerInterface
*/
protected $storeManager;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
parent::__construct($context);
And you can get current store url and code in your function:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
You can try using MagentoStoreModelStoreManagerInterface
/**
* @var MagentoStoreModelStoreManagerInterface
*/
protected $storeManager;
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
parent::__construct($context);
And you can get current store url and code in your function:
public function getCustomUrl($orderData)
if($this->emailHelper->dynamicUrl())
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
else
return $this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId());
answered 1 hour ago
magefmsmagefms
3,0773631
3,0773631
add a comment |
add a 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%2f274787%2fhow-to-pass-store-code-to-custom-url-in-magento-2%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
Maybe you can try like this
$this->storeManager->getStore()->getStoreUrl().'/'.$this->storeManager->getStore()->getCode().'oId/'.$orderData->getIncrementId().'/fId/'.$this->getFollowUpId();
– magefms
1 hour ago
It is working fine when you use this in frontend but when you use for backend operation like cron or admin area it is not working.
– Chirag Patel
1 hour ago
haven't tried it before but maybe setting the current store first using
setCurrentStore($storeId);
will make it work?– magefms
1 hour ago