File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
app/code/Magento/CatalogInventory/Model/Source Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -26,4 +26,23 @@ public function getAllOptions()
26
26
['value ' => \Magento \CatalogInventory \Model \Stock::STOCK_OUT_OF_STOCK , 'label ' => __ ('Out of Stock ' )]
27
27
];
28
28
}
29
+
30
+ /**
31
+ * Add Value Sort To Collection Select
32
+ *
33
+ * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
34
+ * @param string $dir
35
+ *
36
+ * @return $this
37
+ */
38
+ public function addValueSortToCollection ($ collection , $ dir = \Magento \Framework \Data \Collection::SORT_ORDER_DESC )
39
+ {
40
+ $ collection ->getSelect ()->joinLeft (
41
+ ['stock_item_table ' => 'cataloginventory_stock_item ' ],
42
+ "e.entity_id=stock_item_table.product_id " ,
43
+ []
44
+ );
45
+ $ collection ->getSelect ()->order ("stock_item_table.qty $ dir " );
46
+ return $ this
47
+ }
29
48
}
You can’t perform that action at this time.
0 commit comments