Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Configuration Class Reference
Inheritance diagram for Configuration:
StockConfigurationInterface

Public Member Functions

 __construct (ConfigInterface $config, ScopeConfigInterface $scopeConfig, MinsaleqtyHelper $minsaleqtyHelper, StoreManagerInterface $storeManager)
 
 getDefaultScopeId ()
 
 getIsQtyTypeIds ($filter=null)
 
 isQty ($productTypeId)
 
 canSubtractQty ($store=null)
 
 getMinQty ($store=null)
 
 getMinSaleQty ($store=null, $customerGroupId=null)
 
 getMaxSaleQty ($store=null)
 
 getNotifyStockQty ($store=null)
 
 getEnableQtyIncrements ($store=null)
 
 getQtyIncrements ($store=null)
 
 getBackorders ($store=null)
 
 getManageStock ($store=null)
 
 getCanBackInStock ($store=null)
 
 isShowOutOfStock ($store=null)
 
 isAutoReturnEnabled ($store=null)
 
 isDisplayProductStockStatus ($store=null)
 
 getDefaultConfigValue ($field, $store=null)
 
 getStockThresholdQty ($store=null)
 
 getConfigItemOptions ()
 

Data Fields

const DEFAULT_WEBSITE_ID = 1
 
const XML_PATH_GLOBAL = 'cataloginventory/options/'
 
const XML_PATH_CAN_SUBTRACT = 'cataloginventory/options/can_subtract'
 
const XML_PATH_CAN_BACK_IN_STOCK = 'cataloginventory/options/can_back_in_stock'
 
const XML_PATH_ITEM = 'cataloginventory/item_options/'
 
const XML_PATH_MIN_QTY = 'cataloginventory/item_options/min_qty'
 
const XML_PATH_MIN_SALE_QTY = 'cataloginventory/item_options/min_sale_qty'
 
const XML_PATH_MAX_SALE_QTY = 'cataloginventory/item_options/max_sale_qty'
 
const XML_PATH_BACKORDERS = 'cataloginventory/item_options/backorders'
 
const XML_PATH_NOTIFY_STOCK_QTY = 'cataloginventory/item_options/notify_stock_qty'
 
const XML_PATH_MANAGE_STOCK = 'cataloginventory/item_options/manage_stock'
 
const XML_PATH_ENABLE_QTY_INCREMENTS = 'cataloginventory/item_options/enable_qty_increments'
 
const XML_PATH_QTY_INCREMENTS = 'cataloginventory/item_options/qty_increments'
 
const XML_PATH_SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock'
 
const XML_PATH_ITEM_AUTO_RETURN = 'cataloginventory/item_options/auto_return'
 
const XML_PATH_DISPLAY_PRODUCT_STOCK_STATUS = 'cataloginventory/options/display_product_stock_status'
 
const XML_PATH_STOCK_THRESHOLD_QTY = 'cataloginventory/options/stock_threshold_qty'
 

Protected Attributes

 $config
 
 $scopeConfig
 
 $minsaleqtyHelper
 
 $isQtyTypeIds
 
 $storeManager
 

Detailed Description

Class Configuration

Definition at line 17 of file Configuration.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ConfigInterface  $config,
ScopeConfigInterface  $scopeConfig,
MinsaleqtyHelper  $minsaleqtyHelper,
StoreManagerInterface  $storeManager 
)
Parameters
ConfigInterface$config
ScopeConfigInterface$scopeConfig
MinsaleqtyHelper$minsaleqtyHelper
StoreManagerInterface$storeManager

Definition at line 139 of file Configuration.php.

Member Function Documentation

◆ canSubtractQty()

canSubtractQty (   $store = null)

Check if is possible subtract value from item qty

Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
bool

Implements StockConfigurationInterface.

Definition at line 200 of file Configuration.php.

