1

I'm using following code:-

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID)

Same code I want to use for Magento2, how can I achieve?

1 Answer 1

1

Something like:

$this->storeManager->setCurrentStore(0);

Where $this->storeManage is an instance of Magento\Store\Model\StoreManagerInterface

Ex:

public function __construct(
    \Magento\Store\Model\StoreManagerInterface $storeManager
) {
    $this->storeManager = $storeManager;
}
1
  • Thanks for the help and converting Mage_Core_Model_App :: ADMIN_STORE_ID to magento 2 Aug 27, 2020 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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