/** * {@inheritdoc} */ public function modifyData(array $data) { $fieldCode = 'quantity_and_stock_status'; $model = $this->locator->getProduct(); $modelId = $model->getId(); /** @var StockItemInterface $stockItem */ $stockItem = $this->stockRegistry->getStockItem($modelId, $model->getStore()->getWebsiteId()); $stockData = $modelId ? $this->getData($stockItem) : []; if (!empty($stockData)) { $data[$modelId][self::DATA_SOURCE_DEFAULT][self::STOCK_DATA_FIELDS] = $stockData; } if (isset($stockData['is_in_stock'])) { $data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode]['is_in_stock'] = (int) $stockData['is_in_stock']; } if (!empty($this->stockConfiguration->getDefaultConfigValue(StockItemInterface::MIN_SALE_QTY))) { $minSaleQtyData = null; $defaultConfigValue = $this->stockConfiguration->getDefaultConfigValue(StockItemInterface::MIN_SALE_QTY); if (strpos($defaultConfigValue, 'a:') === 0) { // Set data source for dynamicRows Minimum Qty Allowed in Shopping Cart $minSaleQtyValue = unserialize($defaultConfigValue); foreach ($minSaleQtyValue as $group => $qty) { $minSaleQtyData[] = [StockItemInterface::CUSTOMER_GROUP_ID => $group, StockItemInterface::MIN_SALE_QTY => $qty]; } } else { $minSaleQtyData = $defaultConfigValue; } $path = $modelId . '/' . self::DATA_SOURCE_DEFAULT . '/stock_data/min_qty_allowed_in_shopping_cart'; $data = $this->arrayManager->set($path, $data, $minSaleQtyData); } return $data; }
/** * Get default config value * * @param string $field * @return string|null */ public function getDefaultConfigValue($field) { return $this->stockConfiguration->getDefaultConfigValue($field); }
/** * {@inheritdoc} */ public function getValue($name) { $value = $this->stockConfiguration->getDefaultConfigValue($name); return is_numeric($value) ? (double) $value : $value; }
/** * {@inheritdoc} */ public function getValue($name) { return $this->stockConfiguration->getDefaultConfigValue($name); }