Closed chefbuitenhuis closed 6 years ago
@hostep I think it's a future-proof solution - but you're right that we will lose backwards compatibility. I'd love to see your suggestion so I can perhaps update this PR.
Maybe there is an internal API which can be used to fetch this information instead of doing a SQL query. It will probably be a bit more overhead, but using raw SQL is bound to cause issues like this.
If raw SQL is still needed, you can probably try to check for the version of Magento being used (or the version of the Magento_Catalog module itself, or maybe even do feature detecting to see of the class TableMaintainer
exists) and let the code execute differently based on that.
But best solution in my opinion is to ditch the SQL queries and look for an internal API from Magento to get that same information. Since that's a much more stable solution. (We just discovered another big problem in this module with direct SQL queries, which is fetching wrong data in a Magento Enterprise version, since the database structure for configurable/simple products is different then the Magento Community version. So the wrong simple products are associated with configurables in the export of this module. A colleague of mine is writing a new bug report for this at the moment.)
Hello,
thanks for reporting this and for the pull request.
I agree that using the TableMaintainer class is preferable but indeed backwards compatibility is an issue. For now the issue is fixed with the following by checking if the store_{id} tables exist if not return the base index table.
This will be integrated in the next release (1.2.0)
Release 1.2.0 has been published
Magento 2.2.5 introduced parallel indexers which caused the catalog-product relationship to be saved to different table for each storeview. The table name used in the query to retrieve those nodes had to be changed so it would pick the appropiate table for the collection.
The table name is now generated by using the store id of the current collection.