Item.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\CatalogInventory\Model\Stock;
  7. use Magento\Catalog\Model\Product;
  8. use Magento\CatalogInventory\Api\Data\StockItemInterface;
  9. use Magento\CatalogInventory\Api\StockConfigurationInterface as StockConfigurationInterface;
  10. use Magento\CatalogInventory\Api\StockItemRepositoryInterface as StockItemRepositoryInterface;
  11. use Magento\CatalogInventory\Api\StockRegistryInterface;
  12. use Magento\Framework\Api\AttributeValueFactory;
  13. use Magento\Framework\Api\ExtensionAttributesFactory;
  14. use Magento\Framework\Model\AbstractExtensibleModel;
  15. /**
  16. * Catalog Inventory Stock Item Model
  17. *
  18. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  19. * @SuppressWarnings(PHPMD.ExcessivePublicCount)
  20. */
  21. class Item extends AbstractExtensibleModel implements StockItemInterface
  22. {
  23. /**
  24. * Stock item entity code
  25. */
  26. const ENTITY = 'cataloginventory_stock_item';
  27. /**
  28. * Prefix of model events names
  29. *
  30. * @var string
  31. */
  32. protected $_eventPrefix = 'cataloginventory_stock_item';
  33. const WEBSITE_ID = 'website_id';
  34. /**
  35. * Parameter name in event
  36. *
  37. * In observe method you can use $observer->getEvent()->getItem() in this case
  38. *
  39. * @var string
  40. */
  41. protected $_eventObject = 'item';
  42. /**
  43. * Store model manager
  44. *
  45. * @var \Magento\Store\Model\StoreManagerInterface
  46. */
  47. protected $storeManager;
  48. /**
  49. * @var StockConfigurationInterface
  50. */
  51. protected $stockConfiguration;
  52. /**
  53. * @var StockRegistryInterface
  54. */
  55. protected $stockRegistry;
  56. /**
  57. * @var StockConfigurationInterface
  58. */
  59. protected $stockItemRepository;
  60. /**
  61. * @var float|false
  62. */
  63. protected $qtyIncrements;
  64. /**
  65. * Store id
  66. *
  67. * @var int|null
  68. */
  69. protected $storeId;
  70. /**
  71. * Customer group id
  72. *
  73. * @var int|null
  74. */
  75. protected $customerGroupId;
  76. /**
  77. * @var \Magento\Customer\Model\Session
  78. */
  79. protected $customerSession;
  80. /**
  81. * @param \Magento\Framework\Model\Context $context
  82. * @param \Magento\Framework\Registry $registry
  83. * @param ExtensionAttributesFactory $extensionFactory
  84. * @param AttributeValueFactory $customAttributeFactory
  85. * @param \Magento\Customer\Model\Session $customerSession
  86. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  87. * @param StockConfigurationInterface $stockConfiguration
  88. * @param StockRegistryInterface $stockRegistry
  89. * @param StockItemRepositoryInterface $stockItemRepository
  90. * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  91. * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  92. * @param array $data
  93. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  94. */
  95. public function __construct(
  96. \Magento\Framework\Model\Context $context,
  97. \Magento\Framework\Registry $registry,
  98. ExtensionAttributesFactory $extensionFactory,
  99. AttributeValueFactory $customAttributeFactory,
  100. \Magento\Customer\Model\Session $customerSession,
  101. \Magento\Store\Model\StoreManagerInterface $storeManager,
  102. StockConfigurationInterface $stockConfiguration,
  103. StockRegistryInterface $stockRegistry,
  104. StockItemRepositoryInterface $stockItemRepository,
  105. \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
  106. \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
  107. array $data = []
  108. ) {
  109. parent::__construct(
  110. $context,
  111. $registry,
  112. $extensionFactory,
  113. $customAttributeFactory,
  114. $resource,
  115. $resourceCollection,
  116. $data
  117. );
  118. $this->customerSession = $customerSession;
  119. $this->storeManager = $storeManager;
  120. $this->stockConfiguration = $stockConfiguration;
  121. $this->stockRegistry = $stockRegistry;
  122. $this->stockItemRepository = $stockItemRepository;
  123. }
  124. /**
  125. * Initialize resource model
  126. *
  127. * @return void
  128. */
  129. protected function _construct()
  130. {
  131. $this->_init(\Magento\CatalogInventory\Model\ResourceModel\Stock\Item::class);
  132. }
  133. /**
  134. * @return int|null
  135. */
  136. public function getItemId()
  137. {
  138. return $this->_getData(static::ITEM_ID);
  139. }
  140. /**
  141. * Retrieve Website Id
  142. *
  143. * @return int
  144. */
  145. public function getWebsiteId()
  146. {
  147. $websiteId = $this->getData(static::WEBSITE_ID);
  148. if ($websiteId === null) {
  149. $websiteId = $this->stockConfiguration->getDefaultScopeId();
  150. }
  151. return (int) $websiteId;
  152. }
  153. /**
  154. * Retrieve stock identifier
  155. *
  156. * @return int
  157. */
  158. public function getStockId()
  159. {
  160. $stockId = $this->getData(static::STOCK_ID);
  161. if ($stockId === null) {
  162. $stockId = $this->stockRegistry->getStock($this->getWebsiteId())->getStockId();
  163. }
  164. return (int) $stockId;
  165. }
  166. /**
  167. * Retrieve Product Id
  168. *
  169. * @return int
  170. */
  171. public function getProductId()
  172. {
  173. return (int) $this->_getData(static::PRODUCT_ID);
  174. }
  175. /**
  176. * @return bool
  177. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  178. */
  179. public function getStockStatusChangedAuto()
  180. {
  181. return (bool) $this->_getData(static::STOCK_STATUS_CHANGED_AUTO);
  182. }
  183. /**
  184. * @return float
  185. */
  186. public function getQty()
  187. {
  188. return null === $this->_getData(static::QTY) ? null : (float)$this->_getData(static::QTY);
  189. }
  190. /**
  191. * Retrieve Stock Availability
  192. *
  193. * @return bool|int
  194. */
  195. public function getIsInStock()
  196. {
  197. if (!$this->getManageStock()) {
  198. return true;
  199. }
  200. return (bool) $this->_getData(static::IS_IN_STOCK);
  201. }
  202. /**
  203. * @return bool
  204. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  205. */
  206. public function getIsQtyDecimal()
  207. {
  208. return (bool) $this->_getData(static::IS_QTY_DECIMAL);
  209. }
  210. /**
  211. * @return bool
  212. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  213. */
  214. public function getIsDecimalDivided()
  215. {
  216. return (bool) $this->_getData(static::IS_DECIMAL_DIVIDED);
  217. }
  218. /**
  219. * @return string Timestamp
  220. */
  221. public function getLowStockDate()
  222. {
  223. return $this->_getData(static::LOW_STOCK_DATE);
  224. }
  225. /**
  226. * Check if notification message should be added despite of backorders notification flag
  227. *
  228. * @return bool
  229. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  230. */
  231. public function getShowDefaultNotificationMessage()
  232. {
  233. return false;
  234. }
  235. /**
  236. * @return bool
  237. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  238. */
  239. public function getUseConfigMinQty()
  240. {
  241. return (bool) $this->_getData(static::USE_CONFIG_MIN_QTY);
  242. }
  243. /**
  244. * Retrieve minimal quantity available for item status in stock
  245. *
  246. * @return float
  247. */
  248. public function getMinQty()
  249. {
  250. if ($this->getUseConfigMinQty()) {
  251. $minQty = $this->stockConfiguration->getMinQty($this->getStoreId());
  252. } else {
  253. $minQty = (float)$this->getData(static::MIN_QTY);
  254. }
  255. return $minQty;
  256. }
  257. /**
  258. * @return bool
  259. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  260. */
  261. public function getUseConfigMinSaleQty()
  262. {
  263. return (bool) $this->_getData(static::USE_CONFIG_MIN_SALE_QTY);
  264. }
  265. /**
  266. * Retrieve Minimum Qty Allowed in Shopping Cart or NULL when there is no limitation
  267. *
  268. * @return float
  269. */
  270. public function getMinSaleQty()
  271. {
  272. if ($this->getUseConfigMinSaleQty()) {
  273. $customerGroupId = $this->getCustomerGroupId();
  274. $minSaleQty = $this->stockConfiguration->getMinSaleQty($this->getStoreId(), $customerGroupId);
  275. } else {
  276. $minSaleQty = (float) $this->getData(static::MIN_SALE_QTY);
  277. }
  278. return $minSaleQty;
  279. }
  280. /**
  281. * @return bool
  282. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  283. */
  284. public function getUseConfigMaxSaleQty()
  285. {
  286. return (bool) $this->_getData(static::USE_CONFIG_MAX_SALE_QTY);
  287. }
  288. /**
  289. * Retrieve Maximum Qty Allowed in Shopping Cart data wrapper
  290. *
  291. * @return float
  292. */
  293. public function getMaxSaleQty()
  294. {
  295. if ($this->getUseConfigMaxSaleQty()) {
  296. $customerGroupId = $this->getCustomerGroupId();
  297. $maxSaleQty = $this->stockConfiguration->getMaxSaleQty($this->getStoreId(), $customerGroupId);
  298. } else {
  299. $maxSaleQty = (float) $this->getData(static::MAX_SALE_QTY);
  300. }
  301. return $maxSaleQty;
  302. }
  303. /**
  304. * @return bool
  305. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  306. */
  307. public function getUseConfigNotifyStockQty()
  308. {
  309. return (bool) $this->_getData(static::USE_CONFIG_NOTIFY_STOCK_QTY);
  310. }
  311. /**
  312. * Retrieve Notify for Quantity Below data wrapper
  313. *
  314. * @return float
  315. */
  316. public function getNotifyStockQty()
  317. {
  318. if ($this->getUseConfigNotifyStockQty()) {
  319. return $this->stockConfiguration->getNotifyStockQty($this->getStoreId());
  320. }
  321. return (float) $this->getData(static::NOTIFY_STOCK_QTY);
  322. }
  323. /**
  324. * @return bool
  325. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  326. */
  327. public function getUseConfigEnableQtyInc()
  328. {
  329. return (bool) $this->_getData(static::USE_CONFIG_ENABLE_QTY_INC);
  330. }
  331. /**
  332. * Retrieve whether Quantity Increments is enabled
  333. *
  334. * @return bool
  335. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  336. */
  337. public function getEnableQtyIncrements()
  338. {
  339. if ($this->getUseConfigEnableQtyInc()) {
  340. return $this->stockConfiguration->getEnableQtyIncrements($this->getStoreId());
  341. }
  342. return (bool) $this->getData(static::ENABLE_QTY_INCREMENTS);
  343. }
  344. /**
  345. * Retrieve whether config for Quantity Increments should be used
  346. *
  347. * @return bool
  348. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  349. */
  350. public function getUseConfigQtyIncrements()
  351. {
  352. return (bool) $this->_getData(static::USE_CONFIG_QTY_INCREMENTS);
  353. }
  354. /**
  355. * Retrieve Quantity Increments
  356. *
  357. * @return int|float|false
  358. */
  359. public function getQtyIncrements()
  360. {
  361. if ($this->qtyIncrements === null) {
  362. if ($this->getEnableQtyIncrements()) {
  363. if ($this->getUseConfigQtyIncrements()) {
  364. $this->qtyIncrements = $this->stockConfiguration->getQtyIncrements($this->getStoreId());
  365. } else {
  366. $this->qtyIncrements = $this->getData(static::QTY_INCREMENTS);
  367. }
  368. if ($this->getIsQtyDecimal()) { // Cast accordingly to decimal qty usage
  369. $this->qtyIncrements = (float) $this->qtyIncrements;
  370. } else {
  371. $this->qtyIncrements = (int) $this->qtyIncrements;
  372. }
  373. }
  374. if ($this->qtyIncrements <= 0) {
  375. $this->qtyIncrements = false;
  376. }
  377. }
  378. return $this->qtyIncrements;
  379. }
  380. /**
  381. * @return bool
  382. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  383. */
  384. public function getUseConfigBackorders()
  385. {
  386. return (bool) $this->_getData(static::USE_CONFIG_BACKORDERS);
  387. }
  388. /**
  389. * Retrieve backorders status
  390. *
  391. * @return int
  392. */
  393. public function getBackorders()
  394. {
  395. if ($this->getUseConfigBackorders()) {
  396. return $this->stockConfiguration->getBackorders($this->getStoreId());
  397. }
  398. return (int) $this->getData(static::BACKORDERS);
  399. }
  400. /**
  401. * @return bool
  402. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  403. */
  404. public function getUseConfigManageStock()
  405. {
  406. return (bool) $this->_getData(static::USE_CONFIG_MANAGE_STOCK);
  407. }
  408. /**
  409. * Retrieve can Manage Stock
  410. *
  411. * @return int
  412. */
  413. public function getManageStock()
  414. {
  415. if ($this->getUseConfigManageStock()) {
  416. return $this->stockConfiguration->getManageStock($this->getStoreId());
  417. }
  418. return (int) $this->getData(static::MANAGE_STOCK);
  419. }
  420. /**
  421. * Add error to Quote Item
  422. *
  423. * @param \Magento\Quote\Model\Quote\Item $item
  424. * @param string $itemError
  425. * @param string $quoteError
  426. * @param string $errorIndex
  427. * @return $this
  428. */
  429. protected function _addQuoteItemError(
  430. \Magento\Quote\Model\Quote\Item $item,
  431. $itemError,
  432. $quoteError,
  433. $errorIndex = 'error'
  434. ) {
  435. $item->setHasError(true);
  436. $item->setMessage($itemError);
  437. $item->setQuoteMessage($quoteError);
  438. $item->setQuoteMessageIndex($errorIndex);
  439. return $this;
  440. }
  441. /**
  442. * Save object data
  443. *
  444. * @return $this
  445. * @throws \Exception
  446. */
  447. public function save()
  448. {
  449. $this->stockItemRepository->save($this);
  450. return $this;
  451. }
  452. /**
  453. * Add product data to stock item
  454. *
  455. * @param Product $product
  456. * @return $this
  457. */
  458. public function setProduct(Product $product)
  459. {
  460. $this->setProductId($product->getId())
  461. ->setStoreId($product->getStoreId())
  462. ->setProductTypeId($product->getTypeId())
  463. ->setProductName($product->getName())
  464. ->setProductStatusChanged($product->dataHasChangedFor('status'))
  465. ->setProductChangedWebsites($product->getIsChangedWebsites());
  466. return $this;
  467. }
  468. /**
  469. * Setter for store id
  470. *
  471. * @param int $value Value of store id
  472. * @return $this
  473. */
  474. public function setStoreId($value)
  475. {
  476. $this->storeId = $value;
  477. return $this;
  478. }
  479. /**
  480. * Retrieve Store Id (product or current)
  481. *
  482. * @return int
  483. */
  484. public function getStoreId()
  485. {
  486. if ($this->storeId === null) {
  487. $this->storeId = $this->storeManager->getStore()->getId();
  488. }
  489. return $this->storeId;
  490. }
  491. /**
  492. * Getter for customer group id, return current customer group if not set
  493. *
  494. * @return int
  495. */
  496. public function getCustomerGroupId()
  497. {
  498. if ($this->customerGroupId === null) {
  499. return $this->customerSession->getCustomerGroupId();
  500. }
  501. return $this->customerGroupId;
  502. }
  503. /**
  504. * Setter for customer group id
  505. *
  506. * @param int $value Value of customer group id
  507. * @return $this
  508. */
  509. public function setCustomerGroupId($value)
  510. {
  511. $this->customerGroupId = $value;
  512. return $this;
  513. }
  514. //@codeCoverageIgnoreStart
  515. /**
  516. * @param int $itemId
  517. * @return $this
  518. */
  519. public function setItemId($itemId)
  520. {
  521. return $this->setData(self::ITEM_ID, $itemId);
  522. }
  523. /**
  524. * @param int $productId
  525. * @return $this
  526. */
  527. public function setProductId($productId)
  528. {
  529. return $this->setData(self::PRODUCT_ID, $productId);
  530. }
  531. /**
  532. * Set Website Id
  533. *
  534. * @param int $websiteId
  535. * @return $this
  536. */
  537. public function setWebsiteId($websiteId)
  538. {
  539. return $this->setData(self::WEBSITE_ID, $websiteId);
  540. }
  541. /**
  542. * Set stock identifier
  543. *
  544. * @param int $stockId
  545. * @return $this
  546. */
  547. public function setStockId($stockId)
  548. {
  549. return $this->setData(self::STOCK_ID, $stockId);
  550. }
  551. /**
  552. * @param float $qty
  553. * @return $this
  554. */
  555. public function setQty($qty)
  556. {
  557. return $this->setData(self::QTY, $qty);
  558. }
  559. /**
  560. * Set Stock Availability
  561. *
  562. * @param bool|int $isInStock
  563. * @return $this
  564. */
  565. public function setIsInStock($isInStock)
  566. {
  567. return $this->setData(self::IS_IN_STOCK, $isInStock);
  568. }
  569. /**
  570. * @param bool $isQtyDecimal
  571. * @return $this
  572. */
  573. public function setIsQtyDecimal($isQtyDecimal)
  574. {
  575. return $this->setData(self::IS_QTY_DECIMAL, $isQtyDecimal);
  576. }
  577. /**
  578. * @param bool $useConfigMinQty
  579. * @return $this
  580. */
  581. public function setUseConfigMinQty($useConfigMinQty)
  582. {
  583. return $this->setData(self::USE_CONFIG_MIN_QTY, $useConfigMinQty);
  584. }
  585. /**
  586. * Set minimal quantity available for item status in stock
  587. *
  588. * @param float $minQty
  589. * @return $this
  590. */
  591. public function setMinQty($minQty)
  592. {
  593. return $this->setData(self::MIN_QTY, $minQty);
  594. }
  595. /**
  596. * @param int $useConfigMinSaleQty
  597. * @return $this
  598. */
  599. public function setUseConfigMinSaleQty($useConfigMinSaleQty)
  600. {
  601. return $this->setData(self::USE_CONFIG_MIN_SALE_QTY, $useConfigMinSaleQty);
  602. }
  603. /**
  604. * Set Minimum Qty Allowed in Shopping Cart or NULL when there is no limitation
  605. *
  606. * @param float $minSaleQty
  607. * @return $this
  608. */
  609. public function setMinSaleQty($minSaleQty)
  610. {
  611. return $this->setData(self::MIN_SALE_QTY, $minSaleQty);
  612. }
  613. /**
  614. * @param bool $useConfigMaxSaleQty
  615. * @return $this
  616. */
  617. public function setUseConfigMaxSaleQty($useConfigMaxSaleQty)
  618. {
  619. return $this->setData(self::USE_CONFIG_MAX_SALE_QTY, $useConfigMaxSaleQty);
  620. }
  621. /**
  622. * Set Maximum Qty Allowed in Shopping Cart data wrapper
  623. *
  624. * @param float $maxSaleQty
  625. * @return $this
  626. */
  627. public function setMaxSaleQty($maxSaleQty)
  628. {
  629. return $this->setData(self::MAX_SALE_QTY, $maxSaleQty);
  630. }
  631. /**
  632. * @param bool $useConfigBackorders
  633. * @return $this
  634. */
  635. public function setUseConfigBackorders($useConfigBackorders)
  636. {
  637. return $this->setData(self::USE_CONFIG_BACKORDERS, $useConfigBackorders);
  638. }
  639. /**
  640. * Set backOrders status
  641. *
  642. * @param int $backOrders
  643. * @return $this
  644. */
  645. public function setBackorders($backOrders)
  646. {
  647. return $this->setData(self::BACKORDERS, $backOrders);
  648. }
  649. /**
  650. * @param bool $useConfigNotifyStockQty
  651. * @return $this
  652. */
  653. public function setUseConfigNotifyStockQty($useConfigNotifyStockQty)
  654. {
  655. return $this->setData(self::USE_CONFIG_NOTIFY_STOCK_QTY, $useConfigNotifyStockQty);
  656. }
  657. /**
  658. * Set Notify for Quantity Below data wrapper
  659. *
  660. * @param float $notifyStockQty
  661. * @return $this
  662. */
  663. public function setNotifyStockQty($notifyStockQty)
  664. {
  665. return $this->setData(self::NOTIFY_STOCK_QTY, $notifyStockQty);
  666. }
  667. /**
  668. * @param bool $useConfigQtyIncrements
  669. * @return $this
  670. */
  671. public function setUseConfigQtyIncrements($useConfigQtyIncrements)
  672. {
  673. return $this->setData(self::USE_CONFIG_QTY_INCREMENTS, $useConfigQtyIncrements);
  674. }
  675. /**
  676. * Set Quantity Increments data wrapper
  677. *
  678. * @param float $qtyIncrements
  679. * @return $this
  680. */
  681. public function setQtyIncrements($qtyIncrements)
  682. {
  683. return $this->setData(self::QTY_INCREMENTS, $qtyIncrements);
  684. }
  685. /**
  686. * @param bool $useConfigEnableQtyInc
  687. * @return $this
  688. */
  689. public function setUseConfigEnableQtyInc($useConfigEnableQtyInc)
  690. {
  691. return $this->setData(self::USE_CONFIG_ENABLE_QTY_INC, $useConfigEnableQtyInc);
  692. }
  693. /**
  694. * Set whether Quantity Increments is enabled
  695. *
  696. * @param bool $enableQtyIncrements
  697. * @return $this
  698. */
  699. public function setEnableQtyIncrements($enableQtyIncrements)
  700. {
  701. return $this->setData(self::ENABLE_QTY_INCREMENTS, $enableQtyIncrements);
  702. }
  703. /**
  704. * @param bool $useConfigManageStock
  705. * @return $this
  706. */
  707. public function setUseConfigManageStock($useConfigManageStock)
  708. {
  709. return $this->setData(self::USE_CONFIG_MANAGE_STOCK, $useConfigManageStock);
  710. }
  711. /**
  712. * @param bool $manageStock
  713. * @return $this
  714. */
  715. public function setManageStock($manageStock)
  716. {
  717. return $this->setData(self::MANAGE_STOCK, $manageStock);
  718. }
  719. /**
  720. * @param string $lowStockDate
  721. * @return $this
  722. */
  723. public function setLowStockDate($lowStockDate)
  724. {
  725. return $this->setData(self::LOW_STOCK_DATE, $lowStockDate);
  726. }
  727. /**
  728. * @param bool $isDecimalDivided
  729. * @return $this
  730. */
  731. public function setIsDecimalDivided($isDecimalDivided)
  732. {
  733. return $this->setData(self::IS_DECIMAL_DIVIDED, $isDecimalDivided);
  734. }
  735. /**
  736. * @param int $stockStatusChangedAuto
  737. * @return $this
  738. */
  739. public function setStockStatusChangedAuto($stockStatusChangedAuto)
  740. {
  741. return $this->setData(self::STOCK_STATUS_CHANGED_AUTO, $stockStatusChangedAuto);
  742. }
  743. /**
  744. * {@inheritdoc}
  745. *
  746. * @return \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface|null
  747. */
  748. public function getExtensionAttributes()
  749. {
  750. return $this->_getExtensionAttributes();
  751. }
  752. /**
  753. * {@inheritdoc}
  754. *
  755. * @param \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface $extensionAttributes
  756. * @return $this
  757. */
  758. public function setExtensionAttributes(
  759. \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface $extensionAttributes
  760. ) {
  761. return $this->_setExtensionAttributes($extensionAttributes);
  762. }
  763. //@codeCoverageIgnoreEnd
  764. }