Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-catalog-inventory
Model
Source
Stock.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\CatalogInventory\Model\Source
;
7
8
use
Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
;
9
19
class
Stock
extends
AbstractSource
20
{
26
public
function
getAllOptions
()
27
{
28
return
[
29
[
'value'
=>
\Magento\CatalogInventory\Model\Stock::STOCK_IN_STOCK
,
'label'
=>
__
(
'In Stock'
)],
30
[
'value'
=>
\Magento\CatalogInventory\Model\Stock::STOCK_OUT_OF_STOCK
,
'label'
=>
__
(
'Out of Stock'
)]
31
];
32
}
33
43
public
function
addValueSortToCollection
(
$collection
, $dir = \
Magento
\Framework\Data\
Collection::SORT_ORDER_DESC
)
44
{
45
$collection
->getSelect()->joinLeft(
46
[
'stock_item_table'
=>
'cataloginventory_stock_item'
],
47
"e.entity_id=stock_item_table.product_id"
,
48
[]
49
);
50
$collection
->getSelect()->order(
"stock_item_table.qty $dir"
);
51
return
$this;
52
}
53
}
Magento\Framework\Data\Collection\SORT_ORDER_DESC
const SORT_ORDER_DESC
Definition:
Collection.php:23
Magento\CatalogInventory\Model\Stock\STOCK_OUT_OF_STOCK
const STOCK_OUT_OF_STOCK
Definition:
Stock.php:43
Magento\CatalogInventory\Model\Source\Stock\getAllOptions
getAllOptions()
Definition:
Stock.php:26
__
__()
Definition:
__.php:13
Magento\CatalogInventory\Model\Source\Stock
Definition:
Stock.php:19
Magento\CatalogInventory\Model\Source\Stock\addValueSortToCollection
addValueSortToCollection($collection, $dir=\Magento\Framework\Data\Collection::SORT_ORDER_DESC)
Definition:
Stock.php:43
Magento\CatalogInventory\Model\Stock\STOCK_IN_STOCK
const STOCK_IN_STOCK
Definition:
Stock.php:45
Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
Definition:
AbstractSource.php:16
Magento
Magento\CatalogInventory\Model\Source
Definition:
Backorders.php:6
$collection
$collection
Definition:
catalog_category_with_apostrophe_rollback.php:17