trilix / akeneo-events-api-bundle
Akeneo PIM Events API Bundle
0.7.0
2021-09-10 16:48 UTC
Requires
- akeneo/pim-community-dev: ^5.0
- beberlei/assert: ^3.3
- guzzlehttp/guzzle: ~6.0
- psr/http-client: ^1
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-09-10 22:53:35 UTC
README
事件API是构建对Akeneo PIM活动做出响应的集成的一种平滑且简单的方式。您需要的只是一个PIM事件API包和一个接收Akeneo PIM事件的目标端点。
目录
入门
要求
- Akeneo PIM >= 5.0 (CE & EE)
安装
通过composer安装
php composer.phar require trilix/akeneo-events-api-bundle:^0.7.0
要启用此包,请将以下行添加到 config/bundles.php 文件中
return [ // ... Trilix\EventsApiBundle\TrilixEventsApiBundle::class => ['all' => true] ]
在env文件末尾添加以下行
EVENTS_API_REQUEST_URL=your_request_url
其中 your_request_url
是将所有事件(见 事件类型)发送到的目标位置。
创建文件 config/packages/trilix_events_api.yml,内容如下
trilix_events_api: transport: factory: "pim_events_api.transport_factory.http" options: request_url: "%env(EVENTS_API_REQUEST_URL)%"
清除缓存
php bin/console cache:clear --env=prod
运行以下命令以创建一个向消费者发送事件的作业
php bin/console akeneo:batch:create-job 'Deliver outer event to consumer' deliver_outer_event_to_consumer internal deliver_outer_event_to_consumer
确保Akeneo作业队列守护进程正在运行。有关更多信息,请参阅设置作业队列守护进程。
功能
工作原理
在Akeneo PIM中发生某些事件。这会触发一种机制,将事件以HTTP POST请求的形式发送到您的请求URL。每个请求都包含事件,以及对应的以JSON格式呈现的事件类型(见 示例)。
事件API对每个事件发送一个请求,请求发送是实时的。
通过事件API发送的事件类型
category_updated 事件的示例
{ "event_type": "category_updated", "payload": { "code": "cameras", "labels": { "de_DE": "Cameras", "en_US": "Cameras new name", "fr_FR": "Caméras" }, "parent": "master" }, "event_time": 1565021907 }
product_model_removed 事件的示例
{ "event_type": "product_model_removed", "payload": { "code": "derby" }, "event_time": 1579792377 }
事件类型结构
注意 ❗
如果Akeneo家族包含变体,则在家族更新(或其变体)期间,Akeneo将重新保存相关产品。这将触发发送 product_updated 事件。
许可证
此项目采用MIT许可证 - 请参阅LICENSE 文件以获取详细信息