webgriffe/SyliusAkeneoPlugin

Ability to customize which identifiers to enqueue

Closed this issue · 5 comments

Currently the responsibility to find which are the identifiers to enqueue is given to the importer which have to implement the method \Webgriffe\SyliusAkeneoPlugin\ImporterInterface::getIdentifiersModifiedSince().

So if one wants to customize that logic (for example adding some kind of filter) he needs to replace the entire importer.

So I suggest to isolate the responsibility of finding identifiers that have been modified since a given date to a dedicated interface.

A quick but not so clean way to do this is to dispatch an event in the \Webgriffe\SyliusAkeneoPlugin\ApiClient::findProductsModifiedSince() method. Then subscribers/listener may customize the default provided filters that will be used to actually perform the search products API call.

@webgriffe/wg-devs @aleho what do you think?

aleho commented

This would certainly be a quick win without having to BC break the importer / API client.

On the other hand using the official API client is much more fun and should prove a stable investment in the long run.
Any ideas on that front?

(I personally don't really enjoy using too many event handlers because that tends to get very messy and needs tidy documentation and developers.)

Hi @aleho I agree that switching to the official would be much better and we already have it ready in the #20 PR.

Anyway it brings too many BC breaks and we can merge it in 2.0 only.

I also agree that events are messy especially when debugging, anyway they are good for providing extension points which is the goal of the issue.

Adding the event dispatcher to the ApiClient sounds too messy. Moreover it's very hard to test this behavior.

After thinking about this I figured that it's better to wait the 2.0. In 1.x users can still decorate the ApiClient to customize the filter.

Now that we have the official Akeneo API client we decided to dispatch an event in \Webgriffe\SyliusAkeneoPlugin\Product\Importer::getIdentifiersModifiedSince allowing subcribers to customize the SearchBuilder object.