我无法在2.2.4的全新安装中应用新主题。升级至2.2.5不能解决问题。
我无法在2.2.4的全新安装中应用新主题。升级至2.2.5不能解决问题。
Answers:
注意:这是Magento 2.2.4中的一个已知问题(请参阅GitHub问题),下面的修复只是临时修复。您不应该直接更改Magento核心文件(覆盖或创建插件)
更改Magento\Email\Model\AbstractTemplate.php
此:
public function setForcedArea($templateId)
{
if ($this->area) {
throw new \LogicException(__('Area is already set'));
}
$this->area = $this->emailConfig->getTemplateArea($templateId);
return $this;
}
为了这:
public function setForcedArea($templateId)
{
if (!isset($this->area)) {
$this->area = $this->emailConfig->getTemplateArea($templateId);
}
return $this;
}
它应该解决这个问题
更新:也可以通过应用此补丁来修复
对于Something went wrong while saving this configuration: Area is already set
保存主题配置时的固定错误。您想要Magento\Email\Model\AbstractTemplate.php
在自定义模块中为覆盖文件创建插件。并具有更新setForcedArea()
功能。
文件路径:magento / app / code / Vendor / AreaConfigFix / registration.php
<?php
use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_AreaConfigFix', __DIR__);
文件路径: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>
文件路径: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>
文件路径: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;
}
}
我是这样做的,而不是安装magento给出的补丁或直接更改核心文件:
“文件路径:magento / app / code / Vendor / ThemeErrorFix / registration.php”
<?php
use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_ThemeErrorFix', __DIR__);
“文件路径: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>
“文件路径: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>
“文件路径: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;
}
}