Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StockDataFilter.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  const MAX_QTY_VALUE = 99999999;
20 
24  protected $scopeConfig;
25 
30 
35  public function __construct(
38  ) {
39  $this->scopeConfig = $scopeConfig;
40  $this->stockConfiguration = $stockConfiguration;
41  }
42 
50  public function filter(array $stockData)
51  {
52  if (!isset($stockData['use_config_manage_stock'])) {
53  $stockData['use_config_manage_stock'] = 0;
54  }
55 
56  if ($stockData['use_config_manage_stock'] == 1 && !isset($stockData['manage_stock'])) {
57  $stockData['manage_stock'] = $this->stockConfiguration->getManageStock();
58  }
59  if (isset($stockData['qty']) && (double)$stockData['qty'] > self::MAX_QTY_VALUE) {
61  }
62 
63  if (isset($stockData['min_qty']) && (int)$stockData['min_qty'] < 0) {
64  $stockData['min_qty'] = 0;
65  }
66 
67  if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) {
68  $stockData['is_decimal_divided'] = 0;
69  }
70 
71  return $stockData;
72  }
73 }
__construct(ScopeConfigInterface $scopeConfig, StockConfigurationInterface $stockConfiguration)
$stockData
Definition: products.php:27