Theming is something that changes the whole shopping experience of your store with a topping of some stylish design elements and features that your default Magento store never had. But every time when you upgrade to latest Magento 2.x version, you will face some issue or difficulties while using your Magento store functionality. But due to its wide developer community issue will no longer remain unsolved.
Recently, after upgrading to latest Magento 2.2.x lots of store owner are facing a theme switching issue with an error like “something went wrong while saving this configuration. The area is already set.” Basically, this issue comes from the default Magento core to fix it quickly, we can create an extension that will allow us to switch theme and apply our favorite theme on store frontend. The first file we need to create is di.xml inside out extension folder at below path.
Step 1: First, we need to create “di.xml” file inside extension the below directory
app\code\Vendor\Extension\etc
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Email\Model\AbstractTemplate">
<plugin name="vendor_extension_email_template_plugin"
type="Vendor\Extension\Model\Magento\Email\AbstractTemplate" />
</type>
</config>
Step 2: lastly, you need to create “AbstractTemplate.php” file inside extension the below directory
app\code\Vendor\Extension\Model\Magento\Email
<?php
namespace Vendor\Extension\Model\Magento\Email;
class AbstractTemplate extends AbstractModel implements TemplateTypesInterface
{
public function beforeSetForcedArea(\Magento\Email\Model\AbstractTemplate $subject){
if (!isset($this->area)){
$this->area = $this->emailConfig->getTemplateArea($templateId);
}
return $this;
}
}
Feel free to ask questions regarding this code. Happy Coding!