Magento 2.3.1 Change store view in controller_action_predispatch eventsales_order_save_commit_after event triggered twice?Magento2: Re-direct to custom URL from observerSet custom price of product when adding to cart code not workingMagento 1.9 - Order object passed to event observer is emptyRedirect to correct store view by customer browser languageCustomer save after event magento2controller_action_predispatch is not observing after logoutMagento 2 controller_action_predispatch observer not working as expectedCreate event and observer for customer sign up (Magento 2)Sign up (guest checkout) issue in Magento 2
Do Goblin tokens count as Goblins?
Why is there paternal, for fatherly, fraternal, for brotherly, but no similar word for sons?
How to find the version of extensions used on a Joomla website without access to the backend?
How to say "just a precision" properly in English?
When is one 'Ready' to make Original Contributions to Mathematics?
Why do people prefer metropolitan areas, considering monsters and villains?
White's last move?
Does the Milky Way orbit around anything?
What's the big deal about the Nazgûl losing their horses?
What is the highest level of accuracy in motion control a Victorian society could achieve?
What is the meaning of "prairie-dog" in this sentence?
Is there a minimum amount of electricity that can be fed back into the grid?
Howto display unicode character u2026 in terminal mode in emacs
Better random (unique) file name
Examples of fluid (including air) being used to transmit digital data?
Did Stalin kill all Soviet officers involved in the Winter War?
How to deal with a Murder Hobo Paladin?
Do grungs have a written language?
Was the 45.9°C temperature in France in June 2019 the highest ever recorded in France?
Why do we need a bootloader separate from our application program in microcontrollers?
What's the difference between a type and a kind?
How to get the speed of my spaceship?
How do I explain how I handle unrealistic expectations from superiors in an interview?
PhD: When to quit and move on?
Magento 2.3.1 Change store view in controller_action_predispatch event
sales_order_save_commit_after event triggered twice?Magento2: Re-direct to custom URL from observerSet custom price of product when adding to cart code not workingMagento 1.9 - Order object passed to event observer is emptyRedirect to correct store view by customer browser languageCustomer save after event magento2controller_action_predispatch is not observing after logoutMagento 2 controller_action_predispatch observer not working as expectedCreate event and observer for customer sign up (Magento 2)Sign up (guest checkout) issue in Magento 2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
In my extension, the default storeview is English and I want to set Arabic storeview, only one time when the customer comes first time on my website. I'm using controller_action_predispatch event to check customer comes the first time or not, if not, customer can move to English storeview as well. Following is my piece of code:
NamespaceModulenameetcfrontendevents.xml
<event name="controller_action_predispatch">
<observer name="switch_store" instance="NamespaceModulenameObserverSwitchStore" shared="false" />
</event>
NamespaceModulenameObserverSwitchStore.php
protected $storeManager;
public function __construct(
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
public function execute(MagentoFrameworkEventObserver $observer)
if ($this->firstVisit()) // Customer's first visit logic inside firstVisit() function
$storeId = $this->storeManager->getStore($target_store)->getId();
$this->storeManager->setCurrentStore($storeId);
return $this;
This code is working fine for the first time, but when the user tries to switch English storeview, he/she would be redirected to the same storeview, that is Arabic. I debugged so many times, but in logs, I'm getting perfect output and not reflecting the change on the frontend. I think this is a cache issue, but not sure. Please let me know if anyone has a solution for this.
Thanks in anticipate.
event-observer cache store-view magento2.3.1 store-switcher
add a comment |
In my extension, the default storeview is English and I want to set Arabic storeview, only one time when the customer comes first time on my website. I'm using controller_action_predispatch event to check customer comes the first time or not, if not, customer can move to English storeview as well. Following is my piece of code:
NamespaceModulenameetcfrontendevents.xml
<event name="controller_action_predispatch">
<observer name="switch_store" instance="NamespaceModulenameObserverSwitchStore" shared="false" />
</event>
NamespaceModulenameObserverSwitchStore.php
protected $storeManager;
public function __construct(
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
public function execute(MagentoFrameworkEventObserver $observer)
if ($this->firstVisit()) // Customer's first visit logic inside firstVisit() function
$storeId = $this->storeManager->getStore($target_store)->getId();
$this->storeManager->setCurrentStore($storeId);
return $this;
This code is working fine for the first time, but when the user tries to switch English storeview, he/she would be redirected to the same storeview, that is Arabic. I debugged so many times, but in logs, I'm getting perfect output and not reflecting the change on the frontend. I think this is a cache issue, but not sure. Please let me know if anyone has a solution for this.
Thanks in anticipate.
event-observer cache store-view magento2.3.1 store-switcher
add a comment |
In my extension, the default storeview is English and I want to set Arabic storeview, only one time when the customer comes first time on my website. I'm using controller_action_predispatch event to check customer comes the first time or not, if not, customer can move to English storeview as well. Following is my piece of code:
NamespaceModulenameetcfrontendevents.xml
<event name="controller_action_predispatch">
<observer name="switch_store" instance="NamespaceModulenameObserverSwitchStore" shared="false" />
</event>
NamespaceModulenameObserverSwitchStore.php
protected $storeManager;
public function __construct(
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
public function execute(MagentoFrameworkEventObserver $observer)
if ($this->firstVisit()) // Customer's first visit logic inside firstVisit() function
$storeId = $this->storeManager->getStore($target_store)->getId();
$this->storeManager->setCurrentStore($storeId);
return $this;
This code is working fine for the first time, but when the user tries to switch English storeview, he/she would be redirected to the same storeview, that is Arabic. I debugged so many times, but in logs, I'm getting perfect output and not reflecting the change on the frontend. I think this is a cache issue, but not sure. Please let me know if anyone has a solution for this.
Thanks in anticipate.
event-observer cache store-view magento2.3.1 store-switcher
In my extension, the default storeview is English and I want to set Arabic storeview, only one time when the customer comes first time on my website. I'm using controller_action_predispatch event to check customer comes the first time or not, if not, customer can move to English storeview as well. Following is my piece of code:
NamespaceModulenameetcfrontendevents.xml
<event name="controller_action_predispatch">
<observer name="switch_store" instance="NamespaceModulenameObserverSwitchStore" shared="false" />
</event>
NamespaceModulenameObserverSwitchStore.php
protected $storeManager;
public function __construct(
MagentoStoreModelStoreManagerInterface $storeManager
)
$this->storeManager = $storeManager;
public function execute(MagentoFrameworkEventObserver $observer)
if ($this->firstVisit()) // Customer's first visit logic inside firstVisit() function
$storeId = $this->storeManager->getStore($target_store)->getId();
$this->storeManager->setCurrentStore($storeId);
return $this;
This code is working fine for the first time, but when the user tries to switch English storeview, he/she would be redirected to the same storeview, that is Arabic. I debugged so many times, but in logs, I'm getting perfect output and not reflecting the change on the frontend. I think this is a cache issue, but not sure. Please let me know if anyone has a solution for this.
Thanks in anticipate.
event-observer cache store-view magento2.3.1 store-switcher
event-observer cache store-view magento2.3.1 store-switcher
edited Jun 28 at 3:59
poojan sharma
8091 silver badge10 bronze badges
8091 silver badge10 bronze badges
asked Jun 27 at 13:13
Dhara BhattiDhara Bhatti
4731 silver badge12 bronze badges
4731 silver badge12 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
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%2f279931%2fmagento-2-3-1-change-store-view-in-controller-action-predispatch-event%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f279931%2fmagento-2-3-1-change-store-view-in-controller-action-predispatch-event%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