Giter Site home page Giter Site logo

trilix-gmbh / akeneo-events-api-bundle Goto Github PK

View Code? Open in Web Editor NEW
20.0 5.0 11.0 79 KB

The Events API Bundle for Akeneo PIM delivers catalog changes as events to a 3rd party systems.

License: MIT License

PHP 100.00%
akeneo-pim event symfony deliver-events ifttt-webhooks integrations webhooks

akeneo-events-api-bundle's Introduction

Akeneo PIM Events API

The Events API is a smooth and easy way to build integrations that respond to activities in Akeneo PIM. All you need is PIM Events API Bundle and an endpoint where to send Akeneo PIM events.

Table of contents

Getting Started

Requirements

  • Akeneo PIM >= 5.0 (CE & EE)

Installation

Install via composer:

php composer.phar require trilix/akeneo-events-api-bundle:^0.7.0

To enable the bundle add to the config/bundles.php file:

return [
    // ...
    Trilix\EventsApiBundle\TrilixEventsApiBundle::class => ['all' => true]
]

Add the following line at the end of env file:

EVENTS_API_REQUEST_URL=your_request_url

where your_request_url is a target location where all the events (see event types) will be delivered.

Create file config/packages/trilix_events_api.yml with the following:

trilix_events_api:
    transport:
        factory: "pim_events_api.transport_factory.http"
        options:
            request_url: "%env(EVENTS_API_REQUEST_URL)%"

Clear cache:

php bin/console cache:clear --env=prod

Run the following command to create a job to deliver events to consumer:

php bin/console akeneo:batch:create-job 'Deliver outer event to consumer' deliver_outer_event_to_consumer internal deliver_outer_event_to_consumer

Make sure Akeneo job queue daemon is running. For more information read Setting up the job queue daemon.

Functionality

How it works

Some event(s) happens in Akeneo PIM. This triggers a mechanism to send those event(s) as HTTP POST request to your Request URL. Each request contains event, with correspondent event type presented in JSON format (see example).

Events API sends one request per one event, and sending of requests happens in real-time.

Event types delivered over Events API

Event Description
category_created New category was created
category_updated Existing category was updated
category_removed Existing category was deleted
attribute_created New attribute was created
attribute_updated Existing attribute was updated
attribute_removed Existing attribute was deleted
family_created New family was created
family_updated Existing family was updated
family_removed Existing family was deleted
product_created New product was created
product_updated Existing product was updated
product_removed Existing product was deleted
product_model_created New product model was created
product_model_updated Existing product model was updated
product_model_removed Existing product model was deleted

Example of category_updated event

{
  "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
}

Example of product_model_removed event

{
  "event_type": "product_model_removed",
  "payload": {
    "code": "derby"
  },
  "event_time": 1579792377
}

Event Type Structure

Field Type Description
event_type String Type of event which happened (see event types)
payload Object Contains information which represents the event. For events related to deletion of entity it contains entity only identifier (identifier value for Products and code for all others)
event_time Integer Timestamp in seconds when the event was created

Attention ❗

