Price.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ProductAlert\Model;
  7. use Magento\ProductAlert\Model\ResourceModel\Price\Customer\Collection;
  8. /**
  9. * ProductAlert for changed price model
  10. *
  11. * @method int getCustomerId()
  12. * @method \Magento\ProductAlert\Model\Price setCustomerId(int $value)
  13. * @method int getProductId()
  14. * @method \Magento\ProductAlert\Model\Price setProductId(int $value)
  15. * @method float getPrice()
  16. * @method \Magento\ProductAlert\Model\Price setPrice(float $value)
  17. * @method int getWebsiteId()
  18. * @method \Magento\ProductAlert\Model\Price setWebsiteId(int $value)
  19. * @method string getAddDate()
  20. * @method \Magento\ProductAlert\Model\Price setAddDate(string $value)
  21. * @method string getLastSendDate()
  22. * @method \Magento\ProductAlert\Model\Price setLastSendDate(string $value)
  23. * @method int getSendCount()
  24. * @method \Magento\ProductAlert\Model\Price setSendCount(int $value)
  25. * @method int getStatus()
  26. * @method \Magento\ProductAlert\Model\Price setStatus(int $value)
  27. * @method int getStoreId()
  28. * @method \Magento\ProductAlert\Model\Stock setStoreId(int $value)
  29. *
  30. * @author Magento Core Team <core@magentocommerce.com>
  31. *
  32. * @api
  33. * @since 100.0.2
  34. */
  35. class Price extends \Magento\Framework\Model\AbstractModel
  36. {
  37. /**
  38. * @var \Magento\ProductAlert\Model\ResourceModel\Price\Customer\CollectionFactory
  39. */
  40. protected $_customerColFactory;
  41. /**
  42. * @param \Magento\Framework\Model\Context $context
  43. * @param \Magento\Framework\Registry $registry
  44. * @param \Magento\ProductAlert\Model\ResourceModel\Price\Customer\CollectionFactory $customerColFactory
  45. * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  46. * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  47. * @param array $data
  48. */
  49. public function __construct(
  50. \Magento\Framework\Model\Context $context,
  51. \Magento\Framework\Registry $registry,
  52. \Magento\ProductAlert\Model\ResourceModel\Price\Customer\CollectionFactory $customerColFactory,
  53. \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
  54. \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
  55. array $data = []
  56. ) {
  57. $this->_customerColFactory = $customerColFactory;
  58. parent::__construct($context, $registry, $resource, $resourceCollection, $data);
  59. }
  60. /**
  61. * Create customer collection.
  62. *
  63. * @return void
  64. */
  65. protected function _construct()
  66. {
  67. $this->_init(\Magento\ProductAlert\Model\ResourceModel\Price::class);
  68. }
  69. /**
  70. * Create customer collection.
  71. *
  72. * @return Collection
  73. */
  74. public function getCustomerCollection()
  75. {
  76. return $this->_customerColFactory->create();
  77. }
  78. /**
  79. * Load by param.
  80. *
  81. * @return $this
  82. */
  83. public function loadByParam()
  84. {
  85. if ($this->getProductId() !== null && $this->getCustomerId() !== null && $this->getWebsiteId() !== null) {
  86. $this->getResource()->loadByParam($this);
  87. }
  88. return $this;
  89. }
  90. /**
  91. * Method for deleting customer from website.
  92. *
  93. * @param int $customerId
  94. * @param int $websiteId
  95. * @return $this
  96. */
  97. public function deleteCustomer($customerId, $websiteId = 0)
  98. {
  99. $this->getResource()->deleteCustomer($this, $customerId, $websiteId);
  100. return $this;
  101. }
  102. }