setono/sylius-miinto-plugin

Sylius与Miinto集成

安装次数: 3,692

依赖者: 0

建议者: 0

安全: 0

星星: 0

关注者: 2

分支: 0

开放问题: 2

类型:sylius-plugin


README

Latest Version Latest Unstable Version Software License Build Status Code Coverage

将Miinto的订单API集成到您的Sylius商店。

安装

步骤 1: 下载插件

打开命令行,进入您的项目目录,并执行以下命令以下载此捆绑包的最新稳定版本

$ composer require setono/sylius-miinto-plugin

此命令要求您全局安装Composer,如Composer文档中的安装章节所述。

步骤 2: 启用插件

然后,通过将其添加到项目中 config/bundles.php 文件中注册的插件/捆绑包列表中,启用插件,在 SyliusGridBundleFrameworkBundle 之前

<?php

# config/bundles.php

return [
    Setono\SyliusMiintoPlugin\SetonoSyliusMiintoPlugin::class => ['all' => true],
    // ...
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
    // ...
];

步骤 3: 配置插件

# config/packages/_sylius.yaml

imports:
    # ...
    
    - { resource: "@SetonoSyliusMiintoPlugin/Resources/config/app/config.yaml" }
    
    # ...
# config/routes/setono_sylius_miinto.yaml

setono_sylius_miinto:
    resource: "@SetonoSyliusMiintoPlugin/Resources/config/routing.yaml"

步骤 4: 更新数据库模式

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

步骤 5: 输入所需的配置选项

# config/packages/setono_sylius_miinto.yaml

setono_sylius_miinto:
    product_variant_gtin_field: gtin
    miinto:
        username: '%env(MIINTO_USERNAME)%'
        password: '%env(MIINTO_PASSWORD)%'

product_variant_gtin_field 配置选项很重要,因为这是匹配Miinto中的产品与您商店中的产品的默认方式。它由 ProductVariantMapper 使用。如果您尚未向您的变体添加GTIN字段,您可以使用 条形码插件

如果您不使用GTIN,则应使用您的实现覆盖 ProductVariantMapper 服务(setono_sylius_miinto.mapper.product_variant)。

沙盒配置

当您想使用沙盒凭据时,您还应指定特殊的端点URL

# config/packages/dev/setono_sylius_miinto.yaml

setono_sylius_miinto:
    miinto:
        auth_endpoint: https://api-auth-sandbox.miinto.net
        resource_endpoint: https://api-order-sandbox.miinto.net

步骤 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
            'Setono\SyliusMiintoPlugin\Message\Command\CommandInterface': async

用法

此插件以两阶段方式运行:首先处理挂起的传输,告诉Miinto哪些传输接受,哪些拒绝。下一阶段将处理接受的位(订单)并将这些订单转换为Sylius订单。

第一个命令(第一阶段),您应该每分钟运行一次,如下所示

$ php bin/console setono:sylius-miinto:pending-transfers

下一个(第二阶段)将处理订单。此命令不必运行那么频繁。每5或10分钟应该足够

$ php bin/console setono:sylius-miinto:process-orders

故障排除

  • 您请求了一个不存在的参数 "setono_sylius_miinto.model.order.class"。

    您在 SyliusGridBundleFrameworkBundle 之后定义了插件。