24

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.

8

4 Answers 4

54

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

9
  • 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, 2018 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. May 23, 2018 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. Aug 28, 2018 at 11:39
  • 2
    Issue resolved in Magento2.2.6 Sep 19, 2018 at 11:53
  • 1
    Thanks for updating your answer with the link to the patch file :) Oct 8, 2018 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;
    }
}
1
  • not working for me
    – Manjunath
    Oct 22, 2019 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;
}
}
0

I corrected your code by removing the duplicated type attribute.

<?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="Vendor\ThemeErrorFix\Model\Template" />

</config>

Your Answer

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

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