201  {
202  return $this->scopeConfig->isSetFlag(
203  self::XML_PATH_CAN_SUBTRACT,
204  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
205  $store
206  );
207  }

◆ getBackorders()

getBackorders (   $store = null)

Retrieve backorders status

Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
int

Implements StockConfigurationInterface.

Definition at line 293 of file Configuration.php.

294  {
295  return (int) $this->scopeConfig->getValue(
296  self::XML_PATH_BACKORDERS,
297  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
298  $store
299  );
300  }

◆ getCanBackInStock()

getCanBackInStock (   $store = null)

Retrieve can Back in stock

Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
bool @SuppressWarnings(PHPMD.BooleanGetMethodName)

Implements StockConfigurationInterface.

Definition at line 324 of file Configuration.php.

325  {
326  return $this->scopeConfig->isSetFlag(
327  self::XML_PATH_CAN_BACK_IN_STOCK,
328  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
329  $store
330  );
331  }

◆ getConfigItemOptions()

getConfigItemOptions ( )

Retrieve inventory item options (used in config)

Returns
string[]

Implements StockConfigurationInterface.

Definition at line 411 of file Configuration.php.

412  {
413  return [
414  'min_qty',
415  'backorders',
416  'min_sale_qty',
417  'max_sale_qty',
418  'notify_stock_qty',
419  'manage_stock',
420  'enable_qty_increments',
421  'qty_increments',
422  'is_decimal_divided'
423  ];
424  }

◆ getDefaultConfigValue()

getDefaultConfigValue (   $field,
  $store = null 
)
Parameters
string$field
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
string|null

Implements StockConfigurationInterface.

Definition at line 384 of file Configuration.php.

385  {
386  return $this->scopeConfig->getValue(
387  self::XML_PATH_ITEM . $field,
388  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
389  $store
390  );
391  }

◆ getDefaultScopeId()

getDefaultScopeId ( )

{Retrieve Default Scope ID

Returns
int
}

Implements StockConfigurationInterface.

Definition at line 154 of file Configuration.php.

155  {
156  // TODO: should be fixed in MAGETWO-46043
157  // "0" is id of admin website, which is used in backend during save entity
158  return 0;
159  }

◆ getEnableQtyIncrements()

getEnableQtyIncrements (   $store = null)

Retrieve whether Quantity Increments is enabled

Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
bool @SuppressWarnings(PHPMD.BooleanGetMethodName)

Implements StockConfigurationInterface.

Definition at line 265 of file Configuration.php.

266  {
267  return (bool) $this->scopeConfig->getValue(
268  self::XML_PATH_ENABLE_QTY_INCREMENTS,
269  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
270  $store
271  );
272  }

◆ getIsQtyTypeIds()

getIsQtyTypeIds (   $filter = null)
Parameters
int | null$filter
Returns
array

Implements StockConfigurationInterface.

Definition at line 165 of file Configuration.php.

166  {
167  if (null === $this->isQtyTypeIds) {
168  $this->isQtyTypeIds = [];
169  foreach ($this->config->getAll() as $typeId => $typeConfig) {
170  $this->isQtyTypeIds[$typeId] = isset($typeConfig['is_qty']) ? $typeConfig['is_qty'] : false;
171  }
172  }
174  if ($filter !== null) {
175  foreach ($result as $key => $value) {
176  if ($value !== $filter) {
177  unset($result[$key]);
178  }
179  }
180  }
181  return $result;
182  }
$value
Definition: gender.phtml:16

◆ getManageStock()

getManageStock (   $store = null)

Retrieve Manage Stock data wrapper

Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
int

Implements StockConfigurationInterface.

Definition at line 308 of file Configuration.php.

309  {
310  return (int) $this->scopeConfig->isSetFlag(
311  self::XML_PATH_MANAGE_STOCK,
312  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
313  $store
314  );
315  }

◆ getMaxSaleQty()

getMaxSaleQty (   $store = null)
Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
float|null

Implements StockConfigurationInterface.

