Register own listeners on create/update vendor
zvitek opened this issue · 3 comments
Hello, I would like to extend you plugin for more images. Everything is ok, but I have a problem to register event listener for upload files. Is there a way how to register own listener on vendor create/update event?
Thank you for help
Hi @zvitek. You can use the ImageUploadListener from Sylius (https://docs.sylius.com/en/latest/cookbook/images/images-on-entity.html):
# services.yml
services:
app.listener.images_upload:
class: Sylius\Bundle\CoreBundle\EventListener\ImagesUploadListener
parent: sylius.listener.images_upload
autowire: true
autoconfigure: false
public: false
tags:
- { name: kernel.event_listener, event: sylius.shipping_method.pre_create, method: uploadImages }
- { name: kernel.event_listener, event: sylius.shipping_method.pre_update, method: uploadImages }
By the way, we already did that in our Sylius Marketplace Plugin: https://odiseo.io/plugins-and-bundles/premium/sylius-mvm-plugin
Regards.
Hello @bigboss86, thank you for answer, I try it according to the same article. But that's the problem.
When I register this listener in services.yaml
, I get an error The service "app.listener.images_upload" cannot use the "parent" option in the same file where "_instanceof" configuration is defined as using both is not supported
Ok, I tried to insert this listener to _sylius.yaml
and change event from sylius.shipping_method.pre_update
to sylius.vendor.pre_update
. Error was away, but when I submit the form I get an error 1048 Column 'path' cannot be null
.
I think that the listener is not called and therfore, I wanted to check if the event sylius.vendor.pre_update
exist or is different.
Thank you