infrangible / m2-catalog-product-list-sort-stock
Moves out-of-stock products to the end of the product lists of all categories, before the sort order chosen by the customer.
Package info
github.com/infrangible-dev/m2-catalog-product-list-sort-stock
Type:magento2-module
pkg:composer/infrangible/m2-catalog-product-list-sort-stock
Requires
- php: >=8.1
- infrangible/m2-foundation: ~3.0.2
- magento/framework: ~103.0.6
- magento/module-catalog-inventory: ~100.4.6
- magento/module-catalog-search: ~102.0.6
- magento/module-config: ~101.2.6
- magento/module-inventory-catalog-api: ~1.3.4
- magento/module-inventory-elasticsearch: ~1.2.3
- magento/module-store: ~101.1.6
Requires (Dev)
- infrangible/phpstan-magento: ~1.2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-30 16:11:36 UTC
README
Shows out of stock products at the end of the product lists of all categories. Customers see the products they can buy first, and the out of stock products still follow at the end of the list, for example to be found and to stay visible to search engines.
How it works
Magento shows out of stock products in the product lists only if "Display Out of Stock Products" is enabled in Stores > Configuration > Catalog > Inventory > Stock Options. They are then mixed with the other products.
The module sorts by stock before the sort order that the customer has chosen (position, name, price and so on), so within the products in stock and within the out of stock products, the chosen sort order is kept. The search engine (OpenSearch or Elasticsearch) does the sorting, so out of stock products are at the end of the whole list, not of each page.
Magento itself already sorts out of stock products to the end in the search results, and in Adobe Commerce in categories with the automatic sorting "Move out of stock to bottom". The module does this in all categories.
Configuration
Stores > Configuration > Infrangible Solutions > Product List: Out of Stock Last > General > Enable (default: Yes, per store view).
Requirements
- Magento Open Source or Adobe Commerce 2.4.6 or newer
- The inventory modules of Magento (MSI), including Magento_InventoryElasticsearch: they add the stock to the search index
- PHP 8.1 or newer
Installation
composer require infrangible/m2-catalog-product-list-sort-stock bin/magento module:enable Infrangible_CatalogProductListSortStock bin/magento setup:upgrade bin/magento cache:flush
In production mode, also run bin/magento setup:di:compile.
License
Infrangible Product List: Out of Stock Last is licensed under the MIT License - see the LICENSE file for details.