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..
Hi guys, I need to export orders via a Middleware as a CSV. We need one file per order and one line
Hi guys, I need to export orders via a Middleware as a CSV. We need one file per order and one line per orderitem. I need something like this in the end:
order_nr,position,article_numer 123,1,article1 123,2,article2 123,3,article3
What's the best way to solve this?
Comments
-
My initial idea was to iterate about orders (with an
OrderReadStreamPlugin
), because I have all of the needed data there (order-data and also order-item-data in theitem
key).
Another approach would be to iterate over orderitems (with anOrderItemReadStreamPlugin
), but I have no idea if it's possible to write them to the same order-csv afterwards.If I try to use
OrderReadStreamPlugin
as the input with this mapping:'order_nr' => 'order_reference', 'position' => function($payload) { return array_keys($payload['items']); }, 'article_numer' => function($payload) { return array_column($payload['items'], 'sku'); }
... it fails while writing the CSV, because two items of the payload are now arrays:
Array to string conversion
0 -
i think the approach is generally the one that would be triggered here https://documentation.spryker.com/docs/spryker-middleware#omsmiddlewareconnector-module, right?
0 -
can you dump what these arrays are that canβt be converted?
0 -
what is the writer you are using?
0 -
SprykerMiddleware\Zed\Process\Communication\Plugin\Stream\CsvOutputStreamPlugin
0 -
-
well, this does not look like it is conceptually possible
0 -
you are trying to put a hierarchical structure into a flat structure
0 -
or, i misunderstood. you do not need the above meta data for the order, but just the items, correct?
0 -
I know the order-metadata in every row
0 -
which field from the provided data maps to which field of the target structure?
0 -
kind of weird, but that's how it is π
0 -
ok π
0 -
which field from the provided data maps to which field of the target structure?
What do you mean?
0 -
something like
artikel_nummer -> article_numer
0 -
but that is already clearer
0 -
oh, I just tried to simplify the mapping, the payload in the screenshot uses still the real mapping, just with more fields
0 -
I was also thinking about creating an
OrderItemIterator
which processes als order-items and saves them into the file (per order), but not sure if this will work.0 -
-
i think that is the way to go
0 -
not 100% sure though where to hook in. the iterator might be a good place
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
- 924 Developer Corner
- 783 Spryker Development
- 88 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
- 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