|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\Bundle\Utils\SqlStatements |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/techdivision/import-product-bundle |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Bundle\Utils; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\AbstractSqlStatements; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Utility class with the SQL statements to use. |
|
27
|
|
|
* |
|
28
|
|
|
* @author Tim Wagner <[email protected]> |
|
29
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
31
|
|
|
* @link https://github.com/techdivision/import-product-bundle |
|
32
|
|
|
* @link http://www.techdivision.com |
|
33
|
|
|
*/ |
|
34
|
|
|
class SqlStatements extends AbstractSqlStatements |
|
35
|
|
|
{ |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The SQL statement to load the bundle option with the passed name/parent/store ID. |
|
39
|
|
|
* |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
const BUNDLE_OPTION = 'bundle_option'; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* The SQL statement to load the bundle option value with the passed name/parent/store ID. |
|
46
|
|
|
* |
|
47
|
|
|
* @var string |
|
48
|
|
|
*/ |
|
49
|
|
|
const BUNDLE_OPTION_VALUE = 'bundle_option_value'; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* The SQL statement to load the bundle selection with the passed option/parent product/product ID. |
|
53
|
|
|
* |
|
54
|
|
|
* @var string |
|
55
|
|
|
*/ |
|
56
|
|
|
const BUNDLE_SELECTION = 'bundle_selection'; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* The SQL statement to load the bundle selection price with the passed selection/website ID. |
|
60
|
|
|
* |
|
61
|
|
|
* @var string |
|
62
|
|
|
*/ |
|
63
|
|
|
const BUNDLE_SELECTION_PRICE = 'bundle_selection_price'; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* The SQL statement to create a new product bundle option. |
|
67
|
|
|
* |
|
68
|
|
|
* @var string |
|
69
|
|
|
*/ |
|
70
|
|
|
const CREATE_PRODUCT_BUNDLE_OPTION = 'create.product_bundle_option'; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* The SQL statement to update an existion product bundle option. |
|
74
|
|
|
* |
|
75
|
|
|
* @var string |
|
76
|
|
|
*/ |
|
77
|
|
|
const UPDATE_PRODUCT_BUNDLE_OPTION = 'update.product_bundle_option'; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* The SQL statement to create a new product bundle option value. |
|
81
|
|
|
* |
|
82
|
|
|
* @var string |
|
83
|
|
|
*/ |
|
84
|
|
|
const CREATE_PRODUCT_BUNDLE_OPTION_VALUE = 'create.product_bundle_option_value'; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* The SQL statement to create a new product bundle selection. |
|
88
|
|
|
* |
|
89
|
|
|
* @var string |
|
90
|
|
|
*/ |
|
91
|
|
|
const CREATE_PRODUCT_BUNDLE_SELECTION = 'create.product_bundle_selection'; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* The SQL statement to update an existion product bundle selection. |
|
95
|
|
|
* |
|
96
|
|
|
* @var string |
|
97
|
|
|
*/ |
|
98
|
|
|
const UPDATE_PRODUCT_BUNDLE_SELECTION = 'update.product_bundle_selection'; |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* The SQL statement to create a new product bundle selection price. |
|
102
|
|
|
* |
|
103
|
|
|
* @var string |
|
104
|
|
|
*/ |
|
105
|
|
|
const CREATE_PRODUCT_BUNDLE_SELECTION_PRICE = 'insert.product_bundle_selection_price'; |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* The SQL statement to update an existion product bundle selection price. |
|
109
|
|
|
* |
|
110
|
|
|
* @var string |
|
111
|
|
|
*/ |
|
112
|
|
|
const UPDATE_PRODUCT_BUNDLE_SELECTION_PRICE = 'update.product_bundle_selection_price'; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* The SQL statements. |
|
116
|
|
|
* |
|
117
|
|
|
* @var array |
|
118
|
|
|
*/ |
|
119
|
|
|
private $statements = array( |
|
120
|
|
|
SqlStatements::BUNDLE_OPTION => |
|
121
|
|
|
'SELECT t0.* |
|
122
|
|
|
FROM catalog_product_bundle_option t0 |
|
123
|
|
|
INNER JOIN catalog_product_bundle_option_value t1 |
|
124
|
|
|
ON t0.parent_id = :parent_id |
|
125
|
|
|
AND t0.option_id = t1.option_id |
|
126
|
|
|
AND t1.title = :title |
|
127
|
|
|
AND t1.store_id = :store_id', |
|
128
|
|
|
SqlStatements::BUNDLE_OPTION_VALUE => |
|
129
|
|
|
'SELECT t0.* |
|
130
|
|
|
FROM catalog_product_bundle_option_value t0 |
|
131
|
|
|
INNER JOIN catalog_product_bundle_option t1 |
|
132
|
|
|
ON t1.parent_id = :parent_id |
|
133
|
|
|
AND t0.option_id = t1.option_id |
|
134
|
|
|
AND t0.title = :title |
|
135
|
|
|
AND t0.store_id = :store_id', |
|
136
|
|
|
SqlStatements::BUNDLE_SELECTION => |
|
137
|
|
|
'SELECT * |
|
138
|
|
|
FROM catalog_product_bundle_selection |
|
139
|
|
|
WHERE option_id = :option_id |
|
140
|
|
|
AND parent_product_id = :parent_product_id |
|
141
|
|
|
AND product_id = :product_id', |
|
142
|
|
|
SqlStatements::BUNDLE_SELECTION_PRICE => |
|
143
|
|
|
'SELECT * |
|
144
|
|
|
FROM catalog_product_bundle_selection_price |
|
145
|
|
|
WHERE selection_id = :selection_id |
|
146
|
|
|
AND website_id = :website_id', |
|
147
|
|
|
SqlStatements::CREATE_PRODUCT_BUNDLE_OPTION => |
|
148
|
|
|
'INSERT |
|
149
|
|
|
INTO catalog_product_bundle_option |
|
150
|
|
|
(parent_id, |
|
151
|
|
|
required, |
|
152
|
|
|
position, |
|
153
|
|
|
type) |
|
154
|
|
|
VALUES (:parent_id, |
|
155
|
|
|
:required, |
|
156
|
|
|
:position, |
|
157
|
|
|
:type)', |
|
158
|
|
|
SqlStatements::UPDATE_PRODUCT_BUNDLE_OPTION => |
|
159
|
|
|
'UPDATE catalog_product_bundle_option |
|
160
|
|
|
SET parent_id = :parent_id, |
|
161
|
|
|
required = :required, |
|
162
|
|
|
position = :position, |
|
163
|
|
|
type = :type |
|
164
|
|
|
WHERE option_id = :option_id', |
|
165
|
|
|
SqlStatements::CREATE_PRODUCT_BUNDLE_OPTION_VALUE => |
|
166
|
|
|
'INSERT |
|
167
|
|
|
INTO catalog_product_bundle_option_value |
|
168
|
|
|
(option_id, |
|
169
|
|
|
store_id, |
|
170
|
|
|
title) |
|
171
|
|
|
VALUES (:option_id, |
|
172
|
|
|
:store_id, |
|
173
|
|
|
:title)', |
|
174
|
|
|
SqlStatements::CREATE_PRODUCT_BUNDLE_SELECTION => |
|
175
|
|
|
'INSERT |
|
176
|
|
|
INTO catalog_product_bundle_selection |
|
177
|
|
|
(option_id, |
|
178
|
|
|
parent_product_id, |
|
179
|
|
|
product_id, |
|
180
|
|
|
position, |
|
181
|
|
|
is_default, |
|
182
|
|
|
selection_price_type, |
|
183
|
|
|
selection_price_value, |
|
184
|
|
|
selection_qty, |
|
185
|
|
|
selection_can_change_qty) |
|
186
|
|
|
VALUES (:option_id, |
|
187
|
|
|
:parent_product_id, |
|
188
|
|
|
:product_id, |
|
189
|
|
|
:position, |
|
190
|
|
|
:is_default, |
|
191
|
|
|
:selection_price_type, |
|
192
|
|
|
:selection_price_value, |
|
193
|
|
|
:selection_qty, |
|
194
|
|
|
:selection_can_change_qty)', |
|
195
|
|
|
SqlStatements::UPDATE_PRODUCT_BUNDLE_SELECTION => |
|
196
|
|
|
'UPDATE catalog_product_bundle_selection |
|
197
|
|
|
SET option_id = :option_id, |
|
198
|
|
|
parent_product_id = :parent_product_id, |
|
199
|
|
|
product_id = :product_id, |
|
200
|
|
|
position = :position, |
|
201
|
|
|
is_default = :is_default, |
|
202
|
|
|
selection_price_type = :selection_price_type, |
|
203
|
|
|
selection_price_value = :selection_price_value, |
|
204
|
|
|
selection_qty = :selection_qty, |
|
205
|
|
|
selection_can_change_qty = :selection_can_change_qty |
|
206
|
|
|
WHERE selection_id = :selection_id', |
|
207
|
|
|
SqlStatements::CREATE_PRODUCT_BUNDLE_SELECTION_PRICE => |
|
208
|
|
|
'INSERT |
|
209
|
|
|
INTO catalog_product_bundle_selection_price |
|
210
|
|
|
(selection_id, |
|
211
|
|
|
website_id, |
|
212
|
|
|
selection_price_type, |
|
213
|
|
|
selection_price_value) |
|
214
|
|
|
VALUES (:selection_id, |
|
215
|
|
|
:website_id, |
|
216
|
|
|
:selection_price_type, |
|
217
|
|
|
:selection_price_value)', |
|
218
|
|
|
SqlStatements::UPDATE_PRODUCT_BUNDLE_SELECTION_PRICE => |
|
219
|
|
|
'UPDATE catalog_product_bundle_selection_price |
|
220
|
|
|
SET selection_price_type = :selection_price_type, |
|
221
|
|
|
selection_price_value = :selection_price_value |
|
222
|
|
|
WHERE selection_id = :selection_id |
|
223
|
|
|
AND website_id = :website_id' |
|
224
|
|
|
); |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* Initialize the the SQL statements. |
|
228
|
|
|
*/ |
|
229
|
|
|
public function __construct() |
|
230
|
|
|
{ |
|
231
|
|
|
|
|
232
|
|
|
// merge the class statements |
|
233
|
|
|
foreach ($this->statements as $key => $statement) { |
|
234
|
|
|
$this->preparedStatements[$key] = $statement; |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
} |
|
238
|
|
|
|