I am working on a Shopware 6 project and I want to change the product listing behavior on category pages (and search results).
Requirement:
Regardless of which sorting option a customer selects (price ascending, relevance, name, etc.), all out-of-stock products should always be shown at the end of the product listing.
What I’ve tried so far:
Subscribed to ProductListingCriteriaEvent and added an extra sorting:
$criteria->addSorting(new FieldSorting(‘stock’, FieldSorting::DESCENDING));