Programmatically How can set a theme for specific stores in Magento 2.1

1 Answer 1


You can set theme for specific store using below script.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$config = $objectManager->get("\Magento\Theme\Model\Config"); 
$storeManager  = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');

I have used default luma theme ID, You can change it based on theme.

$themeId = 2; 
$theme = $objectManager->get("\Magento\Theme\Model\ThemeFactory")->create()->load($themeId);

I have get current storeId, you can set store ID as per your requirement.

$storeId= $storeManager->getStore()->getStoreId();
if ($theme->getId()) {

If you want to set theme based on website then below is the code.

$websiteId = $storeManager->getWebsite()->getId();
if ($theme->getId()) {


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.