【问题标题】:Getting error 'Area is already set' while changing theme for Magento 2.2.4更改 Magento 2.2.4 的主题时出现错误“区域已设置”
【发布时间】:2018-11-11 05:30:30
【问题描述】:

我复制了 magento-frontend-luma 主题 并更改供应商\主题名称并粘贴到设计文件夹中 magento2\app\design\frontend\Webmyne\pruthvi

在registration.php中

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/Webmyne/pruthvi',
    __DIR__
);

在theme.xml中

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Webmyne Pruthvi</title>
    <parent>Magento/blank</parent>
    <media>
        <preview_image>media/preview.jpg</preview_image>
    </media>
</theme>

在 composer.json 中

{
    "name": "webmyne/pruthvi",
    "description": "N/A",
    "require": {
        "php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
        "magento/theme-frontend-blank": "100.2.*",
        "magento/framework": "101.0.*"
    },
    "type": "magento2-theme",
    "version": "100.2.3",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}

但是当我尝试改变主题时 从内容 > 设计 > 配置

我收到了错误 '区域已设置'

【问题讨论】:

    标签: magento themes magento2 magento2.2


    【解决方案1】:

    我认为问题出在您的registration.php 文件中

    试试这样改

    \Magento\Framework\Component\ComponentRegistrar::register(
        \Magento\Framework\Component\ComponentRegistrar::THEME,
        'Webmyne_pruthvi',
        __DIR__
    );
    

    所以删除声明中的frontend 部分。如果您从已经声明为前端区域的主题继承,则无需指定区域。

    【讨论】:

      【解决方案2】:

      这是 Magento 2.2.4 C.E. 的重新拥有的问题

      Magento 已由 Daniel Ruf 在 PR #15137 https://github.com/magento/magento2/commit/7019a0a1392095185505ff3ca7b97dd3e9cb4ef2 修复,并已在 2.2-develop 分支合并

      您需要修改 setForcedArea 方法的代码并使用下面的方法替换该方法代码。

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

      参考:

      【讨论】:

        猜你喜欢
        • 2018-12-28
        • 1970-01-01
        • 2017-11-20
        • 2016-03-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-16
        • 1970-01-01
        相关资源
        最近更新 更多