This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Fulltext Collection modifies query, losing where clause #3465
Labels
You can continue the conversation there. Go to discussion →
Magento: 2.4.3-p1
ES: 2.10.23.2
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.
It comes with a custom landingpage using it's own controller. On that controller the core's productlist (
Magento\Catalog\Block\Product\ListProduct
) block is embedded. Via plugin the productlist collection is modified reflecting the module's special needs.In
afterGetProductCollection
of theMagento\Catalog\Model\Layer
class the plugin modifies the collection's query adding a list of SKUs:$result->distinct(true)->addAttributeToFilter('entity_id', ['in' => $this->helperData->getIdsBySku($sku)]);
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
load()
command inMagento\Catalog\Block\Product\ListProduct::_beforeToHtml()
is somehow responsible.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.
I then disabled all Smile modules and went back to magento's core adapter for Elasticsearch 7.
While the first query did not change, this is the second one (shortened again):
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.
In the frontend this yields the desired outcome.
My questions are: what, why, where does your module mangle with the query? Could this be an unwelcome sideeffect for third party modules?
The text was updated successfully, but these errors were encountered: