What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hello all, I am trying to extend DataImport by creating my own Importer Module that imports data fr
Hello all,
I am trying to extend DataImport by creating my own Importer Module that imports data from the Queue. Everything works fine except the triggering of the Publishing event $this->addPublishEvents(...
. Here is the code for the writer step:
class AntelopeWriterStep extends PublishAwareStep implements DataSetWriterInterface { public const KEY_NAME = 'name'; public const KEY_COLOR = 'color'; use DataSetWriterPersistenceStateAwareTrait; /** * @throws PropelException * @throws AmbiguousComparisonException */ public function write(DataSetInterface $dataSet) { $this->setDataSetWriterPersistenceState(false); $antelopeEntity = PyzAntelopeQuery::create()->filterByName($dataSet[static::KEY_NAME])->findOneOrCreate(); $antelopeEntity->setColor($dataSet[static::KEY_COLOR]); if ($antelopeEntity->isNew() || $antelopeEntity->isModified()) { $antelopeEntity->save(); // for publish event $this->addPublishEvents( AntelopeEvents::ENTITY_PYZ_ANTELOPE_CREATE, $antelopeEntity->getIdAntelope() ); } } public function flush() { $this->setDataSetWriterPersistenceState(true); } }
And here is how I am adding the writer step in the factory :
public function getAntelopeQueueDataImporter(): DataImporter { /** @var DataImporter $dataImporter */ $dataImporter = $this->createQueueDataImporter( $this->getConfig()->getAntelopeDataImporterConfiguration() ); $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); // validation step $dataSetStepBroker->addStep( $this->getAntelopeValidatorStep()); // publisher step $dataSetStepBroker->addStep( $this->getAntelopePublisherStep()); $dataImporter->addDataSetStepBroker($dataSetStepBroker); // writing step $dataImporter->setDataSetWriter(new AntelopeWriterStep()); return $dataImporter; }
Can you please tell me if this the right way to do it?
Comments
-
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
Hey, how do you see that publishing is not working? Have you checked if your save() method is being called?
0 -
@florian.scholz I have another importer module that uses CSV file to import, this works fine with it. I mean this exact line of code:
// for publish event $this->addPublishEvents( AntelopeEvents::ENTITY_PYZ_ANTELOPE_CREATE, $antelopeEntity->getIdAntelope() ); }
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
wrong Florian mentioned 😉
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
Ok, can you check if the condition
if ($antelopeEntity->isNew() || $antelopeEntity->isModified())
is being met? i mean in the writer-step you posted here. It feels like it is not even reached0 -
Sorry about the wrong mention. Let me check and I will get back to you.
0 -
@florian.scholz It seems like it works with
class AntelopeValidatorStep extends PublishAwareStep implements DataImportStepInterface { public function execute(DataSetInterface $dataSet) { ...
But not with
class AntelopeWriterStep extends PublishAwareStep implements DataSetWriterInterface { public function write(DataSetInterface $dataSet) { ...
This will work for me 🙂
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
Interesting, tbh I dont know what is missing there right now - I sadly dont have time to debug further by myself the next two days but I will definitely look into this later that week because i am very curious about that.
Maybe another community member can help you. If not, please create a support ticket0 -
Thank you very much 🙂
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
Hey, I finally had time to take a small look:
why do you have$this->setDataSetWriterPersistenceState(true);
inside the flush() instead ofDataImporterPublisher::triggerEvents();
?0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 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