Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <event name="controller_action_predispatch">
  2. <observer name="switch_store" instance="NamespaceModulenameObserverSwitchStore" shared="false" />
  3. </event>
  4.  
  5. protected $storeManager;
  6.  
  7. public function __construct(
  8. MagentoStoreModelStoreManagerInterface $storeManager
  9. ) {
  10. $this->storeManager = $storeManager;
  11. }
  12.  
  13. public function execute(MagentoFrameworkEventObserver $observer) {
  14. if ($this->firstVisit()) { // Customer's first visit logic inside firstVisit() function
  15. $storeId = $this->storeManager->getStore($target_store)->getId();
  16. $this->storeManager->setCurrentStore($storeId);
  17. }
  18. return $this;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement