2024-07-19

Magento缺少Notifier模块

magento缺少notifier模块

概述
magento 2 slack notifier 模块自动将记录器异常发送到指定的 slack 通道。此集成通过直接向您的 slack 工作区发送实时通知,帮助您及时了解 magento 商店中的关键问题。

特点

  • 将记录器异常发送到 slack 通道
  • 可配置的日志级别(警报、调试、严重、信息、错误、紧急、通知、警告)
  • 选择使用同步或异步发送
  • 自定义消息服务,使用异步/同步选项将消息发送到指定通道(针对开发人员)

安装

使用 composer
导航到您的 magento 2 根目录。

需要使用 composer 的模块:
作曲家需要 magify/magento2-module-slacknotifier

启用模块:
php bin/magento 模块:启用 magify_slacknotifier

运行安装升级命令:
php bin/magento 设置:升级

配置

在 magento 管理面板中,导航至商店 > 配置 > 高级 > 开发人员 > slack 通知程序.

配置以下设置:

  • 激活:启用或禁用 slack 通知器模块。
  • 使用异步发送:选择是异步还是同步发送消息。
  • api timeout:设置api调用的超时时长(以秒为单位)。使用 0 表示无限期等待。
  • 记录器类型:选择要发送到 slack 的日志类型(例如,警报、调试、关键等)。
  • url:slack api url。通常,这将是 https://slack.com/api/chat.postmessage.
  • 频道 id:将发送消息的 slack 频道的 id。
  • token:您的 slack 应用令牌。

用法
配置完成后,模块会自动将指定类型的日志异常发送到您的 slack 通道。您可以监控这些通知,以快速响应 magento 商店中的问题。

自定义消息服务

概述
自定义消息服务允许开发者将任何消息发送到指定的 slack 通道,并可以选择异步或同步发送。

注意
如果函数参数中未设置通道和令牌,则服务将使用 magento 管理面板中配置的值。

用法
以下是如何在 magento 2 模块中使用自定义消息服务的示例:

1 – 在你的类中注入 custommessage:

<?php namespace YourVendorName/SlackNotifier/Controller/Index;

use Magento/Framework/App/Action/Action;
use Magento/Framework/App/Action/Context;
use YourVendorName/SlackNotifier/Model/CustomMessage;

class Test extends Action
{
    protected $customMessage;

    public function __construct(Context $context, CustomMessage $customMessage)
    {
        $this->customMessage = $customMessage;
        parent::__construct($context);
    }

    public function execute()
    {
        $title= "This is a test title";
        $message = "This is a test message";
        $async = false; // or true based on your requirement
        $channel = "your-channel-id";
        $token = "your-token";

        $this-&gt;customMessage-&gt;notifyMessage($title, $message, $async, $channel, $token);
    }
}
登录后复制

2 – 使用您的标题、消息、频道 id、令牌和发送类型(异步/同步)调用 notificationmessage 方法。

支持
如需支持和功能请求,请在 github 存储库上提出问题。

以上就是Magento缺少Notifier模块的详细内容,更多请关注php中文网其它相关文章!

https://www.php.cn/faq/888342.html

发表回复

Your email address will not be published. Required fields are marked *