I want every collection with 0 stock to get moved to the bottom (last position)

I've tried using a plugin. My di.xml

<type name="Magento\Catalog\Model\Layer">
        <plugin name="Vendor_Module_Plugin"

My file name CollectionPlugin.php

class CollectionPlugin
   public function aroundgetProductCollection(
        Layer $subject,
        callable $proceed
    ) {
        $collection = $proceed();
        $collection->setOrder('is_salable DESC');
        return $collection;

For some reason, It removes every product from the collection.

1 Answer 1


for category pages its works check this Blog link.

  • Thank you very much, I was on this page and it didn't work before. Is there a way to keep the order and just append the 0 stock products to the end? Apr 29, 2020 at 13:41

Your Answer

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

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