Domanda

In other file I use this code to get base URL

$this->storeManager->getStore()->getBaseUrl()

where $this->storeManager is a instance of \Magento\Store\Model\StoreManagerInterface

My question is, how can I get base URL in cronjob? because the code gets store first before getting base url, and in cronjob, magento uses 0 as current store (Global store)

Any help would be appriciate.

È stato utile?

Soluzione

I think before calling getBaseUrl() you need to set your current store then you can get correct URL.

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

Where $storeId is your store Id which you want the base URL.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top