1 | <?php |
||
35 | class EeBunchSubject extends BunchSubject |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * The row ID of the product that has been created recently. |
||
40 | * |
||
41 | * @var integer |
||
42 | */ |
||
43 | protected $lastRowId; |
||
44 | |||
45 | /** |
||
46 | * The mapping for the SKUs to the created row IDs. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $skuRowIdMapping = array(); |
||
51 | |||
52 | /** |
||
53 | * The mapping for the supported backend types (for the product entity) => persist methods. |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $backendTypes = array( |
||
58 | 'datetime' => array('persistProductDatetimeAttribute', 'loadProductDatetimeAttributeByRowIdAndAttributeIdAndStoreId'), |
||
59 | 'decimal' => array('persistProductDecimalAttribute', 'loadProductDecimalAttributeByRowIdAndAttributeIdAndStoreId'), |
||
60 | 'int' => array('persistProductIntAttribute', 'loadProductIntAttributeByRowIdAndAttributeIdAndStoreId'), |
||
61 | 'text' => array('persistProductTextAttribute', 'loadProductTextAttributeByRowIdAndAttributeIdAndStoreId'), |
||
62 | 'varchar' => array('persistProductVarcharAttribute', 'loadProductVarcharAttributeByRowIdAndAttributeIdAndStoreId') |
||
63 | ); |
||
64 | |||
65 | /** |
||
66 | * Mappings for the table column => CSV column header. |
||
67 | * |
||
68 | * @var array |
||
69 | */ |
||
70 | protected $headerStockMappings = array( |
||
71 | 'qty' => array('qty', 'float'), |
||
72 | 'min_qty' => array('out_of_stock_qty', 'float'), |
||
73 | 'use_config_min_qty' => array('use_config_min_qty', 'int'), |
||
74 | 'is_qty_decimal' => array('is_qty_decimal', 'int'), |
||
75 | 'backorders' => array('allow_backorders', 'int'), |
||
76 | 'use_config_backorders' => array('use_config_backorders', 'int'), |
||
77 | 'min_sale_qty' => array('min_cart_qty', 'float'), |
||
78 | 'use_config_min_sale_qty' => array('use_config_min_sale_qty', 'int'), |
||
79 | 'max_sale_qty' => array('max_cart_qty', 'float'), |
||
80 | 'use_config_max_sale_qty' => array('use_config_max_sale_qty', 'int'), |
||
81 | 'is_in_stock' => array('is_in_stock', 'int'), |
||
82 | 'notify_stock_qty' => array('notify_on_stock_below', 'float'), |
||
83 | 'use_config_notify_stock_qty' => array('use_config_notify_stock_qty', 'int'), |
||
84 | 'manage_stock' => array('manage_stock', 'int'), |
||
85 | 'use_config_manage_stock' => array('use_config_manage_stock', 'int'), |
||
86 | 'use_config_qty_increments' => array('use_config_qty_increments', 'int'), |
||
87 | 'qty_increments' => array('qty_increments', 'float'), |
||
88 | 'use_config_enable_qty_inc' => array('use_config_enable_qty_inc', 'int'), |
||
89 | 'enable_qty_increments' => array('enable_qty_increments', 'int'), |
||
90 | 'is_decimal_divided' => array('is_decimal_divided', 'int'), |
||
91 | 'deferred_stock_update' => array('deferred_stock_update', 'int'), |
||
92 | 'use_config_deferred_stock_update' => array('use_config_deferred_stock_update', 'int'), |
||
93 | ); |
||
94 | |||
95 | /** |
||
96 | * Clean up the global data after importing the bunch. |
||
97 | * |
||
98 | * @return void |
||
99 | */ |
||
100 | public function tearDown() |
||
112 | |||
113 | /** |
||
114 | * Set's the row ID of the product that has been created recently. |
||
115 | * |
||
116 | * @param string $lastRowId The row ID |
||
117 | * |
||
118 | * @return void |
||
119 | */ |
||
120 | public function setLastRowId($lastRowId) |
||
124 | |||
125 | /** |
||
126 | * Return's the row ID of the product that has been created recently. |
||
127 | * |
||
128 | * @return string The row Id |
||
129 | */ |
||
130 | public function getLastRowId() |
||
134 | |||
135 | /** |
||
136 | * Add the passed SKU => row ID mapping. |
||
137 | * |
||
138 | * @param string $sku The SKU |
||
139 | * |
||
140 | * @return void |
||
141 | */ |
||
142 | public function addSkuRowIdMapping($sku) |
||
146 | |||
147 | /** |
||
148 | * Return's the product rows with the passed SKU. |
||
149 | * |
||
150 | * @param string $sku The SKU of the product rows to return |
||
151 | * |
||
152 | * @return array The product rows |
||
153 | */ |
||
154 | public function getProductRowsBySku($sku) |
||
158 | |||
159 | /** |
||
160 | * Return's the next available product entity ID. |
||
161 | * |
||
162 | * @return integer The next available product entity ID |
||
163 | */ |
||
164 | public function nextIdentifier() |
||
168 | |||
169 | /** |
||
170 | * Load's and return's the product with the passed SKU and timestamp. |
||
171 | * |
||
172 | * @param string $sku The SKU of the product to return |
||
173 | * @param integer $timestamp The timestamp to find the matching scheduled update |
||
174 | * |
||
175 | * @return array The product |
||
176 | */ |
||
177 | public function loadProductBySkuAndTimestamp($sku, $timestamp) |
||
181 | |||
182 | /** |
||
183 | * Load's and return's the datetime attribute with the passed row/attribute/store ID. |
||
184 | * |
||
185 | * @param integer $row The row ID of the attribute |
||
186 | * @param integer $attributeId The attribute ID of the attribute |
||
187 | * @param integer $storeId The store ID of the attribute |
||
188 | * |
||
189 | * @return array|null The datetime attribute |
||
190 | */ |
||
191 | public function loadProductDatetimeAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
195 | |||
196 | /** |
||
197 | * Load's and return's the decimal attribute with the passed row/attribute/store ID. |
||
198 | * |
||
199 | * @param integer $row The row ID of the attribute |
||
200 | * @param integer $attributeId The attribute ID of the attribute |
||
201 | * @param integer $storeId The store ID of the attribute |
||
202 | * |
||
203 | * @return array|null The decimal attribute |
||
204 | */ |
||
205 | public function loadProductDecimalAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
209 | |||
210 | /** |
||
211 | * Load's and return's the integer attribute with the passed row/attribute/store ID. |
||
212 | * |
||
213 | * @param integer $row The row ID of the attribute |
||
214 | * @param integer $attributeId The attribute ID of the attribute |
||
215 | * @param integer $storeId The store ID of the attribute |
||
216 | * |
||
217 | * @return array|null The integer attribute |
||
218 | */ |
||
219 | public function loadProductIntAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
223 | |||
224 | /** |
||
225 | * Load's and return's the text attribute with the passed row/attribute/store ID. |
||
226 | * |
||
227 | * @param integer $row The row ID of the attribute |
||
228 | * @param integer $attributeId The attribute ID of the attribute |
||
229 | * @param integer $storeId The store ID of the attribute |
||
230 | * |
||
231 | * @return array|null The text attribute |
||
232 | */ |
||
233 | public function loadProductTextAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
237 | |||
238 | /** |
||
239 | * Load's and return's the varchar attribute with the passed row/attribute/store ID. |
||
240 | * |
||
241 | * @param integer $row The row ID of the attribute |
||
242 | * @param integer $attributeId The attribute ID of the attribute |
||
243 | * @param integer $storeId The store ID of the attribute |
||
244 | * |
||
245 | * @return array|null The varchar attribute |
||
246 | */ |
||
247 | public function loadProductVarcharAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
251 | } |
||
252 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.