I have upgraded my Magento v2.3.0 to v2.4.2 running on Mysql 8. Everything went well except products not showing up on category page.

Below is the class responsible to fetch products on category page.


And function responsible for the same is

public function getLoadedProductCollection()
    $collection = $this->_getProductCollection();

    $categoryId = $this->getLayer()->getCurrentCategory()->getId();
    foreach ($collection as $product) {
        $product->setData('category_id', $categoryId);

    return $collection;

Debugging deeper, I found following function inside the class


 * @inheritdoc
public function getCollection(\Magento\Catalog\Model\Category $category)
    if (!isset($this->factories[$this->engineResolver->getCurrentSearchEngine()])) {
        throw new \DomainException('Undefined factory ' . $this->engineResolver->getCurrentSearchEngine());
    $collection = $this->factories[$this->engineResolver->getCurrentSearchEngine()]->create();

    return $collection;

Variable $collection returns count of zero. $category is showing the right category. On Admin panel, products are visible under that category.

I ran Indexing but no luck

Edit #1:

While debugging, below was the sql query of $collection

SELECT `e`.* FROM `catalog_product_entity` AS `e` WHERE (NULL)

Edit #2:

Debugging fresh Magento 2.4.2 where products are displayed on category page, below was the sql query of $collection

SELECT `e`.* FROM `catalog_product_entity` AS `e`

WHERE (NULL) was not present

From where does this condition gets added?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy