I'm implementing module which will change the store id for current webiste but not the default store id like this:


In magento 2 backend i've configured default store view for my current website like this:

config store

the problem is i need to get this default store id from current website in my observer so i can do some function, roughly what i need like this:

$storeId = $this->getDefaultStoreId(); //this is what i need!!
$customStoreId = $this->getCustomStoreId(); //this is my function to get custom store id, nvm this
} else{

1 Answer 1


You can get current store id from below code:

$storeManager = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface');

$storeId = (int) $this->getRequest()->getParam('store', 0);

$store = $storeManager->getStore($storeId);

  • What we need to do when we are capture payment for diff. website store and payment merchant is diff. for both store ?
    – Yogesh
    Nov 24, 2017 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.