Option.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Eav\Model\Entity\Attribute;
  7. use Magento\Eav\Api\Data\AttributeOptionInterface;
  8. use Magento\Framework\Model\AbstractModel;
  9. /**
  10. * Entity attribute option model
  11. *
  12. * @method int getAttributeId()
  13. * @method \Magento\Eav\Model\Entity\Attribute\Option setAttributeId(int $value)
  14. *
  15. * @api
  16. * @codeCoverageIgnore
  17. * @since 100.0.2
  18. */
  19. class Option extends AbstractModel implements AttributeOptionInterface
  20. {
  21. /**
  22. * Resource initialization
  23. *
  24. * @return void
  25. */
  26. public function _construct()
  27. {
  28. $this->_init(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option::class);
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function getLabel()
  34. {
  35. return $this->getData(AttributeOptionInterface::LABEL);
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function getValue()
  41. {
  42. return $this->getData(AttributeOptionInterface::VALUE);
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function getSortOrder()
  48. {
  49. return $this->getData(AttributeOptionInterface::SORT_ORDER);
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function getIsDefault()
  55. {
  56. return $this->getData(AttributeOptionInterface::IS_DEFAULT);
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function getStoreLabels()
  62. {
  63. return $this->getData(AttributeOptionInterface::STORE_LABELS);
  64. }
  65. /**
  66. * Set option label
  67. *
  68. * @param string $label
  69. * @return $this
  70. */
  71. public function setLabel($label)
  72. {
  73. return $this->setData(AttributeOptionInterface::LABEL, $label);
  74. }
  75. /**
  76. * Set option value
  77. *
  78. * @param string $value
  79. * @return string
  80. */
  81. public function setValue($value)
  82. {
  83. return $this->setData(AttributeOptionInterface::VALUE, $value);
  84. }
  85. /**
  86. * Set option order
  87. *
  88. * @param int $sortOrder
  89. * @return $this
  90. */
  91. public function setSortOrder($sortOrder)
  92. {
  93. return $this->setData(AttributeOptionInterface::SORT_ORDER, $sortOrder);
  94. }
  95. /**
  96. * set is default
  97. *
  98. * @param bool $isDefault
  99. * @return $this
  100. */
  101. public function setIsDefault($isDefault)
  102. {
  103. return $this->setData(AttributeOptionInterface::IS_DEFAULT, $isDefault);
  104. }
  105. /**
  106. * Set option label for store scopes
  107. *
  108. * @param \Magento\Eav\Api\Data\AttributeOptionLabelInterface[] $storeLabels
  109. * @return $this
  110. */
  111. public function setStoreLabels(array $storeLabels = null)
  112. {
  113. return $this->setData(AttributeOptionInterface::STORE_LABELS, $storeLabels);
  114. }
  115. }