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