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?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communitySomething 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;
}