Item.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace Dotdigitalgroup\Email\Model\Customer\Wishlist;
  3. /**
  4. * Wishlist product item to sync.
  5. *
  6. */
  7. class Item
  8. {
  9. /**
  10. * @var string
  11. */
  12. public $sku;
  13. /**
  14. * @var string
  15. */
  16. public $qty;
  17. /**
  18. * @var string
  19. */
  20. public $name;
  21. /**
  22. * @var float
  23. */
  24. public $price;
  25. /**
  26. * @var float
  27. */
  28. public $totalValueOfProduct;
  29. /**
  30. * @param \Magento\Catalog\Model\Product $product
  31. *
  32. * @return $this
  33. */
  34. public function setProduct($product)
  35. {
  36. $this->setSku($product->getSku());
  37. $this->setName($product->getName());
  38. return $this;
  39. }
  40. /**
  41. * @param string $name
  42. *
  43. * @return $this
  44. */
  45. public function setName($name)
  46. {
  47. $this->name = $name;
  48. return $this;
  49. }
  50. /**
  51. * @return string
  52. */
  53. public function getName()
  54. {
  55. return $this->name;
  56. }
  57. /**
  58. * @param float $qty
  59. *
  60. * @return $this
  61. */
  62. public function setQty($qty)
  63. {
  64. $this->qty = (int)$qty;
  65. return $this;
  66. }
  67. /**
  68. * @return float
  69. */
  70. public function getQty()
  71. {
  72. return $this->qty;
  73. }
  74. /**
  75. * @return float
  76. */
  77. public function getTotalValueOfProduct()
  78. {
  79. return $this->totalValueOfProduct;
  80. }
  81. /**
  82. * @param \Magento\Catalog\Model\Product $product
  83. *
  84. * @return $this
  85. */
  86. public function setPrice($product)
  87. {
  88. $this->price = (float)number_format($product->getFinalPrice(), 2, '.', '');
  89. $total = $this->price * $this->qty;
  90. $this->totalValueOfProduct = (float)number_format($total, 2, '.', '');
  91. return $this;
  92. }
  93. /**
  94. * @return float
  95. */
  96. public function getPrice()
  97. {
  98. return $this->price;
  99. }
  100. /**
  101. * @param string $sku
  102. *
  103. * @return $this
  104. */
  105. public function setSku($sku)
  106. {
  107. $this->sku = $sku;
  108. return $this;
  109. }
  110. /**
  111. * @return string
  112. */
  113. public function getSku()
  114. {
  115. return $this->sku;
  116. }
  117. /**
  118. * @return array
  119. */
  120. public function expose()
  121. {
  122. return get_object_vars($this);
  123. }
  124. }