|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* ShopServer version 0.4.0 |
|
4
|
|
|
* Class named with version XXYY from version numbering XX.YY.ZZ |
|
5
|
|
|
* |
|
6
|
|
|
* @todo we need to move kernel out of Product. |
|
7
|
|
|
* @todo we need to move kernel out of DBQuery. |
|
8
|
|
|
* @todo we need to find out what to do with hasIntranetAccess and stock |
|
9
|
|
|
* @todo we need to work out with getPictures() and Kernel->useModule |
|
10
|
|
|
* |
|
11
|
|
|
* @category XMLRPC_Server |
|
12
|
|
|
* @package Intraface_XMLRPC_Shop |
|
13
|
|
|
* @author Lars Olesen <[email protected]> |
|
14
|
|
|
* @version @package-version@ |
|
15
|
|
|
*/ |
|
16
|
|
|
class Intraface_XMLRPC_Shop_Server0100 extends Intraface_XMLRPC_Server0100 |
|
17
|
|
|
{ |
|
18
|
|
|
protected $webshop; |
|
19
|
|
|
protected $basket; |
|
20
|
|
|
protected $product; |
|
21
|
|
|
protected $doctrine; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Constructor |
|
25
|
|
|
* |
|
26
|
|
|
* @param $encoding the encoding used for the XML_RPC2 backend |
|
27
|
|
|
* |
|
28
|
|
|
* @return unknown_type |
|
|
|
|
|
|
29
|
|
|
*/ |
|
30
|
|
|
public function __construct(Doctrine_Connection_Common $doctrine, $encoding = 'utf-8') |
|
31
|
|
|
{ |
|
32
|
|
|
$this->doctrine = $doctrine; |
|
33
|
|
|
parent::__construct($encoding); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Gets a list with products |
|
38
|
|
|
* |
|
39
|
|
|
* @param struct $credentials Credentials to use the server |
|
40
|
|
|
* @param integer $shop_id Id for the shop |
|
41
|
|
|
* @param array $search Optional search array |
|
42
|
|
|
* |
|
43
|
|
|
* @return array |
|
44
|
|
|
*/ |
|
45
|
|
View Code Duplication |
public function getProducts($credentials, $shop_id, $search = array()) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
$this->checkCredentials($credentials); |
|
48
|
|
|
|
|
49
|
|
|
$offset = 0; |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
$search = $this->processRequestData($search); |
|
52
|
|
|
|
|
53
|
|
|
$mixed = array(); |
|
54
|
|
|
if (!empty($search)) { |
|
55
|
|
|
$mixed = $search; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$search = ''; |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
$this->_factoryWebshop($shop_id); |
|
61
|
|
|
|
|
62
|
|
|
$products = array(); |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
$area = ''; |
|
65
|
|
|
|
|
66
|
|
|
if (!empty($mixed['area'])) { |
|
67
|
|
|
$area = $mixed['area']; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
$product = new Intraface_modules_product_Gateway($this->webshop->kernel); |
|
71
|
|
|
|
|
72
|
|
|
if (!isset($mixed['use_paging']) || $mixed['use_paging'] == 'true') { |
|
73
|
|
|
$product->getDBQuery()->usePaging('paging'); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
// sublevel has to be used so other searches are not overwritten |
|
77
|
|
|
$product->getDBQuery()->storeResult('use_stored', 'webshop_' . $area . '_' . md5($this->credentials['session_id']), 'sublevel'); |
|
78
|
|
|
$debug2 = serialize($mixed); |
|
79
|
|
|
if (isset($mixed['offset']) and is_numeric($mixed['offset']) and $mixed['offset'] > 0) { |
|
|
|
|
|
|
80
|
|
|
$product->getDBQuery()->useStored(true); |
|
81
|
|
|
$product->getDBQuery()->setPagingOffset((int)$mixed['offset']); |
|
82
|
|
|
$debug2 .= 'offset ' . $mixed['offset']; |
|
83
|
|
|
} elseif (isset($mixed['use_stored']) and array_key_exists('use_stored', $mixed) and $mixed['use_stored'] == 'true') { |
|
|
|
|
|
|
84
|
|
|
$product->getDBQuery()->useStored(true); |
|
85
|
|
|
$debug2 .= 'use_stored true'; |
|
86
|
|
|
} else { |
|
87
|
|
|
if (array_key_exists('search', $mixed) and !empty($mixed['search'])) { |
|
|
|
|
|
|
88
|
|
|
$product->getDBQuery()->setFilter('search', $mixed['search']); |
|
89
|
|
|
$debug2 .= 'search ' . $mixed['search']; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
if (array_key_exists('keywords', $mixed) and !empty($mixed['keywords'])) { |
|
|
|
|
|
|
93
|
|
|
$product->getDBQuery()->setFilter('keywords', $mixed['keywords']); |
|
94
|
|
|
$debug2 .= 'keyword ' . $mixed['keywords']; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
if (array_key_exists('category', $mixed) and !empty($mixed['category'])) { |
|
|
|
|
|
|
98
|
|
|
$product->getDBQuery()->setFilter('shop_id', $shop_id); |
|
99
|
|
|
$product->getDBQuery()->setFilter('category', $mixed['category']); |
|
100
|
|
|
$debug2 .= 'category ' . $mixed['category']; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
if (isset($mixed['ids']) and array_key_exists('ids', $mixed) and is_array($mixed['ids'])) { |
|
|
|
|
|
|
104
|
|
|
$product->getDBQuery()->setFilter('ids', $mixed['ids']); |
|
105
|
|
|
$debug2 .= 'ids ' . implode(', ', $mixed['ids']); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
if (array_key_exists('sorting', $mixed) and !empty($mixed['sorting'])) { |
|
|
|
|
|
|
109
|
|
|
$product->getDBQuery()->setFilter('sorting', $mixed['sorting']); |
|
110
|
|
|
$debug2 .= 'sorting ' . $mixed['sorting']; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
if (false !== ($currency_gateway = $this->getCurrencyGateway())) { |
|
115
|
|
|
$currencies = $currency_gateway->findAllWithExchangeRate(); |
|
116
|
|
|
} else { |
|
117
|
|
|
$currencies = false; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
return $this->prepareResponseData(array( |
|
121
|
|
|
'parameter' => $mixed, |
|
122
|
|
|
//'debug2' => $debug2, |
|
|
|
|
|
|
123
|
|
|
'products' => $this->cleanUpProductList($product->getAllProducts('webshop', $currencies)), |
|
124
|
|
|
'paging' => $product->getDBQuery()->getPaging(), |
|
125
|
|
|
'search' => array(), |
|
126
|
|
|
)); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Gets a list with products in given category |
|
131
|
|
|
* |
|
132
|
|
|
* @param struct $credentials Credentials to use the server |
|
133
|
|
|
* @param integer $shop_id Id for the shop |
|
134
|
|
|
* @param integer $category_id Id of category |
|
135
|
|
|
* @param integer $results_per_page Optional returned products per page |
|
136
|
|
|
* @param integer $pagging_offset Otional offset for pagging. |
|
137
|
|
|
* |
|
138
|
|
|
* @return array |
|
139
|
|
|
*/ |
|
140
|
|
View Code Duplication |
public function getProductsInCategoryId($credentials, $shop_id, $category_id, $results_per_page = 0, $pagging_offset = 0) |
|
|
|
|
|
|
141
|
|
|
{ |
|
142
|
|
|
$search = array(); |
|
143
|
|
|
$search['area'] = 'category_'.$category_id; |
|
144
|
|
|
if ($results_per_page > 0) { |
|
145
|
|
|
$search['use_paging'] = 'true'; |
|
146
|
|
|
} else { |
|
147
|
|
|
$search['use_paging'] = 'false'; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
$search['category'] = $category_id; |
|
151
|
|
|
$search['offset'] = $pagging_offset; |
|
152
|
|
|
|
|
153
|
|
|
return $this->getProducts($credentials, $shop_id, $search); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Gets a list with products with a given keyword or with given keywords |
|
158
|
|
|
* |
|
159
|
|
|
* @param struct $credentials Credentials to use the server |
|
160
|
|
|
* @param integer $shop_id Id for the shop |
|
161
|
|
|
* @param mixed $keyword Integer with keyword id or array with keyword ids. |
|
162
|
|
|
* @param integer $results_per_page optional returned products per page |
|
163
|
|
|
* @param integer $pagging_offset optional offset for pagging. |
|
164
|
|
|
* |
|
165
|
|
|
* @return array |
|
166
|
|
|
*/ |
|
167
|
|
View Code Duplication |
public function getProductsWithKeywordId($credentials, $shop_id, $keyword, $results_per_page = 0, $pagging_offset = 0) |
|
|
|
|
|
|
168
|
|
|
{ |
|
169
|
|
|
|
|
170
|
|
|
$search = array(); |
|
171
|
|
|
if (is_array($keyword)) { |
|
172
|
|
|
$search['area'] = 'keyword_'.implode('-', $keyword); |
|
173
|
|
|
} else { |
|
174
|
|
|
$search['area'] = 'keyword_'.$keyword; |
|
175
|
|
|
} |
|
176
|
|
|
if ($results_per_page > 0) { |
|
177
|
|
|
$search['use_paging'] = 'true'; |
|
178
|
|
|
} else { |
|
179
|
|
|
$search['use_paging'] = 'false'; |
|
180
|
|
|
} |
|
181
|
|
|
$search['keywords'] = $keyword; |
|
182
|
|
|
$search['offset'] = $pagging_offset; |
|
183
|
|
|
|
|
184
|
|
|
return $this->getProducts($credentials, $shop_id, $search); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Returns product ids with keyword id |
|
189
|
|
|
* |
|
190
|
|
|
* @param struct $credentials Credentials to use the server |
|
191
|
|
|
* @param integer $shop_id Id for the shop |
|
192
|
|
|
* @param mixed $keyword Integer with keyword id or array with keyword ids. |
|
193
|
|
|
* @return array |
|
194
|
|
|
*/ |
|
195
|
|
View Code Duplication |
public function getProductIdsWithKeywordId($credentials, $shop_id, $keyword) |
|
|
|
|
|
|
196
|
|
|
{ |
|
197
|
|
|
$this->checkCredentials($credentials); |
|
198
|
|
|
$this->_factoryWebshop($shop_id); |
|
199
|
|
|
|
|
200
|
|
|
$gateway = new Intraface_modules_product_Gateway($this->webshop->kernel); |
|
201
|
|
|
|
|
202
|
|
|
return $this->prepareResponseData( |
|
203
|
|
|
$gateway->getProductIdsWithKeywordForShop($this->processRequestData($keyword)) |
|
204
|
|
|
); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* Gets a list with products with a given keyword or with given keywords |
|
209
|
|
|
* |
|
210
|
|
|
* @param struct $credentials Credentials to use the server |
|
211
|
|
|
* @param integer $shop_id Id for the shop |
|
212
|
|
|
* @param integer $attribute_id Integer with attribute id. |
|
213
|
|
|
* @param integer $results_per_page optional returned products per page |
|
214
|
|
|
* @param integer $pagging_offset optional offset for pagging. |
|
215
|
|
|
* |
|
216
|
|
|
* @return array |
|
217
|
|
|
*/ |
|
218
|
|
|
public function getProductsWithVariationAttributeId($credentials, $shop_id, $attribute_id, $results_per_page = 0, $pagging_offset = 0) |
|
|
|
|
|
|
219
|
|
|
{ |
|
220
|
|
|
$this->checkCredentials($credentials); |
|
221
|
|
|
$this->_factoryWebshop($shop_id); |
|
222
|
|
|
|
|
223
|
|
|
|
|
224
|
|
|
$gateway = new Intraface_modules_product_Attribute_Group_Gateway($this->getDoctrine()); |
|
225
|
|
|
try { |
|
226
|
|
|
$attribute_group = $gateway->findByAttributeId($attribute_id); |
|
227
|
|
|
} catch (Intraface_Gateway_Exception $e) { |
|
228
|
|
|
return $this->prepareResponseData( |
|
229
|
|
|
array( |
|
230
|
|
|
'http_header_status' => 'HTTP/1.0 404 Not Found', |
|
231
|
|
|
'products' => array(), |
|
232
|
|
|
'attribute_group' => array() |
|
233
|
|
|
) |
|
234
|
|
|
); |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
$gateway = new Intraface_modules_product_ProductDoctrineGateway($this->getDoctrine(), null); |
|
|
|
|
|
|
238
|
|
|
$doctrine_products = $gateway->findByVariationAttributeId($this->processRequestData($attribute_id)); |
|
239
|
|
|
|
|
240
|
|
|
return $this->prepareResponseData( |
|
241
|
|
|
array( |
|
242
|
|
|
'http_header_status' => 'HTTP/1.0 200 OK', |
|
243
|
|
|
'products' => $this->createDoctrineProductsListArray($doctrine_products, $attribute_id), |
|
244
|
|
|
'attribute_group' => $this->createAttributeGroupArray($attribute_group) |
|
245
|
|
|
) |
|
246
|
|
|
); |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* Formats array to return from product list from Doctrine |
|
251
|
|
|
* |
|
252
|
|
|
* @param object $doctrine_products Doctrine_Collection |
|
253
|
|
|
* @return array with products |
|
254
|
|
|
*/ |
|
255
|
|
|
private function createDoctrineProductsListArray($doctrine_products, $attribute_id = null) |
|
256
|
|
|
{ |
|
257
|
|
|
if (false !== ($currency_gateway = $this->getCurrencyGateway())) { |
|
258
|
|
|
$currencies = $currency_gateway->findAllWithExchangeRate(); |
|
259
|
|
|
} else { |
|
260
|
|
|
$currencies = false; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
$shared_filehandler = $this->kernel->useModule('filemanager'); |
|
264
|
|
|
$shared_filehandler->includeFile('AppendFile.php'); |
|
265
|
|
|
|
|
266
|
|
|
$products = array(); |
|
267
|
|
|
$key = 0; |
|
268
|
|
|
foreach ($doctrine_products as $p) { |
|
269
|
|
|
$products[$key]['id'] = $p->getId(); |
|
270
|
|
|
$products[$key]['number'] = $p->getDetails()->getNumber(); |
|
271
|
|
|
$products[$key]['name'] = $p->getDetails()->getTranslation('da')->name; |
|
272
|
|
|
$products[$key]['unit'] = $p->getDetails()->getUnit(); |
|
273
|
|
|
$products[$key]['detail_id'] = $p->getDetails()->getId(); |
|
274
|
|
|
$products[$key]['vat_percent'] = $p->getDetails()->getVatPercent()->getAsIso(2); |
|
275
|
|
|
$products[$key]['stock'] = $p['stock']; |
|
276
|
|
|
$products[$key]['has_variation'] = $p->hasVariation(); |
|
277
|
|
|
|
|
278
|
|
|
// $products[$key]['stock_status'] = $p['stock_status']; |
|
|
|
|
|
|
279
|
|
|
|
|
280
|
|
|
$products[$key]['currency']['DKK']['price'] = $p->getDetails()->getPrice()->getAsIso(2); |
|
281
|
|
|
$products[$key]['currency']['DKK']['price_incl_vat'] = $p->getDetails()->getPriceIncludingVat()->getAsIso(2); |
|
282
|
|
|
$products[$key]['currency']['DKK']['before_price'] = $p->getDetails()->getBeforePrice()->getAsIso(2); |
|
283
|
|
|
$products[$key]['currency']['DKK']['before_price_incl_vat'] = $p->getDetails()->getBeforePriceIncludingVat()->getAsIso(2); |
|
284
|
|
|
|
|
285
|
|
View Code Duplication |
if ($currencies && $currencies->count() > 0) { |
|
286
|
|
|
foreach ($currencies as $currency) { |
|
287
|
|
|
$products[$key]['currency'][$currency->getType()->getIsoCode()]['price'] = $p->getDetails()->getPriceInCurrency($currency); |
|
288
|
|
|
$products[$key]['currency'][$currency->getType()->getIsoCode()]['price_incl_vat'] = $p->getDetails()->getPriceIncludingVatInCurrency($currency); |
|
289
|
|
|
$products[$key]['currency'][$currency->getType()->getIsoCode()]['before_price'] = $p->getDetails()->getBeforePriceInCurrency($currency); |
|
290
|
|
|
$products[$key]['currency'][$currency->getType()->getIsoCode()]['before_price_incl_vat'] = $p->getDetails()->getBeforePriceIncludingVatInCurrency($currency); |
|
291
|
|
|
} |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
$products[$key]['pictures'] = $this->getProductPictures($p); |
|
295
|
|
|
|
|
296
|
|
|
if ($p->hasVariation() && $p->hasStock() && $attribute_id != null) { |
|
297
|
|
|
try { |
|
298
|
|
|
$variaton_gateway = new Intraface_modules_product_Variation_Gateway($p); |
|
299
|
|
|
$variations = $variaton_gateway->findWithAttributeId($attribute_id); |
|
300
|
|
|
} catch (Intraface_Gateway_Exception $e) { |
|
301
|
|
|
$variations = array(); |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
$stub_product = new Intraface_XMLRPC_Shop_Server0100_Product($p, $this->webshop->kernel); |
|
305
|
|
|
$products[$key]['attribute_stock_for_sale'] = 0; |
|
306
|
|
|
|
|
307
|
|
|
foreach ($variations as $variation) { |
|
308
|
|
|
$stock = $variation->getStock($stub_product)->get(); |
|
309
|
|
|
$products[$key]['attribute_stock_for_sale'] += $stock['for_sale']; |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
|
|
313
|
|
|
/*$return['variations'][] = array( |
|
|
|
|
|
|
314
|
|
|
'variation' => array( |
|
315
|
|
|
'id' => $variation->getId(), |
|
316
|
|
|
'detail_id' => $detail->getId(), |
|
317
|
|
|
'number' => $variation->getNumber(), |
|
318
|
|
|
'name' => $variation->getName(), |
|
319
|
|
|
'attributes' => $attributes_array, |
|
320
|
|
|
'identifier' => $attribute_string, |
|
321
|
|
|
'price_incl_vat' => $detail->getPriceIncludingVat($product)->getAsIso(2), |
|
322
|
|
|
'weight' => $product->get('weight') + $detail->getWeightDifference(2), |
|
323
|
|
|
'currency' => $variation_currency |
|
324
|
|
|
), |
|
325
|
|
|
'stock' => $stock |
|
326
|
|
|
); |
|
327
|
|
|
*/ |
|
328
|
|
|
} |
|
329
|
|
|
$key++; |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
return $products; |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
private function getProductPictures($product) |
|
336
|
|
|
{ |
|
337
|
|
|
$append_file = new AppendFile($this->kernel, 'product', $product->getId()); |
|
338
|
|
|
$appendix_list = $append_file->getList(); |
|
339
|
|
|
|
|
340
|
|
|
$pictures = array(); |
|
341
|
|
|
|
|
342
|
|
|
if (count($appendix_list) > 0) { |
|
343
|
|
|
foreach ($appendix_list as $key => $appendix) { |
|
344
|
|
|
$tmp_filehandler = new FileHandler($this->kernel, $appendix['file_handler_id']); |
|
345
|
|
|
$pictures[$key]['id'] = $appendix['file_handler_id']; |
|
346
|
|
|
$pictures[$key]['original']['icon_uri'] = $tmp_filehandler->get('icon_uri'); |
|
347
|
|
|
$pictures[$key]['original']['name'] = $tmp_filehandler->get('file_name'); |
|
348
|
|
|
$pictures[$key]['original']['width'] = $tmp_filehandler->get('width'); |
|
349
|
|
|
$pictures[$key]['original']['height'] = $tmp_filehandler->get('height'); |
|
350
|
|
|
$pictures[$key]['original']['file_uri'] = $tmp_filehandler->get('file_uri'); |
|
351
|
|
|
$pictures[$key]['appended_file_id'] = $appendix['id']; |
|
352
|
|
|
|
|
353
|
|
|
if ($tmp_filehandler->get('is_image')) { |
|
354
|
|
|
$tmp_filehandler->createInstance(); |
|
355
|
|
|
$instances = $tmp_filehandler->instance->getList('include_hidden'); |
|
356
|
|
|
foreach ($instances as $instance) { |
|
357
|
|
|
$pictures[$key][$instance['name']]['file_uri'] = $instance['file_uri']; |
|
358
|
|
|
$pictures[$key][$instance['name']]['name'] = $instance['name']; |
|
359
|
|
|
$pictures[$key][$instance['name']]['width'] = $instance['width']; |
|
360
|
|
|
$pictures[$key][$instance['name']]['height'] = $instance['height']; |
|
361
|
|
|
} |
|
362
|
|
|
} |
|
363
|
|
|
$tmp_filehandler->__destruct(); |
|
364
|
|
|
unset($tmp_filehandler); |
|
365
|
|
|
} |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
return $pictures; |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
|
|
private function createAttributeGroupArray($attribute_group) |
|
372
|
|
|
{ |
|
373
|
|
|
foreach ($attribute_group->attribute as $attribute) { |
|
374
|
|
|
$attributes[] = array( |
|
|
|
|
|
|
375
|
|
|
'id' => $attribute->getId(), |
|
376
|
|
|
'name' => $attribute->getName()); |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
|
|
$attribute = $attribute_group->attribute->getFirst(); |
|
|
|
|
|
|
380
|
|
|
return array( |
|
381
|
|
|
'id' => $attribute_group->getId(), |
|
382
|
|
|
'name' => $attribute_group->getName(), |
|
383
|
|
|
'attributes' => $attributes); |
|
|
|
|
|
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* Make sure we only include necessary data. Several things more might |
|
388
|
|
|
* be left out. Mostly we remove description. |
|
389
|
|
|
* |
|
390
|
|
|
* @param array products |
|
391
|
|
|
* @return array cleaned up products |
|
392
|
|
|
*/ |
|
393
|
|
View Code Duplication |
private function cleanUpProductList($products) |
|
|
|
|
|
|
394
|
|
|
{ |
|
395
|
|
|
$return = array(); |
|
396
|
|
|
foreach ($products as $key => $p) { |
|
397
|
|
|
$return[$key]['id'] = $p['id']; |
|
398
|
|
|
$return[$key]['number'] = $p['number']; |
|
399
|
|
|
$return[$key]['name'] = $p['name']; |
|
400
|
|
|
$return[$key]['price'] = $p['price']; |
|
401
|
|
|
$return[$key]['unit'] = $p['unit']; |
|
402
|
|
|
$return[$key]['vat'] = $p['vat']; |
|
403
|
|
|
$return[$key]['weight'] = $p['weight']; |
|
404
|
|
|
$return[$key]['detail_id'] = $p['detail_id']; |
|
405
|
|
|
$return[$key]['vat_percent'] = $p['vat_percent']; |
|
406
|
|
|
$return[$key]['price_incl_vat'] = $p['price_incl_vat']; |
|
407
|
|
|
$return[$key]['stock'] = $p['stock']; |
|
408
|
|
|
$return[$key]['has_variation'] = $p['has_variation']; |
|
409
|
|
|
$return[$key]['stock_status'] = $p['stock_status']; |
|
410
|
|
|
|
|
411
|
|
|
foreach ($p['currency'] as $k => $c) { |
|
412
|
|
|
$return[$key]['currency'][$k]['price'] = $c['price']->getAsIso(2); |
|
413
|
|
|
$return[$key]['currency'][$k]['price_incl_vat'] = $c['price_incl_vat']->getAsIso(2); |
|
414
|
|
|
$return[$key]['currency'][$k]['before_price'] = $c['before_price']->getAsIso(2); |
|
415
|
|
|
$return[$key]['currency'][$k]['before_price_incl_vat'] = $c['before_price_incl_vat']->getAsIso(2); |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
|
|
if (isset($p['pictures'])) { |
|
419
|
|
|
$return[$key]['pictures'] = $p['pictures']; |
|
420
|
|
|
} |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
return $return; |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
/** |
|
427
|
|
|
* Gets one product |
|
428
|
|
|
* |
|
429
|
|
|
* @param struct $credentials Credentials to use the server |
|
430
|
|
|
* @param integer $shop_id Id for the shop |
|
431
|
|
|
* @param integer $id Product id |
|
432
|
|
|
* |
|
433
|
|
|
* @return array |
|
434
|
|
|
*/ |
|
435
|
|
View Code Duplication |
public function getProduct($credentials, $shop_id, $id) |
|
|
|
|
|
|
436
|
|
|
{ |
|
437
|
|
|
$this->checkCredentials($credentials); |
|
438
|
|
|
|
|
439
|
|
|
$this->_factoryWebshop($shop_id); |
|
440
|
|
|
|
|
441
|
|
|
if (!is_numeric($id)) { |
|
442
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
443
|
|
|
throw new XML_RPC2_FaultException('product id must be an integer', -5); |
|
444
|
|
|
} |
|
445
|
|
|
|
|
446
|
|
|
$id = $this->processRequestData(intval($id)); |
|
447
|
|
|
|
|
448
|
|
|
$return = array(); |
|
449
|
|
|
|
|
450
|
|
|
$product = new Product($this->kernel, $id); |
|
451
|
|
|
if ($product->get('id') == 0 || $product->get('do_show') == 0 || $product->get('active') == 0) { |
|
452
|
|
|
return array('product' => array('id' => 0)); |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
$product->getPictures(); |
|
456
|
|
|
$return['product'] = $product->get(); |
|
457
|
|
|
$return['product']['currency']['DKK']['price'] = $product->getDetails()->getPrice()->getAsIso(2); |
|
458
|
|
|
$return['product']['currency']['DKK']['price_incl_vat'] = $product->getDetails()->getPriceIncludingVat()->getAsIso(2); |
|
459
|
|
|
$return['product']['currency']['DKK']['before_price'] = $product->getDetails()->getBeforePrice()->getAsIso(2); |
|
460
|
|
|
$return['product']['currency']['DKK']['before_price_incl_vat'] = $product->getDetails()->getBeforePriceIncludingVat()->getAsIso(2); |
|
461
|
|
|
|
|
462
|
|
|
if (false !== ($currency_gateway = $this->getCurrencyGateway())) { |
|
463
|
|
|
foreach ($currency_gateway->findAllWithExchangeRate() as $currency) { |
|
464
|
|
|
$return['product']['currency'][$currency->getType()->getIsoCode()]['price'] = $product->getDetails()->getPriceInCurrency($currency)->getAsIso(2); |
|
465
|
|
|
$return['product']['currency'][$currency->getType()->getIsoCode()]['price_incl_vat'] = $product->getDetails()->getPriceIncludingVatInCurrency($currency)->getAsIso(2); |
|
466
|
|
|
$return['product']['currency'][$currency->getType()->getIsoCode()]['before_price'] = $product->getDetails()->getBeforePriceInCurrency($currency)->getAsIso(2); |
|
467
|
|
|
$return['product']['currency'][$currency->getType()->getIsoCode()]['before_price_incl_vat'] = $product->getDetails()->getBeforePriceIncludingVatInCurrency($currency)->getAsIso(2); |
|
468
|
|
|
} |
|
469
|
|
|
} |
|
470
|
|
|
|
|
471
|
|
|
if (!$product->hasVariation() && $product->get('stock')) { |
|
472
|
|
|
$return['stock'] = $product->getStock()->get(); |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
if ($product->get('has_variation')) { |
|
476
|
|
|
$variations = $product->getVariations(); |
|
477
|
|
|
foreach ($variations as $variation) { |
|
478
|
|
|
if ($product->get('stock')) { |
|
479
|
|
|
$stock = $variation->getStock($product)->get(); |
|
480
|
|
|
} else { |
|
481
|
|
|
$stock = false; |
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
|
|
$detail = $variation->getDetail(); |
|
485
|
|
|
$attribute_string = ''; |
|
486
|
|
|
$attributes_array = $variation->getAttributesAsArray(); |
|
487
|
|
|
|
|
488
|
|
|
foreach ($attributes_array as $attribute) { |
|
489
|
|
|
if ($attribute_string != '') { |
|
490
|
|
|
$attribute_string .= '-'; |
|
491
|
|
|
} |
|
492
|
|
|
$attribute_string .= $attribute['id']; |
|
493
|
|
|
|
|
494
|
|
|
// We calculate all products which is on stock with this attribute to be able to mark unused attributes in list. |
|
495
|
|
|
if (!isset($attribute_for_sale[$attribute['id']])) { |
|
496
|
|
|
$attribute_for_sale[$attribute['id']] = 0; |
|
|
|
|
|
|
497
|
|
|
} |
|
498
|
|
|
if ($stock !== false) { |
|
499
|
|
|
// If for_sale is less than zero we add zero. |
|
500
|
|
|
$attribute_for_sale[$attribute['id']] += (($stock['for_sale'] < 0) ? 0 : $stock['for_sale']); |
|
|
|
|
|
|
501
|
|
|
} else { |
|
502
|
|
|
// If product does not use stock, then we calculate one up, as the attribute is always in use. |
|
503
|
|
|
$attribute_for_sale[$attribute['id']] += 1; |
|
504
|
|
|
} |
|
505
|
|
|
} |
|
506
|
|
|
|
|
507
|
|
|
$variation_currency['DKK']['price'] = $detail->getPrice($product)->getAsIso(2); |
|
|
|
|
|
|
508
|
|
|
$variation_currency['DKK']['price_incl_vat'] = $detail->getPriceIncludingVat($product)->getAsIso(2); |
|
|
|
|
|
|
509
|
|
|
|
|
510
|
|
|
if (isset($currency_gateway) && is_object($currency_gateway)) { |
|
511
|
|
|
foreach ($currency_gateway->findAllWithExchangeRate() as $currency) { |
|
512
|
|
|
$variation_currency[$currency->getType()->getIsoCode()]['price'] = $detail->getPriceInCurrency($currency, 0, $product)->getAsIso(2); |
|
513
|
|
|
$variation_currency[$currency->getType()->getIsoCode()]['price_incl_vat'] = $detail->getPriceIncludingVatInCurrency($currency, 0, $product)->getAsIso(2); |
|
514
|
|
|
} |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
$return['variations'][] = array( |
|
518
|
|
|
'variation' => array( |
|
519
|
|
|
'id' => $variation->getId(), |
|
520
|
|
|
'detail_id' => $detail->getId(), |
|
521
|
|
|
'number' => $variation->getNumber(), |
|
522
|
|
|
'name' => $variation->getName(), |
|
523
|
|
|
'attributes' => $attributes_array, |
|
524
|
|
|
'identifier' => $attribute_string, |
|
525
|
|
|
'price_incl_vat' => $detail->getPriceIncludingVat($product)->getAsIso(2), |
|
526
|
|
|
'weight' => $product->get('weight') + $detail->getWeightDifference(2), |
|
527
|
|
|
'currency' => $variation_currency |
|
528
|
|
|
), |
|
529
|
|
|
'stock' => $stock |
|
530
|
|
|
); |
|
531
|
|
|
} |
|
532
|
|
|
|
|
533
|
|
|
// We should make a Doctrine Product_X_AttributeGroup class and get all the groups i one sql |
|
534
|
|
|
$groups = $product->getAttributeGroups(); |
|
535
|
|
|
$group_gateway = new Intraface_modules_product_Attribute_Group_Gateway; |
|
536
|
|
|
foreach ($groups as $key => $group) { |
|
537
|
|
|
// Make sure we only include necessary data |
|
538
|
|
|
$return['attribute_groups'][$key]['id'] = $group['id']; |
|
539
|
|
|
$return['attribute_groups'][$key]['name'] = $group['name']; |
|
540
|
|
|
$attributes = $group_gateway->findById($group['id'])->getAttributesUsedByProduct($product); |
|
541
|
|
|
foreach ($attributes as $attribute) { |
|
542
|
|
|
// No products has attribute on stock we remove it from the list. |
|
543
|
|
|
if (isset($attribute_for_sale[$attribute->getId()]) && $attribute_for_sale[$attribute->getId()] == 0) { |
|
544
|
|
|
$is_used = 0; |
|
545
|
|
|
} else { |
|
546
|
|
|
$is_used = 1; |
|
547
|
|
|
} |
|
548
|
|
|
|
|
549
|
|
|
$return['attribute_groups'][$key]['attributes'][] = array( |
|
550
|
|
|
'id' => $attribute->getId(), |
|
551
|
|
|
'name' => $attribute->getName(), |
|
552
|
|
|
'is_used' => $is_used |
|
553
|
|
|
); |
|
554
|
|
|
} |
|
555
|
|
|
} |
|
556
|
|
|
} |
|
557
|
|
|
|
|
558
|
|
|
return $this->prepareResponseData($return); |
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
/** |
|
562
|
|
|
* Gets related products |
|
563
|
|
|
* |
|
564
|
|
|
* @param struct $credentials Credentials to use the server |
|
565
|
|
|
* @param integer $shop_id Id for the shop |
|
566
|
|
|
* @param integer $id Product id |
|
|
|
|
|
|
567
|
|
|
* |
|
568
|
|
|
* @return array |
|
569
|
|
|
*/ |
|
570
|
|
View Code Duplication |
public function getRelatedProducts($credentials, $shop_id, $product_id) |
|
|
|
|
|
|
571
|
|
|
{ |
|
572
|
|
|
$this->checkCredentials($credentials); |
|
573
|
|
|
|
|
574
|
|
|
$this->_factoryWebshop($shop_id); |
|
575
|
|
|
|
|
576
|
|
|
if (!is_numeric($product_id)) { |
|
577
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
578
|
|
|
throw new XML_RPC2_FaultException('product id must be an integer', -5); |
|
579
|
|
|
} |
|
580
|
|
|
|
|
581
|
|
|
$product_id = $this->processRequestData(intval($product_id)); |
|
582
|
|
|
|
|
583
|
|
|
if (false !== ($currency_gateway = $this->getCurrencyGateway())) { |
|
584
|
|
|
$currencies = $currency_gateway->findAllWithExchangeRate(); |
|
585
|
|
|
} else { |
|
586
|
|
|
$currencies = false; |
|
587
|
|
|
} |
|
588
|
|
|
|
|
589
|
|
|
$product = new Product($this->kernel, $product_id); |
|
590
|
|
|
return $this->prepareResponseData($this->cleanUpProductList($product->getRelatedProducts($currencies, 'webshop'))); |
|
|
|
|
|
|
591
|
|
|
} |
|
592
|
|
|
|
|
593
|
|
|
/** |
|
594
|
|
|
* Gets featured products |
|
595
|
|
|
* |
|
596
|
|
|
* Method is experimental and only used by discimport.dk. If you need to use it |
|
597
|
|
|
* as well, please contact [email protected]. |
|
598
|
|
|
* |
|
599
|
|
|
* @param struct $credentials Credentials to use the server |
|
600
|
|
|
* @param integer $shop_id Id for the shop |
|
601
|
|
|
* |
|
602
|
|
|
* @return array |
|
603
|
|
|
*/ |
|
604
|
|
View Code Duplication |
public function getFeaturedProducts($credentials, $shop_id) |
|
|
|
|
|
|
605
|
|
|
{ |
|
606
|
|
|
$related_products = array(); |
|
|
|
|
|
|
607
|
|
|
|
|
608
|
|
|
$this->checkCredentials($credentials); |
|
609
|
|
|
|
|
610
|
|
|
$this->_factoryWebshop($shop_id); |
|
611
|
|
|
|
|
612
|
|
|
$db = MDB2::singleton(DB_DSN); |
|
613
|
|
|
|
|
614
|
|
|
if (PEAR::isError($db)) { |
|
615
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
616
|
|
|
throw new XML_RPC2_FaultException($db->getMessage() . $db->getUserInfo(), -1); |
|
617
|
|
|
} |
|
618
|
|
|
|
|
619
|
|
|
$featured = new Intraface_modules_shop_FeaturedProducts($this->kernel->intranet, $this->webshop->getShop(), $db); |
|
620
|
|
|
$all = $featured->getAll(); |
|
621
|
|
|
|
|
622
|
|
|
if (false !== ($currency_gateway = $this->getCurrencyGateway())) { |
|
623
|
|
|
$currencies = $currency_gateway->findAllWithExchangeRate(); |
|
624
|
|
|
} else { |
|
625
|
|
|
$currencies = false; |
|
626
|
|
|
} |
|
627
|
|
|
|
|
628
|
|
|
$related_products = array(); |
|
629
|
|
|
|
|
630
|
|
|
foreach ($all as $row) { |
|
631
|
|
|
$product_gateway = new Intraface_modules_product_Gateway($this->kernel); |
|
632
|
|
|
$product_gateway->getDBQuery()->setFilter('keywords', array($row['keyword_id'])); |
|
633
|
|
|
|
|
634
|
|
|
$related_products[] = array( |
|
635
|
|
|
'title' => $row['headline'], |
|
636
|
|
|
'products' => $this->cleanUpProductList($product_gateway->getAllProducts('webshop', $currencies)) |
|
637
|
|
|
); |
|
638
|
|
|
} |
|
639
|
|
|
|
|
640
|
|
|
return $this->prepareResponseData($related_products); |
|
641
|
|
|
} |
|
642
|
|
|
|
|
643
|
|
|
/** |
|
644
|
|
|
* Gets product keywords which can be used to sort ones webshop |
|
645
|
|
|
* |
|
646
|
|
|
* |
|
647
|
|
|
* @param struct $credentials Credentials to use the server |
|
648
|
|
|
* @param integer $shop_id Id for the shop |
|
649
|
|
|
* |
|
650
|
|
|
* @return array with id and keywords |
|
651
|
|
|
*/ |
|
652
|
|
View Code Duplication |
function getProductKeywords($credentials, $shop_id) |
|
|
|
|
|
|
653
|
|
|
{ |
|
654
|
|
|
$this->checkCredentials($credentials); |
|
655
|
|
|
$this->_factoryWebshop($shop_id); |
|
656
|
|
|
|
|
657
|
|
|
$product = new Product($this->kernel); |
|
658
|
|
|
$keywords = $product->getKeywordAppender(); |
|
659
|
|
|
return $this->prepareResponseData($keywords->getUsedKeywords()); |
|
660
|
|
|
} |
|
661
|
|
|
|
|
662
|
|
|
/** |
|
663
|
|
|
* Returns the categories for the shop |
|
664
|
|
|
* |
|
665
|
|
|
* @param struct $credentials Credentials to use the server |
|
666
|
|
|
* @param integer $shop_id Id for the shop |
|
667
|
|
|
* |
|
668
|
|
|
* @return array with categories |
|
669
|
|
|
* |
|
670
|
|
|
*/ |
|
671
|
|
View Code Duplication |
public function getProductCategories($credentials, $shop_id) |
|
|
|
|
|
|
672
|
|
|
{ |
|
673
|
|
|
if (is_object($return = $this->checkCredentials($credentials))) { |
|
674
|
|
|
return $return; |
|
675
|
|
|
} |
|
676
|
|
|
|
|
677
|
|
|
$this->_factoryWebshop($shop_id); |
|
678
|
|
|
$category = new Intraface_Category( |
|
679
|
|
|
$this->kernel, |
|
680
|
|
|
MDB2::singleton(DB_DSN), |
|
681
|
|
|
new Intraface_Category_Type('shop', $shop_id) |
|
682
|
|
|
); |
|
683
|
|
|
|
|
684
|
|
|
return $this->prepareResponseData($category->getAllCategories()); |
|
685
|
|
|
} |
|
686
|
|
|
|
|
687
|
|
|
/** |
|
688
|
|
|
* Returns the pictures for the product categories for the shop |
|
689
|
|
|
* |
|
690
|
|
|
* @param struct $credentials Credentials to use the server |
|
691
|
|
|
* @param integer $shop_id Id for the shop |
|
692
|
|
|
* @param integer $category_id Categori id |
|
693
|
|
|
* |
|
694
|
|
|
* @return array with pictures for categories |
|
695
|
|
|
*/ |
|
696
|
|
View Code Duplication |
public function getProductCategoryPicture($credentials, $shop_id, $category_id) |
|
|
|
|
|
|
697
|
|
|
{ |
|
698
|
|
|
if (is_object($return = $this->checkCredentials($credentials))) { |
|
699
|
|
|
return $return; |
|
700
|
|
|
} |
|
701
|
|
|
|
|
702
|
|
|
$this->_factoryWebshop($shop_id); |
|
703
|
|
|
$module = $this->kernel->useModule('filemanager'); |
|
|
|
|
|
|
704
|
|
|
require_once 'Intraface/shared/filehandler/AppendFile.php'; |
|
705
|
|
|
|
|
706
|
|
|
$pictures = array(); |
|
707
|
|
|
|
|
708
|
|
|
$append_file = new AppendFile($this->kernel, 'category', $category_id); |
|
709
|
|
|
$appendix_list = $append_file->getList(); |
|
710
|
|
|
foreach ($appendix_list as $key => $appendix) { |
|
711
|
|
|
$tmp_filehandler = new FileHandler($this->kernel, $appendix['file_handler_id']); |
|
712
|
|
|
$pictures[$key]['id'] = $appendix['file_handler_id']; |
|
713
|
|
|
$pictures[$key]['original']['icon_uri'] = $tmp_filehandler->get('icon_uri'); |
|
714
|
|
|
$pictures[$key]['original']['name'] = $tmp_filehandler->get('file_name'); |
|
715
|
|
|
$pictures[$key]['original']['width'] = $tmp_filehandler->get('width'); |
|
716
|
|
|
$pictures[$key]['original']['height'] = $tmp_filehandler->get('height'); |
|
717
|
|
|
$pictures[$key]['original']['file_uri'] = $tmp_filehandler->get('file_uri'); |
|
718
|
|
|
$pictures[$key]['appended_file_id'] = $appendix['id']; |
|
719
|
|
|
|
|
720
|
|
|
if ($tmp_filehandler->get('is_image')) { |
|
721
|
|
|
$tmp_filehandler->createInstance(); |
|
722
|
|
|
$instances = $tmp_filehandler->instance->getList('include_hidden'); |
|
723
|
|
|
foreach ($instances as $instance) { |
|
724
|
|
|
$pictures[$key][$instance['name']]['file_uri'] = $instance['file_uri']; |
|
725
|
|
|
$pictures[$key][$instance['name']]['name'] = $instance['name']; |
|
726
|
|
|
$pictures[$key][$instance['name']]['width'] = $instance['width']; |
|
727
|
|
|
$pictures[$key][$instance['name']]['height'] = $instance['height']; |
|
728
|
|
|
} |
|
729
|
|
|
} |
|
730
|
|
|
//$tmp_filehandler->__destruct(); |
|
|
|
|
|
|
731
|
|
|
unset($tmp_filehandler); |
|
732
|
|
|
} |
|
733
|
|
|
|
|
734
|
|
|
return $this->prepareResponseData($pictures); |
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
/** |
|
738
|
|
|
* Add product to basket |
|
739
|
|
|
* |
|
740
|
|
|
* @param struct $credentials Credentials to use the server |
|
741
|
|
|
* @param integer $shop_id Id for the shop |
|
742
|
|
|
* @param integer $produt_id Product id to add |
|
|
|
|
|
|
743
|
|
|
* @param integer $product_variation_id Product variation id to change |
|
744
|
|
|
* @param integer $quantity Optional quantity |
|
745
|
|
|
* @param string $text Extra text to the itemline |
|
746
|
|
|
* @param integer $product_detail_id Product detail id |
|
747
|
|
|
* |
|
748
|
|
|
* @return boolean |
|
749
|
|
|
*/ |
|
750
|
|
View Code Duplication |
public function addProductToBasket($credentials, $shop_id, $product_id, $product_variation_id, $quantity = 1, $text = '', $product_detail_id = 0) |
|
|
|
|
|
|
751
|
|
|
{ |
|
752
|
|
|
if (is_object($return = $this->checkCredentials($credentials))) { |
|
753
|
|
|
return $return; |
|
754
|
|
|
} |
|
755
|
|
|
|
|
756
|
|
|
$this->_factoryWebshop($shop_id); |
|
757
|
|
|
|
|
758
|
|
|
if (!is_numeric($product_id)) { |
|
759
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
760
|
|
|
throw new XML_RPC2_FaultException('product id must be an integer', -5); |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
$product_id = $this->processRequestData(intval($product_id)); |
|
764
|
|
|
$product_variation_id = $this->processRequestData(intval($product_variation_id)); |
|
765
|
|
|
$quantity = $this->processRequestData(intval($quantity)); |
|
766
|
|
|
$text = $this->processRequestData($text); |
|
767
|
|
|
$product_detail_id = $this->processRequestData(intval($product_detail_id)); |
|
768
|
|
|
|
|
769
|
|
|
return $this->prepareResponseData( |
|
770
|
|
|
$this->webshop->getBasket()->add($product_id, $product_variation_id, $quantity, $text, $product_detail_id) |
|
771
|
|
|
); |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
/** |
|
775
|
|
|
* Change the quantity of one product in basket |
|
776
|
|
|
* |
|
777
|
|
|
* @param struct $credentials Credentials to use the server |
|
778
|
|
|
* @param integer $shop_id Id for the shop |
|
779
|
|
|
* @param integer $product_id Product id to change |
|
780
|
|
|
* @param integer $product_variation_id Product_variation_id to change |
|
781
|
|
|
* @param integer $quantity New quantity |
|
782
|
|
|
* @param string $text Extra text to the itemline |
|
783
|
|
|
* @param integer $product_detail_id Product detail id |
|
784
|
|
|
* |
|
785
|
|
|
* @return mixed |
|
786
|
|
|
*/ |
|
787
|
|
|
public function changeProductInBasket($credentials, $shop_id, $product_id, $product_variation_id, $quantity, $text = '', $product_detail_id = 0) |
|
788
|
|
|
{ |
|
789
|
|
|
$this->checkCredentials($credentials); |
|
790
|
|
|
|
|
791
|
|
|
$this->_factoryWebshop($shop_id); |
|
792
|
|
|
|
|
793
|
|
|
if (!is_numeric($product_id) and !is_numeric($quantity)) { |
|
|
|
|
|
|
794
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
795
|
|
|
throw new XML_RPC2_FaultException('product id and quantity must be integers', -5); |
|
796
|
|
|
} |
|
797
|
|
|
|
|
798
|
|
|
$product_id = intval($product_id); |
|
799
|
|
|
$product_variation_id = intval($product_variation_id); |
|
800
|
|
|
$quantity = intval($quantity); |
|
801
|
|
|
$text = $this->processRequestData($text); |
|
802
|
|
|
$product_detail_id = intval($product_detail_id); |
|
803
|
|
|
|
|
804
|
|
|
if (!$this->webshop->getBasket()->change($product_id, $product_variation_id, $quantity, $text, $product_detail_id)) { |
|
805
|
|
|
return false; |
|
806
|
|
|
} |
|
807
|
|
|
|
|
808
|
|
|
return true; |
|
809
|
|
|
} |
|
810
|
|
|
|
|
811
|
|
|
/** |
|
812
|
|
|
* Gets an array with the current basket |
|
813
|
|
|
* |
|
814
|
|
|
* @param struct $credentials Credentials to use the server |
|
815
|
|
|
* @param integer $shop_id Id for the shop |
|
816
|
|
|
* @param struct $customer customer values |
|
817
|
|
|
* |
|
818
|
|
|
* @return array |
|
819
|
|
|
*/ |
|
820
|
|
View Code Duplication |
public function getBasket($credentials, $shop_id, $customer = array()) |
|
|
|
|
|
|
821
|
|
|
{ |
|
822
|
|
|
$this->checkCredentials($credentials); |
|
823
|
|
|
|
|
824
|
|
|
$this->_factoryWebshop($shop_id); |
|
825
|
|
|
|
|
826
|
|
|
$customer = $this->processRequestData($customer); |
|
827
|
|
|
|
|
828
|
|
|
// we put the possibility for BasketEvaluation not to be run. |
|
829
|
|
|
if (is_string($customer) && $customer == 'no_evaluation') { |
|
|
|
|
|
|
830
|
|
|
// nothing happens |
|
831
|
|
|
} elseif (is_array($customer)) { |
|
832
|
|
|
$basketevaluation = new Intraface_modules_shop_BasketEvaluation(MDB2::singleton(DB_DSN), $this->webshop->kernel->intranet, $this->webshop->shop); |
|
833
|
|
|
if (!$basketevaluation->run($this->webshop->getBasket(), $customer)) { |
|
|
|
|
|
|
834
|
|
|
// We should see to return the result in some way. |
|
835
|
|
|
} |
|
836
|
|
|
} |
|
837
|
|
|
|
|
838
|
|
|
if (false !== ($currency_gateway = $this->getCurrencyGateway())) { |
|
839
|
|
|
$currencies = $currency_gateway->findAllWithExchangeRate(); |
|
840
|
|
|
} else { |
|
841
|
|
|
$currencies = false; |
|
842
|
|
|
} |
|
843
|
|
|
|
|
844
|
|
|
return $this->prepareResponseData(array( |
|
845
|
|
|
'items' => $this->webshop->getBasket()->getItems($currencies), |
|
846
|
|
|
'total_price' => $this->webshop->getBasket()->getTotalPriceInCurrencies($currencies), |
|
847
|
|
|
'weight' => $this->webshop->getBasket()->getTotalWeight() |
|
848
|
|
|
)); |
|
849
|
|
|
} |
|
850
|
|
|
|
|
851
|
|
|
/** |
|
852
|
|
|
* Places an order in Intraface based on the current basket |
|
853
|
|
|
* |
|
854
|
|
|
* @param struct $credentials Credentials to use the server |
|
855
|
|
|
* @param integer $shop_id Id for the shop |
|
856
|
|
|
* @param struct $values Values to save |
|
857
|
|
|
* |
|
858
|
|
|
* @return integer $order_id |
|
859
|
|
|
*/ |
|
860
|
|
View Code Duplication |
public function placeOrder($credentials, $shop_id, $values) |
|
|
|
|
|
|
861
|
|
|
{ |
|
862
|
|
|
$this->checkCredentials($credentials); |
|
863
|
|
|
|
|
864
|
|
|
$this->_factoryWebshop($shop_id); |
|
865
|
|
|
|
|
866
|
|
|
$values = $this->processRequestData($values); |
|
867
|
|
|
|
|
868
|
|
|
if (!is_array($this->webshop->getBasket()->getItems()) or count($this->webshop->getBasket()->getItems()) <= 0) { |
|
|
|
|
|
|
869
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
870
|
|
|
throw new XML_RPC2_FaultException('order could not be sent - cart is empty', -4); |
|
871
|
|
|
} |
|
872
|
|
|
|
|
873
|
|
|
if (empty($values['description'])) { |
|
874
|
|
|
$values['description'] = $this->webshop->getShop()->getName(); |
|
875
|
|
|
} |
|
876
|
|
|
|
|
877
|
|
|
if (!$order_id = $this->webshop->placeOrder($values)) { |
|
878
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
879
|
|
|
throw new XML_RPC2_FaultException('order could not be placed. It returned the following error: ' . strtolower(implode(', ', $this->webshop->error->getMessage())), -4); |
|
880
|
|
|
} |
|
881
|
|
|
|
|
882
|
|
|
return $this->prepareResponseData($this->webshop->getOrderIdentifierKey()); |
|
883
|
|
|
} |
|
884
|
|
|
|
|
885
|
|
|
/** |
|
886
|
|
|
* Saves buyer details |
|
887
|
|
|
* |
|
888
|
|
|
* @param struct $credentials Credentials to use the server |
|
889
|
|
|
* @param integer $shop_id Id for the shop |
|
890
|
|
|
* @param struct $values Values to save |
|
891
|
|
|
* |
|
892
|
|
|
* @return boolean true or false |
|
893
|
|
|
*/ |
|
894
|
|
View Code Duplication |
public function saveAddress($credentials, $shop_id, $values) |
|
|
|
|
|
|
895
|
|
|
{ |
|
896
|
|
|
$this->checkCredentials($credentials); |
|
897
|
|
|
|
|
898
|
|
|
$this->_factoryWebshop($shop_id); |
|
899
|
|
|
|
|
900
|
|
|
if (!is_array($values)) { |
|
901
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
902
|
|
|
throw new XML_RPC2_FaultException('details could not be saved - nothing to save', -4); |
|
903
|
|
|
} |
|
904
|
|
|
|
|
905
|
|
|
$values = $this->processRequestData($values); |
|
906
|
|
|
|
|
907
|
|
|
if (!$this->webshop->getBasket()->saveAddress($values)) { |
|
908
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
909
|
|
|
throw new XML_RPC2_FaultException('datails could not be saved ' . strtolower(implode(', ', $this->webshop->error->getMessage())), -4); |
|
910
|
|
|
} |
|
911
|
|
|
|
|
912
|
|
|
return $this->prepareResponseData(true); |
|
913
|
|
|
} |
|
914
|
|
|
|
|
915
|
|
|
/** |
|
916
|
|
|
* Get buyer details |
|
917
|
|
|
* |
|
918
|
|
|
* @param struct $credentials Credentials to use the server |
|
919
|
|
|
* @param integer $shop_id Id for the shop |
|
920
|
|
|
* |
|
921
|
|
|
* @return array |
|
922
|
|
|
*/ |
|
923
|
|
|
public function getAddress($credentials, $shop_id) |
|
924
|
|
|
{ |
|
925
|
|
|
$this->checkCredentials($credentials); |
|
926
|
|
|
|
|
927
|
|
|
$this->_factoryWebshop($shop_id); |
|
928
|
|
|
|
|
929
|
|
|
return $this->prepareResponseData($this->webshop->getBasket()->getAddress()); |
|
930
|
|
|
} |
|
931
|
|
|
|
|
932
|
|
|
/** |
|
933
|
|
|
* Saves customer coupon |
|
934
|
|
|
* |
|
935
|
|
|
* @param struct $credentials Credentials to use the server |
|
936
|
|
|
* @param integer $shop_id Id for the shop |
|
937
|
|
|
* @param string $customer_coupon Customer coupon to save |
|
938
|
|
|
* |
|
939
|
|
|
* @return boolean true or false |
|
940
|
|
|
*/ |
|
941
|
|
View Code Duplication |
public function saveCustomerCoupon($credentials, $shop_id, $customer_coupon) |
|
|
|
|
|
|
942
|
|
|
{ |
|
943
|
|
|
$this->checkCredentials($credentials); |
|
944
|
|
|
|
|
945
|
|
|
$this->_factoryWebshop($shop_id); |
|
946
|
|
|
|
|
947
|
|
|
$customer_coupon = $this->processRequestData($customer_coupon); |
|
948
|
|
|
if (!$this->webshop->getBasket()->saveCustomerCoupon($customer_coupon)) { |
|
949
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
950
|
|
|
throw new XML_RPC2_FaultException('datails could not be saved ' . strtolower(implode(', ', $this->webshop->error->getMessage())), -4); |
|
951
|
|
|
} |
|
952
|
|
|
|
|
953
|
|
|
return $this->prepareResponseData(true); |
|
954
|
|
|
} |
|
955
|
|
|
|
|
956
|
|
|
|
|
957
|
|
|
/** |
|
958
|
|
|
* Get customer coupon |
|
959
|
|
|
* |
|
960
|
|
|
* @param struct $credentials Credentials to use the server |
|
961
|
|
|
* @param integer $shop_id Id for the shop |
|
962
|
|
|
* |
|
963
|
|
|
* @return array |
|
964
|
|
|
*/ |
|
965
|
|
|
public function getCustomerCoupon($credentials, $shop_id) |
|
966
|
|
|
{ |
|
967
|
|
|
$this->checkCredentials($credentials); |
|
968
|
|
|
|
|
969
|
|
|
$this->_factoryWebshop($shop_id); |
|
970
|
|
|
return $this->prepareResponseData($this->webshop->getBasket()->getCustomerCoupon()); |
|
971
|
|
|
} |
|
972
|
|
|
|
|
973
|
|
|
/** |
|
974
|
|
|
* Saves customer EAN location number |
|
975
|
|
|
* |
|
976
|
|
|
* @param struct $credentials Credentials to use the server |
|
977
|
|
|
* @param integer $shop_id Id for the shop |
|
978
|
|
|
* @param string $customer_ean Customer EAN to save |
|
979
|
|
|
* |
|
980
|
|
|
* @return boolean true or false |
|
981
|
|
|
*/ |
|
982
|
|
View Code Duplication |
public function saveCustomerEan($credentials, $shop_id, $customer_ean) |
|
|
|
|
|
|
983
|
|
|
{ |
|
984
|
|
|
$this->checkCredentials($credentials); |
|
985
|
|
|
|
|
986
|
|
|
$this->_factoryWebshop($shop_id); |
|
987
|
|
|
|
|
988
|
|
|
$customer_ean = $this->processRequestData($customer_ean); |
|
989
|
|
|
if (!$this->webshop->getBasket()->saveCustomerEan($customer_ean)) { |
|
990
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
991
|
|
|
throw new XML_RPC2_FaultException('ean could not be saved ' . strtolower(implode(', ', $this->webshop->error->getMessage())), -4); |
|
992
|
|
|
} |
|
993
|
|
|
|
|
994
|
|
|
return $this->prepareResponseData(true); |
|
995
|
|
|
} |
|
996
|
|
|
|
|
997
|
|
|
|
|
998
|
|
|
/** |
|
999
|
|
|
* Get customer EAN location number |
|
1000
|
|
|
* |
|
1001
|
|
|
* @param struct $credentials Credentials to use the server |
|
1002
|
|
|
* @param integer $shop_id Id for the shop |
|
1003
|
|
|
* |
|
1004
|
|
|
* @return array |
|
1005
|
|
|
*/ |
|
1006
|
|
|
public function getCustomerEan($credentials, $shop_id) |
|
1007
|
|
|
{ |
|
1008
|
|
|
$this->checkCredentials($credentials); |
|
1009
|
|
|
|
|
1010
|
|
|
$this->_factoryWebshop($shop_id); |
|
1011
|
|
|
|
|
1012
|
|
|
return $this->prepareResponseData($this->webshop->getBasket()->getCustomerEan()); |
|
1013
|
|
|
} |
|
1014
|
|
|
|
|
1015
|
|
|
/** |
|
1016
|
|
|
* Saves customer comment |
|
1017
|
|
|
* |
|
1018
|
|
|
* @param struct $credentials Credentials to use the server |
|
1019
|
|
|
* @param integer $shop_id Id for the shop |
|
1020
|
|
|
* @param string $customer_comment Customer coupon to save |
|
1021
|
|
|
* |
|
1022
|
|
|
* @return boolean true or false |
|
1023
|
|
|
*/ |
|
1024
|
|
View Code Duplication |
public function saveCustomerComment($credentials, $shop_id, $customer_comment) |
|
|
|
|
|
|
1025
|
|
|
{ |
|
1026
|
|
|
$this->checkCredentials($credentials); |
|
1027
|
|
|
|
|
1028
|
|
|
$this->_factoryWebshop($shop_id); |
|
1029
|
|
|
|
|
1030
|
|
|
$customer_comment = $this->processRequestData($customer_comment); |
|
1031
|
|
|
if (!$this->webshop->getBasket()->saveCustomerComment($customer_comment)) { |
|
1032
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
1033
|
|
|
throw new XML_RPC2_FaultException('datails could not be saved ' . strtolower(implode(', ', $this->webshop->error->getMessage())), -4); |
|
1034
|
|
|
} |
|
1035
|
|
|
|
|
1036
|
|
|
return $this->prepareResponseData(true); |
|
1037
|
|
|
} |
|
1038
|
|
|
|
|
1039
|
|
|
|
|
1040
|
|
|
/** |
|
1041
|
|
|
* Get customer comment |
|
1042
|
|
|
* |
|
1043
|
|
|
* @param struct $credentials Credentials to use the server |
|
1044
|
|
|
* @param integer $shop_id Id for the shop |
|
1045
|
|
|
* |
|
1046
|
|
|
* @return array |
|
1047
|
|
|
*/ |
|
1048
|
|
|
public function getCustomerComment($credentials, $shop_id) |
|
1049
|
|
|
{ |
|
1050
|
|
|
$this->checkCredentials($credentials); |
|
1051
|
|
|
|
|
1052
|
|
|
$this->_factoryWebshop($shop_id); |
|
1053
|
|
|
|
|
1054
|
|
|
return $this->prepareResponseData($this->webshop->getBasket()->getCustomerComment()); |
|
1055
|
|
|
} |
|
1056
|
|
|
|
|
1057
|
|
|
/** |
|
1058
|
|
|
* Get possible payment methods |
|
1059
|
|
|
* |
|
1060
|
|
|
* @param struct $credentials Credentials to use the server |
|
1061
|
|
|
* @param integer $shop_id Id for the shop |
|
1062
|
|
|
* |
|
1063
|
|
|
* @return array |
|
1064
|
|
|
*/ |
|
1065
|
|
|
public function getPaymentMethods($credentials, $shop_id) |
|
1066
|
|
|
{ |
|
1067
|
|
|
$this->checkCredentials($credentials); |
|
1068
|
|
|
|
|
1069
|
|
|
$this->_factoryWebshop($shop_id); |
|
1070
|
|
|
|
|
1071
|
|
|
return $this->prepareResponseData($this->webshop->getPaymentMethods()); |
|
1072
|
|
|
} |
|
1073
|
|
|
|
|
1074
|
|
|
/** |
|
1075
|
|
|
* Saves payment method |
|
1076
|
|
|
* |
|
1077
|
|
|
* @param struct $credentials Credentials to use the server |
|
1078
|
|
|
* @param integer $shop_id Id for the shop |
|
1079
|
|
|
* @param string $payment_method Payment method to save |
|
1080
|
|
|
* |
|
1081
|
|
|
* @return boolean true or false |
|
1082
|
|
|
*/ |
|
1083
|
|
View Code Duplication |
public function savePaymentMethod($credentials, $shop_id, $payment_method) |
|
|
|
|
|
|
1084
|
|
|
{ |
|
1085
|
|
|
$this->checkCredentials($credentials); |
|
1086
|
|
|
|
|
1087
|
|
|
$this->_factoryWebshop($shop_id); |
|
1088
|
|
|
|
|
1089
|
|
|
$payment_method = $this->processRequestData($payment_method); |
|
1090
|
|
|
if (!$this->webshop->getBasket()->savePaymentMethod($payment_method)) { |
|
1091
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
1092
|
|
|
throw new XML_RPC2_FaultException('datails could not be saved ' . strtolower(implode(', ', $this->webshop->error->getMessage())), -4); |
|
1093
|
|
|
} |
|
1094
|
|
|
|
|
1095
|
|
|
return $this->prepareResponseData(true); |
|
1096
|
|
|
} |
|
1097
|
|
|
|
|
1098
|
|
|
/** |
|
1099
|
|
|
* Returns selected payment method |
|
1100
|
|
|
* |
|
1101
|
|
|
* @param struct $credentials Credentials to use the server |
|
1102
|
|
|
* @param integer $shop_id Id for the shop |
|
1103
|
|
|
* |
|
1104
|
|
|
* @return array |
|
1105
|
|
|
*/ |
|
1106
|
|
|
public function getPaymentMethod($credentials, $shop_id) |
|
1107
|
|
|
{ |
|
1108
|
|
|
$this->checkCredentials($credentials); |
|
1109
|
|
|
|
|
1110
|
|
|
$this->_factoryWebshop($shop_id); |
|
1111
|
|
|
|
|
1112
|
|
|
return $this->prepareResponseData($this->webshop->getBasket()->getPaymentMethod()); |
|
1113
|
|
|
} |
|
1114
|
|
|
|
|
1115
|
|
|
/** |
|
1116
|
|
|
* Get receipt text |
|
1117
|
|
|
* |
|
1118
|
|
|
* @param struct $credentials Credentials to use the server |
|
1119
|
|
|
* @param integer $shop_id Id for the shop |
|
1120
|
|
|
* |
|
1121
|
|
|
* @return array |
|
1122
|
|
|
*/ |
|
1123
|
|
|
public function getReceiptText($credentials, $shop_id) |
|
1124
|
|
|
{ |
|
1125
|
|
|
$this->checkCredentials($credentials); |
|
1126
|
|
|
|
|
1127
|
|
|
$this->_factoryWebshop($shop_id); |
|
1128
|
|
|
return $this->prepareResponseData($this->webshop->getReceiptText()); |
|
1129
|
|
|
} |
|
1130
|
|
|
|
|
1131
|
|
|
/** |
|
1132
|
|
|
* Get url for terms of trade |
|
1133
|
|
|
* |
|
1134
|
|
|
* @param struct $credentials Credentials to use the server |
|
1135
|
|
|
* @param integer $shop_id Id for the shop |
|
1136
|
|
|
* |
|
1137
|
|
|
* @return string |
|
1138
|
|
|
*/ |
|
1139
|
|
|
public function getTermsOfTradeUrl($credentials, $shop_id) |
|
1140
|
|
|
{ |
|
1141
|
|
|
$this->checkCredentials($credentials); |
|
1142
|
|
|
|
|
1143
|
|
|
$this->_factoryWebshop($shop_id); |
|
1144
|
|
|
|
|
1145
|
|
|
return $this->prepareResponseData($this->webshop->getShop()->getTermsOfTradeUrl()); |
|
1146
|
|
|
} |
|
1147
|
|
|
|
|
1148
|
|
|
/** |
|
1149
|
|
|
* Get default currency. |
|
1150
|
|
|
* |
|
1151
|
|
|
* @param struct $credentials Credentials to use the server |
|
1152
|
|
|
* @param integer $shop_id Id for the shop |
|
1153
|
|
|
* |
|
1154
|
|
|
* @return string |
|
1155
|
|
|
*/ |
|
1156
|
|
|
public function getCurrency($credentials, $shop_id) |
|
1157
|
|
|
{ |
|
1158
|
|
|
$this->checkCredentials($credentials); |
|
1159
|
|
|
|
|
1160
|
|
|
$this->_factoryWebshop($shop_id); |
|
1161
|
|
|
|
|
1162
|
|
|
return $this->prepareResponseData($this->getCurrencyArray()); |
|
1163
|
|
|
} |
|
1164
|
|
|
|
|
1165
|
|
|
/** |
|
1166
|
|
|
* Returns currency gateway if there is access to it |
|
1167
|
|
|
*/ |
|
1168
|
|
View Code Duplication |
private function getCurrencyGateway() |
|
|
|
|
|
|
1169
|
|
|
{ |
|
1170
|
|
|
if ($this->webshop->kernel->intranet->hasModuleAccess('currency')) { |
|
1171
|
|
|
$this->webshop->kernel->useModule('currency', true); // true: ignore intranet access |
|
1172
|
|
|
return new Intraface_modules_currency_Currency_Gateway($this->doctrine); |
|
1173
|
|
|
} |
|
1174
|
|
|
return false; |
|
1175
|
|
|
} |
|
1176
|
|
|
|
|
1177
|
|
|
/** |
|
1178
|
|
|
* Returns an array with currency information. |
|
1179
|
|
|
* |
|
1180
|
|
|
* @return array default currency and valid currencies |
|
1181
|
|
|
*/ |
|
1182
|
|
View Code Duplication |
private function getCurrencyArray() |
|
|
|
|
|
|
1183
|
|
|
{ |
|
1184
|
|
|
$currency['default'] = 'DKK'; |
|
|
|
|
|
|
1185
|
|
|
$currency['currencies']['DKK'] = 'Danish Krone'; |
|
1186
|
|
|
|
|
1187
|
|
|
if (false !== ($currency_gateway = $this->getCurrencyGateway())) { |
|
1188
|
|
|
foreach ($currency_gateway->findAllWithExchangeRate() as $c) { |
|
1189
|
|
|
$currency['currencies'][$c->getType()->getIsoCode()] = $c->getType()->getDescription(); |
|
1190
|
|
|
} |
|
1191
|
|
|
} |
|
1192
|
|
|
|
|
1193
|
|
|
if (false !== ($default_currency = $this->webshop->getShop()->getDefaultCurrency($currency_gateway))) { |
|
1194
|
|
|
$currency['default'] = $default_currency->getType()->getIsoCode(); |
|
1195
|
|
|
} |
|
1196
|
|
|
|
|
1197
|
|
|
return $currency; |
|
1198
|
|
|
} |
|
1199
|
|
|
|
|
1200
|
|
|
/** |
|
1201
|
|
|
* Get identifier |
|
1202
|
|
|
* |
|
1203
|
|
|
* @param struct $credentials Credentials to use the server |
|
1204
|
|
|
* @param integer $shop_id Id for the shop |
|
1205
|
|
|
* |
|
1206
|
|
|
* @return string |
|
1207
|
|
|
*/ |
|
1208
|
|
|
public function getIdentifier($credentials, $shop_id) |
|
1209
|
|
|
{ |
|
1210
|
|
|
$this->checkCredentials($credentials); |
|
1211
|
|
|
|
|
1212
|
|
|
$this->_factoryWebshop($shop_id); |
|
1213
|
|
|
|
|
1214
|
|
|
return $this->prepareResponseData($this->webshop->getShop()->getIdentifier()); |
|
1215
|
|
|
} |
|
1216
|
|
|
|
|
1217
|
|
|
/** |
|
1218
|
|
|
* Gets information about the company |
|
1219
|
|
|
* |
|
1220
|
|
|
* @param struct $credentials Credentials to use the server |
|
1221
|
|
|
* |
|
1222
|
|
|
* @return array |
|
1223
|
|
|
*/ |
|
1224
|
|
View Code Duplication |
public function getCompanyInformation($credentials) |
|
|
|
|
|
|
1225
|
|
|
{ |
|
1226
|
|
|
$this->checkCredentials($credentials); |
|
1227
|
|
|
$address = array(); |
|
1228
|
|
|
$address['name'] = $this->kernel->getIntranet()->getAddress()->get('name'); |
|
1229
|
|
|
$address['address'] = $this->kernel->getIntranet()->getAddress()->get('address'); |
|
1230
|
|
|
$address['postcode'] = $this->kernel->getIntranet()->getAddress()->get('postcode'); |
|
1231
|
|
|
$address['city'] = $this->kernel->getIntranet()->getAddress()->get('city'); |
|
1232
|
|
|
$address['cvr'] = $this->kernel->getIntranet()->getAddress()->get('cvr'); |
|
1233
|
|
|
return $this->prepareResponseData($address); |
|
1234
|
|
|
} |
|
1235
|
|
|
|
|
1236
|
|
|
/** |
|
1237
|
|
|
* Initialize the webshop |
|
1238
|
|
|
* |
|
1239
|
|
|
* @return void |
|
1240
|
|
|
*/ |
|
1241
|
|
View Code Duplication |
private function _factoryWebshop($shop_id) |
|
|
|
|
|
|
1242
|
|
|
{ |
|
1243
|
|
|
if (!$this->kernel->intranet->hasModuleAccess('shop')) { |
|
1244
|
|
|
require_once 'XML/RPC2/Exception.php'; |
|
1245
|
|
|
throw new XML_RPC2_FaultException('The intranet does not have access to the module webshop', -2); |
|
1246
|
|
|
} |
|
1247
|
|
|
$this->kernel->module('shop'); |
|
1248
|
|
|
|
|
1249
|
|
|
$gateway = new Intraface_modules_shop_ShopGateway($this->doctrine); |
|
1250
|
|
|
$shop = $gateway->findById($shop_id); |
|
1251
|
|
|
if ($shop === false) { |
|
1252
|
|
|
throw new XML_RPC2_FaultException('Could not find shop', 1); |
|
1253
|
|
|
} |
|
1254
|
|
|
$this->webshop = new Intraface_modules_shop_Coordinator($this->kernel, $shop, $this->credentials['session_id']); |
|
1255
|
|
|
} |
|
1256
|
|
|
|
|
1257
|
|
|
private function getDoctrine() |
|
1258
|
|
|
{ |
|
1259
|
|
|
return $this->doctrine; |
|
1260
|
|
|
} |
|
1261
|
|
|
} |
|
1262
|
|
|
|
|
1263
|
|
|
/** |
|
1264
|
|
|
* Stub class used to serve Stock which expects old implementation of product. |
|
1265
|
|
|
* @author sune |
|
1266
|
|
|
* |
|
1267
|
|
|
*/ |
|
1268
|
|
|
class Intraface_XMLRPC_Shop_Server0100_Product |
|
1269
|
|
|
{ |
|
1270
|
|
|
|
|
1271
|
|
|
public $kernel; |
|
1272
|
|
|
private $product; |
|
1273
|
|
|
|
|
1274
|
|
|
public function __construct($product, $kernel) |
|
1275
|
|
|
{ |
|
1276
|
|
|
$this->kernel = $kernel; |
|
1277
|
|
|
$this->product = $product; |
|
1278
|
|
|
} |
|
1279
|
|
|
|
|
1280
|
|
|
public function get($value) |
|
1281
|
|
|
{ |
|
1282
|
|
|
if ($value == 'id') { |
|
1283
|
|
|
return $this->getId(); |
|
1284
|
|
|
} |
|
1285
|
|
|
|
|
1286
|
|
|
throw new Exception('Value '.$value.' not implemented!'); |
|
1287
|
|
|
} |
|
1288
|
|
|
|
|
1289
|
|
|
public function getId() |
|
1290
|
|
|
{ |
|
1291
|
|
|
return $this->product->getId(); |
|
1292
|
|
|
} |
|
1293
|
|
|
} |
|
1294
|
|
|
|
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.