-
Magento: 2.4.3-p1 I am not sure if this is a bug on your part or a bug at all, but... Additionally to the ES module I am running a highly modified version of the mageplaza product finder module. In But in the frontend this limitation is gone, magento reverts back to an unfiltered list of ALL products only limited to a default page size of 12 (set by the product finder module). Upon further investigation I found that the I added this to the plugin to compare the queries before and after:
Before:
After (shortened):
The last query actually contains ALL entity_ids available in the store, not only the 5 from the first query.
This time there are two where clauses, the first one being the one that limits the query to the five desired products. The second one again listing all SKUs in the store. But since both are add using AND the second one does not have any effect. My questions are: what, why, where does your module mangle with the query? Could this be an unwelcome sideeffect for third party modules? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Here we send a request to Elasticsearch for getting the appropriate results and then we filter the collection on the returning ids. If you're having all your products ids in the result, it's likely that another module is manipulating the collection and reseting the filtering. Regards |
Beta Was this translation helpful? Give feedback.
-
I'm moving this to Discussions because this is not an issue |
Beta Was this translation helpful? Give feedback.
-
This is the problem. This will erase any existing where clause. How is this not an issue?
For clarification, this is the query that arrives at
Then your code kills the WHERE part and instead ads a where clause including all entity_ids, not just the five in the original query. |
Beta Was this translation helpful? Give feedback.
-
Hello @OvalMedia, This is not an issue because this is by design. That's why availability, visibility and stock status filters are "hardcoded" through XML requests definitions (see
Otherwise, you would have the Elasticsuite request returning 20 products out of 1245 as per requested by the pagination, but "ooopsie" the DB filter limits that to 11 products and your first page of result/of the category contains fewer products than expected. What's why the Elasticsuite product collection implements its own "addFieldToFilter" to intercept any proper attribute filtering to render it as an Elasticsearch request query filter. My guess is that your "where" condition you're losing is not added to the collection thought the first method, but by doing a side effect on "collection->getCatalogPreparedSelect()". The correct approach is to find a way to replicate your "where" condition at the Elasticsearch request level.
I invite you to browse or wiki to see how to add the extra data you need through datasources and then how to implement the filtering. Regards, |
Beta Was this translation helpful? Give feedback.
-
Addendum for @OvalMedia, I scrolled up and saw indeed that the third party module is adding a SQL condition through addAttributeToFilter which the Elasticsuite product collection does not override. It if where me, I would simply use the product collection to do a search on the sku, but if you want to stick to the approach of that module, you could simply replace
by
Regards, |
Beta Was this translation helpful? Give feedback.
Addendum for @OvalMedia, I scrolled up and saw indeed that the third party module is adding a SQL condition through addAttributeToFilter which the Elasticsuite product collection does not override.
It if where me, I would simply use the product collection to do a search on the sku, but if you want to stick to the approach of that module, you could simply replace
by
Regards,