My problem is that : all products in category page not showing.

And when i displayed the query of $_productColection in Magento_Catalog/templates/product/list.phtml :

 * Product list template
 * @var $block \Magento\Catalog\Block\Product\ListProduct
$_productCollection = $block->getLoadedProductCollection();

i have (NULL) at the end of the query:

SELECT `e`.*, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, `stock_status_index`.`is_salable` FROM `catalog_product_entity` AS `e` INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' INNER JOIN `catalog_product_entity` AS `product` ON product.entity_id = e.entity_id INNER JOIN `inventory_stock_2` AS `stock_status_index` ON product.sku = stock_status_index.sku WHERE (stock_status_index.is_salable = 1) AND (NULL)

It was modified at the time of $collection->load(); in vendor/magento/module-catalog/Block/Product/ListProduct.php - line 212

    protected function _beforeToHtml()
       $collection = $this->_getProductCollection();

        if (!$collection->isLoaded()) {

        $categoryId = $this->getLayer()->getCurrentCategory()->getId();

        if ($categoryId) {
            foreach ($collection as $product) {
                $product->setData('category_id', $categoryId);

        return parent::_beforeToHtml();

Does anyone know this NULL value ? And where is the file that loads this value?

2 Answers 2


The "AND (NULL)" condition effectively does nothing and has no effect on the query results. It is likely a remnant of some debugging or development code that was not properly removed before the query was executed.

You can safely remove the "AND (NULL)" part of the query without affecting the results of the query.

  • Hi, if i remove the "AND NULL" condition in the query, it 's displayed all saleable products. But I would like to display only the products in the spcecified category.
    – Heri Rak
    Mar 3, 2023 at 15:18

Try this (stock_status_index.is_salable = 1 AND NULL)

Instead of this (stock_status_index.is_salable = 1) AND (NULL)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.