Hướng dẫn fix lỗi Something went wrong while saving this configuration: Area is already set trong Magento 2

Trong bài viết này mình sẽ hướng dẫn các bạn cách fix lỗi Something went wrong while saving this configuration: Area is already set trong Magento 2.

Lỗi này xảy ra trong quá trình chúng ta Save Configuration và có dạng như sau.

lỗi Something went wrong while saving this configuration: Area is already set trong Magento 2

Nó làm cho chúng ta không thể lưu lại những cài đặt của mình, bây giờ mình sẽ chỉ các bạn cách để fix lỗi này.

Cách sửa lỗi

Đầu tiên các bạn tìm tới file AbstractTemplate.php theo đường dẫn vendor/magento/module-email/Model/AbstractTemplate.php và mở nó lên bằng một trình soạn code.

Tiếp theo chúng ta tìm đoạn code:

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

Nó nằm ở dòng thứ 535.

code cần sửa

Thay đoạn code trên thành:

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

Sửa xong chúng ta lưu lại rồi vào trang admin kiểm tra kết quả

save được thành công

Đã Save được thành công, vậy là mình đã hướng dẫn xong cách fix lỗi Something went wrong while saving this configuration: Area is already set trong Magento 2.

Cảm ơn các bạn đã đọc bài viết.

5 2 votes
Article Rating

Callula Huy

Callula is the Marketing Executive at Magetop. With more than 5 years of copywriting under her belt, Callula is into creating valuable content that is straight to the point. Life student. Workaholic. Foreign languages and traveling aficionado.

Leave a Reply or put your Question here

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x