-
Notifications
You must be signed in to change notification settings - Fork 63
/
Wishlist.php
executable file
·93 lines (84 loc) · 2.39 KB
/
Wishlist.php
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
<?php
namespace Dotdigitalgroup\Email\Model;
use Dotdigitalgroup\Email\Model\ResourceModel\Wishlist as WishlistResource;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\Model\Context;
use Magento\Framework\Model\ResourceModel\AbstractResource;
use Magento\Framework\Registry;
use Magento\Framework\Stdlib\DateTime;
class Wishlist extends \Magento\Framework\Model\AbstractModel
{
/**
* @var \Magento\Framework\Stdlib\DateTime
*/
private $dateTime;
/**
* @var WishlistResource
*/
private $wishlistResource;
/**
* Wishlist constructor.
*
* @param Context $context
* @param Registry $registry
* @param DateTime $dateTime
* @param WishlistResource $wishlistResource
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Stdlib\DateTime $dateTime,
WishlistResource $wishlistResource,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
$this->dateTime = $dateTime;
$this->wishlistResource = $wishlistResource;
parent::__construct(
$context,
$registry,
$resource,
$resourceCollection,
$data
);
}
/**
* Constructor.
*
* @return void
*/
public function _construct()
{
parent::_construct();
$this->_init(\Dotdigitalgroup\Email\Model\ResourceModel\Wishlist::class);
}
/**
* Prepare data to be saved to database.
*
* @return $this
*/
public function beforeSave()
{
parent::beforeSave();
if ($this->isObjectNew() && !$this->getCreatedAt()) {
$this->setCreatedAt($this->dateTime->formatDate(true));
}
$this->setUpdatedAt($this->dateTime->formatDate(true));
return $this;
}
/**
* Reset.
*
* @param string|null $from
* @param string|null $to
* @return int
*/
public function reset(string $from = null, string $to = null)
{
return $this->wishlistResource->resetWishlists($from, $to);
}
}