Shopware Version 6.5.7.3
We have a couple of plugins on the Shopware store, one of them is an addition and filter for invoice numbers on the order grid in the administration.
In December we got a very nice support ticket from Sebastian working at dot21.net. We have a bug, that the order list is not loading if our plugin is loaded. I knew, that this happens if one has very much invoices, because Shopware doesn’t have a string filter in the core and therefore I implemented the filter with a dropdown – which means I load all invoice numbers into the select.
Shopware Community is best community
We are giving our best to be pragmatic, and because no one was complaining, there was no priority in fixing this known bug. But now there was! So in December I took the time to replace the dropdown with a proper text filter. Thanks to Benny from vanWittlaer and flkasper (whoever this is, drop me an email and I’m happy to have a coffee, beer or soda with you!) I had a great starting point and hopefully I’ll write another blogpost about this, detailing how I made it work, because it didn’t work on first try.
We rolled out the update and Sebastian was happy. Unfortunately in January he finally had time to checkout the update – and it didn’t work ? ?. Back to the drawing board.
I couldn’t reproduce the error and with the help of Sebastian that changed:
TypeError: undefined is not an object (evaluating ‘doc.config.custom.invoiceNumber’)
Browser console
I still couldn’t reproduce it locally and after testing our extension with a current Shopware version I looked for an incompatibility with one of the other modules, because if it works on a naked Shopware. But even with disabled modules the problem still preserved.
Being nice and a capitalist is impossible
I already decided to abort the support case, because our extension only costs 10€ a month and debugging a problem which is not plugin related (works on a naked Shopware) will never be compensated. That’s business baby!
But being nice and a nerd is easy
But as you can see, we are too often stupid lefties, trying to help nonetheless. Ok let’s be fair, we are nerds and solving the problem is not the important part for most of us, but understanding what the fuck is going wrong – and adding a solution only takes a minute, often.
But what WAS the problem – you ask?
Let’s start, what was NOT the problem:
- I thought one of the plugins was rewriting the API call to load the orders – that was not the problem.
- Or the API controller is changing the criteria to load them – same: not the problem.
Migrations are always broken
If you migrated data from an old system to a new one, you might already know: Migrations are always broken and the data is never clean. This was the case here as well. I didn’t look into the database, but after deleting the content of the config
column in document
, the issue was reproducible. Woho!
More validation
Technically Shopware should not write broken data, but if they are migrated, we need to handle them, so I changed our plugin a little:
# Before
v-if="doc.config.custom.invoiceNumber"
# After
v-if="doc.config && doc.config.custom && doc.config.custom.invoiceNumber"
2 thoughts on “Shopware 6: Migrations and missing data”