1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
(defined('BASEPATH')) OR exit('No direct script access allowed'); |
4
|
|
|
|
5
|
|
View Code Duplication |
if (!function_exists('load_cat')) { |
6
|
|
|
|
7
|
|
|
function load_cat() { |
8
|
|
|
|
9
|
|
|
$ci = &get_instance(); |
10
|
|
|
return $ci->db->get('shop_category')->result_array(); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
} |
14
|
|
|
if (!function_exists('test_ex')) { |
15
|
|
|
|
16
|
|
|
function test_ex() { |
17
|
|
|
|
18
|
|
|
exit('1'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
} |
22
|
|
View Code Duplication |
if (!function_exists('load_product')) { |
23
|
|
|
|
24
|
|
|
function load_product() { |
25
|
|
|
|
26
|
|
|
$ci = &get_instance(); |
27
|
|
|
$arr = []; |
28
|
|
|
foreach ($ci->db->get('shop_products')->result_array() as $key => $val) { |
29
|
|
|
$arr[$val['id']] = $val['external_id']; |
30
|
|
|
} |
31
|
|
|
return $arr; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
View Code Duplication |
if (!function_exists('load_urls')) { |
37
|
|
|
|
38
|
|
|
function load_urls() { |
39
|
|
|
|
40
|
|
|
$ci = &get_instance(); |
41
|
|
|
$arr = []; |
42
|
|
|
foreach ($ci->db->get('shop_products')->result_array() as $key => $val) { |
43
|
|
|
$arr[$val['id']] = $val['url']; |
44
|
|
|
} |
45
|
|
|
return $arr; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if (!function_exists('load_main_curr')) { |
51
|
|
|
|
52
|
|
|
function load_main_curr() { |
53
|
|
|
|
54
|
|
|
$ci = &get_instance(); |
55
|
|
|
$mainCurrencyId = $ci->db->select('id')->where('main', 1)->get('shop_currencies')->row_array(); |
56
|
|
|
if (!empty($mainCurrencyId)) { |
57
|
|
|
$mainCurrencyId = $mainCurrencyId['id']; |
58
|
|
|
} else { |
59
|
|
|
$mainCurrencyId = 1; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $mainCurrencyId; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
View Code Duplication |
if (!function_exists('get_product_category')) { |
68
|
|
|
|
69
|
|
|
function get_product_category($id) { |
70
|
|
|
|
71
|
|
|
$ci = &get_instance(); |
72
|
|
|
$result = $ci->db |
73
|
|
|
->join('shop_category', 'shop_category.id=shop_products.category_id') |
74
|
|
|
->where('shop_products.id', $id) |
75
|
|
|
->get('shop_products') |
76
|
|
|
->row_array(); |
77
|
|
|
return $result; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
View Code Duplication |
if (!function_exists('load_brand')) { |
83
|
|
|
|
84
|
|
|
function load_brand() { |
85
|
|
|
|
86
|
|
|
$ci = &get_instance(); |
87
|
|
|
return $ci->db->get('shop_brands_i18n')->result_array(); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
} |
91
|
|
|
|
92
|
|
View Code Duplication |
if (!function_exists('load_prop')) { |
93
|
|
|
|
94
|
|
|
function load_prop() { |
95
|
|
|
|
96
|
|
|
$ci = &get_instance(); |
97
|
|
|
return $ci->db->get('shop_product_properties')->result_array(); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
if (!function_exists('load_prop_data')) { |
103
|
|
|
|
104
|
|
|
function load_prop_data() { |
105
|
|
|
|
106
|
|
|
$ci = &get_instance(); |
107
|
|
|
$arr = []; |
108
|
|
|
|
109
|
|
|
$productTableProperties = $ci->db->select('shop_product_properties_data.property_id, shop_product_property_value_i18n.value, shop_product_property_value_i18n.locale') |
110
|
|
|
->from('shop_product_properties_data') |
111
|
|
|
->join('shop_product_property_value', 'shop_product_properties_data.value_id = shop_product_property_value.id') |
112
|
|
|
->join('shop_product_property_value_i18n', 'shop_product_property_value.id = shop_product_property_value_i18n.id') |
113
|
|
|
->get()->result_array(); |
114
|
|
|
|
115
|
|
View Code Duplication |
foreach ($productTableProperties as $val) { |
116
|
|
|
$arr[$val['property_id'] . '_' . $val['product_id']] = $val['value']; |
117
|
|
|
} |
118
|
|
|
return $arr; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
} |
122
|
|
View Code Duplication |
if (!function_exists('load_multiple_prop')) { |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Load multiple prop |
126
|
|
|
* @return array |
127
|
|
|
*/ |
128
|
|
|
function load_multiple_prop() { |
129
|
|
|
|
130
|
|
|
$ci = &get_instance(); |
131
|
|
|
$arr = []; |
132
|
|
|
$result = $ci->db->get('mod_exchange'); |
133
|
|
|
if ($result) { |
134
|
|
|
foreach ($result->result_array() as $val) { |
135
|
|
|
$arr[$val['external_id']] = $val['value']; |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
return $arr; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
if (!function_exists('is_cat')) { |
144
|
|
|
|
145
|
|
|
function is_cat($cat_ex_id, &$cats) { |
146
|
|
|
|
147
|
|
|
foreach ($cats as $val) { |
148
|
|
|
if ($val['external_id'] == $cat_ex_id) { |
149
|
|
|
return $val; |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
return false; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
if (!function_exists('is_prod')) { |
159
|
|
|
|
160
|
|
|
function is_prod($prod_ex_id, $prods) { |
161
|
|
|
|
162
|
|
|
if (in_array($prod_ex_id, $prods)) { |
163
|
|
|
return ['id' => array_search($prod_ex_id, $prods)]; |
164
|
|
|
} else { |
165
|
|
|
return false; |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
if (!function_exists('is_brand')) { |
172
|
|
|
|
173
|
|
|
function is_brand($brand_name, $brands) { |
174
|
|
|
|
175
|
|
|
foreach ($brands as $val) { |
176
|
|
|
if ($val['name'] == $brand_name) { |
177
|
|
|
return $val['id']; |
178
|
|
|
} |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
return false; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
} |
185
|
|
|
if (!function_exists('is_prop')) { |
186
|
|
|
|
187
|
|
|
function is_prop($prop_id, $props) { |
188
|
|
|
|
189
|
|
|
foreach ($props as $val) { |
190
|
|
|
if ($val['external_id'] == $prop_id) { |
191
|
|
|
return $val; |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
return false; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
if (!function_exists('is_prop_multiple')) { |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* |
204
|
|
|
* @param int $prop_id |
205
|
|
|
* @param array $props all properties |
206
|
|
|
* @return boolean |
207
|
|
|
*/ |
208
|
|
|
function is_prop_multiple($prop_id, $props) { |
209
|
|
|
|
210
|
|
|
foreach ($props as $val) { |
211
|
|
|
if ($val[external_id] == $prop_id) { |
212
|
|
|
if ($val[multiple]) { |
213
|
|
|
return TRUE; |
214
|
|
|
} |
215
|
|
|
} |
216
|
|
|
} |
217
|
|
|
return false; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
if (!function_exists('is_prop_data')) { |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @param int $prop_id |
226
|
|
|
* @param int $prod_id |
227
|
|
|
* @param array $props |
228
|
|
|
* @return bool |
229
|
|
|
*/ |
230
|
|
|
function is_prop_data($prop_id, $prod_id, $props) { |
231
|
|
|
|
232
|
|
|
return array_key_exists($prop_id . '_' . $prod_id, $props); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
} |