Browsed by
Tag: script

Sequence of Magento 2 Install / Upgrade / Recurring scripts

Sequence of Magento 2 Install / Upgrade / Recurring scripts

Preamble In one of my last tasks I had to write an upgrade script in which an assignment of a newly created frontend theme to some of the stores should be implemented. The following code-part describes what I did here: /** * */ protected function assignNewThemeToSelectedStores() { $storeIdsForNewTheme = []; foreach ($this->storesCodesWithNewTheme as $storeCode) { $storeIdsForNewTheme[] = $this->storeRepository->get($storeCode)->getId(); } /** @var \Magento\Theme\Model\ResourceModel\Theme\Collection $themes */ $themes = $this->themeCollectionFactory->create()->loadRegisteredThemes(); /** * @var \Magento\Theme\Model\Theme $theme */ foreach ($themes as $theme) { if ($theme->getCode()…

Read More Read More