1 | <?php |
||
36 | class EeBunchSubject extends BunchSubject |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * The row ID of the product that has been created recently. |
||
41 | * |
||
42 | * @var integer |
||
43 | */ |
||
44 | protected $lastRowId; |
||
45 | |||
46 | /** |
||
47 | * The mapping for the SKUs to the created row IDs. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $skuRowIdMapping = array(); |
||
52 | |||
53 | /** |
||
54 | * The mapping for the supported backend types (for the product entity) => persist methods. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $backendTypes = array( |
||
59 | 'datetime' => array('persistDatetimeAttribute', 'loadProductDatetimeAttributeByRowIdAndAttributeIdAndStoreId'), |
||
60 | 'decimal' => array('persistDecimalAttribute', 'loadProductDecimalAttributeByRowIdAndAttributeIdAndStoreId'), |
||
61 | 'int' => array('persistIntAttribute', 'loadProductIntAttributeByRowIdAndAttributeIdAndStoreId'), |
||
62 | 'text' => array('persistTextAttribute', 'loadProductTextAttributeByRowIdAndAttributeIdAndStoreId'), |
||
63 | 'varchar' => array('persistVarcharAttribute', 'loadProductVarcharAttributeByRowIdAndAttributeIdAndStoreId') |
||
64 | ); |
||
65 | |||
66 | /** |
||
67 | * Mappings for the table column => CSV column header. |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $headerStockMappings = array( |
||
72 | 'qty' => array('qty', 'float'), |
||
73 | 'min_qty' => array('out_of_stock_qty', 'float'), |
||
74 | 'use_config_min_qty' => array('use_config_min_qty', 'int'), |
||
75 | 'is_qty_decimal' => array('is_qty_decimal', 'int'), |
||
76 | 'backorders' => array('allow_backorders', 'int'), |
||
77 | 'use_config_backorders' => array('use_config_backorders', 'int'), |
||
78 | 'min_sale_qty' => array('min_cart_qty', 'float'), |
||
79 | 'use_config_min_sale_qty' => array('use_config_min_sale_qty', 'int'), |
||
80 | 'max_sale_qty' => array('max_cart_qty', 'float'), |
||
81 | 'use_config_max_sale_qty' => array('use_config_max_sale_qty', 'int'), |
||
82 | 'is_in_stock' => array('is_in_stock', 'int'), |
||
83 | 'notify_stock_qty' => array('notify_on_stock_below', 'float'), |
||
84 | 'use_config_notify_stock_qty' => array('use_config_notify_stock_qty', 'int'), |
||
85 | 'manage_stock' => array('manage_stock', 'int'), |
||
86 | 'use_config_manage_stock' => array('use_config_manage_stock', 'int'), |
||
87 | 'use_config_qty_increments' => array('use_config_qty_increments', 'int'), |
||
88 | 'qty_increments' => array('qty_increments', 'float'), |
||
89 | 'use_config_enable_qty_inc' => array('use_config_enable_qty_inc', 'int'), |
||
90 | 'enable_qty_increments' => array('enable_qty_increments', 'int'), |
||
91 | 'is_decimal_divided' => array('is_decimal_divided', 'int'), |
||
92 | 'deferred_stock_update' => array('deferred_stock_update', 'int'), |
||
93 | 'use_config_deferred_stock_update' => array('use_config_deferred_stock_update', 'int'), |
||
94 | ); |
||
95 | |||
96 | /** |
||
97 | * Return's TRUE, if the passed URL key varchar value IS related with the passed PK. |
||
98 | * |
||
99 | * @param array $productVarcharAttribute The varchar value to check |
||
100 | * @param integer $pk The primary key to check |
||
101 | * |
||
102 | * @return boolean TRUE if the URL key is related, else FALSE |
||
103 | */ |
||
104 | protected function isUrlKeyOf($productVarcharAttribute, $pk) |
||
108 | |||
109 | /** |
||
110 | * Clean up the global data after importing the bunch. |
||
111 | * |
||
112 | * @param string $serial The serial of the actual import |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | public function tearDown($serial) |
||
128 | |||
129 | /** |
||
130 | * Set's the row ID of the product that has been created recently. |
||
131 | * |
||
132 | * @param string $lastRowId The row ID |
||
133 | * |
||
134 | * @return void |
||
135 | */ |
||
136 | public function setLastRowId($lastRowId) |
||
140 | |||
141 | /** |
||
142 | * Return's the row ID of the product that has been created recently. |
||
143 | * |
||
144 | * @return string The row Id |
||
145 | */ |
||
146 | public function getLastRowId() |
||
150 | |||
151 | /** |
||
152 | * Add the passed SKU => row ID mapping. |
||
153 | * |
||
154 | * @param string $sku The SKU |
||
155 | * |
||
156 | * @return void |
||
157 | */ |
||
158 | public function addSkuRowIdMapping($sku) |
||
162 | |||
163 | /** |
||
164 | * Return's the product rows with the passed SKU. |
||
165 | * |
||
166 | * @param string $sku The SKU of the product rows to return |
||
167 | * |
||
168 | * @return array The product rows |
||
169 | */ |
||
170 | public function getProductRowsBySku($sku) |
||
174 | |||
175 | /** |
||
176 | * Return's the next available product entity ID. |
||
177 | * |
||
178 | * @return integer The next available product entity ID |
||
179 | */ |
||
180 | public function nextIdentifier() |
||
184 | |||
185 | /** |
||
186 | * Load's and return's the product with the passed SKU and timestamp. |
||
187 | * |
||
188 | * @param string $sku The SKU of the product to return |
||
189 | * @param integer $timestamp The timestamp to find the matching scheduled update |
||
190 | * |
||
191 | * @return array The product |
||
192 | */ |
||
193 | public function loadProductBySkuAndTimestamp($sku, $timestamp) |
||
197 | |||
198 | /** |
||
199 | * Load's and return's the datetime attribute with the passed row/attribute/store ID. |
||
200 | * |
||
201 | * @param integer $rowId The row ID of the attribute |
||
202 | * @param integer $attributeId The attribute ID of the attribute |
||
203 | * @param integer $storeId The store ID of the attribute |
||
204 | * |
||
205 | * @return array|null The datetime attribute |
||
206 | */ |
||
207 | public function loadProductDatetimeAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
211 | |||
212 | /** |
||
213 | * Load's and return's the decimal attribute with the passed row/attribute/store ID. |
||
214 | * |
||
215 | * @param integer $rowId The row ID of the attribute |
||
216 | * @param integer $attributeId The attribute ID of the attribute |
||
217 | * @param integer $storeId The store ID of the attribute |
||
218 | * |
||
219 | * @return array|null The decimal attribute |
||
220 | */ |
||
221 | public function loadProductDecimalAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
225 | |||
226 | /** |
||
227 | * Load's and return's the integer attribute with the passed row/attribute/store ID. |
||
228 | * |
||
229 | * @param integer $rowId The row ID of the attribute |
||
230 | * @param integer $attributeId The attribute ID of the attribute |
||
231 | * @param integer $storeId The store ID of the attribute |
||
232 | * |
||
233 | * @return array|null The integer attribute |
||
234 | */ |
||
235 | public function loadProductIntAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
239 | |||
240 | /** |
||
241 | * Load's and return's the text attribute with the passed row/attribute/store ID. |
||
242 | * |
||
243 | * @param integer $rowId The row ID of the attribute |
||
244 | * @param integer $attributeId The attribute ID of the attribute |
||
245 | * @param integer $storeId The store ID of the attribute |
||
246 | * |
||
247 | * @return array|null The text attribute |
||
248 | */ |
||
249 | public function loadProductTextAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
253 | |||
254 | /** |
||
255 | * Load's and return's the varchar attribute with the passed row/attribute/store ID. |
||
256 | * |
||
257 | * @param integer $rowId The row ID of the attribute |
||
258 | * @param integer $attributeId The attribute ID of the attribute |
||
259 | * @param integer $storeId The store ID of the attribute |
||
260 | * |
||
261 | * @return array|null The varchar attribute |
||
262 | */ |
||
263 | public function loadProductVarcharAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId) |
||
267 | } |
||
268 |
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.