Definition at line 236 of file Configuration.php.

237  {
238  return (float)$this->scopeConfig->getValue(
239  self::XML_PATH_MAX_SALE_QTY,
240  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
241  $store
242  );
243  }

◆ getMinQty()

getMinQty (   $store = null)
Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
float

Implements StockConfigurationInterface.

Definition at line 213 of file Configuration.php.

214  {
215  return (float)$this->scopeConfig->getValue(
216  self::XML_PATH_MIN_QTY,
217  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
218  $store
219  );
220  }

◆ getMinSaleQty()

getMinSaleQty (   $store = null,
  $customerGroupId = null 
)
Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
int$customerGroupId
Returns
float

Implements StockConfigurationInterface.

Definition at line 227 of file Configuration.php.

228  {
229  return (float)$this->minsaleqtyHelper->getConfigValue($customerGroupId, $store);
230  }

◆ getNotifyStockQty()

getNotifyStockQty (   $store = null)
Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
float

Implements StockConfigurationInterface.

Definition at line 249 of file Configuration.php.

250  {
251  return (float) $this->scopeConfig->getValue(
252  self::XML_PATH_NOTIFY_STOCK_QTY,
253  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
254  $store
255  );
256  }

◆ getQtyIncrements()

getQtyIncrements (   $store = null)
Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
float

Implements StockConfigurationInterface.

Definition at line 278 of file Configuration.php.

279  {
280  return (float)$this->scopeConfig->getValue(
281  self::XML_PATH_QTY_INCREMENTS,
282  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
283  $store
284  );
285  }

◆ getStockThresholdQty()

getStockThresholdQty (   $store = null)
Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
string|null

Definition at line 397 of file Configuration.php.

398  {
399  return $this->scopeConfig->getValue(
400  self::XML_PATH_STOCK_THRESHOLD_QTY,
401  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
402  $store
403  );
404  }

◆ isAutoReturnEnabled()

isAutoReturnEnabled (   $store = null)

Check if credit memo items auto return option is enabled

Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
bool

Implements StockConfigurationInterface.

Definition at line 354 of file Configuration.php.

355  {
356  return $this->scopeConfig->isSetFlag(
357  self::XML_PATH_ITEM_AUTO_RETURN,
358  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
359  $store
360  );
361  }

◆ isDisplayProductStockStatus()

isDisplayProductStockStatus (   $store = null)

Get 'Display product stock status' option value Shows if it is necessary to show product stock status ('in stock'/'out of stock')

Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
bool

Implements StockConfigurationInterface.

Definition at line 370 of file Configuration.php.

371  {
372  return $this->scopeConfig->isSetFlag(
373  self::XML_PATH_DISPLAY_PRODUCT_STOCK_STATUS,
374  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
375  $store
376  );
377  }

◆ isQty()

isQty (   $productTypeId)
Parameters
int$productTypeId
Returns
bool

Implements StockConfigurationInterface.

Definition at line 188 of file Configuration.php.

189  {
190  $result = $this->getIsQtyTypeIds();
191  return isset($result[$productTypeId]) ? $result[$productTypeId] : false;
192  }

◆ isShowOutOfStock()

isShowOutOfStock (   $store = null)

Display out of stock products option

Parameters
null | string | bool | int | \Magento\Store\Model\Store$store
Returns
bool

Implements StockConfigurationInterface.

Definition at line 339 of file Configuration.php.

340  {
341  return $this->scopeConfig->isSetFlag(
342  self::XML_PATH_SHOW_OUT_OF_STOCK,
343  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
344  $store
345  );
346  }

Field Documentation

◆ $config

$config
protected

Definition at line 107 of file Configuration.php.

◆ $isQtyTypeIds

$isQtyTypeIds
protected

Definition at line 126 of file Configuration.php.

◆ $minsaleqtyHelper

$minsaleqtyHelper
protected

