I want to show Out of Stock items after in stock items. I found solution here, but its for Magento 1.8. I need same for Magento 2.


Please update your code to sort according to current direction (By ASC or By DESC)

  $collection = $subject->getCollection();
         ['_inventory_table' => 'cataloginventory_stock_item'], 
         "_inventory_table.product_id = e.entity_id", ['is_in_stock']
  $collection->getSelect()->order(['is_in_stock ' . $currentDirection]);

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.