SourceItem.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Inventory\Model;
  8. use Magento\Framework\Model\AbstractExtensibleModel;
  9. use Magento\Inventory\Model\ResourceModel\SourceItem as SourceItemResourceModel;
  10. use Magento\InventoryApi\Api\Data\SourceItemExtensionInterface;
  11. use Magento\InventoryApi\Api\Data\SourceItemInterface;
  12. /**
  13. * {@inheritdoc}
  14. *
  15. * @codeCoverageIgnore
  16. */
  17. class SourceItem extends AbstractExtensibleModel implements SourceItemInterface
  18. {
  19. /**
  20. * @inheritdoc
  21. */
  22. protected function _construct()
  23. {
  24. $this->_init(SourceItemResourceModel::class);
  25. }
  26. /**
  27. * @inheritdoc
  28. */
  29. public function getSku(): ?string
  30. {
  31. return $this->getData(self::SKU);
  32. }
  33. /**
  34. * @inheritdoc
  35. */
  36. public function setSku(?string $sku): void
  37. {
  38. $this->setData(self::SKU, $sku);
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function getSourceCode(): ?string
  44. {
  45. return $this->getData(self::SOURCE_CODE);
  46. }
  47. /**
  48. * @inheritdoc
  49. */
  50. public function setSourceCode(?string $sourceCode): void
  51. {
  52. $this->setData(self::SOURCE_CODE, $sourceCode);
  53. }
  54. /**
  55. * @inheritdoc
  56. */
  57. public function getQuantity(): ?float
  58. {
  59. return $this->getData(self::QUANTITY) === null ?
  60. null:
  61. (float)$this->getData(self::QUANTITY);
  62. }
  63. /**
  64. * @inheritdoc
  65. */
  66. public function setQuantity(?float $quantity): void
  67. {
  68. $this->setData(self::QUANTITY, $quantity);
  69. }
  70. /**
  71. * @inheritdoc
  72. */
  73. public function getStatus(): ?int
  74. {
  75. return $this->getData(self::STATUS) === null ?
  76. null:
  77. (int)$this->getData(self::STATUS);
  78. }
  79. /**
  80. * @inheritdoc
  81. */
  82. public function setStatus(?int $status): void
  83. {
  84. $this->setData(self::STATUS, $status);
  85. }
  86. /**
  87. * @inheritdoc
  88. */
  89. public function getExtensionAttributes(): ?SourceItemExtensionInterface
  90. {
  91. $extensionAttributes = $this->_getExtensionAttributes();
  92. if (null === $extensionAttributes) {
  93. $extensionAttributes = $this->extensionAttributesFactory->create(SourceItemInterface::class);
  94. $this->setExtensionAttributes($extensionAttributes);
  95. }
  96. return $extensionAttributes;
  97. }
  98. /**
  99. * @inheritdoc
  100. */
  101. public function setExtensionAttributes(SourceItemExtensionInterface $extensionAttributes): void
  102. {
  103. $this->_setExtensionAttributes($extensionAttributes);
  104. }
  105. }