Hi
I have multiple stores in my Magento website setup
I am having a concept where each store has a different theme, so I would like to assign my custom theme to a specific store using programmatically.
Can anyone have an idea how can I achieve this?
Solved! Go to Solution.
Hi @Noah_Sinnis
You can achieve this functionality by creating installData or upgradeData scripts.
After creating script add below code to that file :
use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
/**
* @var ConfigInterface
*/
private $configInterface;
public function __construct(
.....................
ConfigInterface $configInterface,
................
) {
................
$this->configInterface = $configInterface;
..................
}
$this->configInterface->saveConfig('design/theme/theme_id', {{theme_id}}, 'stores', {{store_id}});
You can get theme_id from theme table.
For more details refer this link - https://magento.stackexchange.com/questions/213806/magento-2-how-to-assign-custom-theme-to-specific-...
Hope it helps !
Hi @Noah_Sinnis
Does it mean you would like to add your custom theme to store using programatically ?
Yes, I mean the same.
Hi @Noah_Sinnis
You can achieve this functionality by creating installData or upgradeData scripts.
After creating script add below code to that file :
use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
/**
* @var ConfigInterface
*/
private $configInterface;
public function __construct(
.....................
ConfigInterface $configInterface,
................
) {
................
$this->configInterface = $configInterface;
..................
}
$this->configInterface->saveConfig('design/theme/theme_id', {{theme_id}}, 'stores', {{store_id}});
You can get theme_id from theme table.
For more details refer this link - https://magento.stackexchange.com/questions/213806/magento-2-how-to-assign-custom-theme-to-specific-...
Hope it helps !
Yes, I have tried the code and it works.
Thank you for your help.
Hi @Noah_Sinnis
Glad to know that its work for you !
Happy to help and keep helping ![]()