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

Public Member Functions

 getVisibleStatusIds ()
 
 getSaleableStatusIds ()
 
 getAllOptions ()
 
 getOptionText ($optionId)
 
 addValueSortToCollection ($collection, $dir='asc')
 
- 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 ()
 

Static Public Member Functions

static getOptionArray ()
 

Data Fields

const STATUS_ENABLED = 1
 
const STATUS_DISABLED = 2
 

Additional Inherited Members

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

Detailed Description

Product status functionality model

@api

Since
100.0.2

Definition at line 18 of file Status.php.

Member Function Documentation

◆ addValueSortToCollection()

addValueSortToCollection (   $collection,
  $dir = 'asc' 
)

Add Value Sort To Collection Select

Parameters
\Magento\Eav\Model\Entity\Collection\AbstractCollection$collection
string$dirdirection
Returns
AbstractSource

Definition at line 96 of file Status.php.

97  {
98  $attributeCode = $this->getAttribute()->getAttributeCode();
99  $attributeId = $this->getAttribute()->getId();
100  $attributeTable = $this->getAttribute()->getBackend()->getTable();
101  $linkField = $this->getAttribute()->getEntity()->getLinkField();
102 
103  if ($this->getAttribute()->isScopeGlobal()) {
104  $tableName = $attributeCode . '_t';
105 
106  $collection->getSelect()->joinLeft(
107  [$tableName => $attributeTable],
108  "e.{$linkField}={$tableName}.{$linkField}" .
109  " AND {$tableName}.attribute_id='{$attributeId}'" .
110  " AND {$tableName}.store_id='0'",
111  []
112  );
113 
114  $valueExpr = $tableName . '.value';
115  } else {
116  $valueTable1 = $attributeCode . '_t1';
117  $valueTable2 = $attributeCode . '_t2';
118 
119  $collection->getSelect()->joinLeft(
120  [$valueTable1 => $attributeTable],
121  "e.{$linkField}={$valueTable1}.{$linkField}" .
122  " AND {$valueTable1}.attribute_id='{$attributeId}'" .
123  " AND {$valueTable1}.store_id='0'",
124  []
125  )->joinLeft(
126  [$valueTable2 => $attributeTable],
127  "e.{$linkField}={$valueTable2}.{$linkField}" .
128  " AND {$valueTable2}.attribute_id='{$attributeId}'" .
129  " AND {$valueTable2}.store_id='{$collection->getStoreId()}'",
130  []
131  );
132 
133  $valueExpr = $collection->getConnection()->getCheckSql(
134  $valueTable2 . '.value_id > 0',
135  $valueTable2 . '.value',
136  $valueTable1 . '.value'
137  );
138  }
139 
140  $collection->getSelect()->order($valueExpr . ' ' . $dir);
141 
142  return $this;
143  }
$tableName
Definition: trigger.php:13
$attributeCode
Definition: extend.phtml:12

◆ getAllOptions()

getAllOptions ( )

Retrieve option array with empty value

Returns
string[]

Implements SourceInterface.

Definition at line 65 of file Status.php.

66  {
67  $result = [];
68 
69  foreach (self::getOptionArray() as $index => $value) {
70  $result[] = ['value' => $index, 'label' => $value];
71  }
72 
73  return $result;
74  }
$value
Definition: gender.phtml:16
$index
Definition: list.phtml:44

◆ getOptionArray()

static getOptionArray ( )
static

Retrieve option array

Returns
string[]

Definition at line 55 of file Status.php.

56  {
57  return [self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled')];
58  }
__()
Definition: __.php:13

◆ getOptionText()

getOptionText (   $optionId)

Retrieve option text by option value

Parameters
string$optionId
Returns
string

Implements SourceInterface.

Definition at line 82 of file Status.php.

◆ getSaleableStatusIds()

getSaleableStatusIds ( )

Retrieve Saleable Status Ids Default Product Enable status

Returns
int[]

Definition at line 45 of file Status.php.

◆ getVisibleStatusIds()

getVisibleStatusIds ( )

#- Retrieve Visible Status Ids

Returns
int[]

Definition at line 34 of file Status.php.

Field Documentation

◆ STATUS_DISABLED

const STATUS_DISABLED = 2

Definition at line 25 of file Status.php.

◆ STATUS_ENABLED

const STATUS_ENABLED = 1

#+ Product Status values

Definition at line 23 of file Status.php.


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