setono/sylius-klaviyo-plugin

Sylius 的 Klaviyo 集成

安装数: 5,502

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 3

分支: 3

开放问题: 3

类型:sylius-plugin

v0.3.6 2024-01-29 08:26 UTC

README

Latest Version Latest Unstable Version Software License Build Status Code Coverage

使用此插件将您的商店与 Klaviyo 集成。

安装

步骤 1: 下载插件

打开命令控制台,进入您的项目目录并执行以下命令以下载此插件的最新稳定版本

$ composer require setono/sylius-klaviyo-plugin

步骤 2: 启用插件

然后,通过将以下内容添加到项目 config/bundles.php 文件中注册的插件/包列表中启用插件

<?php

return [
    // ...
    
    Setono\SyliusKlaviyoPlugin\SetonoSyliusKlaviyoPlugin::class => ['all' => true],
    
    // It is important to add plugin before the grid bundle
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
        
    // ...
];

注意:您必须在网格包之前实例化插件,否则您将看到如下异常:您请求了不存在的参数 "setono_sylius_klaviyo.model.member_list.class"。

步骤 3: 导入路由

# config/routes/setono_sylius_klaviyo.yaml
setono_sylius_klaviyo:
    resource: "@SetonoSyliusKlaviyoPlugin/Resources/config/routes.yaml"

如果您不使用本地化 URL,请使用此路由文件:@SetonoSyliusKlaviyoPlugin/Resources/config/routes_no_locale.yaml

步骤 4: 配置插件

# config/packages/setono_sylius_klaviyo.yaml
imports:
    - { resource: "@SetonoSyliusKlaviyoPlugin/Resources/config/app/config.yaml" }

setono_sylius_klaviyo:
    credentials:
        public_token: "%env(KLAVIYO_PUBLIC_TOKEN)%"
        private_token: "%env(KLAVIYO_PRIVATE_TOKEN)%"

然后请记住设置以下环境变量:KLAVIYO_PUBLIC_TOKENKLAVIYO_PRIVATE_TOKEN,分别使用相应的令牌。

步骤 5: 更新数据库模式

使用 Doctrine 迁移创建迁移文件并更新数据库。

$ bin/console doctrine:migrations:diff
$ bin/console doctrine:migrations:migrate

步骤 6: 使用异步传输(可选,但推荐)

此插件中的所有命令都将扩展 CommandInterface。因此,您可以通过将以下内容添加到您的 信使配置 来轻松路由所有命令。

# config/packages/messenger.yaml
framework:
    messenger:
        routing:
            # Route all command messages to the async transport
            # This presumes that you have already set up an 'async' transport
            # See docs on how to setup a transport like that: https://symfony.com.cn/doc/current/messenger.html#transports-async-queued-messages
            'Setono\SyliusKlaviyoPlugin\Message\Command\CommandInterface': async

用法

设置完成后,您希望将通道与 Klaviyo 中的列表关联起来。转到 /admin/klaviyo/member-lists/ 并同步列表。之后,编辑列表并启用列表上的通道。