- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 !
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to assign custom theme programmatically to store in magento 2
Hi @Noah_Sinnis
Does it mean you would like to add your custom theme to store using programatically ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to assign custom theme programmatically to store in magento 2
Yes, I mean the same.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 !
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to assign custom theme programmatically to store in magento 2
Yes, I have tried the code and it works.
Thank you for your help.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: How to assign custom theme programmatically to store in magento 2
Hi @Noah_Sinnis
Glad to know that its work for you !
Happy to help and keep helping