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

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 – Kassé Koulou Aug 27 '20 at 17:40

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.