本文整理汇总了PHP中Magento\CatalogInventory\Api\StockConfigurationInterface::getManageStock方法的典型用法代码示例。如果您正苦于以下问题:PHP StockConfigurationInterface::getManageStock方法的具体用法?PHP StockConfigurationInterface::getManageStock怎么用?PHP StockConfigurationInterface::getManageStock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\CatalogInventory\Api\StockConfigurationInterface
的用法示例。
在下文中一共展示了StockConfigurationInterface::getManageStock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: useManageStockFilter
/**
* Add Use Manage Stock Condition to collection
*
* @param null|int $storeId
* @return $this
*/
public function useManageStockFilter($storeId = null)
{
$this->joinInventoryItem();
$manageStockExpr = $this->getConnection()->getCheckSql($this->_getInventoryItemField('use_config_manage_stock') . ' = 1', (int) $this->stockConfiguration->getManageStock($storeId), $this->_getInventoryItemField('manage_stock'));
$this->getSelect()->where($manageStockExpr . ' = ?', 1);
return $this;
}
示例2: getManageStock
/**
* Retrieve can Manage Stock
*
* @return int
*/
public function getManageStock()
{
if ($this->getUseConfigManageStock()) {
return $this->stockConfiguration->getManageStock($this->getStoreId());
}
return (int) $this->getData(static::MANAGE_STOCK);
}
示例3: filter
/**
* Filter stock data
*
* @param array $stockData
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function filter(array $stockData)
{
if (!isset($stockData['use_config_manage_stock'])) {
$stockData['use_config_manage_stock'] = 0;
}
if ($stockData['use_config_manage_stock'] == 1 && !isset($stockData['manage_stock'])) {
$stockData['manage_stock'] = $this->stockConfiguration->getManageStock();
}
if (isset($stockData['qty']) && (double) $stockData['qty'] > self::MAX_QTY_VALUE) {
$stockData['qty'] = self::MAX_QTY_VALUE;
}
if (isset($stockData['min_qty']) && (int) $stockData['min_qty'] < 0) {
$stockData['min_qty'] = 0;
}
if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) {
$stockData['is_decimal_divided'] = 0;
}
return $stockData;
}
示例4: fillSimpleProductData
/**
* Fill simple product data during generation
*
* @param \Magento\Catalog\Model\Product $product
* @param \Magento\Catalog\Model\Product $parentProduct
* @param array $postData
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*
* @return void
*/
protected function fillSimpleProductData(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $parentProduct, $postData)
{
$product->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID)->setTypeId($postData['weight'] ? ProductType::TYPE_SIMPLE : ProductType::TYPE_VIRTUAL)->setAttributeSetId($parentProduct->getNewVariationsAttributeSetId());
foreach ($product->getTypeInstance()->getEditableAttributes($product) as $attribute) {
if ($attribute->getIsUnique() || $attribute->getAttributeCode() == 'url_key' || $attribute->getFrontend()->getInputType() == 'gallery' || $attribute->getFrontend()->getInputType() == 'media_image' || !$attribute->getIsVisible()) {
continue;
}
$product->setData($attribute->getAttributeCode(), $parentProduct->getData($attribute->getAttributeCode()));
}
$postData['stock_data'] = $parentProduct->getStockData();
$postData['stock_data']['manage_stock'] = $postData['quantity_and_stock_status']['qty'] === '' ? 0 : 1;
if (!isset($postData['stock_data']['is_in_stock'])) {
$stockStatus = $parentProduct->getQuantityAndStockStatus();
$postData['stock_data']['is_in_stock'] = $stockStatus['is_in_stock'];
}
$configDefaultValue = $this->stockConfiguration->getManageStock($product->getStoreId());
$postData['stock_data']['use_config_manage_stock'] = $postData['stock_data']['manage_stock'] == $configDefaultValue ? 1 : 0;
$postData = $this->processMediaGallery($product, $postData);
$postData['status'] = isset($postData['status']) ? $postData['status'] : \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED;
$product->addData($postData)->setWebsiteIds($parentProduct->getWebsiteIds())->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE);
}