/
Default.php
165 lines (131 loc) · 3.25 KB
/
Default.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
/**
* @copyright Copyright (c) Metaways Infosystems GmbH, 2011
* @license LGPLv3, http://www.arcavias.com/en/license
* @package MShop
* @subpackage Product
*/
/**
* Default product stock item implementation.
*
* @package MShop
* @subpackage Product
*/
class MShop_Product_Item_Stock_Default
extends MShop_Common_Item_Abstract
implements MShop_Product_Item_Stock_Interface
{
private $_values;
/**
* Initializes the stock item object with the given values
*/
public function __construct( array $values = array( ) )
{
parent::__construct('product.stock.', $values);
$this->_values = $values;
}
/**
* Returns the product Id.
*
* @return integer Product Id
*/
public function getProductId()
{
return ( isset( $this->_values['prodid'] ) ? (int) $this->_values['prodid'] : null );
}
/**
* Sets the Product Id.
*
* @param integer $prodid New product Id
*/
public function setProductId( $prodid )
{
if ( $prodid == $this->getProductId() ) { return; }
$this->_values['prodid'] = (int) $prodid;
$this->setModified();
}
/**
* Returns the warehouse Id.
*
* @return integer Warehouse Id
*/
public function getWarehouseId()
{
return ( isset( $this->_values['warehouseid'] ) ? (int) $this->_values['warehouseid'] : null );
}
/**
* Sets the warehouse Id.
*
* @param integer|null $warehouseid New warehouse Id
*/
public function setWarehouseId( $warehouseid )
{
if ( $warehouseid === $this->getWarehouseId() ) { return; }
if ( $warehouseid !== null ) {
$warehouseid = (int) $warehouseid;
}
$this->_values['warehouseid'] = $warehouseid;
$this->setModified();
}
/**
* Returns the stock level.
*
* @return integer Stock level
*/
public function getStocklevel()
{
return ( isset( $this->_values['stocklevel'] ) ? (int) $this->_values['stocklevel'] : null );
}
/**
* Sets the stock level.
*
* @param integer|null $stocklevel New stock level
*/
public function setStocklevel( $stocklevel )
{
if ( $stocklevel === $this->getStocklevel() ) { return; }
if ( $stocklevel !== null ) {
$stocklevel = (int) $stocklevel;
}
$this->_values['stocklevel'] = $stocklevel;
$this->setModified();
}
/**
* Returns the back in stock date of the product.
*
* @return string Back in stock date of the product
*/
public function getDateBack()
{
return ( isset( $this->_values['backdate'] ) ? (string) $this->_values['backdate'] : null );
}
/**
* Sets the product back in stock date.
*
* @param string|null $backdate New back in stock date of the product
*/
public function setDateBack( $backdate )
{
if ( $backdate === $this->getDateBack() ) { return; }
$this->_checkDateFormat($backdate);
if ( $backdate !== null ) {
$backdate = (string) $backdate;
}
$this->_values['backdate'] = $backdate;
$this->setModified();
}
/**
* Returns the item values as array.
*
* @return Associative list of item properties and their values
*/
public function toArray()
{
$list = parent::toArray();
$list['product.stock.productid'] = $this->getProductId();
$list['product.stock.warehouseid'] = $this->getWarehouseId();
$list['product.stock.stocklevel'] = $this->getStocklevel();
$list['product.stock.dateback'] = $this->getDateBack();
return $list;
}
}