Magento 2 Equivalent for Mage :: app () -> setCurrentStore (Mage_Core_Model_App :: ADMIN_STORE_ID)

Aug 28 2020

Używam następującego kodu: -

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

Ten sam kod, którego chcę użyć dla Magento2, jak mogę to osiągnąć?

Odpowiedzi

1 SohelRana Aug 27 2020 at 23:30

Coś jak:

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

Gdzie $ this-> storeManage jest instancją Magento \ Store \ Model \ StoreManagerInterface

Dawny:

public function __construct(
    \Magento\Store\Model\StoreManagerInterface $storeManager ) { $this->storeManager = $storeManager;
}