If Akeneo family contains variants, then during family update (or it's variants as well), Akeneo will re-save related products. It will trigger sending product_updated events.

License

This project is licensed under the MIT License - see the LICENSE file for details

akeneo-events-api-bundle's People

Contributors

cplaetzinger avatar gotgelf avatar psw1986 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

akeneo-events-api-bundle's Issues

Installation fails: URI must be a string or UriInterface

Akeneo: 3.1.9

I'm following the installation manual.
After running a command to create a job, I'm getting:

In functions.php line 62:

  [InvalidArgumentException]
  URI must be a string or UriInterface


Exception trace:
 () at /app/vendor/guzzlehttp/psr7/src/functions.php:62
 GuzzleHttp\Psr7\uri_for() at /app/vendor/guzzlehttp/guzzle/src/Client.php:75
 GuzzleHttp\Client->__construct() at /app/var/cache/dev/Container5nxyayi/getObjectSavedSubscriberService.php:8
...

Parameters and config are fine.

Payload for event with type product_model_created differs from Akeneo API

The payload for events of type product_model_created differs from the JSON returned by the Akeneo HTTP API.

Steps to reproduce:

  • Create a new product model in the Akeneo web interface.

The events API sends the following event

{
  "event_type": "product_model_created",
  "payload": {
    "code": "foo_bar",
    "family_variant": "test_family_variant_cp",
    "parent": null,
    "categories": [],
    "values": [],
    "created": "2020-01-13T10:43:34+00:00",
    "updated": "2020-01-13T10:43:34+00:00",
    "associations": [],
    "metadata": {
      "workflow_status": "working_copy"
    }
  },
  "event_time": 1578912214
}

When you retrieve the same product model using the Akeneo HTTP API you'll get the following response:

{
  "code": "foo_bar",
  "family_variant": "test_family_variant_cp",
  "parent": null,
  "categories": [],
  "values": {},
  "created": "2020-01-13T10:43:34+00:00",
  "updated": "2020-01-13T10:43:34+00:00",
  "associations": [],
  "metadata": {
    "workflow_status": "working_copy"
  }
}

The issue is regarding the format of the values attributes. This is has to be an object/map (like it is in the response of the Akeneo HTTP API). But if there are not values yet the Event API sends the values attribute as empty array. This is wrong.

"deliver_outer_event_to_consumer" is not registered

I'm using the VM from Bitnami to run an instance of Akeneo (https://bitnami.com/stack/akeneo/virtual-machine) o VirtualBox 6.0.20 r137117 (Qt5.6.3)

I followed all the steps to install the addon, but when I try to create the job I get an error. I know it's a newbie trouble, but I don't know what to try.

TIA

bitnami@debian:/opt/bitnami/apps/akeneo/htdocs$ bin/console akeneo:batch:create-job 'Deliver outer event to consumer' deliver_outer_event_to_consumer internal deliver_outer_event_to_consumer
This script is running with a memory_limit of 800M. Please visit https://docs.bitnami.com/general/apps/akeneo/ to learn more about how to change this setting.
16:57:25 ERROR     [console] Error thrown while running command "akeneo:batch:create-job 'Deliver outer event to consumer' deliver_outer_event_to_consumer internal deliver_outer_event_to_consumer". Message: "The job "deliver_outer_event_to_consumer" is not registered" ["exception" => Akeneo\Tool\Component\Batch\Job\UndefinedJobException { …},"command" => "akeneo:batch:create-job 'Deliver outer event to consumer' deliver_outer_event_to_consumer internal deliver_outer_event_to_consumer","message" => "The job "deliver_outer_event_to_consumer" is not registered"]

In JobRegistry.php line 56:

  The job "deliver_outer_event_to_consumer" is not registered


akeneo:batch:create-job [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <connector> <job> <type> <code> [<config>] [<label>]

I am not able to get it working

I have setup Akeneo CE version 3.2.3. I have attached system-info file for more details.

I have followed the document and everything looks good. Except when I update any product it should trigger the endpoint with the payload. But I don't see any job event trigger.

I have checked logs in pim-community-standard/var/logs, /var/log/akeneo_daemon.err.log, /var/log/akeneo_daemon.out.log, /var/log/apache2/akeneo-pim_*

It seems to me I am missing one of the step, Can someone help?

ubuntu@ip-10-81-13-230:~$ /usr/bin/php7.2 /path/pim-community-standard/bin/console debug:config TrilixEventsApiBundle

Current configuration for "TrilixEventsApiBundle"
trilix_events_api:
applications:
default:
uri: 'http://exampl.com/v1/pim/event/publish'

akeneo-pim-system-info_2019-09-03_09_40.txt

How can I receive the attribute option event?

I cannot see any event from PIM when I create/update the attribute option in some attributes.
Please let me know how can I receive this event or please suggest the solution for this. Thank you.

Akeneo5 upgrade

Hello Trilix gmbh,

Are there any plans to upgrade the bundle to the Akeneo v5?

Payload for family_upate and family_create differs from Akeneo API

The payload for events of type family_update and family_create differs from the JSON returned by the Akeneo HTTP API.

Steps to reproduce:

  • Create a new family in the Akeneo web interface. Fill only the code attribute, leave other attributes empty
  • The events API sends the following event
{
  "event_type": "family_created",
  "payload": {
    "code": "test_family_cp",
    "attributes": [
      "sku"
    ],
    "attribute_as_label": "sku",
    "attribute_as_image": null,
    "attribute_requirements": {
      "default": [
        "sku"
      ],
      "ecommerce": [
        "sku"
      ],
      "print": [
        "sku"
      ]
    },
    "labels": []
  }
}
  • Getting the same family using the Akeneo HTTP API returns the following JSON:
{
  "code": "test_family_cp",
  "attributes": [
    "sku"
  ],
  "attribute_as_label": "sku",
  "attribute_as_image": null,
  "attribute_requirements": {
    "default": [
      "sku"
    ],
    "ecommerce": [
      "sku"
    ],
    "print": [
      "sku"
    ]
  },
  "labels": {}
}

As you can see there is a difference for the labels attribute. If the labels are empty the events API sends it as empty array but it should be an empty map/object.

Event with type product_removed not published

I was not able to receive a product_removed event. I tried to delete a standalone product as well as a product which belongs to a product model. But in both cases no product_removed event is sent.

Is there anything I can check or provide in order to investigate further?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.