28 const ENTITY =
'cataloginventory_stock_item';
154 return $this->
_getData(static::ITEM_ID);
166 $websiteId = $this->stockConfiguration->getDefaultScopeId();
178 $stockId = $this->
getData(static::STOCK_ID);
179 if ($stockId ===
null) {
180 $stockId = $this->stockRegistry->getStock($this->
getWebsiteId())->getStockId();
182 return (
int) $stockId;
192 return (
int) $this->
_getData(static::PRODUCT_ID);
201 return (
bool) $this->
_getData(static::STOCK_STATUS_CHANGED_AUTO);
209 return null === $this->
_getData(static::QTY) ? null : (float)$this->
_getData(static::QTY);
222 return (
bool) $this->
_getData(static::IS_IN_STOCK);
231 return (
bool) $this->
_getData(static::IS_QTY_DECIMAL);
240 return (
bool) $this->
_getData(static::IS_DECIMAL_DIVIDED);
248 return $this->
_getData(static::LOW_STOCK_DATE);
268 return (
bool) $this->
_getData(static::USE_CONFIG_MIN_QTY);
279 $minQty = $this->stockConfiguration->getMinQty($this->
getStoreId());
281 $minQty = (float)$this->
getData(static::MIN_QTY);
292 return (
bool) $this->
_getData(static::USE_CONFIG_MIN_SALE_QTY);
306 $minSaleQty = (float) $this->
getData(static::MIN_SALE_QTY);
317 return (
bool) $this->
_getData(static::USE_CONFIG_MAX_SALE_QTY);
331 $maxSaleQty = (float) $this->
getData(static::MAX_SALE_QTY);
342 return (
bool) $this->
_getData(static::USE_CONFIG_NOTIFY_STOCK_QTY);
353 return $this->stockConfiguration->getNotifyStockQty($this->
getStoreId());
355 return (
float) $this->
getData(static::NOTIFY_STOCK_QTY);
364 return (
bool) $this->
_getData(static::USE_CONFIG_ENABLE_QTY_INC);
376 return $this->stockConfiguration->getEnableQtyIncrements($this->
getStoreId());
378 return (
bool) $this->
getData(static::ENABLE_QTY_INCREMENTS);
389 return (
bool) $this->
_getData(static::USE_CONFIG_QTY_INCREMENTS);
399 if ($this->qtyIncrements ===
null) {
402 $this->qtyIncrements = $this->stockConfiguration->getQtyIncrements($this->
getStoreId());
404 $this->qtyIncrements = $this->
getData(static::QTY_INCREMENTS);
408 $this->qtyIncrements = (float) $this->qtyIncrements;
410 $this->qtyIncrements = (int) $this->qtyIncrements;
413 if ($this->qtyIncrements <= 0) {
414 $this->qtyIncrements =
false;
426 return (
bool) $this->
_getData(static::USE_CONFIG_BACKORDERS);
437 return $this->stockConfiguration->getBackorders($this->
getStoreId());
439 return (
int) $this->
getData(static::BACKORDERS);
448 return (
bool) $this->
_getData(static::USE_CONFIG_MANAGE_STOCK);
459 return $this->stockConfiguration->getManageStock($this->
getStoreId());
461 return (
int) $this->
getData(static::MANAGE_STOCK);
477 $errorIndex =
'error' 479 $item->setHasError(
true);
480 $item->setMessage($itemError);
481 $item->setQuoteMessage($quoteError);
482 $item->setQuoteMessageIndex($errorIndex);
494 $this->stockItemRepository->save($this);
508 ->setProductTypeId(
$product->getTypeId())
509 ->setProductName(
$product->getName())
510 ->setProductStatusChanged(
$product->dataHasChangedFor(
'status'))
511 ->setProductChangedWebsites(
$product->getIsChangedWebsites());
534 if ($this->storeId ===
null) {
535 $this->storeId = $this->storeManager->getStore()->getId();
547 if ($this->customerGroupId ===
null) {
548 return $this->customerSession->getCustomerGroupId();
561 $this->customerGroupId =
$value;
573 return $this->
setData(self::ITEM_ID, $itemId);
604 return $this->
setData(self::STOCK_ID, $stockId);
613 return $this->
setData(self::QTY, $qty);
624 return $this->
setData(self::IS_IN_STOCK, $isInStock);
633 return $this->
setData(self::IS_QTY_DECIMAL, $isQtyDecimal);
642 return $this->
setData(self::USE_CONFIG_MIN_QTY, $useConfigMinQty);
653 return $this->
setData(self::MIN_QTY, $minQty);
662 return $this->
setData(self::USE_CONFIG_MIN_SALE_QTY, $useConfigMinSaleQty);
673 return $this->
setData(self::MIN_SALE_QTY, $minSaleQty);
682 return $this->
setData(self::USE_CONFIG_MAX_SALE_QTY, $useConfigMaxSaleQty);
693 return $this->
setData(self::MAX_SALE_QTY, $maxSaleQty);
702 return $this->
setData(self::USE_CONFIG_BACKORDERS, $useConfigBackorders);
713 return $this->
setData(self::BACKORDERS, $backOrders);
722 return $this->
setData(self::USE_CONFIG_NOTIFY_STOCK_QTY, $useConfigNotifyStockQty);
733 return $this->
setData(self::NOTIFY_STOCK_QTY, $notifyStockQty);
742 return $this->
setData(self::USE_CONFIG_QTY_INCREMENTS, $useConfigQtyIncrements);
762 return $this->
setData(self::USE_CONFIG_ENABLE_QTY_INC, $useConfigEnableQtyInc);
773 return $this->
setData(self::ENABLE_QTY_INCREMENTS, $enableQtyIncrements);
782 return $this->
setData(self::USE_CONFIG_MANAGE_STOCK, $useConfigManageStock);
791 return $this->
setData(self::MANAGE_STOCK, $manageStock);
800 return $this->
setData(self::LOW_STOCK_DATE, $lowStockDate);
809 return $this->
setData(self::IS_DECIMAL_DIVIDED, $isDecimalDivided);
818 return $this->
setData(self::STOCK_STATUS_CHANGED_AUTO, $stockStatusChangedAuto);
setEnableQtyIncrements($enableQtyIncrements)
setIsDecimalDivided($isDecimalDivided)
setExtensionAttributes(\Magento\CatalogInventory\Api\Data\StockItemExtensionInterface $extensionAttributes)
_getExtensionAttributes()
getShowDefaultNotificationMessage()
getUseConfigEnableQtyInc()
setIsQtyDecimal($isQtyDecimal)
_addQuoteItemError(\Magento\Quote\Model\Quote\Item $item, $itemError, $quoteError, $errorIndex='error')
setUseConfigNotifyStockQty($useConfigNotifyStockQty)
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
setUseConfigQtyIncrements($useConfigQtyIncrements)
setUseConfigManageStock($useConfigManageStock)
setUseConfigEnableQtyInc($useConfigEnableQtyInc)
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Store\Model\StoreManagerInterface $storeManager, StockConfigurationInterface $stockConfiguration, StockRegistryInterface $stockRegistry, StockItemRepositoryInterface $stockItemRepository, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
getUseConfigNotifyStockQty()
setManageStock($manageStock)
getUseConfigManageStock()
setLowStockDate($lowStockDate)
setUseConfigBackorders($useConfigBackorders)
setNotifyStockQty($notifyStockQty)
setCustomerGroupId($value)
setQtyIncrements($qtyIncrements)
setUseConfigMinSaleQty($useConfigMinSaleQty)
setStockStatusChangedAuto($stockStatusChangedAuto)
setBackorders($backOrders)
setUseConfigMaxSaleQty($useConfigMaxSaleQty)
getData($key='', $index=null)
setUseConfigMinQty($useConfigMinQty)
setData($key, $value=null)
setMaxSaleQty($maxSaleQty)
getUseConfigQtyIncrements()
getStockStatusChangedAuto()
setMinSaleQty($minSaleQty)
setProduct(Product $product)