How can I attach something like postPersist on a spy product entity when created/updated?
The background is that akeneo importer uses dynamic entity feature which writes directly to db and avoids methods from the facade so I can't attach postCreate or postUpdate plugins. How can I handle that in order to do something when product is being created/updated via dynamic entity feature?
Answers
-
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,075 βοΈ - Guardians (admin)
Heyhey,
I have not tested it bymyself, but have you tried to create your own propel-behavior? I could imagine that you can hook into that by doing this, similar how Spryker created the behaviors.
All the best,
Florian
0 -
Hey, it is okay about behavior. Spy_product table has behavior, it saves events in spy_event_behavior_change table. But I am not able to consume it and handle it. Do you have an idea why?
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,075 βοΈ - Guardians (admin)
Heyhey,
I didnt mean to reuse the "event" behavior of Spryker - but now that I think about it this could also be a way to go. Initially I thought about creating your own behavior.What have you tried so far to consume it?
All the best,
Florian
0 -
Hey, first of all thank you for trying to understand and willingness to help.
I tried to attach listener on Entity.spy_product.create event and write my own code for handling it. I also tried to find already any listener consuming that event but couldn't catch it in debugger. Do you have an idea why?0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,075 βοΈ - Guardians (admin)
Heyhey,
so normally I used the "event" behavior just for Publish&Synchronize. And I think this is still the most common use-case.
The latest best practise for Pub&Sync is to register the event handler in the Zed Publisher module (DependencyProvider) like shown in our elearning on Spryker Safari.
BUT: you dont want to do Pub&Sync here. So the old way of handling events for Pub&Sync could be the place to look for. Have a look at
src/Pyz/Zed/Event/EventDependencyProvider.php
and define your own subscriber and listener. I think if this is properly defined, your change/create event will be placed on a queue you defined (by default likely "event"-queue) and it will be processed via the background task. But instead of doing the publish/Sync to your event you can have your own logic then.All the best,
Florian
0 -
Awesome. I will let you know how that went π Thanks! This sounds like good.
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 75 Spryker News
- 920 Developer Corner
- 780 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 25 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random