Link.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Bundle\Model;
  8. /**
  9. * Class Link
  10. * @codeCoverageIgnore
  11. */
  12. class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements
  13. \Magento\Bundle\Api\Data\LinkInterface
  14. {
  15. /**#@+
  16. * Constants
  17. */
  18. const KEY_ID = 'id';
  19. const KEY_SKU = 'sku';
  20. const KEY_OPTION_ID = 'option_id';
  21. const KEY_QTY = 'qty';
  22. const KEY_POSITION = 'position';
  23. const KEY_IS_DEFAULT = 'is_default';
  24. const KEY_PRICE = 'price';
  25. const KEY_PRICE_TYPE = 'price_type';
  26. const KEY_CAN_CHANGE_QUANTITY = 'selection_can_change_quantity';
  27. /**#@-*/
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function getId()
  32. {
  33. return $this->getData(self::KEY_ID);
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function setId($id)
  39. {
  40. return $this->setData(self::KEY_ID, $id);
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function getSku()
  46. {
  47. return $this->getData(self::KEY_SKU);
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function getOptionId()
  53. {
  54. return $this->getData(self::KEY_OPTION_ID);
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function getQty()
  60. {
  61. return $this->getData(self::KEY_QTY);
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. public function getPosition()
  67. {
  68. return $this->getData(self::KEY_POSITION);
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function getIsDefault()
  74. {
  75. return $this->getData(self::KEY_IS_DEFAULT);
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function getPrice()
  81. {
  82. return $this->getData(self::KEY_PRICE);
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public function getPriceType()
  88. {
  89. return $this->getData(self::KEY_PRICE_TYPE);
  90. }
  91. /**
  92. * {@inheritdoc}
  93. */
  94. public function getCanChangeQuantity()
  95. {
  96. return $this->getData(self::KEY_CAN_CHANGE_QUANTITY);
  97. }
  98. /**
  99. * Set linked product sku
  100. *
  101. * @param string $sku
  102. * @return $this
  103. */
  104. public function setSku($sku)
  105. {
  106. return $this->setData(self::KEY_SKU, $sku);
  107. }
  108. /**
  109. * Set option id
  110. *
  111. * @param int $optionId
  112. * @return $this
  113. */
  114. public function setOptionId($optionId)
  115. {
  116. return $this->setData(self::KEY_OPTION_ID, $optionId);
  117. }
  118. /**
  119. * Set qty
  120. *
  121. * @param float $qty
  122. * @return $this
  123. */
  124. public function setQty($qty)
  125. {
  126. return $this->setData(self::KEY_QTY, $qty);
  127. }
  128. /**
  129. * Set position
  130. *
  131. * @param int $position
  132. * @return $this
  133. */
  134. public function setPosition($position)
  135. {
  136. return $this->setData(self::KEY_POSITION, $position);
  137. }
  138. /**
  139. * Set is default
  140. *
  141. * @param bool $isDefault
  142. * @return $this
  143. */
  144. public function setIsDefault($isDefault)
  145. {
  146. return $this->setData(self::KEY_IS_DEFAULT, $isDefault);
  147. }
  148. /**
  149. * Set price
  150. *
  151. * @param float $price
  152. * @return $this
  153. */
  154. public function setPrice($price)
  155. {
  156. return $this->setData(self::KEY_PRICE, $price);
  157. }
  158. /**
  159. * Set price type
  160. *
  161. * @param int $priceType
  162. * @return $this
  163. */
  164. public function setPriceType($priceType)
  165. {
  166. return $this->setData(self::KEY_PRICE_TYPE, $priceType);
  167. }
  168. /**
  169. * Set whether quantity could be changed
  170. *
  171. * @param int $canChangeQuantity
  172. * @return $this
  173. */
  174. public function setCanChangeQuantity($canChangeQuantity)
  175. {
  176. return $this->setData(self::KEY_CAN_CHANGE_QUANTITY, $canChangeQuantity);
  177. }
  178. /**
  179. * {@inheritdoc}
  180. *
  181. * @return \Magento\Bundle\Api\Data\LinkExtensionInterface|null
  182. */
  183. public function getExtensionAttributes()
  184. {
  185. return $this->_getExtensionAttributes();
  186. }
  187. /**
  188. * {@inheritdoc}
  189. *
  190. * @param \Magento\Bundle\Api\Data\LinkExtensionInterface $extensionAttributes
  191. * @return $this
  192. */
  193. public function setExtensionAttributes(\Magento\Bundle\Api\Data\LinkExtensionInterface $extensionAttributes)
  194. {
  195. return $this->_setExtensionAttributes($extensionAttributes);
  196. }
  197. }