25

I am unable to apply a new theme in a clean install of 2.2.4. Upading to 2.2.5 does not fix the problem.

53

Note : This is a know issue in Magento 2.2.4 (see GitHub issue) and below fix is just a temp fix. You should not directly change the Magento core file (override or create a plugin)

Change in Magento\Email\Model\AbstractTemplate.php this:

public function setForcedArea($templateId)
{
    if ($this->area) {
        throw new \LogicException(__('Area is already set'));
    }
    $this->area = $this->emailConfig->getTemplateArea($templateId);
    return $this;
}

For this:

public function setForcedArea($templateId)
{
    if (!isset($this->area)) {
        $this->area = $this->emailConfig->getTemplateArea($templateId);
    }
    return $this;
}

It should fix the issue

Update : can also be fixed by applying this Patch

  • 3
    Thanks! This has solved my issue. To reproduce: In Content > Design > Configuration > "Edit" your theme on Store View Level. If you do any change (no matter if applying a theme or changing a logo) the following message pops up: "Something went wrong while saving this configuration: Area is already set [on hold]". – eskaliert May 13 '18 at 13:03
  • 3
    It worked as i edited in core file. How to override this specifc model file so i dont edit any core file. What is the folder structure i need to use in app folder. – Alaksandar Jesus Gene May 23 '18 at 13:10
  • 2
    Magento 2 doesn't do hotfix releases, unfortunately. However, they've released an official patch over here: magento.com/tech-resources/download (search for MAGETWO-93036). Apply this patch by using below command patch -p1 < m2-hotfixes/EE-MAGETWO-93036-2018-07-02-07-07-16.patch. After applying mention patch and It works perfectly. – Swapnil Tatkondawar Aug 28 '18 at 11:39
  • 2
    Issue resolved in Magento2.2.6 – Manish Maheshwari Sep 19 '18 at 11:53
  • 1
    Thanks for updating your answer with the link to the patch file :) – Jonathan Marzullo Oct 8 '18 at 15:36
2

For fixed error Something went wrong while saving this configuration: Area is already set while saving theme configuration. You want create plugin for override Magento\Email\Model\AbstractTemplate.php file in custom module. And update setForcedArea() function.

File path: magento/app/code/Vendor/AreaConfigFix/registration.php

<?php
use \Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_AreaConfigFix', __DIR__);

File path: magento/app/code/Vendor/AreaConfigFix/etc/module.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_AreaConfigFix" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Email"/>
        </sequence>
    </module>
</config>

File path: magento/app/code/Vendor/AreaConfigFix/etc/di.xml

<?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="email_setforced_area" type="Vendor\AreaConfigFix\Plugin\Email\Model\AbstractTemplate" />
    </type>
</config>

File path: magento/app/code/Vendor/AreaConfigFix/Plugin/Email/Model/AbstractTemplate.php

<?php
namespace Vendor\AreaConfigFix\Plugin\Email\Model;

class AbstractTemplate
{
    private $emailConfig;

    public function __construct(\Magento\Email\Model\Template\Config $emailConfig)
    {
        $this->emailConfig = $emailConfig;
    }

    public function aroundSetForcedArea(\Magento\Email\Model\AbstractTemplate $subject, \Closure $proceed, $templateId)
    {
        if (!isset($this->area)) {
            $this->area = $this->emailConfig->getTemplateArea($templateId);
        }
        return $this;
    }
}
  • not working for me – Manjunath Oct 22 at 13:26
0

Instead of installing the patch given by magento or changing the core files directly here is how I did it:

"File path: magento/app/code/Vendor/ThemeErrorFix/registration.php"

<?php
use \Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_ThemeErrorFix', __DIR__);

"File path: magento/app/code/Vendor/ThemeErrorFix/etc/module.xml"

    <?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_ThemeErrorFix" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Email"/>
        </sequence>
    </module>
</config>

"File path: magento/app/code/Vendor/ThemeErrorFix/etc/di.xml"

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Email\Model\Template">
        type="email_setforced_area" type="Vendor\ThemeErrorFix\Model\Template" />

</config>

"File path: magento/app/code/Vendor/ThemeErrorFix/Model/Template.php"

<?php

namespace Vendor\ThemeErrorFix\Model;

use Magento\Email\Model\Template as coreTemplate;

class Template extends coreTemplate

{
   public function setForcedArea($templateId)
{
    if (!isset($this->area)) {
        $this->area = $this->emailConfig->getTemplateArea($templateId);
    }
    return $this;
}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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