Definition at line 119 of file Configuration.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 114 of file Configuration.php.

◆ $storeManager

$storeManager
protected

Definition at line 131 of file Configuration.php.

◆ DEFAULT_WEBSITE_ID

const DEFAULT_WEBSITE_ID = 1

Default website id

Definition at line 22 of file Configuration.php.

◆ XML_PATH_BACKORDERS

const XML_PATH_BACKORDERS = 'cataloginventory/item_options/backorders'

Back orders config path

Definition at line 62 of file Configuration.php.

◆ XML_PATH_CAN_BACK_IN_STOCK

const XML_PATH_CAN_BACK_IN_STOCK = 'cataloginventory/options/can_back_in_stock'

Back in stock config path

Definition at line 37 of file Configuration.php.

◆ XML_PATH_CAN_SUBTRACT

const XML_PATH_CAN_SUBTRACT = 'cataloginventory/options/can_subtract'

Subtract config path

Definition at line 32 of file Configuration.php.

◆ XML_PATH_DISPLAY_PRODUCT_STOCK_STATUS

const XML_PATH_DISPLAY_PRODUCT_STOCK_STATUS = 'cataloginventory/options/display_product_stock_status'

Path to configuration option 'Display product stock status'

Definition at line 97 of file Configuration.php.

◆ XML_PATH_ENABLE_QTY_INCREMENTS

const XML_PATH_ENABLE_QTY_INCREMENTS = 'cataloginventory/item_options/enable_qty_increments'

Enable qty increments config path

Definition at line 77 of file Configuration.php.

◆ XML_PATH_GLOBAL

const XML_PATH_GLOBAL = 'cataloginventory/options/'

Inventory options config path

Definition at line 27 of file Configuration.php.

◆ XML_PATH_ITEM

const XML_PATH_ITEM = 'cataloginventory/item_options/'

Item options config path

Definition at line 42 of file Configuration.php.

◆ XML_PATH_ITEM_AUTO_RETURN

const XML_PATH_ITEM_AUTO_RETURN = 'cataloginventory/item_options/auto_return'

Auto return config path

Definition at line 92 of file Configuration.php.

◆ XML_PATH_MANAGE_STOCK

const XML_PATH_MANAGE_STOCK = 'cataloginventory/item_options/manage_stock'

Manage stock config path

Definition at line 72 of file Configuration.php.

◆ XML_PATH_MAX_SALE_QTY

const XML_PATH_MAX_SALE_QTY = 'cataloginventory/item_options/max_sale_qty'

Max sale qty config path

Definition at line 57 of file Configuration.php.

◆ XML_PATH_MIN_QTY

const XML_PATH_MIN_QTY = 'cataloginventory/item_options/min_qty'

Max qty config path

Definition at line 47 of file Configuration.php.

◆ XML_PATH_MIN_SALE_QTY

const XML_PATH_MIN_SALE_QTY = 'cataloginventory/item_options/min_sale_qty'

Min sale qty config path

Definition at line 52 of file Configuration.php.

◆ XML_PATH_NOTIFY_STOCK_QTY

const XML_PATH_NOTIFY_STOCK_QTY = 'cataloginventory/item_options/notify_stock_qty'

Notify stock config path

Definition at line 67 of file Configuration.php.

◆ XML_PATH_QTY_INCREMENTS

const XML_PATH_QTY_INCREMENTS = 'cataloginventory/item_options/qty_increments'

Qty increments config path

Definition at line 82 of file Configuration.php.

◆ XML_PATH_SHOW_OUT_OF_STOCK

const XML_PATH_SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock'

Show out of stock config path

Definition at line 87 of file Configuration.php.

◆ XML_PATH_STOCK_THRESHOLD_QTY

const XML_PATH_STOCK_THRESHOLD_QTY = 'cataloginventory/options/stock_threshold_qty'

Threshold qty config path

Definition at line 102 of file Configuration.php.


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