Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Stock Class Reference
Inheritance diagram for Stock:
AbstractSource SourceInterface ArrayInterface OptionSourceInterface

Public Member Functions

 getAllOptions ()
 
 addValueSortToCollection ($collection, $dir=\Magento\Framework\Data\Collection::SORT_ORDER_DESC)
 
- Public Member Functions inherited from AbstractSource
 setAttribute ($attribute)
 
 getAttribute ()
 
 getOptionText ($value)
 
 getOptionId ($value)
 
 addValueSortToCollection ($collection, $dir=\Magento\Framework\Data\Collection::SORT_ORDER_DESC)
 
 getFlatColumns ()
 
 getFlatIndexes ()
 
 getFlatUpdateSelect ($store)
 
 getIndexOptionText ($value)
 
 toOptionArray ()
 

Additional Inherited Members

- Protected Attributes inherited from AbstractSource
 $_attribute
 
 $_options = null
 

Detailed Description

CatalogInventory Stock source model @api

Since
100.0.2
Deprecated:
2.3.0 Replaced with Multi Source Inventory https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html

Definition at line 19 of file Stock.php.

Member Function Documentation

◆ addValueSortToCollection()

addValueSortToCollection (   $collection,
  $dir = \Magento\Framework\Data\Collection::SORT_ORDER_DESC 
)

Add Value Sort To Collection Select.

Parameters
\Magento\Eav\Model\Entity\Collection\AbstractCollection$collection
string$dir
Returns
$this
Since
100.2.4

Definition at line 43 of file Stock.php.

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  }

◆ getAllOptions()

getAllOptions ( )

Retrieve option array

Returns
array

Implements SourceInterface.

Definition at line 26 of file Stock.php.

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  }
__()
Definition: __.php:13

The documentation for this class was generated from the following file: