ice_import - Version 1.7.5

Version Notes

Release notes

Dashboard:
- Server setup requirements
- Statistic information
- Self problem detection
- Errors notification

New settings with Yes/No option:
- Hide empty category
- Sort categories in ASC order
- Remove old products
- Import new products
- Update URL key
- Update stock availability
- Update visibility
- Update status
- Update products category

New general settings:
- Batch size
- Tolerance of difference (%), If difference is greater than this value - remove process will be cancelled.

Bugfixes:
- Categories importing
- Removing old products

Download this release

Release Info

Developer IceShop
Extension ice_import
Version 1.7.5
Comparing to
See all releases


Code changes from version 1.6.0 to 1.7.5

Files changed (49) hide show
  1. app/code/community/ICEshop/Iceimport/Block/Adminhtml/Notifications.php +34 -0
  2. app/code/community/ICEshop/Iceimport/Helper/Data.php +132 -0
  3. app/code/community/ICEshop/Iceimport/Helper/Db.php +354 -0
  4. app/code/community/ICEshop/Iceimport/Helper/Format.php +251 -0
  5. app/code/community/ICEshop/Iceimport/Helper/System/System.php +461 -0
  6. app/code/community/ICEshop/Iceimport/Helper/System/Systemcheck.php +623 -0
  7. app/code/community/ICEshop/Iceimport/Model/Convert/Adapter/Product.php +1447 -0
  8. app/code/community/{Iceshop → ICEshop}/Iceimport/Model/Dataflow/Batch/Import.php +7 -6
  9. app/code/community/{Iceshop → ICEshop}/Iceimport/Model/Dataflow/Convert/Parser/Csv.php +44 -19
  10. app/code/community/ICEshop/Iceimport/Model/Observer.php +165 -0
  11. app/code/community/ICEshop/Iceimport/Model/System/Config/Checksystem.php +11 -0
  12. app/code/community/{Iceshop → ICEshop}/Iceimport/Model/System/Config/Defaulttax.php +1 -1
  13. app/code/community/ICEshop/Iceimport/Model/System/Config/Iceshoplink.php +11 -0
  14. app/code/community/{Iceshop/Iceimport/Model/System/Config/Importstock.php → ICEshop/Iceimport/Model/System/Config/Yesno.php} +1 -1
  15. app/code/community/ICEshop/Iceimport/controllers/Adminhtml/IceimportController.php +888 -0
  16. app/code/community/ICEshop/Iceimport/etc/adminhtml.xml +31 -0
  17. app/code/community/{Iceshop → ICEshop}/Iceimport/etc/config.xml +56 -36
  18. app/code/community/ICEshop/Iceimport/etc/system.xml +362 -0
  19. app/code/community/ICEshop/Iceimport/sql/iceimport_setup/mysql4-install-1.7.3.php +72 -0
  20. app/code/community/{Iceshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.4.0-1.5.0.php → ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-0.1.0-1.7.0.php} +7 -3
  21. app/code/community/{Iceshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-0.1.0-1.5.0.php → ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.4.0-1.7.0.php} +8 -2
  22. app/code/community/{Iceshop/Iceimport/sql/iceimport_setup/mysql4-install-1.5.0.php → ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.5.0-1.7.0.php} +35 -33
  23. app/code/community/ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.6.0-1.7.0.php +67 -0
  24. app/code/community/ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.7.0-1.7.5.php +86 -0
  25. app/code/community/{Iceshop → ICEshop}/Iceimport/sql/iceimport_setup/uninstall-old-version.php +1 -0
  26. app/code/community/Iceshop/Iceimport/Model/Convert/Adapter/Product.php +0 -1026
  27. app/code/community/Iceshop/Iceimport/Model/Observer.php +0 -225
  28. app/code/community/Iceshop/Iceimport/Model/System/Config/Categoryactivity.php +0 -15
  29. app/code/community/Iceshop/Iceimport/Model/System/Config/Imageimport.php +0 -15
  30. app/code/community/Iceshop/Iceimport/Model/System/Config/Importdeliveryeta.php +0 -15
  31. app/code/community/Iceshop/Iceimport/Model/System/Config/Importprices.php +0 -15
  32. app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductbrand.php +0 -15
  33. app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductdescription.php +0 -15
  34. app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductean.php +0 -15
  35. app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductmpn.php +0 -15
  36. app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductname.php +0 -15
  37. app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductshdescription.php +0 -15
  38. app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductshsudescription.php +0 -15
  39. app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductsudescription.php +0 -15
  40. app/code/community/Iceshop/Iceimport/Model/System/Config/Lockproddetails.php +0 -15
  41. app/code/community/Iceshop/Iceimport/etc/system.xml +0 -154
  42. app/design/adminhtml/default/default/layout/ICEshop_Iceimport.xml +18 -0
  43. app/design/adminhtml/default/default/template/iceshop/iceimport/notifications.phtml +10 -0
  44. app/etc/modules/{Iceshop_Iceimport.xml → ICEshop_Iceimport.xml} +2 -2
  45. js/ICEshop/Iceimport/jquery-1.9.1.min.js +4 -0
  46. js/ICEshop/Iceimport/script.js +247 -0
  47. package.xml +31 -11
  48. skin/adminhtml/default/default/iceshop/iceimport/images/iceshop_logo_small_16px.png +0 -0
  49. skin/adminhtml/default/default/iceshop/iceimport/styles.css +124 -0
app/code/community/ICEshop/Iceimport/Block/Adminhtml/Notifications.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class ICEshop_Iceimport_Block_Adminhtml_Notifications
5
+ */
6
+ class ICEshop_Iceimport_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
7
+ {
8
+ /**
9
+ * @return array|string
10
+ */
11
+ public function getIceimportProblemsDigest()
12
+ {
13
+ $checker = Mage::helper('iceimport/system_systemcheck')->init();
14
+ $problems_digest = $checker->getExtensionProblemsDigest();
15
+ $response = array();
16
+ if ($problems_digest->getCount() != 0) {
17
+ $problems = $problems_digest->getProblems();
18
+ foreach ($problems as $problem_name => $problem_value) {
19
+ $response[] = array($problem_name => $problem_value);
20
+ }
21
+ }
22
+ return $response;
23
+ }
24
+
25
+ /**
26
+ * Get index management url
27
+ *
28
+ * @return string
29
+ */
30
+ public function getManageUrl()
31
+ {
32
+ return Mage::helper("adminhtml")->getUrl("*/system_config/edit", array('section' => 'iceimport_information'));
33
+ }
34
+ }
app/code/community/ICEshop/Iceimport/Helper/Data.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ICEshop_Iceimport_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ /**
7
+ * @param $extension_name
8
+ * @return bool
9
+ */
10
+ public function isExtensionInstalled($extension_name)
11
+ {
12
+ if (!empty($extension_name)) {
13
+ $modules = Mage::getConfig()->getNode('modules')->children();
14
+ $modules = (array)$modules;
15
+ if (array_key_exists($extension_name, (array)$modules)) {
16
+ return true;
17
+ }
18
+ }
19
+ return false;
20
+ }
21
+
22
+
23
+ /**
24
+ * @param bool $json_encoded
25
+ * @return array|string
26
+ */
27
+ public function getSystemInfo($json_encoded = false)
28
+ {
29
+ $results = array();
30
+ try {
31
+ $checker = Mage::helper('iceimport/system_systemcheck')->init();
32
+ if (!empty($checker)) {
33
+ $results['server'] = $checker->getSystem()->getServer()->getData();
34
+ //$results['system'] = $checker->getSystem()->getMagento()->getData();
35
+ //$results['php'] = $checker->getSystem()->getPhp()->getData();
36
+ //$results['mysql'] = $checker->getSystem()->getMysql()->getData();
37
+ //$results['requirements'] = $checker->getSystem()->getRequirements()->getData();
38
+ }
39
+ } catch (Exception $e) {
40
+ }
41
+
42
+ if ($json_encoded == true) {
43
+ return json_encode($results);
44
+ }
45
+ return $results;
46
+ }
47
+
48
+ protected function _getButtonSettings($settings)
49
+ {
50
+ $default_settings = array(
51
+ 'getBeforeHtml' => '',
52
+ 'getId' => '',
53
+ 'getElementName' => '',
54
+ 'getTitle' => '',
55
+ 'getType' => '',
56
+ 'getClass' => '',
57
+ 'getOnClick' => '',
58
+ 'getStyle' => '',
59
+ 'getValue' => '',
60
+ 'getDisabled' => '',
61
+ 'getLabel' => '',
62
+ 'getAfterHtml' => ''
63
+ );
64
+ if (!empty($settings) && is_array($settings)) {
65
+ foreach ($settings as $key => $setting) {
66
+ $camel_key = str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
67
+ $default_settings['get' . $camel_key] = $setting;
68
+ }
69
+ }
70
+ return $default_settings;
71
+ }
72
+
73
+ /**
74
+ * @param $settings
75
+ * @return string
76
+ */
77
+ public function getButtonHtml($settings)
78
+ {
79
+ $settings = $this->_getButtonSettings($settings);
80
+ $html = $settings['getBeforeHtml'] . '<button '
81
+ . ($settings['getId'] ? ' id="' . $settings['getId'] . '"' : '')
82
+ . ($settings['getElementName'] ? ' name="' . $settings['getElementName'] . '"' : '')
83
+ . ' title="'
84
+ . htmlspecialchars($settings['getTitle'] ? $settings['getTitle'] : $settings['getLabel'], ENT_QUOTES, null, false)
85
+ . '"'
86
+ . ' type="' . $settings['getType'] . '"'
87
+ . ' class="scalable ' . $settings['getClass'] . ($settings['getDisabled'] ? ' disabled' : '') . '"'
88
+ . ' onclick="' . $settings['getOnClick'] . '"'
89
+ . ' style="' . $settings['getStyle'] . '"'
90
+ . ($settings['getValue'] ? ' value="' . $settings['getValue'] . '"' : '')
91
+ . ($settings['getDisabled'] ? ' disabled="disabled"' : '')
92
+ . '><span><span><span>' . $settings['getLabel'] . '</span></span></span></button>' . $settings['getAfterHtml'];
93
+
94
+ return $html;
95
+ }
96
+
97
+ /**
98
+ * Sorts a multi-dimensional array with the given values
99
+ *
100
+ * Seen and modified from: http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/
101
+ *
102
+ * @param array $arr Array to sort
103
+ * @param string $key Field to sort
104
+ * @param string $dir Direction to sort
105
+ * @return array Sorted array
106
+ */
107
+ public function sortMultiDimArr($arr, $key, $dir = 'ASC')
108
+ {
109
+ foreach ($arr as $k => $v) {
110
+ $b[$k] = strtolower($v[$key]);
111
+ }
112
+
113
+ if ($dir == 'ASC') {
114
+ asort($b);
115
+ } else {
116
+ arsort($b);
117
+ }
118
+ foreach ($b as $key => $val) {
119
+ $c[] = $arr[$key];
120
+ }
121
+
122
+ return $c;
123
+ }
124
+
125
+ public function toCamelCase($str, $capitalise_first_char = false) {
126
+ if($capitalise_first_char) {
127
+ $str[0] = strtoupper($str[0]);
128
+ }
129
+ $func = create_function('$c', 'return strtoupper($c[1]);');
130
+ return preg_replace_callback('/_([a-z])/', $func, $str);
131
+ }
132
+ }
app/code/community/ICEshop/Iceimport/Helper/Db.php ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class ICEshop_Iceimport_Helper_Db
5
+ */
6
+ class ICEshop_Iceimport_Helper_Db extends Mage_Core_Helper_Abstract
7
+ {
8
+
9
+ /**
10
+ * @var object
11
+ */
12
+ private $_resource;
13
+
14
+ /**
15
+ * @var object
16
+ */
17
+ private $_reader;
18
+
19
+ /**
20
+ * @var object
21
+ */
22
+ private $_writer;
23
+
24
+ /**
25
+ * @var string
26
+ */
27
+ public $_prefix = '';
28
+
29
+ /**
30
+ * int
31
+ */
32
+ const LOG_ROWS_LIMIT = 500;
33
+
34
+ /**
35
+ * __construct
36
+ */
37
+ public function __construct()
38
+ {
39
+ try {
40
+ $this->_resource = Mage::getSingleton('core/resource');
41
+ $this->_writer = $this->_resource->getConnection('core_write');
42
+ $this->_reader = $this->_resource->getConnection('core_read');
43
+ $prefix = Mage::getConfig()->getTablePrefix();
44
+ if (!empty($prefix[0])) {
45
+ $this->_prefix = $prefix[0];
46
+ }
47
+ return true;
48
+ } catch (Exception $e) {
49
+ return false;
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @param $table_name
55
+ * @param bool|array $conditions
56
+ * @return mixed
57
+ */
58
+ public function getRowsCount($table_name, $conditions = false)
59
+ {
60
+ $sql = "SELECT COUNT(*) AS `row_count` FROM `{$table_name}`";
61
+ if (!empty($conditions) && is_array($conditions)) {
62
+ $sql .= ' WHERE ';
63
+ foreach ($conditions as $key => $condition) {
64
+ if (is_array($condition)) {
65
+ if ($key > 0) {
66
+ $sql .= ' ' . $condition['conjunction'] . ' ';
67
+ }
68
+ $sql .= $condition['field'] . ' ' . $condition['comparison'] . ' ';
69
+ switch ($condition['value_type']) {
70
+ case 'num':
71
+ $sql .= $condition['value'];
72
+ break;
73
+ case 'str':
74
+ $sql .= '\'' . $condition['value'] . '\'';
75
+ break;
76
+ }
77
+ } elseif (is_string($condition)) {
78
+ $sql .= $condition;
79
+ }
80
+ }
81
+
82
+ } elseif (!empty($conditions) && is_string($conditions)) {
83
+ $sql .= $conditions;
84
+ }
85
+ $result = $this->_reader->fetchAll($sql);
86
+ $result = array_shift($result);
87
+ return $result['row_count'];
88
+ }
89
+
90
+ /**
91
+ * @param $table_name
92
+ * @param $field_name
93
+ * @param bool|string $before_group
94
+ * @param bool|string $after_group
95
+ * @return mixed
96
+ */
97
+ public function getRowCountByField($table_name, $field_name, $before_group = false, $after_group = false)
98
+ {
99
+ $approved_before_group = '';
100
+ if ($before_group != false && is_string($before_group)) {
101
+ $approved_before_group = $before_group;
102
+ }
103
+ $approved_after_group = '';
104
+ if ($after_group != false && is_string($after_group)) {
105
+ $approved_after_group = $after_group;
106
+ }
107
+ // select is_default, count(is_default) from icecat_products_images group by is_default;
108
+ $sql = "SELECT `{$field_name}`, COUNT(`{$field_name}`) as `row_count` FROM `{$table_name}`{$approved_before_group} GROUP BY `{$field_name}`{$approved_after_group}";
109
+ $result = $this->_reader->fetchAll($sql);
110
+ return $result;
111
+ }
112
+
113
+ /**
114
+ * @param $table_name
115
+ * @param $field_name
116
+ * @return bool
117
+ */
118
+ public function checkIsFieldExists($table_name, $field_name)
119
+ {
120
+ if (!$this->_checkProcedureExists('FIELD_EXISTS')) {
121
+ //recreate the procedure FIELD_EXISTS
122
+ $this->_recreateFieldExistsProcedure();
123
+ }
124
+ $sql = "CALL FIELD_EXISTS(@_exists, '{$table_name}', '{$field_name}', NULL);";
125
+ $this->_reader->query($sql);
126
+
127
+ $sql = "SELECT @_exists;";
128
+ $res = $this->_reader->fetchCol($sql);
129
+ if (!array_shift($res)) {
130
+ //field exists
131
+ return false;
132
+ }
133
+ return true;
134
+ }
135
+
136
+ /**
137
+ * @param $procedure_name
138
+ * @return bool
139
+ */
140
+ private function _checkProcedureExists($procedure_name)
141
+ {
142
+ $sql = "SET @_exists = (SELECT COUNT(ROUTINE_NAME) FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_SCHEMA = database() AND ROUTINE_NAME = '{$procedure_name}')";
143
+ $this->_reader->query($sql);
144
+
145
+ $sql = "SELECT @_exists;";
146
+ $res = $this->_reader->fetchCol($sql);
147
+ $res = array_shift($res);
148
+ if ($res > 0) {
149
+ //field exists
150
+ return true;
151
+ }
152
+ return false;
153
+ }
154
+
155
+ /**
156
+ *
157
+ */
158
+ private function _recreateFieldExistsProcedure()
159
+ {
160
+ $sql = "CREATE PROCEDURE FIELD_EXISTS(
161
+ OUT _exists BOOLEAN, -- return value
162
+ IN tableName CHAR(255), -- name of table to look for
163
+ IN columnName CHAR(255), -- name of column to look for
164
+ IN dbName CHAR(255) -- optional specific db
165
+ ) BEGIN
166
+ -- try to lookup db if none provided
167
+ SET @_dbName := IF(dbName IS NULL, database(), dbName);
168
+
169
+ IF CHAR_LENGTH(@_dbName) = 0
170
+ THEN -- no specific or current db to check against
171
+ SELECT
172
+ FALSE
173
+ INTO _exists;
174
+ ELSE -- we have a db to work with
175
+ SELECT
176
+ IF(count(*) > 0, TRUE, FALSE)
177
+ INTO _exists
178
+ FROM information_schema.COLUMNS c
179
+ WHERE
180
+ c.TABLE_SCHEMA = @_dbName
181
+ AND c.TABLE_NAME = tableName
182
+ AND c.COLUMN_NAME = columnName;
183
+ END IF;
184
+ END;";
185
+ $this->_writer->query($sql);
186
+ }
187
+
188
+ /**
189
+ * @param $sql
190
+ * @return bool
191
+ */
192
+ public function readQuery($sql)
193
+ {
194
+ if (!empty($sql) && is_string($sql)) {
195
+ return $this->_reader->fetchAll($sql);
196
+ }
197
+ return false;
198
+ }
199
+
200
+ /**
201
+ * @param $key
202
+ * @param $value
203
+ * @param string $type
204
+ * @return bool
205
+ */
206
+ public function insertLogEntry($key, $value, $type = 'info')
207
+ {
208
+ if ($type == 'error') {
209
+ $this->rotateLog();
210
+ }
211
+ if (!empty($key)) {
212
+ return $this->_writer->query("INSERT INTO `{$this->_prefix}iceshop_extensions_logs` (`log_key`, `log_value`, `log_type`)
213
+ VALUES ('{$key}', '{$value}', '{$type}')
214
+ ON DUPLICATE KEY UPDATE `log_value` = VALUES(`log_value`), `log_type` = VALUES(`log_type`)");
215
+ }
216
+ return false;
217
+ }
218
+
219
+ /**
220
+ * @param string $log_type
221
+ * @return bool
222
+ */
223
+ public function rotateLog($log_type = 'error')
224
+ {
225
+ $sql = "SELECT COUNT(*) AS row_amount
226
+ FROM `{$this->_prefix}iceshop_extensions_logs`
227
+ WHERE `log_type` = '{$log_type}';";
228
+ $value = $this->_reader->fetchAll($sql);
229
+ $row_amount = 0;
230
+ if (array_key_exists(0, $value)) {
231
+ $row_amount = $value[0]['row_amount'];
232
+ }
233
+ if ($row_amount > self::LOG_ROWS_LIMIT) {
234
+ $rows_to_delete = $row_amount - self::LOG_ROWS_LIMIT;
235
+ return $this->_writer->query("DELETE
236
+ FROM `{$this->_prefix}iceshop_extensions_logs`
237
+ WHERE `log_type` = '{$log_type}'
238
+ ORDER BY `log_id` ASC
239
+ LIMIT {$rows_to_delete}");
240
+ }
241
+ return false;
242
+ }
243
+
244
+ /**
245
+ * @param $key
246
+ * @return bool
247
+ */
248
+ public function getLogEntryByKey($key)
249
+ {
250
+ if (!empty($key)) {
251
+ $sql = "SELECT `log_value`, `log_type`
252
+ FROM `{$this->_prefix}iceshop_extensions_logs`
253
+ WHERE `log_key` = '{$key}'
254
+ ORDER BY `log_id` DESC
255
+ LIMIT 1;";
256
+ $value = $this->_reader->fetchAll($sql);
257
+ if (array_key_exists(0, $value)) {
258
+ return $value[0];
259
+ }
260
+ }
261
+ return false;
262
+ }
263
+
264
+ /**
265
+ * @param bool $type
266
+ * @param string $comparison
267
+ * @param int $limit
268
+ * @return array|bool
269
+ */
270
+ public function getLogByType($type = false, $comparison = 'eq', $limit = 10)
271
+ {
272
+ $comparison_whitelist = array('eq', 'neq');
273
+ if (!in_array($comparison, $comparison_whitelist)) {
274
+ $comparison = 'eq';
275
+ }
276
+ if (!empty($type)) {
277
+ if ($type == 'report') {
278
+ $result_arr = array();
279
+ $sql = "SELECT `log_value`, `timecol`
280
+ FROM `{$this->_prefix}iceshop_extensions_logs`
281
+ WHERE `log_type` = 'error'
282
+ AND (`timecol` > DATE_SUB(now(), INTERVAL 1 DAY))
283
+ ORDER BY `log_id` DESC;";
284
+ $results = $this->_reader->fetchAll($sql);
285
+ foreach ($results as $row) {
286
+ $result_arr[] = $row;
287
+ }
288
+ return (!empty($result_arr)) ? $result_arr : false;
289
+ } else {
290
+ switch($comparison) {
291
+ case 'eq':
292
+ $result_arr = array();
293
+ $sql = "SELECT `log_value`, `timecol`
294
+ FROM `{$this->_prefix}iceshop_extensions_logs`
295
+ WHERE `log_type` = '{$type}'
296
+ ORDER BY `log_id` DESC
297
+ LIMIT {$limit};";
298
+ $results = $this->_reader->fetchAll($sql);
299
+ foreach ($results as $row) {
300
+ $result_arr[] = $row;
301
+ }
302
+ return (!empty($result_arr)) ? $result_arr : false;
303
+ break;
304
+
305
+ case 'neq':
306
+ $result_arr = array();
307
+ $sql = "SELECT `log_value`, `timecol`
308
+ FROM `{$this->_prefix}iceshop_extensions_logs`
309
+ WHERE `log_type` <> '{$type}'
310
+ ORDER BY `log_id` DESC
311
+ LIMIT {$limit};";
312
+ $results = $this->_reader->fetchAll($sql);
313
+ foreach ($results as $row) {
314
+ $result_arr[] = $row;
315
+ }
316
+ return (!empty($result_arr)) ? $result_arr : false;
317
+ break;
318
+ }
319
+ }
320
+ } else {
321
+ $sql = "SELECT `log_value`, `log_type`, `timecol`
322
+ FROM `{$this->_prefix}iceshop_extensions_logs`
323
+ ORDER BY `log_id` DESC
324
+ LIMIT {$limit};";
325
+ return $this->_reader->fetchAll($sql);
326
+ }
327
+ }
328
+
329
+ /**
330
+ * @param $key
331
+ * @return bool
332
+ */
333
+ public function deleteLogEntry($key)
334
+ {
335
+ if (!empty($key)) {
336
+ return $this->_writer->query("DELETE
337
+ FROM `{$this->_prefix}iceshop_extensions_logs`
338
+ WHERE `log_key` = '{$key}';");
339
+ }
340
+ return false;
341
+ }
342
+
343
+ /**
344
+ * @param $table_name
345
+ * @return bool
346
+ */
347
+ public function getTableName($table_name)
348
+ {
349
+ if (!empty($table_name) && is_string($table_name)) {
350
+ return $this->_resource->getTableName($table_name);
351
+ }
352
+ return false;
353
+ }
354
+ }
app/code/community/ICEshop/Iceimport/Helper/Format.php ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /******************************************************************************
3
+ * Copyright (c) 2010 Jevon Wright and others.
4
+ * All rights reserved. This program and the accompanying materials
5
+ * are made available under the terms of the Eclipse Public License v1.0
6
+ * which accompanies this distribution, and is available at
7
+ * http://www.eclipse.org/legal/epl-v10.html
8
+ *
9
+ * Contributors:
10
+ * Jevon Wright - initial API and implementation
11
+ ****************************************************************************/
12
+
13
+ /**
14
+ * Tries to convert the given HTML into a plain text format - best suited for
15
+ * e-mail display, etc.
16
+ *
17
+ * <p>In particular, it tries to maintain the following features:
18
+ * <ul>
19
+ * <li>Links are maintained, with the 'href' copied over
20
+ * <li>Information in the &lt;head&gt; is lost
21
+ * </ul>
22
+ *
23
+ * @param html the input HTML
24
+ * @return the HTML converted, as best as possible, to text
25
+ */
26
+ class ICEshop_Iceimport_Helper_Format extends Mage_Core_Helper_Abstract
27
+ {
28
+ /**
29
+ * @param $html
30
+ * @return mixed|string
31
+ */
32
+ public function convert_html_to_text($html)
33
+ {
34
+ $html = $this->fix_newlines($html);
35
+
36
+ $doc = new DOMDocument();
37
+ if (!$doc->loadHTML($html))
38
+ return "Could not load HTML - badly formed?";
39
+
40
+ $output = $this->iterate_over_node($doc);
41
+
42
+ // remove leading and trailing spaces on each line
43
+ $output = preg_replace("/[ \t]*\n[ \t]*/im", "\n", $output);
44
+
45
+ // remove leading and trailing whitespace
46
+ $output = trim($output);
47
+
48
+ return $output;
49
+ }
50
+
51
+ /**
52
+ * Unify newlines; in particular, \r\n becomes \n, and
53
+ * then \r becomes \n. This means that all newlines (Unix, Windows, Mac)
54
+ * all become \ns.
55
+ *
56
+ * @param text text with any number of \r, \r\n and \n combinations
57
+ * @return the fixed text
58
+ */
59
+ private function fix_newlines($text)
60
+ {
61
+ // replace \r\n to \n
62
+ $text = str_replace("\r\n", "\n", $text);
63
+ // remove \rs
64
+ $text = str_replace("\r", "\n", $text);
65
+
66
+ return $text;
67
+ }
68
+
69
+ /**
70
+ * @param $node
71
+ * @return null|string
72
+ */
73
+ private function next_child_name($node)
74
+ {
75
+ // get the next child
76
+ $nextNode = $node->nextSibling;
77
+ while ($nextNode != null) {
78
+ if ($nextNode instanceof DOMElement) {
79
+ break;
80
+ }
81
+ $nextNode = $nextNode->nextSibling;
82
+ }
83
+ $nextName = null;
84
+ if ($nextNode instanceof DOMElement && $nextNode != null) {
85
+ $nextName = strtolower($nextNode->nodeName);
86
+ }
87
+
88
+ return $nextName;
89
+ }
90
+
91
+ /**
92
+ * @param $node
93
+ * @return null|string
94
+ */
95
+ private function prev_child_name($node)
96
+ {
97
+ // get the previous child
98
+ $nextNode = $node->previousSibling;
99
+ while ($nextNode != null) {
100
+ if ($nextNode instanceof DOMElement) {
101
+ break;
102
+ }
103
+ $nextNode = $nextNode->previousSibling;
104
+ }
105
+ $nextName = null;
106
+ if ($nextNode instanceof DOMElement && $nextNode != null) {
107
+ $nextName = strtolower($nextNode->nodeName);
108
+ }
109
+
110
+ return $nextName;
111
+ }
112
+
113
+ /**
114
+ * @param $node
115
+ * @return mixed|string
116
+ */
117
+ private function iterate_over_node($node)
118
+ {
119
+ if ($node instanceof DOMText) {
120
+ return preg_replace("/\\s+/im", " ", $node->wholeText);
121
+ }
122
+ if ($node instanceof DOMDocumentType) {
123
+ // ignore
124
+ return "";
125
+ }
126
+
127
+ $nextName = $this->next_child_name($node);
128
+ $prevName = $this->prev_child_name($node);
129
+
130
+ $name = strtolower($node->nodeName);
131
+
132
+ // start whitespace
133
+ switch ($name) {
134
+ case "hr":
135
+ return "------\n";
136
+
137
+ case "style":
138
+ case "head":
139
+ case "title":
140
+ case "meta":
141
+ case "script":
142
+ // ignore these tags
143
+ return "";
144
+
145
+ case "h1":
146
+ case "h2":
147
+ case "h3":
148
+ case "h4":
149
+ case "h5":
150
+ case "h6":
151
+ // add two newlines
152
+ $output = "\n";
153
+ break;
154
+
155
+ case "p":
156
+ case "div":
157
+ // add one line
158
+ $output = "\n";
159
+ break;
160
+
161
+ default:
162
+ // print out contents of unknown tags
163
+ $output = "";
164
+ break;
165
+ }
166
+
167
+ // debug
168
+ //$output .= "[$name,$nextName]";
169
+
170
+ for ($i = 0; $i < $node->childNodes->length; $i++) {
171
+ $n = $node->childNodes->item($i);
172
+
173
+ $text = $this->iterate_over_node($n);
174
+
175
+ $output .= $text;
176
+ }
177
+
178
+ // end whitespace
179
+ switch ($name) {
180
+ case "style":
181
+ case "head":
182
+ case "title":
183
+ case "meta":
184
+ case "script":
185
+ // ignore these tags
186
+ return "";
187
+
188
+ case "tr":
189
+ case "h1":
190
+ case "h2":
191
+ case "h3":
192
+ case "h4":
193
+ case "h5":
194
+ case "h6":
195
+ $output .= "\n";
196
+ break;
197
+
198
+ case "td":
199
+ $output .= "\t";
200
+ break;
201
+
202
+ case "p":
203
+ case "br":
204
+ // add one line
205
+ if ($nextName != "div")
206
+ $output .= "\n";
207
+ break;
208
+
209
+ case "div":
210
+ // add one line only if the next child isn't a div
211
+ if ($nextName != "div" && $nextName != null)
212
+ $output .= "\n";
213
+ break;
214
+
215
+ case "a":
216
+ // links are returned in [text](link) format
217
+ $href = $node->getAttribute("href");
218
+ if ($href == null) {
219
+ // it doesn't link anywhere
220
+ if ($node->getAttribute("name") != null) {
221
+ $output = "[$output]";
222
+ }
223
+ } else {
224
+ if ($href == $output) {
225
+ // link to the same address: just use link
226
+ $output;
227
+ } else {
228
+ // replace it
229
+ $output = "[$output]($href)";
230
+ }
231
+ }
232
+
233
+ // does the next node require additional whitespace?
234
+ switch ($nextName) {
235
+ case "h1":
236
+ case "h2":
237
+ case "h3":
238
+ case "h4":
239
+ case "h5":
240
+ case "h6":
241
+ $output .= "\n";
242
+ break;
243
+ }
244
+
245
+ default:
246
+ // do nothing
247
+ }
248
+
249
+ return $output;
250
+ }
251
+ }
app/code/community/ICEshop/Iceimport/Helper/System/System.php ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Iceshop_Iceimport_Helper_System_System
5
+ */
6
+ class Iceshop_Iceimport_Helper_System_System extends Mage_Core_Helper_Abstract
7
+ {
8
+ /**
9
+ * Sorts a multi-dimensional array with the given values
10
+ *
11
+ * Seen and modified from: http://www.firsttube.com/read/sorting-a-multi-dimensional-array-with-php/
12
+ *
13
+ * @param array $arr Array to sort
14
+ * @param string $key Field to sort
15
+ * @param string $dir Direction to sort
16
+ * @return array Sorted array
17
+ */
18
+ public function sortMultiDimArr($arr, $key, $dir = 'ASC')
19
+ {
20
+ foreach ($arr as $k => $v) {
21
+ $b[$k] = strtolower($v[$key]);
22
+ }
23
+
24
+ if ($dir == 'ASC') {
25
+ asort($b);
26
+ } else {
27
+ arsort($b);
28
+ }
29
+ foreach ($b as $key => $val) {
30
+ $c[] = $arr[$key];
31
+ }
32
+
33
+ return $c;
34
+ }
35
+
36
+ /**
37
+ * Activate/Deactivate a Magento module
38
+ *
39
+ * @param string $name
40
+ * @return string
41
+ */
42
+ public function deactivateModule($name)
43
+ {
44
+ $isDeactivationPossible = true;
45
+ foreach (Mage::getConfig()->getNode('modules')->children() as $moduleName => $item) {
46
+ if ($moduleName == $name) {
47
+ continue;
48
+ }
49
+ if ($item->depends) {
50
+ foreach ($item->depends->children() as $depend) {
51
+ if ($depend->getName() == $name) {
52
+ if ((string)Mage::getConfig()->getModuleConfig($moduleName)->is('active', 'true')) {
53
+ $isDeactivationPossible = false;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ if ($isDeactivationPossible) {
61
+ $xmlPath = Mage::getBaseDir() . DS . 'app' . DS . 'etc' . DS . 'modules' . DS . $name . '.xml';
62
+ if (file_exists($xmlPath)) {
63
+ $xmlObj = new Varien_Simplexml_Config($xmlPath);
64
+
65
+ $currentValue = (string)$xmlObj->getNode('modules/' . $name . '/active');
66
+ if ($currentValue == 'true') {
67
+ $value = false;
68
+ } else {
69
+ $value = true;
70
+ }
71
+
72
+ $xmlObj->setNode(
73
+ 'modules/' . $name . '/active',
74
+ $value ? 'true' : 'false'
75
+ );
76
+
77
+ if (is_writable($xmlPath)) {
78
+ $xmlData = $xmlObj->getNode()->asNiceXml();
79
+ @file_put_contents($xmlPath, $xmlData);
80
+ Mage::app()->getCacheInstance()->clean();
81
+ if ($value) {
82
+ $status = $this->__('The module "%s" has been successfully activated.', $name);
83
+ } else {
84
+ $status = $this->__('The module "%s" has been successfully deactivated.', $name);
85
+ }
86
+ } else {
87
+ $status = $this->__('File %s is not writable.', $xmlPath);
88
+ }
89
+ } else {
90
+ $status = $this->__(
91
+ 'Module %s is probably not installed. File %s does not exist.',
92
+ $name,
93
+ $xmlPath
94
+ );
95
+ }
96
+ } else {
97
+ $status = $this->__('Module can\'t be deactivated because it is a dependency of another module which is still active.');
98
+ }
99
+
100
+ return $status;
101
+ }
102
+
103
+ /**
104
+ * Retrieve a collection of all rewrites
105
+ *
106
+ * @return Varien_Data_Collection Collection
107
+ */
108
+ public function getRewriteCollection()
109
+ {
110
+ $collection = new Varien_Data_Collection();
111
+ $rewrites = $this->_loadRewrites();
112
+
113
+ foreach ($rewrites as $rewriteNodes) {
114
+ foreach ($rewriteNodes as $n) {
115
+ $nParent = $n->xpath('..');
116
+ $module = (string)$nParent[0]->getName();
117
+ $nSubParent = $nParent[0]->xpath('..');
118
+ $component = (string)$nSubParent[0]->getName();
119
+
120
+ if (!in_array($component, array('blocks', 'helpers', 'models'))) {
121
+ continue;
122
+ }
123
+
124
+ $pathNodes = $n->children();
125
+ foreach ($pathNodes as $pathNode) {
126
+ $path = (string)$pathNode->getName();
127
+ $completePath = $module . '/' . $path;
128
+
129
+ $rewriteClassName = (string)$pathNode;
130
+
131
+ $instance = Mage::getConfig()->getGroupedClassName(
132
+ substr($component, 0, -1),
133
+ $completePath
134
+ );
135
+
136
+ $collection->addItem(
137
+ new Varien_Object(
138
+ array(
139
+ 'path' => $completePath,
140
+ 'rewrite_class' => $rewriteClassName,
141
+ 'active_class' => $instance,
142
+ 'status' => ($instance == $rewriteClassName)
143
+ )
144
+ )
145
+ );
146
+ }
147
+ }
148
+ }
149
+
150
+ return $collection;
151
+ }
152
+
153
+ /**
154
+ * Return all rewrites
155
+ *
156
+ * @return array All rwrites
157
+ */
158
+ protected function _loadRewrites()
159
+ {
160
+ $fileName = 'config.xml';
161
+ $modules = Mage::getConfig()->getNode('modules')->children();
162
+
163
+ $return = array();
164
+ foreach ($modules as $modName => $module) {
165
+ if ($module->is('active')) {
166
+ $configFile = Mage::getConfig()->getModuleDir('etc', $modName) . DS . $fileName;
167
+ if (file_exists($configFile)) {
168
+ $xml = file_get_contents($configFile);
169
+ $xml = simplexml_load_string($xml);
170
+
171
+ if ($xml instanceof SimpleXMLElement) {
172
+ $return[$modName] = $xml->xpath('//rewrite');
173
+ }
174
+ }
175
+ }
176
+ }
177
+
178
+ return $return;
179
+ }
180
+
181
+ /**
182
+ * Retrieve a collection of all modules
183
+ *
184
+ * @return Varien_Data_Collection Collection
185
+ */
186
+ public function getModulesCollection()
187
+ {
188
+ $sortValue = Mage::app()->getRequest()->getParam('sort', 'name');
189
+ $sortValue = strtolower($sortValue);
190
+
191
+ $sortDir = Mage::app()->getRequest()->getParam('dir', 'ASC');
192
+ $sortDir = strtoupper($sortDir);
193
+
194
+ $modules = $this->_loadModules();
195
+ $modules = $this->sortMultiDimArr($modules, $sortValue, $sortDir);
196
+
197
+ $collection = new Varien_Data_Collection();
198
+ foreach ($modules as $val) {
199
+ $item = new Varien_Object($val);
200
+ $collection->addItem($item);
201
+ }
202
+
203
+ return $collection;
204
+ }
205
+
206
+ /**
207
+ * Loads the module configurations and checks for some criteria and
208
+ * returns an array with the current modules in the Magento instance.
209
+ *
210
+ * @return array Modules
211
+ */
212
+ protected function _loadModules()
213
+ {
214
+ $modules = array();
215
+ $config = Mage::getConfig();
216
+ foreach ($config->getNode('modules')->children() as $item) {
217
+ $active = ($item->active == 'true') ? true : false;
218
+ $codePool = (string)$config->getModuleConfig($item->getName())->codePool;
219
+ $path = $config->getOptions()->getCodeDir() . DS . $codePool . DS . uc_words($item->getName(), DS);
220
+ $pathExists = file_exists($path);
221
+ $pathExists = $pathExists ? true : false;
222
+ $configExists = file_exists($path . '/etc/config.xml');
223
+ $configExists = $configExists ? true : false;
224
+ $version = (string)$config->getModuleConfig($item->getName())->version;
225
+
226
+ $dependencies = '-';
227
+ if ($item->depends) {
228
+ $depends = array();
229
+ foreach ($item->depends->children() as $depend) {
230
+ $depends[] = $depend->getName();
231
+ }
232
+ if (is_array($depends) && count($depends) > 0) {
233
+ asort($depends);
234
+ $dependencies = implode("\n", $depends);
235
+ }
236
+ }
237
+
238
+ $modules[$item->getName()] = array(
239
+ 'name' => $item->getName(),
240
+ 'active' => $active,
241
+ 'code_pool' => $codePool,
242
+ 'path' => $path,
243
+ 'path_exists' => $pathExists,
244
+ 'config_exists' => $configExists,
245
+ 'version' => $version,
246
+ 'dependencies' => $dependencies
247
+ );
248
+ }
249
+
250
+ return $modules;
251
+ }
252
+
253
+ /**
254
+ * Retrieve a collection of all events
255
+ *
256
+ * @return Varien_Data_Collection Collection
257
+ */
258
+ public function getEventsCollection()
259
+ {
260
+ $sortValue = Mage::app()->getRequest()->getParam('sort', 'event');
261
+ $sortValue = strtolower($sortValue);
262
+
263
+ $sortDir = Mage::app()->getRequest()->getParam('dir', 'ASC');
264
+ $sortDir = strtoupper($sortDir);
265
+
266
+ $events = $this->_loadEvents();
267
+ $events = $this->sortMultiDimArr($events, $sortValue, $sortDir);
268
+
269
+ $collection = new Varien_Data_Collection();
270
+ foreach ($events as $item) {
271
+ $values = $item['children'];
272
+ if (is_array($values)) {
273
+ asort($values);
274
+ }
275
+
276
+ $val = array(
277
+ 'event' => $item['event'],
278
+ 'location' => implode("\n", $values)
279
+ );
280
+
281
+ $item = new Varien_Object($val);
282
+ $collection->addItem($item);
283
+ }
284
+
285
+ return $collection;
286
+ }
287
+
288
+ /**
289
+ * Return all events
290
+ *
291
+ * @return array All events
292
+ */
293
+ protected function _loadEvents()
294
+ {
295
+ $fileName = 'config.xml';
296
+ $modules = Mage::getConfig()->getNode('modules')->children();
297
+
298
+ $events = array();
299
+ foreach ($modules as $modName => $module) {
300
+ if ($module->is('active')) {
301
+ $configFile = Mage::getConfig()->getModuleDir('etc', $modName) . DS . $fileName;
302
+ if (file_exists($configFile)) {
303
+ $xml = file_get_contents($configFile);
304
+ $xml = simplexml_load_string($xml);
305
+
306
+ if ($xml instanceof SimpleXMLElement) {
307
+ $events[$modName] = $xml->xpath('//events');
308
+ }
309
+ }
310
+ }
311
+ }
312
+
313
+ $return = array();
314
+ foreach ($events as $eventNodes) {
315
+ foreach ($eventNodes as $n) {
316
+ $pathNodes = $n->children();
317
+
318
+ foreach ($pathNodes as $pathNode) {
319
+ $eventName = (string)$pathNode->getName();
320
+ $instance = $pathNode->xpath('observers/node()/class');
321
+ $instance = (string)current($instance);
322
+ $instance = Mage::getConfig()->getModelClassName($instance);
323
+
324
+ if (!array_key_exists($eventName, $return)) {
325
+ $return[$eventName] = array(
326
+ 'event' => $eventName,
327
+ 'children' => array()
328
+ );
329
+ }
330
+ if (!in_array($instance, $return[$eventName])) {
331
+ $return[$eventName]['children'][] = $instance;
332
+ }
333
+ }
334
+ }
335
+ }
336
+
337
+ return $return;
338
+ }
339
+
340
+ /**
341
+ * Checks if one or more caches are active
342
+ *
343
+ * @return string Cache Message
344
+ */
345
+ public function checkCaches()
346
+ {
347
+ $active = 0;
348
+ $inactive = 0;
349
+ foreach (Mage::app()->getCacheInstance()->getTypes() as $type) {
350
+ $tmp = $type->getData();
351
+ if ($tmp['status']) {
352
+ $active++;
353
+ } else {
354
+ $inactive++;
355
+ }
356
+ }
357
+
358
+ return $this->__(
359
+ '%s caches active, %s caches inactive',
360
+ $active,
361
+ $inactive
362
+ );
363
+ }
364
+
365
+ /**
366
+ * Checks if all indexes are up-to-date
367
+ *
368
+ * @return string Indexes Message
369
+ */
370
+ public function checkIndizes()
371
+ {
372
+ $ready = 0;
373
+ $processing = 0;
374
+ $reindex = 0;
375
+
376
+ $collection = Mage::getResourceModel('index/process_collection');
377
+ foreach ($collection as $item) {
378
+ $tmp = $item->getData();
379
+ if ($tmp['status'] == 'pending') {
380
+ $ready++;
381
+ } elseif ($tmp['status'] == 'working') {
382
+ $processing++;
383
+ } else {
384
+ $reindex++;
385
+ }
386
+ }
387
+
388
+ return $this->__(
389
+ '%s indexes are ready, %s indexes are working, %s indexes need reindex',
390
+ $ready,
391
+ $processing,
392
+ $reindex
393
+ );
394
+ }
395
+
396
+ /**
397
+ * Returns a small system check report with some essential properties
398
+ *
399
+ * @return array Extension Check Result
400
+ */
401
+ public function checkSystem()
402
+ {
403
+ return $this->_extensionCheck(
404
+ array(
405
+ 'curl',
406
+ 'dom',
407
+ 'gd',
408
+ 'hash',
409
+ 'iconv',
410
+ 'mcrypt',
411
+ 'pcre',
412
+ 'pdo',
413
+ 'pdo_mysql',
414
+ 'simplexml'
415
+ )
416
+ );
417
+ }
418
+
419
+ /**
420
+ * Checks some kind of essential properties
421
+ *
422
+ * @param string $extensions Extensions to check
423
+ * @return array Array with failed and passed checks
424
+ */
425
+ protected function _extensionCheck($extensions)
426
+ {
427
+ $fail = array();
428
+ $pass = array();
429
+
430
+ if (version_compare(phpversion(), '5.2.0', '<')) {
431
+ $fail[] = 'You need <strong>PHP 5.2.0</strong> (or greater)';
432
+ } else {
433
+ $pass[] = 'You have <strong>PHP 5.2.0</strong> (or greater)';
434
+ }
435
+
436
+ if (!ini_get('safe_mode')) {
437
+ $pass[] = 'Safe Mode is <strong>off</strong>';
438
+
439
+ $con = Mage::getSingleton('core/resource')->getConnection('core_read');
440
+ $version = $con->getServerVersion();
441
+
442
+ if (version_compare($version, '4.1.20', '<')) {
443
+ $fail[] = 'You need <strong>MySQL 4.1.20</strong> (or greater)';
444
+ } else {
445
+ $pass[] = 'You have <strong>MySQL 4.1.20</strong> (or greater)';
446
+ }
447
+ } else {
448
+ $fail[] = 'Safe Mode is <strong>on</strong>';
449
+ }
450
+
451
+ foreach ($extensions as $extension) {
452
+ if (!extension_loaded($extension)) {
453
+ $fail[] = 'You are missing the <strong>' . $extension . '</strong> extension';
454
+ } else {
455
+ $pass[] = 'You have the <strong>' . $extension . '</strong> extension';
456
+ }
457
+ }
458
+
459
+ return array('pass' => $pass, 'fail' => $fail);
460
+ }
461
+ }
app/code/community/ICEshop/Iceimport/Helper/System/Systemcheck.php ADDED
@@ -0,0 +1,623 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class ICEshop_Iceimport_Helper_System_Systemcheck
5
+ */
6
+ class ICEshop_Iceimport_Helper_System_Systemcheck extends Mage_Core_Helper_Abstract
7
+ {
8
+ /**
9
+ * @var Varien_Object
10
+ */
11
+ protected $_system;
12
+
13
+ protected function _getHelper()
14
+ {
15
+ return Mage::helper('iceimport/system_system');
16
+ }
17
+
18
+ /**
19
+ * @return Varien_Db_Adapter_Pdo_Mysql
20
+ */
21
+ protected function _getDb()
22
+ {
23
+ return Mage::getSingleton('core/resource')->getConnection('core_read');
24
+ }
25
+
26
+ /**
27
+ * @return $this
28
+ */
29
+ public function init()
30
+ {
31
+ $system = new Varien_Object();
32
+
33
+ /*
34
+ * MAGENTO
35
+ */
36
+ $magento = array(
37
+ 'edition' => (method_exists('Mage', 'getEdition')) ? Mage::getEdition() : '',
38
+ 'version' => (method_exists('Mage', 'getVersion')) ? Mage::getVersion() : '',
39
+ 'developer_mode' => (method_exists('Mage', 'getIsDeveloperMode')) ? Mage::getIsDeveloperMode() : '',
40
+ 'secret_key' => (method_exists('Mage', 'getStoreConfigFlag')) ? Mage::getStoreConfigFlag('admin/security/use_form_key') : '',
41
+ 'flat_catalog_category' => (method_exists('Mage', 'getStoreConfigFlag')) ? Mage::getStoreConfigFlag('catalog/frontend/flat_catalog_category') : '',
42
+ 'flat_catalog_product' => (method_exists('Mage', 'getStoreConfigFlag')) ? Mage::getStoreConfigFlag('catalog/frontend/flat_catalog_product') : ''
43
+ );
44
+ try {
45
+ $magento['cache_status'] = $this->_getHelper()->checkCaches();
46
+ $magento['index_status'] = $this->_getHelper()->checkIndizes();
47
+ } catch (Exception $e) {
48
+ $magento['exception'][] = array(
49
+ 'line' => $e->getLine(),
50
+ 'file' => $e->getFile(),
51
+ 'message' => $e->getMessage()
52
+ );
53
+ }
54
+ $system->setData('magento', new Varien_Object($magento));
55
+
56
+ /*
57
+ * SERVER
58
+ */
59
+
60
+ $server = array(
61
+ 'domain' => isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : null,
62
+ 'ip' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : (isset($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] : ''),
63
+ 'dir' => (method_exists('Mage', 'getBaseDir')) ? Mage::getBaseDir() : '',
64
+ 'info' => php_uname(),
65
+
66
+ );
67
+ $system->setData('server', new Varien_Object($server));
68
+
69
+ /*
70
+ * PHP
71
+ */
72
+
73
+ $php = array(
74
+ 'version' => @phpversion(),
75
+ 'server_api' => @php_sapi_name(),
76
+ 'memory_limit' => @ini_get('memory_limit'),
77
+ 'max_execution_time' => @ini_get('max_execution_time')
78
+ );
79
+ $system->setData('php', new Varien_Object($php));
80
+
81
+ /*
82
+ * MySQL
83
+ */
84
+
85
+ // Get MySQL Server API
86
+ $connection = $this->_getDb()->getConnection();
87
+ if ($connection instanceof PDO) {
88
+ $mysqlServerApi = $connection->getAttribute(PDO::ATTR_CLIENT_VERSION);
89
+ } else {
90
+ $mysqlServerApi = 'n/a';
91
+ }
92
+
93
+ // Get table prefix
94
+ $tablePrefix = (string)Mage::getConfig()->getTablePrefix();
95
+ if (empty($tablePrefix)) {
96
+ $tablePrefix = $this->__('Disabled');
97
+ }
98
+
99
+ // Get MySQL vars
100
+ $sqlQuery = "SHOW VARIABLES;";
101
+ $sqlResult = $this->_getDb()->fetchAll($sqlQuery);
102
+ $mysqlVars = array();
103
+ foreach ($sqlResult as $mysqlVar) {
104
+ $mysqlVars[$mysqlVar['Variable_name']] = $mysqlVar['Value'];
105
+ }
106
+
107
+ $mysql = array(
108
+ 'version' => $this->_getDb()->getServerVersion(),
109
+ 'server_api' => $mysqlServerApi,
110
+ 'database_name' => (string)Mage::getConfig()->getNode('global/resources/default_setup/connection/dbname'),
111
+ 'database_tables' => count($this->_getDb()->listTables()),
112
+ 'table_prefix' => $tablePrefix,
113
+ 'connection_timeout' => $mysqlVars['connect_timeout'] . ' sec.',
114
+ 'wait_timeout' => $mysqlVars['wait_timeout'] . ' sec.',
115
+ 'max_allowed_packet' => array(
116
+ 'current_value' => $mysqlVars['max_allowed_packet'] . ' bytes',
117
+ 'recommended_value' => '>= ' . (16 * 1024 * 1024),
118
+ 'result' => ($mysqlVars['max_allowed_packet'] >= (16 * 1024 * 1024)),
119
+ 'label' => 'Max Allowed Packet',
120
+ 'advice' => array(
121
+ 'label' => $this->__('The maximum size of one packet or any generated/intermediate string.'),
122
+ 'link' => 'https://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_max_allowed_packet'
123
+ )
124
+ ),
125
+ 'thread_stack' => array(
126
+ 'current_value' => $mysqlVars['thread_stack'] . ' bytes',
127
+ 'recommended_value' => '>= ' . (192 * 1024),
128
+ 'result' => ($mysqlVars['thread_stack'] >= (192 * 1024)),
129
+ 'label' => 'Thread Stack',
130
+ 'advice' => array(
131
+ 'label' => $this->__('The stack size for each thread.'),
132
+ 'link' => 'https://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_thread_stack'
133
+ )
134
+ )
135
+ );
136
+ $system->setData('mysql', new Varien_Object($mysql));
137
+ $system->setData('mysql_vars', new Varien_Object($mysqlVars));
138
+
139
+ /*
140
+ * System Requirements
141
+ */
142
+
143
+ if (version_compare($php['version'], '5.3.0', '>=')) {
144
+ $safeMode['current_value'] = 'Deprecated';
145
+ $safeMode['result'] = false;
146
+ } else {
147
+ $safeMode['result'] = (@ini_get('safe_mode')) ? true : false;
148
+ $safeMode['current_value'] = $this->renderBooleanField($safeMode['result']);
149
+ }
150
+ $memoryLimit = $php['memory_limit'];
151
+ $memoryLimit = substr($memoryLimit, 0, strlen($memoryLimit) - 1);
152
+ $phpCurl = @extension_loaded('curl');
153
+ $phpDom = @extension_loaded('dom');
154
+ $phpGd = @extension_loaded('gd');
155
+ $phpHash = @extension_loaded('hash');
156
+ $phpIconv = @extension_loaded('iconv');
157
+ $phpMcrypt = @extension_loaded('mcrypt');
158
+ $phpPcre = @extension_loaded('pcre');
159
+ $phpPdo = @extension_loaded('pdo');
160
+ $phpPdoMysql = @extension_loaded('pdo_mysql');
161
+ $phpSimplexml = @extension_loaded('simplexml');
162
+
163
+ $requirements = array(
164
+ 'php_version' => array(
165
+ 'label' => 'PHP Version',
166
+ 'recommended_value' => '>= 5.3.0',
167
+ 'current_value' => $php['version'],
168
+ 'result' => version_compare($php['version'], '5.3.0', '>='),
169
+ 'advice' => array(
170
+ 'label' => $this->__('PHP version at least 5.3.0 required, recommended to use latest stable release.'),
171
+ 'link' => 'http://php.net/downloads.php'
172
+ )
173
+ ),
174
+ 'mysql_version' => array(
175
+ 'label' => 'MySQL Version',
176
+ 'recommended_value' => '>= 4.1.20',
177
+ 'current_value' => $mysql['version'],
178
+ 'result' => version_compare($mysql['version'], '4.1.20', '>='),
179
+ 'advice' => array(
180
+ 'label' => $this->__('MySQL version at least 4.1.20 required, recommended to use latest stable release.'),
181
+ 'link' => 'http://dev.mysql.com/downloads/mysql/'
182
+ )
183
+ ),
184
+ 'safe_mode' => array(
185
+ 'label' => 'Safe Mode',
186
+ 'recommended_value' => $this->renderBooleanField(false),
187
+ 'current_value' => $safeMode['current_value'],
188
+ 'result' => !$safeMode['result'],
189
+ 'advice' => array(
190
+ 'label' => $this->__('The PHP safe mode is an attempt to solve the shared-server security problem. Deprecated since PHP 5.3.0'),
191
+ 'link' => 'http://www.php.net/manual/en/features.safe-mode.php'
192
+ )
193
+ ),
194
+ 'memory_limit' => array(
195
+ 'label' => 'Memory Limit',
196
+ 'recommended_value' => '>= 512M',
197
+ 'current_value' => $php['memory_limit'],
198
+ 'result' => ($memoryLimit >= 512),
199
+ 'advice' => array(
200
+ 'label' => $this->__('Maximum amount of memory in bytes that a script is allowed to allocate.'),
201
+ 'link' => 'http://ua2.php.net/manual/en/ini.core.php#ini.memory-limit'
202
+ )
203
+ ),
204
+ 'max_execution_time' => array(
205
+ 'label' => 'Max. Execution Time',
206
+ 'recommended_value' => '>= 360 sec.',
207
+ 'current_value' => $php['max_execution_time'],
208
+ 'result' => ($php['max_execution_time'] >= 360),
209
+ 'advice' => array(
210
+ 'label' => $this->__('This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser.'),
211
+ 'link' => 'http://ua2.php.net/manual/en/info.configuration.php#ini.max-execution-time'
212
+ )
213
+ ),
214
+ 'curl' => array(
215
+ 'label' => 'curl',
216
+ 'recommended_value' => $this->renderBooleanField(true),
217
+ 'current_value' => $this->renderBooleanField($phpCurl),
218
+ 'result' => $phpCurl,
219
+ 'advice' => array(
220
+ 'label' => $this->__('CURL is a library that allows to connect and communicate via a variety of different protocols such as HTTP, HTTPS, FTP, Telnet etc.'),
221
+ 'link' => 'http://www.tomjepson.co.uk/enabling-curl-in-php-php-ini-wamp-xamp-ubuntu/'
222
+ )
223
+ ),
224
+ 'dom' => array(
225
+ 'label' => 'dom',
226
+ 'recommended_value' => $this->renderBooleanField(true),
227
+ 'current_value' => $this->renderBooleanField($phpDom),
228
+ 'result' => $phpDom,
229
+ 'advice' => array(
230
+ 'label' => $this->__('The DOM extension allows to operate on XML documents through the DOM API with PHP 5.'),
231
+ 'link' => 'http://www.php.net/manual/en/dom.setup.php'
232
+ )
233
+ ),
234
+ 'gd' => array(
235
+ 'label' => 'gd',
236
+ 'recommended_value' => $this->renderBooleanField(true),
237
+ 'current_value' => $this->renderBooleanField($phpGd),
238
+ 'result' => $phpGd,
239
+ 'advice' => array(
240
+ 'label' => $this->__('GD is a library which supports a variety of formats, below is a list of formats supported by GD and notes to their availability including read/write support.'),
241
+ 'link' => 'http://www.php.net/manual/en/image.installation.php'
242
+ )
243
+ ),
244
+ 'hash' => array(
245
+ 'label' => 'hash',
246
+ 'recommended_value' => $this->renderBooleanField(true),
247
+ 'current_value' => $this->renderBooleanField($phpHash),
248
+ 'result' => $phpHash,
249
+ 'advice' => array(
250
+ 'label' => $this->__('Hash is a library which allows direct or incremental processing of arbitrary length messages using a variety of hashing algorithms.'),
251
+ 'link' => 'http://www.php.net/manual/en/hash.setup.php'
252
+ )
253
+ ),
254
+ 'iconv' => array(
255
+ 'label' => 'iconv',
256
+ 'recommended_value' => $this->renderBooleanField(true),
257
+ 'current_value' => $this->renderBooleanField($phpIconv),
258
+ 'result' => $phpIconv,
259
+ 'advice' => array(
260
+ 'label' => $this->__('Iconv is a module which contains an interface to iconv character set conversion facility.'),
261
+ 'link' => 'http://ua1.php.net/manual/en/iconv.installation.php'
262
+ )
263
+ ),
264
+ 'mcrypt' => array(
265
+ 'label' => 'mcrypt',
266
+ 'recommended_value' => $this->renderBooleanField(true),
267
+ 'current_value' => $this->renderBooleanField($phpMcrypt),
268
+ 'result' => $phpMcrypt,
269
+ 'advice' => array(
270
+ 'label' => $this->__('Mcrypt library supports a wide variety of block algorithms such as DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and GOST in CBC, OFB, CFB and ECB cipher modes.'),
271
+ 'link' => 'http://www.php.net/manual/en/mcrypt.installation.php'
272
+ )
273
+ ),
274
+ 'pcre' => array(
275
+ 'label' => 'pcre',
276
+ 'recommended_value' => $this->renderBooleanField(true),
277
+ 'current_value' => $this->renderBooleanField($phpPcre),
278
+ 'result' => $phpPcre,
279
+ 'advice' => array(
280
+ 'label' => $this->__('The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5, with just a few differences.'),
281
+ 'link' => 'http://www.php.net/manual/en/pcre.installation.php'
282
+ )
283
+ ),
284
+ 'pdo' => array(
285
+ 'label' => 'pdo',
286
+ 'recommended_value' => $this->renderBooleanField(true),
287
+ 'current_value' => $this->renderBooleanField($phpPdo),
288
+ 'result' => $phpPdo,
289
+ 'advice' => array(
290
+ 'label' => $this->__('The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP.'),
291
+ 'link' => 'http://www.php.net/manual/en/pdo.installation.php'
292
+ )
293
+ ),
294
+ 'pdo_mysql' => array(
295
+ 'label' => 'pdo_mysql',
296
+ 'recommended_value' => $this->renderBooleanField(true),
297
+ 'current_value' => $this->renderBooleanField($phpPdoMysql),
298
+ 'result' => $phpPdoMysql,
299
+ 'advice' => array(
300
+ 'label' => $this->__('PDO_MYSQL is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MySQL 3.x, 4.x and 5.x databases.'),
301
+ 'link' => 'http://ua1.php.net/pdo_mysql#ref.pdo-mysql.installation'
302
+ )
303
+ ),
304
+ 'simplexml' => array(
305
+ 'label' => 'simplexml',
306
+ 'recommended_value' => $this->renderBooleanField(true),
307
+ 'current_value' => $this->renderBooleanField($phpSimplexml),
308
+ 'result' => $phpSimplexml,
309
+ 'advice' => array(
310
+ 'label' => $this->__('The SimpleXML extension provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators.'),
311
+ 'link' => 'http://www.php.net/manual/en/simplexml.installation.php'
312
+ )
313
+ )
314
+ );
315
+ $system->setData('requirements', new Varien_Object($requirements));
316
+
317
+ $magento_api = array();
318
+ $magento_api['charset'] = Mage::getStoreConfig("api/config/charset");
319
+ $magento_api_session_timeout = Mage::getStoreConfig('api/config/session_timeout');
320
+ $magento_api['session_timeout'] = array(
321
+ 'result' => ($magento_api_session_timeout >= 3600),
322
+ 'current_value' => $magento_api_session_timeout,
323
+ 'label' => 'Client Session Timeout (sec.)',
324
+ 'recommended_value' => '>= 3600',
325
+ 'advice' => array(
326
+ 'label' => $this->__('This sets the maximum time in seconds a script is allowed to use Magento Core API using one session ID.'),
327
+ 'link' => 'http://www.magentocommerce.com/boards/viewthread/19445/'
328
+ )
329
+ );
330
+ $magento_api['compliance_wsi'] = Mage::getStoreConfig(Mage_Api_Helper_Data::XML_PATH_API_WSI);;
331
+ $magento_api['wsdl_cache_enabled'] = Mage::getStoreConfig('api/config/wsdl_cache_enabled');
332
+ $system->setData('magento_api', new Varien_Object($magento_api));
333
+
334
+ $this->_system = $system;
335
+
336
+ return $this;
337
+ }
338
+
339
+ /**
340
+ * @return Varien_Object
341
+ */
342
+ public function getSystem()
343
+ {
344
+ return $this->_system;
345
+ }
346
+
347
+ /**
348
+ * @param boolean $value
349
+ * @return string
350
+ */
351
+ public function renderBooleanField($value)
352
+ {
353
+ if ($value) {
354
+ return $this->__('Enabled');
355
+ }
356
+ return $this->__('Disabled');
357
+ }
358
+
359
+ /**
360
+ * @param $result
361
+ * @return string
362
+ */
363
+ public function renderRequirementValue($result)
364
+ {
365
+ if ($result) {
366
+ return 'requirement-passed';
367
+ }
368
+ return 'requirement-failed';
369
+ }
370
+
371
+ /**
372
+ * @param $result
373
+ * @return string
374
+ */
375
+ public function renderStatusField($value)
376
+ {
377
+ if ($value) {
378
+ return $this->__('Ok');
379
+ }
380
+ return $this->__('Error');
381
+ }
382
+
383
+ public function renderAdvice($value)
384
+ {
385
+ if (!empty($value) && !empty($value['advice'])) {
386
+ return '<a ' . (!empty($value['advice']['link']) ? 'href="' . $value['advice']['link'] . '" target="_blank"' : 'href="#"') . '" class="iceimport-advice" title="' . $value['advice']['label'] . '"></a>';
387
+ }
388
+ return '';
389
+ }
390
+
391
+ /**
392
+ * Retrieve a collection of all modules
393
+ *
394
+ * @return Varien_Data_Collection Collection
395
+ */
396
+ public function getModulesCollection($exact = false)
397
+ {
398
+ $sortValue = Mage::app()->getRequest()->getParam('sort', 'name');
399
+ $sortValue = strtolower($sortValue);
400
+
401
+ $sortDir = Mage::app()->getRequest()->getParam('dir', 'ASC');
402
+ $sortDir = strtoupper($sortDir);
403
+
404
+ $modules = $this->_loadModules($exact);
405
+ $modules = Mage::helper('iceimport')->sortMultiDimArr($modules, $sortValue, $sortDir);
406
+
407
+ $collection = new Varien_Data_Collection();
408
+ foreach ($modules as $key => $val) {
409
+ $item = new Varien_Object($val);
410
+ $collection->addItem($item);
411
+ }
412
+
413
+ return $collection;
414
+ }
415
+
416
+ /**
417
+ * Loads the module configurations and checks for some criteria and
418
+ * returns an array with the current modules in the Magento instance.
419
+ *
420
+ * @return array Modules
421
+ */
422
+ protected function _loadModules($exact = false)
423
+ {
424
+ $modules = array();
425
+ $config = Mage::getConfig();
426
+ foreach ($config->getNode('modules')->children() as $moduleName => $item) {
427
+ if (!empty($exact) && strlen($exact) != 0) {
428
+ if (strpos(strtolower($moduleName), strtolower($exact)) === false) {
429
+ continue;
430
+ }
431
+ }
432
+ $active = ($item->active == 'true') ? true : false;
433
+ $codePool = (string)$config->getModuleConfig($item->getName())->codePool;
434
+ $path = $config->getOptions()->getCodeDir() . DS . $codePool . DS . uc_words($item->getName(), DS);
435
+ $pathExists = file_exists($path);
436
+ $pathExists = $pathExists ? true : false;
437
+ $configExists = file_exists($path . '/etc/config.xml');
438
+ $configExists = $configExists ? true : false;
439
+ $version = (string)$config->getModuleConfig($item->getName())->version;
440
+ $dependencies = '-';
441
+ if ($item->depends) {
442
+ $depends = array();
443
+ foreach ($item->depends->children() as $depend) {
444
+ $depends[] = $depend->getName();
445
+ }
446
+ if (is_array($depends) && count($depends) > 0) {
447
+ asort($depends);
448
+ $dependencies = implode("\n", $depends);
449
+ }
450
+ }
451
+
452
+ $modules[$item->getName()] = array(
453
+ 'name' => $item->getName(),
454
+ 'active' => $active,
455
+ 'code_pool' => $codePool,
456
+ 'path' => $path,
457
+ 'path_exists' => $pathExists,
458
+ 'config_exists' => $configExists,
459
+ 'version' => $version,
460
+ 'dependencies' => $dependencies
461
+ );
462
+ }
463
+
464
+ return $modules;
465
+ }
466
+
467
+
468
+ /**
469
+ * Retrieve a collection of all rewrites
470
+ *
471
+ * @return Varien_Data_Collection Collection
472
+ */
473
+ public function getRewriteCollection($exact = false)
474
+ {
475
+ $collection = new Varien_Data_Collection();
476
+ $rewrites = $this->_loadRewrites();
477
+
478
+ foreach ($rewrites as $rewriteNodes) {
479
+ foreach ($rewriteNodes as $n) {
480
+ $nParent = $n->xpath('..');
481
+ $module = (string)$nParent[0]->getName();
482
+ $nSubParent = $nParent[0]->xpath('..');
483
+ $component = (string)$nSubParent[0]->getName();
484
+
485
+ if (!in_array($component, array('blocks', 'helpers', 'models'))) {
486
+ continue;
487
+ }
488
+
489
+ $pathNodes = $n->children();
490
+ foreach ($pathNodes as $pathNode) {
491
+ $path = (string)$pathNode->getName();
492
+ $completePath = $module . '/' . $path;
493
+ $rewriteClassName = (string)$pathNode;
494
+
495
+ if (!empty($exact) && strlen($exact) != 0) {
496
+ if ((strpos(strtolower($completePath), strtolower($exact)) === false)
497
+ && (strpos(strtolower($rewriteClassName), strtolower($exact)) === false)
498
+ ) {
499
+ continue;
500
+ }
501
+ }
502
+
503
+ $instance = Mage::getConfig()->getGroupedClassName(
504
+ substr($component, 0, -1),
505
+ $completePath
506
+ );
507
+
508
+ $collection->addItem(
509
+ new Varien_Object(
510
+ array(
511
+ 'path' => $completePath,
512
+ 'rewrite_class' => $rewriteClassName,
513
+ 'active_class' => $instance,
514
+ 'status' => ($instance == $rewriteClassName)
515
+ )
516
+ )
517
+ );
518
+ }
519
+ }
520
+ }
521
+
522
+ return $collection;
523
+ }
524
+
525
+ /**
526
+ * Return all rewrites
527
+ *
528
+ * @return array All rwrites
529
+ */
530
+ protected function _loadRewrites()
531
+ {
532
+ $fileName = 'config.xml';
533
+ $modules = Mage::getConfig()->getNode('modules')->children();
534
+
535
+ $return = array();
536
+ foreach ($modules as $modName => $module) {
537
+ if ($module->is('active')) {
538
+ $configFile = Mage::getConfig()->getModuleDir('etc', $modName) . DS . $fileName;
539
+ if (file_exists($configFile)) {
540
+ $xml = file_get_contents($configFile);
541
+ $xml = simplexml_load_string($xml);
542
+
543
+ if ($xml instanceof SimpleXMLElement) {
544
+ $return[$modName] = $xml->xpath('//rewrite');
545
+ }
546
+ }
547
+ }
548
+ }
549
+
550
+ return $return;
551
+ }
552
+
553
+ /**
554
+ * @return Varien_Object
555
+ */
556
+ public function getExtensionProblemsDigest()
557
+ {
558
+ $problems = array();
559
+ $count = 0;
560
+ //extension problems
561
+ $check_module = $this->getModulesCollection('ICEshop_Iceimport');
562
+ $check_module = $check_module->getLastItem()->getData();
563
+
564
+ if ($check_module['path_exists'] == 0) {
565
+ $problems['extension']['path_exists'] = $check_module['path_exists'];
566
+ $count++;
567
+ }
568
+ if ($check_module['config_exists'] == 0) {
569
+ $problems['extension']['config_exists'] = $check_module['config_exists'];
570
+ $count++;
571
+ }
572
+
573
+ //extension rewrites problems
574
+ $check_rewrites = $this->getRewriteCollection('ICEshop_Iceimport');
575
+ foreach ($check_rewrites as $rewrite) {
576
+ if (!$rewrite['status']) {
577
+ $problems['rewrite'][] = $rewrite;
578
+ $count++;
579
+ }
580
+ }
581
+
582
+ //system requirements (for magento/extension)
583
+ $requirements = $this->getSystem()->getRequirements()->getData();
584
+ foreach ($requirements as $requirement) {
585
+ if (!$requirement['result']) {
586
+ $problems['requirement'][] = $requirement;
587
+ $count++;
588
+ }
589
+ }
590
+
591
+ //magento API problems
592
+ $magento_api_session_timeout = $this->getSystem()->getMagentoApi()->getSessionTimeout();
593
+ if (!$magento_api_session_timeout['result']) {
594
+ $problems['api']['timeout'] = $magento_api_session_timeout;
595
+ $count++;
596
+ }
597
+
598
+ $mysql = $this->getSystem()->getMysql()->getData();
599
+ foreach ($mysql as $mysql_param_name => $mysql_param_value) {
600
+ if (is_array($mysql_param_value) && !$mysql_param_value['result']) {
601
+ $problems['mysql'][$mysql_param_name] = $mysql_param_value;
602
+ $count++;
603
+ }
604
+ }
605
+
606
+ $DB_logger = Mage::helper('iceimport/db');
607
+ $log_feed = $DB_logger->getLogByType('report');
608
+ if (!empty($log_feed) && count($log_feed) > 0) {
609
+ foreach($log_feed as $log_entry) {
610
+ $problems['iceimport_log'][] = array(
611
+ 'label' => 'Iceimport Error',
612
+ 'current_value' => $log_entry['log_value']
613
+ );
614
+ $count++;
615
+ }
616
+ }
617
+
618
+ $problems_digest = new Varien_Object();
619
+ $problems_digest->setData('problems', $problems);
620
+ $problems_digest->setData('count', $count);
621
+ return $problems_digest;
622
+ }
623
+ }
app/code/community/ICEshop/Iceimport/Model/Convert/Adapter/Product.php ADDED
@@ -0,0 +1,1447 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Import Product with additional attributes
5
+ *
6
+ *
7
+ */
8
+ class ICEshop_Iceimport_Model_Convert_Adapter_Product extends Mage_Catalog_Model_Convert_Adapter_Product
9
+ {
10
+ /**
11
+ * @var array
12
+ */
13
+ protected $_categoryCache = array();
14
+
15
+ /**
16
+ * @var null
17
+ */
18
+ protected $_connRes = null;
19
+
20
+ /**
21
+ * @var string
22
+ */
23
+ protected $_tablePrefix = '';
24
+
25
+ /**
26
+ * @var
27
+ */
28
+ protected $_refreshSettings;
29
+
30
+ /**
31
+ *
32
+ */
33
+ public function __construct()
34
+ {
35
+
36
+ $this->_connRes = Mage::getSingleton('core/resource')->getConnection('core_write');
37
+ $tablePrefix = (array)Mage::getConfig()->getTablePrefix();
38
+ if (!empty($tablePrefix)) {
39
+ $this->_tablePrefix = $tablePrefix[0];
40
+ }
41
+
42
+ }
43
+
44
+ /**
45
+ * @param $storeId
46
+ */
47
+ private function _initRefreshSettings($storeId)
48
+ {
49
+ $this->_refreshSettings = new Varien_Object();
50
+ $this->_refreshSettings->setData('categories', (int)Mage::getStoreConfig('importprod_root/importprod/update_categories_from_csv', $storeId));
51
+ $this->_refreshSettings->setData('status', (int)Mage::getStoreConfig('importprod_root/importprod/update_status_from_csv', $storeId));
52
+ $this->_refreshSettings->setData('visibility', (int)Mage::getStoreConfig('importprod_root/importprod/update_visibility_from_csv', $storeId));
53
+ $this->_refreshSettings->setData('is_in_stock', (int)Mage::getStoreConfig('importprod_root/importprod/update_is_in_stock_from_csv', $storeId));
54
+ $this->_refreshSettings->setData('update_hide_category', (int)Mage::getStoreConfig('importprod_root/importprod/update_hide_category', $storeId));
55
+ $this->_refreshSettings->setData('url_key', (int)Mage::getStoreConfig('importprod_root/importprod/update_url_key_from_csv', $storeId));
56
+ $this->_refreshSettings->setData('import_new_products', (int)Mage::getStoreConfig('importprod_root/importprod/import_new_products', $storeId));
57
+ }
58
+
59
+ /**
60
+ * @param $key
61
+ * @return mixed
62
+ */
63
+ private function _getRefreshSetting($key)
64
+ {
65
+ $key = Mage::helper('iceimport')->toCamelCase($key, true);
66
+ return $this->_refreshSettings->{'get' . $key}();
67
+ }
68
+
69
+ /**
70
+ * @param array $importData
71
+ * @return bool
72
+ * @throws Mage_Core_Exception
73
+ */
74
+ public function saveRow(array $importData)
75
+ {
76
+ // separate import data to eav & static
77
+ $sortedProductData = $this->_mapAttributes($importData);
78
+ $productData = $sortedProductData['productData'];
79
+ $iceimportAttributes = $sortedProductData['iceimportAttributes'];
80
+
81
+ //Init session values to count total products and determine the last call of saveRow method
82
+ $session = Mage::getSingleton("core/session");
83
+ $import_total = $session->getData("import_total");
84
+ $counter = $session->getData("counter");
85
+ $skipped_counter = $session->getData("skipped_counter");
86
+
87
+ if (!isset($import_total)) {
88
+ $batchId = Mage::getSingleton('core/app')->getRequest()->getPost('batch_id', 0);
89
+ $batchModel = Mage::getModel('dataflow/batch')->load($batchId);
90
+ $batchImportModel = $batchModel->getBatchImportModel();
91
+ $importIds = $batchImportModel->getIdCollection();
92
+ $import_total = count($importIds);
93
+ $session->setData("import_total", (int)$import_total);
94
+ }
95
+ if (!isset($counter)) {
96
+ $session->setData("counter", 1);
97
+ $counter = $session->getData("counter");
98
+ }
99
+
100
+ if (!isset($skipped_counter)) {
101
+ $session->setData("skipped_counter", 0);
102
+ $skipped_counter = $session->getData("skipped_counter");
103
+ }
104
+
105
+ // mark product ice_import generic
106
+ $productData['varchar']['is_iceimport'] = 1;
107
+ // set website id
108
+ if (empty($iceimportAttributes['websites'])) {
109
+ $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'website');
110
+ Mage::throwException($message);
111
+ }
112
+ $website = Mage::app()->getWebsite(trim($iceimportAttributes['websites']));
113
+ $websiteId = $website->getId();
114
+
115
+ // set store id
116
+ if (empty($iceimportAttributes['store'])) {
117
+ if (!is_null($this->getBatchParams('store'))) {
118
+ $store = $this->getStoreById($this->getBatchParams('store'));
119
+ } else {
120
+ $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'store');
121
+ Mage::throwException($message);
122
+ }
123
+ }
124
+ if (empty($store)) {
125
+ $store = Mage::app()->getStore(trim($iceimportAttributes['store']));
126
+ }
127
+ if ($store === false) {
128
+ $message = Mage::helper('catalog')->__('Skip import row, store "%s" not exists', $iceimportAttributes['store']);
129
+ Mage::throwException($message);
130
+ }
131
+ $storeId = $store->getId();
132
+ //init refresh settings values
133
+ $this->_initRefreshSettings($storeId);
134
+
135
+ // set attribute set
136
+ if (empty($iceimportAttributes['attribute_set'])) {
137
+ $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'attribute_set');
138
+ Mage::throwException($message);
139
+ }
140
+
141
+ // set sku
142
+ if (empty($iceimportAttributes['sku'])) {
143
+ $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'sku');
144
+ Mage::throwException($message);
145
+ }
146
+ $sku = $iceimportAttributes['sku'];
147
+
148
+ // set category, unspsc, unspsc path
149
+ if (empty($iceimportAttributes['categories'])) {
150
+ $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'categories');
151
+ Mage::throwException($message);
152
+ }
153
+ if (!empty($iceimportAttributes['categories'])) {
154
+ $cat_names = explode('/', $iceimportAttributes['categories']);
155
+ foreach ($cat_names as $cat_name) {
156
+ if (empty($cat_name)) {
157
+ $message = Mage::helper('catalog')->__('Skip import row, some of categories does not have name');
158
+ Mage::throwException($message);
159
+ }
160
+ }
161
+ }
162
+ $category = $iceimportAttributes['categories'];
163
+ if (empty($iceimportAttributes['unspsc'])) {
164
+ $message = Mage::helper('catalog')->__('Skip import. Category UNSPSC not defined in store');
165
+ Mage::throwException($message);
166
+ }
167
+ $unspsc = $iceimportAttributes['unspsc'];
168
+ if (empty($iceimportAttributes['unspsc_path'])) {
169
+ $message = Mage::helper('catalog')->__('Skip import. Category UNSPSC path not defined in store');
170
+ Mage::throwException($message);
171
+ }
172
+ if (!empty($iceimportAttributes['unspsc_path'])) {
173
+ $cat_unspscs = explode('/', $iceimportAttributes['unspsc_path']);
174
+ foreach ($cat_unspscs as $cat_unspsc) {
175
+ if (empty($cat_unspsc)) {
176
+ $message = Mage::helper('catalog')->__('Skip import row, some of categories does not have UNSPSC');
177
+ Mage::throwException($message);
178
+ }
179
+ }
180
+ }
181
+ $unspscPath = $iceimportAttributes['unspsc_path'];
182
+ if (!empty($cat_unspscs) && !empty($cat_names) && count($cat_names) != count($cat_unspscs)) {
183
+ $message = Mage::helper('catalog')->__('Skip import row, categories names does not match categories UNSPSC');
184
+ Mage::throwException($message);
185
+ }
186
+ // set in / out of stock
187
+ $isInStock = 0;
188
+ if (!empty($iceimportAttributes['is_in_stock'])) {
189
+ $isInStock = $iceimportAttributes['is_in_stock'];
190
+ }
191
+
192
+ // set qty
193
+ $qty = 0;
194
+ if (!empty($iceimportAttributes['qty'])) {
195
+ $qty = $iceimportAttributes['qty'];
196
+ }
197
+
198
+ // set price
199
+ $price = 0.00;
200
+ if (!empty($iceimportAttributes['price'])) {
201
+ $price = $iceimportAttributes['price'];
202
+ }
203
+
204
+ // set status value
205
+ $statusValue = (!empty($iceimportAttributes['status']) && $iceimportAttributes['status'] == 'Enabled') ? 1 : 0;
206
+ $productData['int']['status'] = $statusValue;
207
+
208
+ // set visibility value
209
+ $visibilityValue = 1;
210
+ if (!empty($iceimportAttributes['visibility'])) {
211
+ switch ($iceimportAttributes['visibility']) {
212
+ case 'Not Visible Individually':
213
+ $visibilityValue = 1;
214
+ break;
215
+ case 'Catalog':
216
+ $visibilityValue = 2;
217
+ break;
218
+ case 'Search':
219
+ $visibilityValue = 3;
220
+ break;
221
+ case 'Catalog, Search':
222
+ $visibilityValue = 4;
223
+ break;
224
+ }
225
+ }
226
+ $productData['int']['visibility'] = $visibilityValue;
227
+
228
+ // set product image
229
+ $productImage = '';
230
+ if (!empty($iceimportAttributes['image'])) {
231
+ $productImage = $iceimportAttributes['image'];
232
+ }
233
+
234
+ $initAttributes = '';
235
+ // init general attributes query
236
+ $initAttributes .= "SELECT @product_entity_type_id := `entity_type_id`
237
+ FROM `{$this->_tablePrefix}eav_entity_type`
238
+ WHERE entity_type_code = 'catalog_product';";
239
+
240
+ $initAttributes .= "SELECT @category_entity_type_id := `entity_type_id`
241
+ FROM `{$this->_tablePrefix}eav_entity_type`
242
+ WHERE entity_type_code = 'catalog_category';";
243
+
244
+ $initAttributes .= "SELECT @attribute_set_id := `attribute_set_id`
245
+ FROM `{$this->_tablePrefix}eav_attribute_set`
246
+ WHERE attribute_set_name = :attribute_set
247
+ AND entity_type_id = @product_entity_type_id;";
248
+
249
+ $initAttributes .= "SELECT @price_id := `attribute_id`
250
+ FROM `{$this->_tablePrefix}eav_attribute`
251
+ WHERE `attribute_code` = 'price'
252
+ AND entity_type_id = @product_entity_type_id;";
253
+
254
+ $initAttributes .= "SELECT @unspsc_id := `attribute_id`
255
+ FROM `{$this->_tablePrefix}eav_attribute`
256
+ WHERE `attribute_code` = 'unspsc'
257
+ AND entity_type_id = @category_entity_type_id;";
258
+
259
+ $initAttributes .= "SELECT @category_name_id := `attribute_id`
260
+ FROM `{$this->_tablePrefix}eav_attribute`
261
+ WHERE `attribute_code` = 'name'
262
+ AND entity_type_id = @category_entity_type_id;";
263
+
264
+ $initAttributes .= "SELECT @category_active_id := `attribute_id`
265
+ FROM `{$this->_tablePrefix}eav_attribute`
266
+ WHERE `attribute_code` = 'is_active'
267
+ AND entity_type_id = @category_entity_type_id;";
268
+
269
+ $initAttributes .= "SELECT @include_nav_bar_id := `attribute_id`
270
+ FROM `{$this->_tablePrefix}eav_attribute`
271
+ WHERE `attribute_code` = 'include_in_menu'
272
+ AND entity_type_id = @category_entity_type_id;";
273
+
274
+ $initAttributes .= "SELECT @category_is_anchor_id := `attribute_id`
275
+ FROM `{$this->_tablePrefix}eav_attribute`
276
+ WHERE `attribute_code` = 'is_anchor'
277
+ AND entity_type_id = @category_entity_type_id;";
278
+
279
+ if (!empty($iceimportAttributes['stock_name'])) {
280
+ $stock_id = $this->_connRes->fetchRow("SELECT stock_id FROM `{$this->_tablePrefix}cataloginventory_stock` WHERE stock_name = :stock_name LIMIT 1", array(
281
+ ':stock_name' => $iceimportAttributes['stock_name']
282
+ ));
283
+ if (!empty($stock_id)) {
284
+ $initAttributes .= "SELECT @stock_id := `stock_id` FROM `{$this->_tablePrefix}cataloginventory_stock` WHERE stock_name = '" . $iceimportAttributes['stock_name'] . "';";
285
+ } else {
286
+ $message = Mage::helper('catalog')->__('Skip import row, stock name "' . $iceimportAttributes['stock_name'] . '" does not exists in the shop');
287
+ Mage::throwException($message);
288
+ }
289
+ } else {
290
+ $initAttributes .= "SELECT @stock_id := `stock_id` FROM `{$this->_tablePrefix}cataloginventory_stock` WHERE stock_name = 'Default';";
291
+ }
292
+ $this->_connRes->query($initAttributes, array(':attribute_set' => $iceimportAttributes['attribute_set']));
293
+
294
+ // get tax class id
295
+ $defaulttaxConf = (int)Mage::getStoreConfig('importprod_root/importprod/default_tax', $storeId);
296
+ $productData['int']['tax_class_id'] = $defaulttaxConf;
297
+
298
+ // get category id
299
+ $categoriesToActiveConf = Mage::getStoreConfig('importprod_root/importprod/category_active', $storeId);
300
+ $categoryIds = $this->_addCategories($category, $storeId, $unspsc, $unspscPath, $categoriesToActiveConf);
301
+
302
+ // get url key
303
+ $url = '';
304
+ if (!empty($productData['varchar']['name'])) {
305
+ $preUrl = explode(' ', strtolower($productData['varchar']['name']));
306
+ $url = implode('-', $preUrl);
307
+ }
308
+ $productData['varchar']['url_key'] = $url;
309
+
310
+ $prodIdFetch = $this->_connRes->fetchRow("SELECT entity_id FROM `{$this->_tablePrefix}catalog_product_entity` WHERE sku = :sku LIMIT 1", array(
311
+ ':sku' => $sku
312
+ ));
313
+ $productId = $prodIdFetch['entity_id'];
314
+ if (!empty($productId)) {
315
+ // check import type (Import only price & qty or all product info)
316
+ $stockConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_stock', $storeId);
317
+ $priceConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_prices', $storeId);
318
+
319
+ $productId = $this->_coreSave($productData, $productId, $storeId, $sku, $categoryIds);
320
+ $this->_corePriceStock($websiteId, $productId, $price, $qty, $sku, $isInStock, $stockConf, $priceConf, 0);
321
+ $this->_connRes->query("INSERT INTO {$this->_tablePrefix}iceshop_iceimport_imported_product_ids (product_id, product_sku) VALUES (:prod_id, :sku) ON DUPLICATE KEY UPDATE product_sku = :sku", array(':prod_id' => $productId, ':sku' => $sku));
322
+ } else {
323
+ if ($this->_getRefreshSetting('import_new_products') == 0) {
324
+ // $session->setData("counter", (int)--$counter);
325
+ $session->setData("skipped_counter", (int)++$skipped_counter);
326
+ return true;
327
+ }
328
+ $productId = $this->_coreSave($productData, $productId, $storeId, $sku, $categoryIds);
329
+ // add price & stock
330
+ $this->_corePriceStock($websiteId, $productId, $price, $qty, $sku, $isInStock);
331
+ $this->_connRes->query("INSERT INTO {$this->_tablePrefix}iceshop_iceimport_imported_product_ids (product_id, product_sku) VALUES (:prod_id, :sku) ON DUPLICATE KEY UPDATE product_sku = :sku", array(':prod_id' => $productId, ':sku' => $sku));
332
+ }
333
+
334
+ // add product image to queue
335
+ if (Mage::getStoreConfig('importprod_root/importprod/import_images')) {
336
+ $this->_addImageToQueue($productId, $productImage);
337
+ }
338
+
339
+ if ($counter < $import_total) {
340
+ $session->setData("counter", (int)++$counter);
341
+ }
342
+
343
+ if (isset($counter) && isset($skipped_counter) && isset($import_total) && (($counter + $skipped_counter) == $import_total)) {
344
+ $this->_runCategoriesSorting();
345
+ $DB_logger = Mage::helper('iceimport/db');
346
+ $this->deleteOldProducts($DB_logger);
347
+
348
+ $session->unsetData('import_total');
349
+ $session->unsetData('counter');
350
+
351
+ $DB_logger->insertLogEntry('error' . md5(microtime(true)), 'New products skipped while export according to Iceimport settings: ' . $skipped_counter, 'stat');
352
+ $session->unsetData('skipped_counter');
353
+
354
+ $date = date('m/d/Y H:i:s');
355
+ $DB_logger->insertLogEntry('iceimport_import_ended', $date);
356
+ }
357
+
358
+ return true;
359
+ }
360
+
361
+ /**
362
+ * @param $arg_attribute
363
+ * @param $arg_value
364
+ * @return bool
365
+ */
366
+ public function getAttributeOptionValue($arg_attribute, $arg_value)
367
+ {
368
+ $attribute_model = Mage::getModel('eav/entity_attribute');
369
+ $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table');
370
+
371
+ $attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
372
+ $attribute = $attribute_model->load($attribute_code);
373
+
374
+ $attribute_options_model->setAttribute($attribute);
375
+ $options = $attribute_options_model->getAllOptions(false);
376
+
377
+ foreach ($options as $option) {
378
+ if ($option['label'] == $arg_value) {
379
+ return $option['value'];
380
+ }
381
+ }
382
+ return false;
383
+ }
384
+
385
+
386
+ /**
387
+ * @param $arg_attribute
388
+ * @param $arg_value
389
+ * @return bool
390
+ * @throws Exception
391
+ */
392
+ public function addAttributeOption($arg_attribute, $arg_value)
393
+ {
394
+ $attribute_model = Mage::getModel('eav/entity_attribute');
395
+ $attribute_options_model = Mage::getModel('eav/entity_attribute_source_table');
396
+
397
+ $attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
398
+ $attribute = $attribute_model->load($attribute_code);
399
+
400
+ $attribute_options_model->setAttribute($attribute);
401
+ $attribute_options_model->getAllOptions(false);
402
+
403
+ $value = array();
404
+ $value['option'] = array($arg_value, $arg_value);
405
+ $result = array('value' => $value);
406
+
407
+ $attribute->setData('option', $result);
408
+ $attribute->save();
409
+
410
+ return $this->getAttributeOptionValue($arg_attribute, $arg_value);
411
+ }
412
+
413
+
414
+ /**
415
+ * @param array $entityData
416
+ * @param null $productId
417
+ * @param int $storeId
418
+ * @param $sku
419
+ * @param $categoryIds
420
+ * @return null
421
+ */
422
+ protected function _coreSave(array $entityData, $productId = null, $storeId = 0, $sku, $categoryIds)
423
+ {
424
+ $coreSaveSQL = '';
425
+ if ($productId === null) {
426
+ // add product to store
427
+ $coreSaveProduct = "INSERT INTO `{$this->_tablePrefix}catalog_product_entity` (`entity_type_id`, `attribute_set_id`, `type_id`, `sku`, `created_at`)
428
+ VALUES (@product_entity_type_id, @attribute_set_id, 'simple', :sku, NOW());
429
+ SELECT @product_id := LAST_INSERT_ID();";
430
+ $this->_connRes->query($coreSaveProduct, array(':sku' => $sku));
431
+ // get product ID
432
+ $prodFetch = $this->_connRes->fetchRow("SELECT @product_id AS prod_id");
433
+ $productId = $prodFetch['prod_id'];
434
+
435
+ } else {
436
+ $productId = (int)$productId;
437
+ $coreSaveSQL .= "SELECT @product_id := {$productId}; ";
438
+ $producteanConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_ean', $storeId);
439
+ $productmpnConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_mpn', $storeId);
440
+ $productnameConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_name', $storeId);
441
+ $productshdescriptionConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_short_description', $storeId);
442
+ $productdescriptionConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_description', $storeId);
443
+ $productshsudescriptionConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_short_summary_description', $storeId);
444
+ $productsudescriptionConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_summary_description', $storeId);
445
+ $productbrandConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_brand', $storeId);
446
+ $deliveryetaConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_delivery_eta', $storeId);
447
+
448
+ foreach ($entityData as $type => $typeAttributes) {
449
+ foreach ($typeAttributes as $attribute => $value) {
450
+ if (
451
+ (
452
+ ($attribute == 'mpn' && $productmpnConf == 0) ||
453
+ ($attribute == 'brand_name' && $productbrandConf == 0) ||
454
+ ($attribute == 'ean' && $producteanConf == 0) ||
455
+ ($attribute == 'name' && $productnameConf == 0) ||
456
+ ($attribute == 'short_description' && $productshdescriptionConf == 0) ||
457
+ ($attribute == 'description' && $productdescriptionConf == 0) ||
458
+ ($attribute == 'short_summary_description' && $productshsudescriptionConf == 0) ||
459
+ ($attribute == 'long_summary_description' && $productsudescriptionConf == 0) ||
460
+ ($attribute == 'delivery_eta' && $deliveryetaConf == 0)
461
+ ) || (
462
+ $attribute == 'sku' ||
463
+ ($attribute == 'attribute_set') ||
464
+ ($attribute == 'categories' && $this->_getRefreshSetting('categories') == 0) ||
465
+ ($attribute == 'unspsc') ||
466
+ ($attribute == 'price') ||
467
+ ($attribute == 'qty') ||
468
+ ($attribute == 'status' && $this->_getRefreshSetting('status') == 0) ||
469
+ ($attribute == 'visibility' && $this->_getRefreshSetting('visibility') == 0) ||
470
+ ($attribute == 'store') ||
471
+ ($attribute == 'websites') ||
472
+ ($attribute == 'is_in_stock' && $this->_getRefreshSetting('is_in_stock') == 0) ||
473
+ ($attribute == 'url_key' && $this->_getRefreshSetting('url_key') == 0) ||
474
+ ($attribute == 'image') ||
475
+ ($attribute == 'unspsc_path') ||
476
+ ($attribute == 'stock_name')
477
+ )
478
+ ) {
479
+ unset($entityData[$type][$attribute]);
480
+ }
481
+ }
482
+ }
483
+ }
484
+
485
+ $bindArray[':store_id'] = $storeId;
486
+
487
+ foreach ($entityData as $type => $typeAttributes) {
488
+
489
+ if ($type != 'spec') {
490
+ $tailCoreSaveSQL = '';
491
+ $attributesInit = '';
492
+ if ($type == 'select') {
493
+ $type = 'int';
494
+ $is_select = 1;
495
+ } else {
496
+ $is_select = 0;
497
+ }
498
+ if (!empty($typeAttributes)) {
499
+ $tailCoreSaveSQL .= "INSERT INTO `{$this->_tablePrefix}catalog_product_entity_{$type}` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ";
500
+ foreach ($typeAttributes as $attribute => $value) {
501
+ if ($is_select == 1) {
502
+ $option_id = $this->getAttributeOptionValue($attribute, $value);
503
+ if (empty($option_id)) {
504
+ $option_id = $this->addAttributeOption($attribute, $value);
505
+ }
506
+ $value = $option_id;
507
+ }
508
+ $attributesInit .= "SELECT @{$attribute}_id := `attribute_id`
509
+ FROM `{$this->_tablePrefix}eav_attribute`
510
+ WHERE `attribute_code` = '{$attribute}'
511
+ AND entity_type_id = @product_entity_type_id;";
512
+
513
+ $tailCoreSaveSQL .= "
514
+ (@product_entity_type_id, @{$attribute}_id, 0, @product_id, :{$attribute} ),
515
+ (@product_entity_type_id, @{$attribute}_id, :store_id, @product_id, :{$attribute} ), ";
516
+ $bindArray[':' . $attribute] = $value;
517
+
518
+ }
519
+ $tailCoreSaveSQL = substr($tailCoreSaveSQL, 0, -2);
520
+ $tailCoreSaveSQL .= "
521
+ ON DUPLICATE KEY UPDATE
522
+ `value` = VALUES (`value`);";
523
+ }
524
+ $coreSaveSQL .= $attributesInit . $tailCoreSaveSQL;
525
+ } else {
526
+ foreach ($typeAttributes as $attribute => $attributeData) {
527
+ $prod_id_field = $attributeData['prod_id_field'];
528
+ $table = $attributeData['table'];
529
+ $field = $attributeData['field'];
530
+ $value = $attributeData['value'];
531
+ if (!empty($table) && !empty($field)) {
532
+ $coreSaveSQL .= "UPDATE `{$this->_tablePrefix}{$table}`
533
+ SET `{$field}` = :{$attribute}
534
+ WHERE `{$prod_id_field}` = @product_id;";
535
+ $bindArray[':' . $attribute] = $value;
536
+ }
537
+ }
538
+ }
539
+ }
540
+ // categories
541
+ if (($productId === null) || ($productId !== null && $this->_getRefreshSetting('categories') == 1)) {
542
+ $coreSaveSQL .= "INSERT INTO `{$this->_tablePrefix}catalog_category_product` (`category_id`, `product_id`, `position`) VALUES ";
543
+ $counter = 1;
544
+
545
+ $mapCategoryIds = array();
546
+ $mapCategoryIds[] = array_pop($categoryIds);
547
+ $delCategoryIds = array_diff($categoryIds, $mapCategoryIds);
548
+
549
+ foreach ($mapCategoryIds as $categoryId) {
550
+ if ($counter < count($mapCategoryIds)) {
551
+ $coreSaveSQL .= " (" . (int)$categoryId . ", @product_id, 1) , ";
552
+ } else if ($counter == count($mapCategoryIds)) {
553
+ $coreSaveSQL .= " (" . (int)$categoryId . ", @product_id, 1) ON DUPLICATE KEY UPDATE `position` = 1; ";
554
+ }
555
+ $counter++;
556
+ }
557
+ if (!empty($delCategoryIds)) {
558
+ foreach ($delCategoryIds as $delCategoryId) {
559
+ $delCategoryId = (int)$delCategoryId;
560
+ $coreSaveSQL .= "DELETE FROM `{$this->_tablePrefix}catalog_category_product` WHERE `category_id` = {$delCategoryId} AND `product_id` = @product_id;";
561
+ }
562
+ }
563
+ try {
564
+ $this->_connRes->query($coreSaveSQL, $bindArray);
565
+ } catch (Exception $e) {
566
+ echo $e->getMessage();
567
+ }
568
+ }
569
+ return $productId;
570
+ }
571
+
572
+ /**
573
+ * @param int $website
574
+ * @param bool $productId
575
+ * @param float $price
576
+ * @param float $qty
577
+ * @param bool $sku
578
+ * @param int $isInStock
579
+ * @param int $stockConf
580
+ * @param int $priceConf
581
+ * @param int $new_product
582
+ * @throws Mage_Core_Exception
583
+ */
584
+ protected function _corePriceStock($website = 0, $productId = false, $price = 0.00, $qty = 0.00, $sku = false, $isInStock = 0, $stockConf = 1, $priceConf = 1, $new_product = 1)
585
+ {
586
+
587
+ if (!$productId) {
588
+ $message = Mage::helper('catalog')->__('Skip import row, product_id for product "%s" not defined ', $sku);
589
+ Mage::throwException($message);
590
+ }
591
+ $stockSaveSQL = '';
592
+ if ($stockConf == 1) {
593
+ $stockSaveSQL .= "INSERT INTO `{$this->_tablePrefix}cataloginventory_stock_item` (`product_id`, `stock_id`, `qty`, `is_in_stock`)
594
+ VALUES (:product_id, @stock_id, :qty,1)
595
+ ON DUPLICATE KEY UPDATE
596
+ `product_id` = :product_id,
597
+ `stock_id` = @stock_id,
598
+ `qty` = :qty";
599
+
600
+ if ($new_product == 1 || $this->_getRefreshSetting('is_in_stock') == 1) {
601
+ $stockSaveSQL .= ",
602
+ `is_in_stock` = :is_in_stock";
603
+ }
604
+ $stockSaveSQL .= ";";
605
+
606
+ $stockSaveSQL .= "INSERT INTO `{$this->_tablePrefix}cataloginventory_stock_status` (`product_id`, `website_id`, `stock_id`, `qty`, `stock_status`)
607
+ VALUES (:product_id, :websiteId, @stock_id, :qty, 1)
608
+ ON DUPLICATE KEY UPDATE
609
+ `product_id` = :product_id,
610
+ `website_id` = :websiteId,
611
+ `stock_id` = @stock_id,
612
+ `qty` = :qty";
613
+ if ($new_product == 1 || $this->_getRefreshSetting('is_in_stock') == 1) {
614
+ $stockSaveSQL .= ",
615
+ `stock_status` = :is_in_stock";
616
+ }
617
+ $stockSaveSQL .= ";";
618
+ } elseif ($new_product == 0) {
619
+ //existent product
620
+ if ($this->_getRefreshSetting('is_in_stock') == 1) {
621
+ $stockSaveSQL .= "UPDATE `{$this->_tablePrefix}cataloginventory_stock_item` SET `is_in_stock` = :is_in_stock WHERE `product_id` = :product_id AND `stock_id` = @stock_id;";
622
+ $stockSaveSQL .= "UPDATE `{$this->_tablePrefix}cataloginventory_stock_status` SET `stock_status` = :is_in_stock WHERE `product_id` = :product_id AND `website_id` = :websiteId AND `stock_id` = @stock_id;";
623
+ $fields_values = array(
624
+ ':websiteId' => $website,
625
+ ':product_id' => $productId,
626
+ ':is_in_stock' => $isInStock
627
+ );
628
+ $this->_connRes->query($stockSaveSQL, $fields_values);
629
+ $stockSaveSQL = '';
630
+ }
631
+ }
632
+
633
+ if ($priceConf == 1) {
634
+ $stockSaveSQL .= "INSERT INTO `{$this->_tablePrefix}catalog_product_website` (`product_id`, `website_id`)
635
+ VALUES (:product_id, :websiteId)
636
+ ON DUPLICATE KEY UPDATE
637
+ `product_id` = :product_id,
638
+ `website_id` = :websiteId;";
639
+
640
+ $stockSaveSQL .= "INSERT INTO `{$this->_tablePrefix}catalog_product_entity_decimal` (`entity_type_id`,`attribute_id`,`store_id`, `entity_id`, `value`)
641
+ VALUES (@product_entity_type_id, @price_id, 0, :product_id, :price)
642
+ ON DUPLICATE KEY UPDATE
643
+ `entity_type_id` = @product_entity_type_id,
644
+ `attribute_id` = @price_id,
645
+ `store_id` = 0,
646
+ `entity_id` = :product_id,
647
+ `value` = :price;";
648
+ }
649
+ if ($priceConf == 1 || $stockConf == 1) {
650
+ $fields_values = array(
651
+ ':websiteId' => $website,
652
+ ':product_id' => $productId,
653
+ ':price' => $price,
654
+ ':qty' => $qty
655
+ );
656
+ if ($this->_getRefreshSetting('is_in_stock') == 1) {
657
+ $fields_values[':is_in_stock'] = $isInStock;
658
+ }
659
+ $this->_connRes->query($stockSaveSQL, $fields_values);
660
+ unset($fields_values, $stockSaveSQL);
661
+ }
662
+ }
663
+
664
+ /**
665
+ * @param bool $productId
666
+ * @param $productImageUrl
667
+ */
668
+ protected function _addImageToQueue($productId = false, $productImageUrl)
669
+ {
670
+ $productImageUrl = trim($productImageUrl);
671
+ if ($productId && !empty($productImageUrl)) {
672
+ // add image if not exists to queue
673
+ $this->_connRes->query(
674
+ "INSERT IGNORE INTO `{$this->_tablePrefix}iceshop_iceimport_image_queue` (`entity_id`, `image_url` )
675
+ VALUES (:product_id, :image_url)",
676
+ array(
677
+ ':product_id' => $productId,
678
+ ':image_url' => $productImageUrl
679
+ )
680
+ );
681
+ }
682
+ }
683
+
684
+ /**
685
+ * @return mixed
686
+ */
687
+ private function getImageQueue()
688
+ {
689
+ return $this->_connRes->fetchAll("SELECT `queue_id`, `entity_id`, `image_url`
690
+ FROM `{$this->_tablePrefix}iceshop_iceimport_image_queue`
691
+ WHERE `is_downloaded` = 0");
692
+ }
693
+
694
+ /**
695
+ * @param $logFileName
696
+ * @throws Exception
697
+ */
698
+ public function processImageQueue($logFileName)
699
+ {
700
+ // download & set product images
701
+ $queueList = $this->getImageQueue();
702
+ if (count($queueList) > 0) {
703
+ $mediaDir = Mage::getBaseDir('media');
704
+ foreach ($queueList as $queue) {
705
+ $queueId = $queue['queue_id'];
706
+ $productId = $queue['entity_id'];
707
+ $imageUrl = $queue['image_url'];
708
+
709
+ $preImageName = explode('/', $imageUrl);
710
+ $imageName = array_pop($preImageName);
711
+ if (file_exists($mediaDir . DS . $imageName)) {
712
+ $imageName = rand() . '_' . time() . $imageName;
713
+ }
714
+
715
+ if (file_put_contents($mediaDir . DS . $imageName, file_get_contents($imageUrl))) {
716
+ $product = Mage::getModel('catalog/product')->load($productId);
717
+ $product->addImageToMediaGallery($mediaDir . DS . $imageName,
718
+ array('image', 'small_image', 'thumbnail'),
719
+ true, true
720
+ );
721
+ $product->save();
722
+ $this->setImageAsDownloaded($queueId);
723
+ echo $product->getCategory() . '<br>';
724
+ unset($product);
725
+ } else {
726
+ Mage::log('Unable download file to ' . $productId, $logFileName);
727
+ continue;
728
+ }
729
+ }
730
+ }
731
+ }
732
+
733
+ /**
734
+ * @param bool $queueId
735
+ */
736
+ private function setImageAsDownloaded($queueId = false)
737
+ {
738
+ if ($queueId) {
739
+ $this->_connRes->query(
740
+ "UPDATE `{$this->_tablePrefix}iceshop_iceimport_image_queue`
741
+ SET is_downloaded = 1
742
+ WHERE queue_id = :queue_id",
743
+ array(':queue_id' => $queueId)
744
+ );
745
+ }
746
+ }
747
+
748
+ /**
749
+ * @param $categories
750
+ * @param $storeId
751
+ * @param $unspsc
752
+ * @param $unspscPath
753
+ * @param int $categoryActive
754
+ * @return array
755
+ */
756
+ protected function _addCategories($categories, $storeId, $unspsc, $unspscPath, $categoryActive = 1)
757
+ {
758
+
759
+ // check if product exists
760
+ $categoryId = $this->_getCategoryIdByUnspsc($unspsc);
761
+
762
+ $categoryIds = array();
763
+ if (!empty($categoryId)) {
764
+ // merge categories by unspsc
765
+ $categoryMergedArray = $this->_categoryMapper($categories, $unspscPath);
766
+ foreach ($categoryMergedArray as $category) {
767
+ $categoryName = $category['name'];
768
+ $categoryUnspsc = $category['unspsc'];
769
+ $categoryTreeId = $this->_getCategoryIdByUnspsc($categoryUnspsc);
770
+ // check category name to current store
771
+ $categoryBindArray = array(
772
+ ':store_id' => 0,
773
+ ':category_id' => $categoryTreeId
774
+ );
775
+ $nameCheckerFetch = $this->_connRes->fetchRow(
776
+ "SELECT value_id
777
+ FROM `{$this->_tablePrefix}catalog_category_entity_varchar`
778
+ WHERE store_id = :store_id
779
+ AND entity_id = :category_id
780
+ AND attribute_id = @category_name_id",
781
+ $categoryBindArray
782
+ );
783
+ $nameChecker = $nameCheckerFetch['value_id'];
784
+ if (!$nameChecker) {
785
+ // add category name to current store
786
+ $categoryBindArray[':category_name'] = $categoryName;
787
+ if (!empty($categoryBindArray[':category_id'])) {
788
+ $this->_connRes->query(
789
+ "INSERT INTO `{$this->_tablePrefix}catalog_category_entity_varchar` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`)
790
+ VALUES (@category_entity_type_id, @category_name_id, :store_id, :category_id, :category_name)",
791
+ $categoryBindArray
792
+ );
793
+ }
794
+ }
795
+ }
796
+ //
797
+
798
+ $activeSetter = '';
799
+ // get current path of category
800
+ $categoryPath = $this->_connRes->fetchRow(
801
+ "SELECT path
802
+ FROM `{$this->_tablePrefix}catalog_category_entity`
803
+ WHERE entity_id = :entity_id",
804
+ array(':entity_id' => $categoryId)
805
+ );
806
+ $categoryPathArray = explode('/', $categoryPath['path']);
807
+ if ($categoryPathArray) {
808
+ $activeSetter = "INSERT INTO `{$this->_tablePrefix}catalog_category_entity_int` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ";
809
+ }
810
+
811
+ $falseCounter = 0;
812
+ foreach ($categoryPathArray as $categoryId) {
813
+ $category = Mage::getModel('catalog/category')->load($categoryId);
814
+ $cid = $category->getId();
815
+ if (!empty($cid)) {
816
+ if (!empty($categoryId)) {
817
+ $categoryIds[] = (int)$categoryId;
818
+ $activeSetter .= "(@category_entity_type_id, @category_active_id, :store_id, " . $categoryId . ", 1),
819
+ (@category_entity_type_id, @category_active_id, 0, " . $categoryId . ", 1), ";
820
+ } else {
821
+ $falseCounter++;
822
+ }
823
+ } else {
824
+ $falseCounter++;
825
+ }
826
+ }
827
+ $activeSetter = substr($activeSetter, 0, -2);
828
+ $activeSetter .= "
829
+ ON DUPLICATE KEY UPDATE
830
+ `value` = 1
831
+ ";
832
+ if (1 == $categoryActive) {
833
+ if ($falseCounter < count($categoryPathArray)) {
834
+ $this->_connRes->query($activeSetter, array(':store_id' => $storeId));
835
+ }
836
+ }
837
+ return $categoryIds;
838
+ } else {
839
+
840
+ // merge unspsc to current name in unspsc & name path's
841
+ $categoryMergedArray = $this->_categoryMapper($categories, $unspscPath);
842
+ // get max created parent category
843
+ $categoryCreateArray = array();
844
+ for ($i = count($categoryMergedArray) - 1; $i >= 0; $i--) {
845
+ $category = $categoryMergedArray[$i];
846
+ $checkCategoryId = $this->_getCategoryIdByUnspsc($category['unspsc']);
847
+ if ($checkCategoryId != null) {
848
+ $categoryId = $this->_buildCategoryTree($checkCategoryId, $storeId, $categoryCreateArray, $categoryActive);
849
+ $categoryIds[] = (int)$categoryId;
850
+ break;
851
+ } else {
852
+ $categoryCreateArray[] = $category;
853
+ }
854
+ }
855
+ return $categoryIds;
856
+ }
857
+ }
858
+
859
+ /**
860
+ * @param $categoryPath
861
+ * @param $unspscPath
862
+ * @return array
863
+ * @throws Mage_Core_Exception
864
+ */
865
+ protected function _categoryMapper($categoryPath, $unspscPath)
866
+ {
867
+ $nameArray = explode('/', $categoryPath);
868
+ $unspscArray = explode('/', $unspscPath);
869
+
870
+ if (count($nameArray) != count($unspscArray)) {
871
+ $message = Mage::helper('catalog')->__('Skip import row, @categories data is invalid');
872
+ Mage::throwException($message);
873
+ }
874
+
875
+ $categoryMergedArray = array(
876
+ array(
877
+ 'unspsc' => 'default_root',
878
+ 'name' => 'Default category'
879
+ )
880
+ );
881
+
882
+ for ($i = 0; $i < count($unspscArray); $i++) {
883
+ $categoryMergedArray[] = array('name' => $nameArray[$i],
884
+ 'unspsc' => $unspscArray[$i]);
885
+ }
886
+
887
+ return $categoryMergedArray;
888
+ }
889
+
890
+ /**
891
+ * @param $unspsc
892
+ * @return int|null
893
+ */
894
+ protected function _getCategoryIdByUnspsc($unspsc)
895
+ {
896
+ if ($unspsc == 'default_root') {
897
+ return Mage::app()->getStore(1)->getRootCategoryId();
898
+ } else {
899
+ $categoryId = $this->_connRes->fetchRow(
900
+ "SELECT entity_id
901
+ FROM `{$this->_tablePrefix}catalog_category_entity_varchar`
902
+ WHERE `value` = :unspsc
903
+ AND attribute_id = @unspsc_id",
904
+ array(':unspsc' => $unspsc)
905
+ );
906
+ return ($categoryId['entity_id']) ? $categoryId['entity_id'] : null;
907
+ }
908
+ }
909
+
910
+ /**
911
+ * @param $parentCategoryId
912
+ * @param $storeId
913
+ * @param $pathArray
914
+ * @param int $categoryActive
915
+ * @return mixed
916
+ */
917
+ protected function _buildCategoryTree($parentCategoryId, $storeId, $pathArray, $categoryActive = 0)
918
+ {
919
+ for ($i = count($pathArray) - 1; $i >= 0; $i--) {
920
+ $category = $pathArray[$i];
921
+ $parentCategoryId = $this->_createCategory($parentCategoryId, $category['unspsc'], $storeId, $category['name'], $categoryActive);
922
+ }
923
+
924
+ return $parentCategoryId;
925
+ }
926
+
927
+ /**
928
+ * @param $parentId
929
+ * @param $unspsc
930
+ * @param $storeId
931
+ * @param $name
932
+ * @param int $categoryActive
933
+ * @return mixed
934
+ */
935
+ protected function _createCategory($parentId, $unspsc, $storeId, $name, $categoryActive = 0)
936
+ {
937
+
938
+ $addCategory = "SELECT @tPath := `path`, @tLevel := `level`
939
+ FROM `{$this->_tablePrefix}catalog_category_entity`
940
+ WHERE `entity_id` = :parent_id;";
941
+ $addCategory .= "SET @tLevel = @tLevel +1;";
942
+
943
+ $addCategory .= "SET @path := CONCAT(@tPath, '/',(SELECT MAX(entity_id) FROM `{$this->_tablePrefix}catalog_category_entity`) +1 );";
944
+
945
+ $addCategory .= "INSERT INTO `{$this->_tablePrefix}catalog_category_entity` (`entity_type_id`, `attribute_set_id`, `parent_id`, `created_at`, `path`, `position`, `level`, `children_count`)
946
+ VALUES (@category_entity_type_id, 0, :parent_id, NOW(), @path, 1, @tLevel, 0);";
947
+
948
+ $addCategory .= "SELECT @catId := LAST_INSERT_ID();";
949
+
950
+ $addCategory .= "UPDATE `{$this->_tablePrefix}catalog_category_entity`
951
+ SET `path` = CONCAT(@tPath, '/', @catId)
952
+ WHERE entity_id = LAST_INSERT_ID();";
953
+
954
+ $addCategory .= "UPDATE `{$this->_tablePrefix}catalog_category_entity`
955
+ SET children_count = children_count +1
956
+ WHERE entity_id = :parent_id;";
957
+
958
+ $addCategory .= "INSERT IGNORE INTO `{$this->_tablePrefix}catalog_category_entity_int` (`entity_type_id`, `attribute_id`,`store_id`, `entity_id`, `value`)
959
+ VALUES (@category_entity_type_id, @category_active_id, 0, @catId, :category_active),
960
+ (@category_entity_type_id, @category_active_id, :store, @catId, :category_active),
961
+ (@category_entity_type_id, @category_is_anchor_id, 0, @catId, 1),
962
+ (@category_entity_type_id, @category_is_anchor_id, :store, @catId, 1),
963
+ (@category_entity_type_id, @include_nav_bar_id, 0, @catId, 1),
964
+ (@category_entity_type_id, @include_nav_bar_id, :store, @catId, 1);";
965
+
966
+ $addCategory .= "INSERT IGNORE INTO `{$this->_tablePrefix}catalog_category_entity_varchar` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`)
967
+ VALUES (@category_entity_type_id, @category_name_id, 0, @catId, :category_name),
968
+ (@category_entity_type_id, @category_name_id, :store, @catId, :category_name),
969
+ (@category_entity_type_id, @unspsc_id, 0, @catId, :unspsc_val),
970
+ (@category_entity_type_id, @unspsc_id, :store, @catId, :unspsc_val);
971
+ ";
972
+
973
+ $this->_connRes->query($addCategory, array(
974
+ ':store' => $storeId,
975
+ ':parent_id' => $parentId,
976
+ ':category_name' => $name,
977
+ ':unspsc_val' => $unspsc,
978
+ ':category_active' => (int)$categoryActive
979
+ ));
980
+
981
+ $categoryIdFetch = $this->_connRes->fetchRow('SELECT @catId AS category_id');
982
+
983
+ return $categoryIdFetch['category_id'];
984
+ }
985
+
986
+ /**
987
+ * @param array $importData
988
+ * @return array
989
+ */
990
+ protected function _mapAttributes(array $importData)
991
+ {
992
+
993
+ // map iceimport attributes, skip some attributes
994
+ $iceAttributes = array();
995
+ foreach ($importData as $attribute => $value) {
996
+ // map iceimport attributes
997
+ if ($attribute == 'sku' ||
998
+ $attribute == 'attribute_set' ||
999
+ $attribute == 'categories' ||
1000
+ $attribute == 'unspsc' ||
1001
+ $attribute == 'price' ||
1002
+ $attribute == 'qty' ||
1003
+ $attribute == 'status' ||
1004
+ $attribute == 'visibility' ||
1005
+ $attribute == 'store' ||
1006
+ $attribute == 'websites' ||
1007
+ $attribute == 'is_in_stock' ||
1008
+ $attribute == 'image' ||
1009
+ $attribute == 'unspsc_path' ||
1010
+ $attribute == 'stock_name'
1011
+ ) {
1012
+
1013
+ $iceAttributes[$attribute] = $value;
1014
+ unset($importData[$attribute]);
1015
+
1016
+ }
1017
+ // skip some attributes
1018
+ if ($attribute == 'type' ||
1019
+ $attribute == 'supplier_product_code' ||
1020
+ $attribute == 'supplier' ||
1021
+ $attribute == 'leader_categories' ||
1022
+ $attribute == 'leader_store' ||
1023
+ $attribute == 'sprice' ||
1024
+ $attribute == 'euprice' ||
1025
+ $attribute == 'icecat_product_id' ||
1026
+ $attribute == 'icecat_category_id' ||
1027
+ $attribute == 'icecat_vendor_id' ||
1028
+ $attribute == 'icecat_quality' ||
1029
+ $attribute == 'icecat_url' ||
1030
+ $attribute == 'icecat_thumbnail_img' ||
1031
+ $attribute == 'icecat_low_res_img' ||
1032
+ $attribute == 'icecat_high_res_img' ||
1033
+ $attribute == 'tax1' ||
1034
+ $attribute == 'tax2' ||
1035
+ $attribute == 'tax3' ||
1036
+ $attribute == 'tax4' ||
1037
+ $attribute == 'min_quantity' ||
1038
+ $attribute == 'loms' ||
1039
+ $attribute == 'image_label' ||
1040
+ $attribute == 'links_title' ||
1041
+ $attribute == 'small_image_label' ||
1042
+ $attribute == 'tax_rate' ||
1043
+ $attribute == 'gallery' ||
1044
+ $attribute == 'weight_type' ||
1045
+ $attribute == 'sku_type' ||
1046
+ $attribute == 'manage_stock' ||
1047
+ $attribute == 'minimal_price' ||
1048
+ $attribute == 'required_options' ||
1049
+ $attribute == 'samples_title' ||
1050
+ $attribute == 'shipment_type' ||
1051
+ $attribute == 'url_path' ||
1052
+ $attribute == 'recurring_profile' ||
1053
+ $attribute == 'product_keys'
1054
+ ) {
1055
+
1056
+ unset($importData[$attribute]);
1057
+
1058
+ }
1059
+
1060
+ }
1061
+
1062
+ // map default attributes
1063
+ $productData = array();
1064
+ foreach ($this->_getDefaultAttributesList() as $backendType => $attributesList) {
1065
+ if ($backendType != 'spec') {
1066
+ foreach ($attributesList as $attribute) {
1067
+ if (isset($importData[$attribute]) && $importData[$attribute] != '') {
1068
+ $productData[$backendType][$attribute] = $importData[$attribute];
1069
+ unset($importData[$attribute]);
1070
+ }
1071
+ }
1072
+ } else {
1073
+ foreach ($attributesList as $attributeCode => $attributeSpecs) {
1074
+ if (isset($importData[$attributeCode]) && $importData[$attributeCode] != false) {
1075
+ $attributeSpecs['value'] = $importData[$attributeCode];
1076
+ $productData[$backendType][$attributeCode] = $attributeSpecs;
1077
+ unset($importData[$attributeCode]);
1078
+ }
1079
+ }
1080
+ }
1081
+ }
1082
+
1083
+ if (!empty($importData)) {
1084
+ foreach ($importData as $attributeCode => $value) {
1085
+ $frontendTypeFetch = $this->_connRes->fetchRow(
1086
+ "SELECT frontend_input FROM `{$this->_tablePrefix}eav_attribute` WHERE `attribute_code` = :code",
1087
+ array(':code' => $attributeCode)
1088
+ );
1089
+ if ($frontendTypeFetch['frontend_input'] == 'select') {
1090
+ $frontendType = $frontendTypeFetch['frontend_input'];
1091
+ if ($frontendType != 'static' && !empty($frontendType) && $value != '') {
1092
+ $productData[$frontendType][$attributeCode] = $value;
1093
+ unset($importData[$attributeCode]);
1094
+ }
1095
+ }
1096
+ }
1097
+ }
1098
+ // map custom attributes
1099
+ if (!empty($importData)) {
1100
+ foreach ($importData as $attributeCode => $value) {
1101
+ $backendTypeFetch = $this->_connRes->fetchRow("SELECT backend_type FROM `{$this->_tablePrefix}eav_attribute` WHERE `attribute_code` = :code", array(':code' => $attributeCode));
1102
+ $backendType = $backendTypeFetch['backend_type'];
1103
+ if (($backendType != 'static' && !empty($backendType) && $value != '')) {
1104
+ $productData[$backendType][$attributeCode] = $value;
1105
+ unset($importData[$attributeCode]);
1106
+ }
1107
+ }
1108
+ }
1109
+
1110
+ $failedAttributes = array();
1111
+ if (count($importData) > 0) {
1112
+ $failedAttributes = array_keys($importData);
1113
+ }
1114
+
1115
+ return array(
1116
+ 'iceimportAttributes' => $iceAttributes,
1117
+ 'productData' => $productData,
1118
+ 'failedAttributes' => $failedAttributes
1119
+ );
1120
+
1121
+ }
1122
+
1123
+ /**
1124
+ * @return array
1125
+ */
1126
+ protected function _getDefaultAttributesList()
1127
+ {
1128
+
1129
+ return array(
1130
+ 'varchar' => array(
1131
+ 'gift_message_available',
1132
+ 'custom_design',
1133
+ 'msrp_display_actual_price_type',
1134
+ 'msrp_enabled',
1135
+ 'options_container',
1136
+ 'page_layout',
1137
+ 'mpn',
1138
+ 'name',
1139
+ 'url_key',
1140
+ 'meta_description',
1141
+ 'meta_title'
1142
+ ),
1143
+ 'int' => array(
1144
+ 'enable_googlecheckout',
1145
+ 'is_recurring',
1146
+ 'links_purchased_separately',
1147
+ 'links_exist',
1148
+ 'status',
1149
+ 'visibility',
1150
+ 'tax_class_id',
1151
+ 'color',
1152
+ 'price_view',
1153
+ 'manufacturer'
1154
+ ),
1155
+ 'text' => array(
1156
+ 'recurring_profile',
1157
+ 'description',
1158
+ 'custom_layout_update',
1159
+ 'meta_keyword',
1160
+ 'short_description'
1161
+ ),
1162
+ 'decimal' => array(
1163
+ 'cost',
1164
+ 'group_price',
1165
+ 'weight',
1166
+ 'special_price',
1167
+ 'msrp'
1168
+ ),
1169
+ 'datetime' => array(
1170
+ 'custom_design_from',
1171
+ 'custom_design_to',
1172
+ 'news_from_date',
1173
+ 'news_to_date',
1174
+ 'special_from_date',
1175
+ 'special_to_date'
1176
+ ),
1177
+ 'spec' => array(
1178
+ 'is_qty_decimal' => array(
1179
+ 'prod_id_field' => 'product_id',
1180
+ 'table' => 'cataloginventory_stock_item',
1181
+ 'field' => 'is_qty_decimal'
1182
+ ),
1183
+ 'use_config_min_qty' => array(
1184
+ 'prod_id_field' => 'product_id',
1185
+ 'table' => 'cataloginventory_stock_item',
1186
+ 'field' => 'use_config_min_qty'
1187
+ ),
1188
+ 'use_config_min_sale_qty' => array(
1189
+ 'prod_id_field' => 'product_id',
1190
+ 'table' => 'cataloginventory_stock_item',
1191
+ 'field' => 'use_config_min_sale_qty'
1192
+ ),
1193
+ 'use_config_max_sale_qty' => array(
1194
+ 'prod_id_field' => 'product_id',
1195
+ 'table' => 'cataloginventory_stock_item',
1196
+ 'field' => 'use_config_max_sale_qty'
1197
+ ),
1198
+ 'use_config_manage_stock' => array(
1199
+ 'prod_id_field' => 'product_id',
1200
+ 'table' => 'cataloginventory_stock_item',
1201
+ 'field' => 'use_config_manage_stock'
1202
+ ),
1203
+ 'is_decimal_divided' => array(
1204
+ 'prod_id_field' => 'product_id',
1205
+ 'table' => 'cataloginventory_stock_item',
1206
+ 'field' => 'is_decimal_divided'
1207
+ ),
1208
+ 'use_config_backorders' => array(
1209
+ 'prod_id_field' => 'product_id',
1210
+ 'table' => 'cataloginventory_stock_item',
1211
+ 'field' => 'use_config_backorders'
1212
+ ),
1213
+ 'use_config_notify_stock_qty' => array(
1214
+ 'prod_id_field' => 'product_id',
1215
+ 'table' => 'cataloginventory_stock_item',
1216
+ 'field' => 'use_config_notify_stock_qty'
1217
+ ),
1218
+ 'max_sale_qty' => array(
1219
+ 'prod_id_field' => 'product_id',
1220
+ 'table' => 'cataloginventory_stock_item',
1221
+ 'field' => 'max_sale_qty'
1222
+ ),
1223
+ 'min_sale_qty' => array(
1224
+ 'prod_id_field' => 'product_id',
1225
+ 'table' => 'cataloginventory_stock_item',
1226
+ 'field' => 'min_sale_qty'
1227
+ ),
1228
+ 'notify_stock_qty' => array(
1229
+ 'prod_id_field' => 'product_id',
1230
+ 'table' => 'cataloginventory_stock_item',
1231
+ 'field' => 'notify_stock_qty'
1232
+ ),
1233
+ 'backorders' => array(
1234
+ 'prod_id_field' => 'product_id',
1235
+ 'table' => 'cataloginventory_stock_item',
1236
+ 'field' => 'backorders'
1237
+ ),
1238
+ 'created_at' => array(
1239
+ 'prod_id_field' => 'entity_id',
1240
+ 'table' => 'catalog_product_entity',
1241
+ 'field' => 'created_at'
1242
+ ),
1243
+ 'min_qty' => array(
1244
+ 'prod_id_field' => 'product_id',
1245
+ 'table' => 'cataloginventory_stock_item',
1246
+ 'field' => 'min_qty'
1247
+ ),
1248
+ 'updated_at' => array(
1249
+ 'prod_id_field' => 'entity_id',
1250
+ 'table' => 'catalog_product_entity',
1251
+ 'field' => 'updated_at'
1252
+ )
1253
+ )
1254
+ );
1255
+ }
1256
+
1257
+ /**
1258
+ * Count child categories products and set them inactive if they have no products
1259
+ *
1260
+ * @param $child_cat
1261
+ */
1262
+ public function CountChildProd($child_cat)
1263
+ {
1264
+ foreach ($child_cat as $cat) {
1265
+ $query = "SELECT `entity_id`
1266
+ FROM `{$this->_tablePrefix}catalog_category_entity`
1267
+ WHERE parent_id = :cat_id";
1268
+ $child_cat = $this->_connRes->fetchAll(
1269
+ $query,
1270
+ array(
1271
+ ':cat_id' => $cat['entity_id']
1272
+ )
1273
+ );
1274
+
1275
+ $query = "SELECT COUNT(*)
1276
+ FROM `{$this->_tablePrefix}catalog_category_product`
1277
+ WHERE category_id = :cat_id ";
1278
+ $cat_products = $this->_connRes->fetchRow(
1279
+ $query,
1280
+ array(
1281
+ ':cat_id' => $cat['entity_id']
1282
+ )
1283
+ );
1284
+
1285
+ if ($cat_products['COUNT(*)'] == 0 && empty($child_cat) && $this->_getRefreshSetting('update_hide_category') == 1) {
1286
+ $this->_connRes->query(
1287
+ "UPDATE `{$this->_tablePrefix}catalog_category_entity_int`
1288
+ SET `value` = 0
1289
+ WHERE `attribute_id` = @category_active_id
1290
+ AND entity_id = :cat_id",
1291
+ array(
1292
+ ':cat_id' => $cat['entity_id']
1293
+ )
1294
+ );
1295
+ } else if (!empty($child_cat)) {
1296
+ $this->CountChildProd($child_cat);
1297
+ }
1298
+ }
1299
+ }
1300
+
1301
+ /**
1302
+ * Run categories resorting procedure
1303
+ */
1304
+ private function _runCategoriesSorting()
1305
+ {
1306
+ // Check if this is last imported product
1307
+ // Do category sort and set categories without products to inactive
1308
+ $catCollection = Mage::getModel('catalog/category')
1309
+ ->getCollection()
1310
+ ->addAttributeToSort('name', 'ASC');
1311
+
1312
+ $category_sort = (int)Mage::getStoreConfig('importprod_root/importprod/category_sort');
1313
+ if ($category_sort == 1) {
1314
+ $position = 1;
1315
+ }
1316
+ foreach ($catCollection as $category) {
1317
+
1318
+ if ($category_sort) {
1319
+ $query = "UPDATE `{$this->_tablePrefix}catalog_category_entity` SET position = :position WHERE entity_id = :cat_id ";
1320
+ $this->_connRes->query($query, array(
1321
+ ':position' => $position++,
1322
+ ':cat_id' => $category->getId()
1323
+ ));
1324
+ }
1325
+
1326
+ $query = "SELECT COUNT(*) FROM `{$this->_tablePrefix}catalog_category_product` WHERE category_id = :cat_id ";
1327
+ $cat_products = $this->_connRes->fetchRow($query, array(
1328
+ ':cat_id' => $category->getId()
1329
+ ));
1330
+
1331
+ if ($cat_products['COUNT(*)'] == 0) {
1332
+ $query = "SELECT `entity_id` FROM `{$this->_tablePrefix}catalog_category_entity` WHERE parent_id = :cat_id";
1333
+ $child_cat = $this->_connRes->fetchAll($query, array(
1334
+ ':cat_id' => $category->getId()
1335
+ ));
1336
+
1337
+ if (isset($child_cat) && count($child_cat) > 0) {
1338
+ //Count child categories products and set them to inactive if they have no
1339
+ $this->CountChildProd($child_cat);
1340
+ } elseif($this->_getRefreshSetting('update_hide_category') == 1) {
1341
+ $this->_connRes->query("UPDATE `{$this->_tablePrefix}catalog_category_entity_int`
1342
+ SET `value` = 0 WHERE `attribute_id` = @category_active_id AND entity_id = :cat_id", array(
1343
+ ':cat_id' => $category->getId()
1344
+ ));
1345
+ }
1346
+ }
1347
+ }
1348
+ }
1349
+
1350
+ /**
1351
+ * @param object $DB_logger
1352
+ * @throws Exception
1353
+ */
1354
+ public function deleteOldProducts($DB_logger)
1355
+ {
1356
+ $delete_old_products = (int)Mage::getStoreConfig('importprod_root/importprod/delete_old_products');
1357
+ if ($delete_old_products) {
1358
+ try {
1359
+ $db_res = Mage::getSingleton('core/resource')->getConnection('core_write');
1360
+ $db_res->query("SELECT @is_iceimport_id := `attribute_id`
1361
+ FROM {$this->_tablePrefix}eav_attribute
1362
+ WHERE attribute_code = 'is_iceimport'");
1363
+
1364
+ $count_prod = $db_res->fetchRow("SELECT COUNT(*) AS count_prod
1365
+ FROM {$this->_tablePrefix}catalog_product_entity AS cpe
1366
+ JOIN {$this->_tablePrefix}catalog_product_entity_varchar AS cpev
1367
+ ON cpe.entity_id = cpev.entity_id
1368
+ AND cpev.value = 1
1369
+ AND cpev.attribute_id = @is_iceimport_id");
1370
+ $count_prod = $count_prod['count_prod'];
1371
+
1372
+ if ($count_prod > 0) {
1373
+ //iceimport products exists, amount > 0
1374
+ $count_del_prod = $db_res->fetchRow("SELECT COUNT(*) AS count__del_prod
1375
+ FROM {$this->_tablePrefix}catalog_product_entity AS cpe
1376
+ JOIN {$this->_tablePrefix}catalog_product_entity_varchar AS cpev
1377
+ ON cpe.entity_id = cpev.entity_id
1378
+ AND cpev.value = 1
1379
+ AND cpev.attribute_id = @is_iceimport_id
1380
+ LEFT JOIN {$this->_tablePrefix}iceshop_iceimport_imported_product_ids AS iip
1381
+ ON cpe.entity_id = iip.product_id
1382
+ WHERE iip.product_id IS NULL");
1383
+
1384
+ $count_del_prod = $count_del_prod['count_del_prod'];
1385
+
1386
+ if ($count_del_prod > 0) {
1387
+ //iceimport products to delete exists, amount > 0
1388
+ $delete_old_products_tolerance = (int)Mage::getStoreConfig('importprod_root/importprod/delete_old_products_tolerance');
1389
+
1390
+ if (round(($count_del_prod / $count_prod * 100), 0) < $delete_old_products_tolerance) {
1391
+
1392
+ //iceimport products to delete franction is less than allowed tolerance, deletion approved
1393
+ $DB_logger->insertLogEntry('iceimport_count_delete_product', $count_del_prod);
1394
+ $db_res->query("DELETE cpe
1395
+ FROM {$this->_tablePrefix}catalog_product_entity AS cpe
1396
+ JOIN {$this->_tablePrefix}catalog_product_entity_varchar AS cpev
1397
+ ON cpe.entity_id = cpev.entity_id
1398
+ AND cpev.value = 1
1399
+ AND cpev.attribute_id = @is_iceimport_id
1400
+ LEFT JOIN {$this->_tablePrefix}iceshop_iceimport_imported_product_ids AS iip
1401
+ ON cpe.entity_id = iip.product_id
1402
+ WHERE iip.product_id IS NULL");
1403
+
1404
+ $db_res->query("DELETE FROM {$this->_tablePrefix}iceshop_iceimport_imported_product_ids");
1405
+ } else {
1406
+ $error_message = 'Attempt to delete more old products than allowed in Iceimport configuration. Interruption of the process.';
1407
+ $DB_logger->insertLogEntry('error' . md5(microtime(true)), $error_message, 'error');
1408
+ $error_message2 = 'Old product percentage: ' . round(($count_del_prod / $count_prod * 100), 0) . '%';
1409
+ $DB_logger->insertLogEntry('error' . md5(microtime(true)), $error_message2, 'error');
1410
+ print $error_message;
1411
+ exit;
1412
+ }
1413
+ }
1414
+ }
1415
+ } catch (Exception $e) {
1416
+ throw new Exception($e->getMessage());
1417
+ }
1418
+ }
1419
+ }
1420
+
1421
+ /**
1422
+ * @throws Exception
1423
+ */
1424
+ public function finish()
1425
+ {
1426
+ /**
1427
+ * Back compatibility event
1428
+ */
1429
+ $DB_logger = Mage::helper('iceimport/db');
1430
+ $tablePrefix = '';
1431
+ $tPrefix = (array)Mage::getConfig()->getTablePrefix();
1432
+ if (!empty($tPrefix)) {
1433
+ $tablePrefix = $tPrefix[0];
1434
+ }
1435
+ $count_imported_products = $DB_logger->getRowsCount($tablePrefix . "iceshop_iceimport_imported_product_ids");
1436
+ $DB_logger->insertLogEntry('iceimport_count_imported_products', $count_imported_products);
1437
+
1438
+ Mage::dispatchEvent($this->_eventPrefix . '_after', array());
1439
+
1440
+ $entity = new Varien_Object();
1441
+ Mage::getSingleton('index/indexer')->processEntityAction(
1442
+ $entity,
1443
+ self::ENTITY,
1444
+ Mage_Index_Model_Event::TYPE_SAVE
1445
+ );
1446
+ }
1447
+ }
app/code/community/{Iceshop → ICEshop}/Iceimport/Model/Dataflow/Batch/Import.php RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Dataflow Batch import model
4
  *
@@ -13,7 +14,7 @@
13
  * @package Mage_Dataflow
14
  * @author Magento Core Team <core@magentocommerce.com>
15
  */
16
- class Iceshop_Iceimport_Model_Dataflow_Batch_Import extends Mage_Dataflow_Model_Batch_Import
17
  {
18
  protected $_connRes = null;
19
 
@@ -28,7 +29,7 @@ class Iceshop_Iceimport_Model_Dataflow_Batch_Import extends Mage_Dataflow_Model_
28
  {
29
 
30
  if ('"libiconv"' == ICONV_IMPL) {
31
- foreach ($data as $item){
32
  foreach ($item as &$value) {
33
  $value = iconv('utf-8', 'utf-8//IGNORE', $value);
34
  }
@@ -36,10 +37,10 @@ class Iceshop_Iceimport_Model_Dataflow_Batch_Import extends Mage_Dataflow_Model_
36
  }
37
 
38
  $batch_import = Mage::getSingleton('core/resource')->getTableName('dataflow/batch_import');
39
- $insert_query = "INSERT INTO ".$batch_import." (`batch_id`, `batch_data`, `status`) VALUES ";
40
- foreach ($data as $item){
41
- if(!empty($item)){
42
- $insert_query .= "(".$this->getBatchId().", '".addslashes(serialize($item))."', 1), ";
43
  }
44
  }
45
  $insert_query = substr($insert_query, 0, -2);
1
  <?php
2
+
3
  /**
4
  * Dataflow Batch import model
5
  *
14
  * @package Mage_Dataflow
15
  * @author Magento Core Team <core@magentocommerce.com>
16
  */
17
+ class ICEshop_Iceimport_Model_Dataflow_Batch_Import extends Mage_Dataflow_Model_Batch_Import
18
  {
19
  protected $_connRes = null;
20
 
29
  {
30
 
31
  if ('"libiconv"' == ICONV_IMPL) {
32
+ foreach ($data as $item) {
33
  foreach ($item as &$value) {
34
  $value = iconv('utf-8', 'utf-8//IGNORE', $value);
35
  }
37
  }
38
 
39
  $batch_import = Mage::getSingleton('core/resource')->getTableName('dataflow/batch_import');
40
+ $insert_query = "INSERT INTO " . $batch_import . " (`batch_id`, `batch_data`, `status`) VALUES ";
41
+ foreach ($data as $item) {
42
+ if (!empty($item)) {
43
+ $insert_query .= "(" . $this->getBatchId() . ", '" . addslashes(serialize($item)) . "', 1), ";
44
  }
45
  }
46
  $insert_query = substr($insert_query, 0, -2);
app/code/community/{Iceshop → ICEshop}/Iceimport/Model/Dataflow/Convert/Parser/Csv.php RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Convert csv parser
4
  *
@@ -6,7 +7,7 @@
6
  * @package Mage_Dataflow
7
  * @author Magento Core Team <core@magentocommerce.com>
8
  */
9
- class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_Model_Convert_Parser_Csv
10
  {
11
  protected $_fields;
12
 
@@ -14,32 +15,36 @@ class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_
14
 
15
  public function parse()
16
  {
 
 
 
 
17
  $default_attr_set_id = Mage::getModel('catalog/product')->getResource()->getEntityType()->getDefaultAttributeSetId();
18
  $attributes = Mage::getModel('catalog/product_attribute_api')->items($default_attr_set_id);
19
 
20
  $req_attributes = array('brand_name', 'ean', 'mpn', 'delivery_eta', 'is_iceimport');
21
  $not_found_attr = array();
22
- foreach($req_attributes as $req_attribute){
23
- foreach($attributes as $_attribute){
24
- if($_attribute['code'] == $req_attribute){
25
  unset($not_found_attr[$req_attribute]);
26
  break;
27
- }else{
28
  $not_found_attr[$req_attribute] = $req_attribute;
29
  }
30
  }
31
  }
32
- if(!empty($not_found_attr)){
33
  echo '
34
  <li style="background-color:#FDD" id="error-0">
35
  <img id="error-0_img" src="' . Mage::getBaseUrl('web') . '/skin/adminhtml/default/default/images/error_msg_icon.gif" class="v-middle" style="margin-right:5px">
36
- <span id="error-0_status" class="text">Not found attributes: ' . implode(", ", $not_found_attr) . ' please check you defaul attribute set.</span>
37
  </li>';
38
  exit;
39
  }
40
 
41
  // fixed for multibyte characters
42
- setlocale(LC_ALL, Mage::app()->getLocale()->getLocaleCode().'.UTF-8');
43
 
44
  $fDel = $this->getVar('delimiter', ',');
45
  $fEnc = $this->getVar('enclose', '"');
@@ -47,7 +52,7 @@ class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_
47
  $fDel = "\t";
48
  }
49
 
50
- $adapterName = $this->getVar('adapter', null);
51
  $adapterMethod = $this->getVar('method', 'saveRow');
52
 
53
  if (!$adapterName || !$adapterMethod) {
@@ -58,8 +63,7 @@ class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_
58
 
59
  try {
60
  $adapter = Mage::getModel($adapterName);
61
- }
62
- catch (Exception $e) {
63
  $message = Mage::helper('dataflow')->__('Declared adapter %s was not found.', $adapterName);
64
  $this->addException($message, Mage_Dataflow_Model_Convert_Exception::FATAL);
65
  return $this;
@@ -75,7 +79,7 @@ class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_
75
  $batchIoAdapter = $this->getBatchModel()->getIoAdapter();
76
 
77
  if (Mage::app()->getRequest()->getParam('files')) {
78
- $file = Mage::app()->getConfig()->getTempVarDir().'/import/'
79
  . urldecode(Mage::app()->getRequest()->getParam('files'));
80
  $this->_copy($file);
81
  }
@@ -85,8 +89,7 @@ class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_
85
  $isFieldNames = $this->getVar('fieldnames', '') == 'true' ? true : false;
86
  if (!$isFieldNames && is_array($this->getVar('map'))) {
87
  $fieldNames = $this->getVar('map');
88
- }
89
- else {
90
  $fieldNames = array();
91
  foreach ($batchIoAdapter->read(true, $fDel, $fEnc) as $v) {
92
  $fieldNames[$v] = $v;
@@ -94,19 +97,26 @@ class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_
94
  }
95
  $countRows = 0;
96
  $currentRow = 0;
97
- $maxRows = 400;
 
 
 
 
 
 
98
  $itemData = array();
99
  while (($csvData = $batchIoAdapter->read(true, $fDel, $fEnc)) !== false) {
100
  if (count($csvData) == 1 && $csvData[0] === null) {
101
  continue;
102
  }
103
- $countRows ++; $i = 0;
 
104
  foreach ($fieldNames as $field) {
105
  $itemData[$currentRow][$field] = isset($csvData[$i]) ? $csvData[$i] : null;
106
- $i ++;
107
  }
108
 
109
- if($currentRow == $maxRows){
110
  $currentRow = 0;
111
  $batchImportModel = $this->getBatchImportModel()
112
  ->setBatchId($this->getBatchModel()->getId())
@@ -116,7 +126,7 @@ class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_
116
  $currentRow++;
117
 
118
  }
119
- if($currentRow < $maxRows && $currentRow != 0){
120
  $batchImportModel = $this->getBatchImportModel()
121
  ->setBatchId($this->getBatchModel()->getId())
122
  ->setBatchData($itemData)->setStatus(1);
@@ -129,6 +139,21 @@ class Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_
129
  ->setAdapter($adapterName)
130
  ->save();
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  return $this;
134
  }
1
  <?php
2
+
3
  /**
4
  * Convert csv parser
5
  *
7
  * @package Mage_Dataflow
8
  * @author Magento Core Team <core@magentocommerce.com>
9
  */
10
+ class ICEshop_Iceimport_Model_Dataflow_Convert_Parser_Csv extends Mage_Dataflow_Model_Convert_Parser_Csv
11
  {
12
  protected $_fields;
13
 
15
 
16
  public function parse()
17
  {
18
+ $DB_logger = Mage::helper('iceimport/db');
19
+ $date = date('m/d/Y H:i:s');
20
+ $DB_logger->insertLogEntry('iceimport_import_started', $date);
21
+
22
  $default_attr_set_id = Mage::getModel('catalog/product')->getResource()->getEntityType()->getDefaultAttributeSetId();
23
  $attributes = Mage::getModel('catalog/product_attribute_api')->items($default_attr_set_id);
24
 
25
  $req_attributes = array('brand_name', 'ean', 'mpn', 'delivery_eta', 'is_iceimport');
26
  $not_found_attr = array();
27
+ foreach ($req_attributes as $req_attribute) {
28
+ foreach ($attributes as $_attribute) {
29
+ if ($_attribute['code'] == $req_attribute) {
30
  unset($not_found_attr[$req_attribute]);
31
  break;
32
+ } else {
33
  $not_found_attr[$req_attribute] = $req_attribute;
34
  }
35
  }
36
  }
37
+ if (!empty($not_found_attr)) {
38
  echo '
39
  <li style="background-color:#FDD" id="error-0">
40
  <img id="error-0_img" src="' . Mage::getBaseUrl('web') . '/skin/adminhtml/default/default/images/error_msg_icon.gif" class="v-middle" style="margin-right:5px">
41
+ <span id="error-0_status" class="text">Not found attributes: ' . implode(", ", $not_found_attr) . ' please check you default attribute set.</span>
42
  </li>';
43
  exit;
44
  }
45
 
46
  // fixed for multibyte characters
47
+ setlocale(LC_ALL, Mage::app()->getLocale()->getLocaleCode() . '.UTF-8');
48
 
49
  $fDel = $this->getVar('delimiter', ',');
50
  $fEnc = $this->getVar('enclose', '"');
52
  $fDel = "\t";
53
  }
54
 
55
+ $adapterName = $this->getVar('adapter', null);
56
  $adapterMethod = $this->getVar('method', 'saveRow');
57
 
58
  if (!$adapterName || !$adapterMethod) {
63
 
64
  try {
65
  $adapter = Mage::getModel($adapterName);
66
+ } catch (Exception $e) {
 
67
  $message = Mage::helper('dataflow')->__('Declared adapter %s was not found.', $adapterName);
68
  $this->addException($message, Mage_Dataflow_Model_Convert_Exception::FATAL);
69
  return $this;
79
  $batchIoAdapter = $this->getBatchModel()->getIoAdapter();
80
 
81
  if (Mage::app()->getRequest()->getParam('files')) {
82
+ $file = Mage::app()->getConfig()->getTempVarDir() . '/import/'
83
  . urldecode(Mage::app()->getRequest()->getParam('files'));
84
  $this->_copy($file);
85
  }
89
  $isFieldNames = $this->getVar('fieldnames', '') == 'true' ? true : false;
90
  if (!$isFieldNames && is_array($this->getVar('map'))) {
91
  $fieldNames = $this->getVar('map');
92
+ } else {
 
93
  $fieldNames = array();
94
  foreach ($batchIoAdapter->read(true, $fDel, $fEnc) as $v) {
95
  $fieldNames[$v] = $v;
97
  }
98
  $countRows = 0;
99
  $currentRow = 0;
100
+ $maxRows = (int)Mage::getStoreConfig(
101
+ 'importprod_root/importprod/iceimport_batch_size',
102
+ Mage::app()
103
+ ->getWebsite()
104
+ ->getDefaultGroup()
105
+ ->getDefaultStoreId()
106
+ );
107
  $itemData = array();
108
  while (($csvData = $batchIoAdapter->read(true, $fDel, $fEnc)) !== false) {
109
  if (count($csvData) == 1 && $csvData[0] === null) {
110
  continue;
111
  }
112
+ $countRows++;
113
+ $i = 0;
114
  foreach ($fieldNames as $field) {
115
  $itemData[$currentRow][$field] = isset($csvData[$i]) ? $csvData[$i] : null;
116
+ $i++;
117
  }
118
 
119
+ if ($currentRow == $maxRows) {
120
  $currentRow = 0;
121
  $batchImportModel = $this->getBatchImportModel()
122
  ->setBatchId($this->getBatchModel()->getId())
126
  $currentRow++;
127
 
128
  }
129
+ if ($currentRow < $maxRows && $currentRow != 0) {
130
  $batchImportModel = $this->getBatchImportModel()
131
  ->setBatchId($this->getBatchModel()->getId())
132
  ->setBatchData($itemData)->setStatus(1);
139
  ->setAdapter($adapterName)
140
  ->save();
141
 
142
+ //latest session cleaning
143
+ //Init session values to count total products and determine the last call of saveRow method
144
+ $session = Mage::getSingleton("core/session");
145
+ $import_total = $session->getData("import_total");
146
+ $counter = $session->getData("counter");
147
+ $skipped_counter = $session->getData("skipped_counter");
148
+ if (isset($import_total)) {
149
+ $session->unsetData("import_total");
150
+ }
151
+ if (isset($counter)) {
152
+ $session->unsetData("counter");
153
+ }
154
+ if (isset($skipped_counter)) {
155
+ $session->unsetData("skipped_counter");
156
+ }
157
 
158
  return $this;
159
  }
app/code/community/ICEshop/Iceimport/Model/Observer.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ICEshop_Iceimport_Model_Observer
4
+ {
5
+ /**
6
+ * Our process ID.
7
+ * @var int
8
+ */
9
+ private $process_id = 'iceshop_iceimport';
10
+
11
+ /**
12
+ * @var array
13
+ */
14
+ private $indexProcess;
15
+
16
+ protected function _construct()
17
+ {
18
+ $this->_init('iceimport/observer');
19
+ }
20
+
21
+
22
+ /**
23
+ * load
24
+ * @access public
25
+ * @throws Exception
26
+ */
27
+ public function load()
28
+ {
29
+ //init logger
30
+ $DB_logger = Mage::helper('iceimport/db');
31
+ $date = date('m/d/Y H:i:s');
32
+ $DB_logger->insertLogEntry('iceimport_import_status_cron', 'Started');
33
+ $DB_logger->insertLogEntry('iceimport_import_started', $date);
34
+ $DB_logger->insertLogEntry('iceimport_import_ended', '');
35
+
36
+ //init DB data
37
+ $db_res = Mage::getSingleton('core/resource')->getConnection('core_write');
38
+ $tablePrefix = '';
39
+ $tPrefix = (array)Mage::getConfig()->getTablePrefix();
40
+ if (!empty($tPrefix)) {
41
+ $tablePrefix = $tPrefix[0];
42
+ }
43
+
44
+ //service actions
45
+ ini_set('max_execution_time', 0);
46
+ ini_set("memory_limit", "512M");
47
+ $profileId = 3;
48
+ $logFileName = 'test.log';
49
+ $recordCount = 0;
50
+
51
+ //checking locks
52
+ $this->indexProcess = new Mage_Index_Model_Process();
53
+ $this->indexProcess->setId($this->process_id);
54
+ if ($this->indexProcess->isLocked()) {
55
+ print 'Error! Another iceimport module cron process is running!';
56
+ die();
57
+ }
58
+ $this->indexProcess->lockAndBlock();
59
+
60
+ Mage::log("Import Started", null, $logFileName);
61
+
62
+ //basic action fired
63
+ $profile = Mage::getModel('dataflow/profile');
64
+ $userModel = Mage::getModel('admin/user');
65
+ $userModel->setUserId(0);
66
+ Mage::getSingleton('admin/session')->setUser($userModel);
67
+ if ($profileId) {
68
+ $profile->load($profileId);
69
+ if (!$profile->getId()) {
70
+ Mage::getSingleton('adminhtml/session')->addError('The profile that you are trying to save no longer exists');
71
+ }
72
+ }
73
+ $profile->run();
74
+ $batchModel = Mage::getSingleton('dataflow/batch');
75
+
76
+ //batch processing
77
+ if ($batchModel->getId()) {
78
+ if ($batchModel->getAdapter()) {
79
+
80
+ $batchId = $batchModel->getId();
81
+ $batchImportModel = $batchModel->getBatchImportModel();
82
+ $importIds = $batchImportModel->getIdCollection();
83
+
84
+ $batchModel = Mage::getModel('dataflow/batch')->load($batchId);
85
+ $adapter = Mage::getModel($batchModel->getAdapter());
86
+
87
+ // delete previous products id
88
+ $DB_logger->insertLogEntry('iceimport_import_status_cron', 'Running');
89
+ try {
90
+ $db_res->query("DELETE FROM {$tablePrefix}iceshop_iceimport_imported_product_ids");
91
+ } catch (Exception $e) {
92
+ $DB_logger->insertLogEntry('iceimport_import_status_cron', 'Failed');
93
+ throw new Exception($e->getMessage());
94
+ }
95
+ foreach ($importIds as $importId) {
96
+
97
+ $recordCount++;
98
+ try {
99
+ $batchImportModel->load($importId);
100
+ if (!$batchImportModel->getId()) {
101
+ $errors[] = Mage::helper('dataflow')->__('Skip undefined row');
102
+ continue;
103
+ }
104
+
105
+ $importData = $batchImportModel->getBatchData();
106
+
107
+ try {
108
+ $adapter->saveRow($importData);
109
+ } catch (Exception $e) {
110
+ $DB_logger->insertLogEntry('iceimport_import_status_cron', 'Failed');
111
+ Mage::log($e->getMessage(), null, $logFileName);
112
+ continue;
113
+ }
114
+
115
+ } catch (Exception $ex) {
116
+ if (!empty($importData['sku'])) {
117
+ Mage::log('Record# ' . $recordCount . ' - SKU = ' . $importData['sku'] . ' - Error - ' . $ex->getMessage(), null, $logFileName);
118
+ } else {
119
+ Mage::log('Record# ' . $recordCount . ' - SKU = undefined - Error - ' . $ex->getMessage(), null, $logFileName);
120
+ }
121
+ }
122
+ }
123
+
124
+ //run cleanup of old products
125
+ $adapter->deleteOldProducts($DB_logger);
126
+
127
+ //run image queue processing
128
+ $adapter->processImageQueue($logFileName);
129
+
130
+ $processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
131
+ $processes->walk('reindexAll');
132
+
133
+ foreach ($profile->getExceptions() as $e) {
134
+ Mage::log($e->getMessage(), null, $logFileName);
135
+ }
136
+ }
137
+ }
138
+ print 'Import Completed';
139
+
140
+ //drop locks
141
+ $this->indexProcess->unlock();
142
+
143
+ //extra logging
144
+ Mage::log("Import Completed", null, $logFileName);
145
+ $count_imported_products = $DB_logger->getRowsCount($tablePrefix . "iceshop_iceimport_imported_product_ids");
146
+ $DB_logger->insertLogEntry('iceimport_count_imported_products', $count_imported_products);
147
+
148
+ // clear dataflow_batch_import table
149
+ try {
150
+ $db_res->query("DELETE FROM {$tablePrefix}iceshop_iceimport_imported_product_ids");
151
+ $db_res->query("TRUNCATE {$tablePrefix}dataflow_batch_import");
152
+ } catch (Exception $e) {
153
+ $DB_logger->insertLogEntry('iceimport_import_status_cron', 'Failed');
154
+ throw new Exception($e->getMessage());
155
+ }
156
+
157
+ //extra logging
158
+ $DB_logger->insertLogEntry('iceimport_import_status_cron', 'Finished');
159
+ $date = date('m/d/Y H:i:s');
160
+ $DB_logger->insertLogEntry('iceimport_import_ended', $date);
161
+
162
+ unset($db_res, $DB_logger, $date, $profile, $profileId, $logFileName);
163
+ }
164
+
165
+ }
app/code/community/ICEshop/Iceimport/Model/System/Config/Checksystem.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ICEshop_Iceimport_Model_System_Config_Checksystem
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ 0 => base64_encode(Mage::getSingleton('adminhtml/url')->getUrl("adminhtml/iceimport/system/"))
9
+ );
10
+ }
11
+ }
app/code/community/{Iceshop → ICEshop}/Iceimport/Model/System/Config/Defaulttax.php RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Iceshop_Iceimport_Model_System_Config_Defaulttax
4
  {
5
  public function toOptionArray()
6
  {
1
  <?php
2
 
3
+ class ICEshop_Iceimport_Model_System_Config_Defaulttax
4
  {
5
  public function toOptionArray()
6
  {
app/code/community/ICEshop/Iceimport/Model/System/Config/Iceshoplink.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ICEshop_Iceimport_Model_System_Config_Iceshoplink
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ 0 => base64_encode('http://www.iceshop.nl/contact/')
9
+ );
10
+ }
11
+ }
app/code/community/{Iceshop/Iceimport/Model/System/Config/Importstock.php → ICEshop/Iceimport/Model/System/Config/Yesno.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Iceshop_Iceimport_Model_System_Config_Importstock
4
  {
5
  public function toOptionArray()
6
  {
1
  <?php
2
 
3
+ class Iceshop_Iceimport_Model_System_Config_Yesno
4
  {
5
  public function toOptionArray()
6
  {
app/code/community/ICEshop/Iceimport/controllers/Adminhtml/IceimportController.php ADDED
@@ -0,0 +1,888 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ICEshop_Iceimport_Adminhtml_IceimportController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ /**
7
+ * indexAction
8
+ *
9
+ * @return void
10
+ *
11
+ * TODO prevent hardcoded html structure
12
+ */
13
+ public function systemAction()
14
+ {
15
+ $checker = Mage::helper('iceimport/system_systemcheck')->init();
16
+ $helper = Mage::helper('iceimport');
17
+ ob_start();
18
+ ?>
19
+ <?php
20
+ //Problems Digest
21
+ $problems_digest = $checker->getExtensionProblemsDigest();
22
+ $problems = $problems_digest->getProblems();
23
+ if ($problems_digest->getCount() > 0) :
24
+ ?>
25
+ <div class="entry-edit" id="iceimport-digest">
26
+ <div class="entry-edit-head collapseable">
27
+ <a class="open section-toggler-iceimport"
28
+ href="#"><?php print $helper->__('Problems Digest'); ?></a>
29
+ </div>
30
+
31
+ <div class="fieldset">
32
+ <div class="hor-scroll">
33
+ <table class="form-list" cellspacing="0" cellpadding="0">
34
+ <?php print sprintf($helper->__('To guarantee the correct functioning of the Iceimport module you need to solve the following %s problems:'), '<strong class="requirement-failed">' . $problems_digest->getCount() . '</strong>'); ?>
35
+ <?php
36
+ $i = 1;
37
+ foreach ($problems as $problem_section_name => $problem_section) {
38
+ foreach ($problem_section as $problem_name => $problem_value) {
39
+ print '<tr>';
40
+ print '<td class="label">';
41
+ print '<label class="problem-digest">' . $helper->__('Problem') . " " . $i . ':</label>';
42
+ print '</td>';
43
+ print '<td class="value">';
44
+ if ($problem_section_name != 'iceimport_log') {
45
+ print '<span class="requirement-passed">"' . $problem_value['label'] . '"</span> ' . $helper->__('current value is') . ' <span class="requirement-failed">"' . $problem_value['current_value'] . '"</span> ' . $helper->__('and recommended value is') . ' <span class="requirement-passed">"' . (!empty($problem_value['recommended_value']) ? $problem_value['recommended_value'] : '') . '"</span>. ' . $helper->__(' Check this parameter in') . ' <a class="section-toggler-trigger-iceimport requirement-passed" data-href="#' . $problem_section_name . '-section" href="#' . $problem_section_name . '-section">' . ucfirst($problem_section_name) . '</a> ' . $helper->__('section') . '.';
46
+ } else {
47
+ print '<span class="requirement-passed">"' . $problem_value['label'] . '"</span> <span class="requirement-failed">"' . $problem_value['current_value'] . '"</span>. ' . $helper->__(' Check ') . ' <a class="section-toggler-trigger-iceimport requirement-passed" data-href="#' . $problem_section_name . '-section" href="#' . $problem_section_name . '-section">' . ucfirst($problem_section_name) . '</a> ' . $helper->__('section') . '.';
48
+ }
49
+ print '</td>';
50
+ print '</tr>';
51
+ $i++;
52
+ }
53
+ }
54
+ ?>
55
+ <tr>
56
+ <td class="label col1">
57
+ <label><?php print $helper->__("Report"); ?></label>
58
+ </td>
59
+ <td class="value col2" colspan="2">
60
+ <a href="<?php print Mage::helper("adminhtml")->getUrl("adminhtml/iceimport/report/") ?>"
61
+ target="_blank">&raquo;<?php print $helper->__('Click to generate'); ?></a>
62
+ <p class="note"><?php print $helper->__("Use this report for more info on found problems or send it to Iceshop B.V. to help analyzing the problem to speed up solution of any issues."); ?></p>
63
+ </td>
64
+ </tr>
65
+ </table>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ <?php
70
+ endif;
71
+ //Check module
72
+ $DB_checker = Mage::helper('iceimport/db');
73
+ $data_flows = $DB_checker->getRowCountByField($DB_checker->getTableName('dataflow_batch_import'), 'batch_id', false, ' ORDER BY 1 DESC LIMIT 50');
74
+ $currently_imported_products = $DB_checker->getRowsCount($DB_checker->_prefix . "iceshop_iceimport_imported_product_ids");
75
+ $table_name = $DB_checker->getTableName('dataflow_profile_history');
76
+ $last_started_by_cron = $DB_checker->getLogEntryByKey('iceimport_import_started');
77
+ $last_finished_by_cron = $DB_checker->getLogEntryByKey('iceimport_import_ended');
78
+ $import_status_cron = $DB_checker->getLogEntryByKey('iceimport_import_status_cron');
79
+ $last_deleted_products_count = $DB_checker->getLogEntryByKey('iceimport_count_delete_product');
80
+ $last_imported_products_count = $DB_checker->getLogEntryByKey('iceimport_count_imported_products');
81
+ $last_run = $DB_checker->readQuery("SELECT `performed_at` FROM {$table_name} WHERE `profile_id` = 3 ORDER BY `performed_at` DESC LIMIT 1");
82
+ ?>
83
+ <span id="iceimport_statistics-section"></span>
84
+ <div class="entry-edit">
85
+ <div class="entry-edit-head collapseable">
86
+ <a href="#" class="section-toggler-iceimport">
87
+ Iceimport Statistics
88
+ </a>
89
+ </div>
90
+
91
+ <div class="fieldset iceimport-hidden">
92
+ <div class="hor-scroll">
93
+ <table class="form-list" cellspacing="0" cellpadding="0">
94
+ <tr>
95
+ <td colspan="2" class="label">
96
+ <label class="iceimport-label-uppercase iceimport-label-bold">
97
+ <?php print $helper->__('Import status by cron'); ?>
98
+ </label>
99
+ </td>
100
+ </tr>
101
+ <tr>
102
+ <td class="label"><label><?php print $helper->__("Started last time at"); ?>:</label></td>
103
+ <td class="value">
104
+ <?php if (!empty($last_started_by_cron['log_value'])) echo $last_started_by_cron['log_value']; else print $helper->__("Never started till now"); ?>
105
+ </td>
106
+ </tr>
107
+ <tr>
108
+ <td class="label"><label><?php print $helper->__("Finished last time at"); ?>:</label></td>
109
+ <td class="value">
110
+ <?php if (!empty($last_finished_by_cron['log_value'])) echo $last_finished_by_cron['log_value']; else print $helper->__("Never started till now"); ?>
111
+ </td>
112
+ </tr>
113
+ <tr>
114
+ <td class="label"><label><?php print $helper->__("Import cron process status"); ?>:</label>
115
+ </td>
116
+ <td class="value">
117
+ <?php if (!empty($import_status_cron['log_value'])) echo $import_status_cron['log_value']; else print $helper->__("Never started till now"); ?>
118
+ </td>
119
+ </tr>
120
+ <?php if (!empty($currently_imported_products) && ($import_status_cron['log_value'] == 'Running' || $import_status_cron['log_value'] == 'Failed')) { ?>
121
+ <tr>
122
+ <td class="label"><label><?php print $helper->__("Currently products imported"); ?>
123
+ :</label></td>
124
+ <td class="value">
125
+ <?php echo $currently_imported_products . ' from ' . $data_flows[0]['row_count']; ?>
126
+ </td>
127
+ </tr>
128
+ <?php } ?>
129
+ <tr>
130
+ <td colspan="2" class="label">
131
+ <label class="iceimport-label-uppercase iceimport-label-bold">
132
+ <?php print $helper->__('Last import Statistics'); ?>
133
+ </label>
134
+ </td>
135
+ </tr>
136
+ <tr>
137
+ <td class="label"><label><?php print $helper->__("Products imported last time "); ?>
138
+ :</label></td>
139
+ <td class="value">
140
+ <?php if (!empty($last_imported_products_count['log_value'])) echo $last_imported_products_count['log_value']; else echo "0"; ?>
141
+ </td>
142
+ </tr>
143
+ <tr>
144
+ <td class="label">
145
+ <label><?php print $helper->__("Removed out of date products last time "); ?>:</label>
146
+ </td>
147
+ <td class="value">
148
+ <?php if (!empty($last_deleted_products_count['log_value'])) echo $last_deleted_products_count['log_value']; else echo "0"; ?>
149
+ </td>
150
+ </tr>
151
+ </table>
152
+ </div>
153
+ </div>
154
+ </div>
155
+
156
+ <?php
157
+ //Check module
158
+ $check_module = $checker->getModulesCollection('ICEshop_Iceimport');
159
+ $check_module = $check_module->getLastItem()->getData();
160
+ ?>
161
+ <span id="extension-section"></span>
162
+ <div class="entry-edit">
163
+ <div class="entry-edit-head collapseable">
164
+ <a href="#"
165
+ class="section-toggler-iceimport"><?php print $helper->__('Extension Diagnostic Info'); ?></a>
166
+ </div>
167
+ <div class="fieldset iceimport-hidden">
168
+ <div class="hor-scroll">
169
+ <table class="form-list" cellspacing="0" cellpadding="0">
170
+ <tr>
171
+ <td class="label"><label><?php print $helper->__('Name'); ?>:</label></td>
172
+ <td class="value"><?php echo $check_module['name']; ?></td>
173
+ </tr>
174
+ <tr>
175
+ <td class="label"><label><?php print $helper->__('Version'); ?>:</label></td>
176
+ <td class="value"><?php echo $check_module['version']; ?></td>
177
+ </tr>
178
+ <tr>
179
+ <td class="label"><label><?php print $helper->__('Code Pool'); ?>:</label></td>
180
+ <td class="value"><?php echo $check_module['code_pool']; ?></td>
181
+ </tr>
182
+ <tr>
183
+ <td class="label"><label><?php print $helper->__('Path'); ?>:</label></td>
184
+ <td class="value"><?php echo $check_module['path']; ?></td>
185
+ </tr>
186
+ <tr>
187
+ <td class="label"><label><?php print $helper->__('Path Exists'); ?>:</label></td>
188
+ <td class="value <?php echo $checker->renderRequirementValue($check_module['path_exists']); ?>">
189
+ <?php echo $checker->renderBooleanField($check_module['path_exists']); ?>
190
+ </td>
191
+ </tr>
192
+ <tr>
193
+ <td class="label"><label><?php print $helper->__('Config Exists'); ?>:</label></td>
194
+ <td class="value <?php echo $checker->renderRequirementValue($check_module['config_exists']); ?>">
195
+ <?php echo $checker->renderBooleanField($check_module['config_exists']); ?>
196
+ </td>
197
+ </tr>
198
+ <tr>
199
+ <td class="label"><label><?php print $helper->__('Dependencies'); ?>:</label></td>
200
+ <td class="value"><?php echo $check_module['dependencies']; ?></td>
201
+ </tr>
202
+ </table>
203
+ </div>
204
+ </div>
205
+ </div>
206
+
207
+ <?php
208
+ //Check rewrites
209
+ $check_rewrites = $checker->getRewriteCollection('ICEshop_Iceimport');
210
+ ?>
211
+ <span id="rewrite-section"></span>
212
+ <div class="entry-edit">
213
+ <div class="entry-edit-head collapseable">
214
+ <a href="#"
215
+ class="section-toggler-iceimport"><?php print $helper->__('Extension Rewrites Status'); ?></a>
216
+ </div>
217
+
218
+ <div class="fieldset iceimport-hidden">
219
+ <div class="hor-scroll">
220
+ <table class="form-list" cellspacing="0" cellpadding="0">
221
+ <tbody>
222
+ <?php
223
+ foreach ($check_rewrites as $rewrite) {
224
+ ?>
225
+ <tr>
226
+ <td>
227
+ <span
228
+ class="iceimport-label-bold iceimport-label-rewrite"><?php print $helper->__('Path'); ?>
229
+ :</span>
230
+ <span><?php echo $rewrite['path']; ?></span>
231
+ <br/>
232
+ <span
233
+ class="iceimport-label-bold iceimport-label-rewrite"><?php print $helper->__('Rewrite Class'); ?>
234
+ :</span>
235
+ <span><?php echo $rewrite['rewrite_class']; ?></span>
236
+ <br/>
237
+ <span
238
+ class="iceimport-label-bold iceimport-label-rewrite"><?php print $helper->__('Active Class'); ?>
239
+ :</span>
240
+ <span><?php echo $rewrite['active_class']; ?></span>
241
+ <br/>
242
+ <span
243
+ class="iceimport-label-bold iceimport-label-rewrite"><?php print $helper->__('Status'); ?>
244
+ :</span>
245
+ <span
246
+ class="<?php echo $checker->renderRequirementValue($rewrite['status']); ?>">
247
+ <?php echo $checker->renderStatusField($rewrite['status']); ?>
248
+ </span>
249
+ <br/>
250
+ <br/>
251
+ </td>
252
+ </tr>
253
+ <?php
254
+ }
255
+ ?>
256
+ </tbody>
257
+ </table>
258
+ </div>
259
+ </div>
260
+ </div>
261
+
262
+ <span id="requirement-section"></span>
263
+ <div class="entry-edit">
264
+ <div class="entry-edit-head collapseable">
265
+ <a class="section-toggler-iceimport" href="#"><?php print $helper->__('System Requirements'); ?></a>
266
+ </div>
267
+
268
+ <?php $requirements = $checker->getSystem()->getRequirements()->getData(); ?>
269
+ <div class="fieldset iceimport-hidden">
270
+ <div class="hor-scroll">
271
+ <table class="form-list firegento-settings-table" cellspacing="0" cellpadding="0">
272
+ <thead>
273
+ <tr>
274
+ <th class="label col1"><?php print $helper->__('Requirement'); ?></th>
275
+ <th class="value col2"><?php print $helper->__('Current Value'); ?></th>
276
+ <th class="value col3"><?php print $helper->__('Recommended Value'); ?></th>
277
+ </tr>
278
+ </thead>
279
+ <tbody>
280
+ <?php foreach ($requirements as $requirement): ?>
281
+ <tr>
282
+ <td class="label col1">
283
+ <label><span
284
+ class="iceimport-pad-label"><?php echo $requirement['label']; ?></span><?php print $checker->renderAdvice($requirement); ?>
285
+ :</label>
286
+ </td>
287
+ <td class="value col2 <?php echo $checker->renderRequirementValue($requirement['result']) ?>">
288
+ <?php echo $requirement['current_value'] ?>
289
+ </td>
290
+ <td class="value col3"><?php echo $requirement['recommended_value'] ?></td>
291
+ </tr>
292
+ <?php endforeach; ?>
293
+ <tr>
294
+ <td class="label col1"><label>phpinfo()</label>
295
+ </td>
296
+ <td class="value col2" colspan="2">
297
+ <a href="<?php print Mage::helper("adminhtml")->getUrl("adminhtml/iceimport/phpinfo/") ?>"
298
+ target="_blank">&raquo;<?php print $helper->__('More info'); ?></a>
299
+ </td>
300
+ </tr>
301
+ <?php ?>
302
+ </tbody>
303
+ </table>
304
+ </div>
305
+ </div>
306
+ </div>
307
+
308
+ <span id="magento-section"></span>
309
+ <div class="entry-edit">
310
+ <div class="entry-edit-head collapseable">
311
+ <a href="#" class="section-toggler-iceimport">Magento Info</a>
312
+ </div>
313
+
314
+ <div class="fieldset iceimport-hidden">
315
+ <div class="hor-scroll">
316
+ <table class="form-list" cellspacing="0" cellpadding="0">
317
+ <tr>
318
+ <td class="label"><label>Edition:</label></td>
319
+ <td class="value"><?php echo $checker->getSystem()->getMagento()->getEdition() ?></td>
320
+ </tr>
321
+ <tr>
322
+ <td class="label"><label>Version:</label></td>
323
+ <td class="value"><?php echo $checker->getSystem()->getMagento()->getVersion() ?></td>
324
+ </tr>
325
+ <tr>
326
+ <td class="label"><label>Developer Mode:</label></td>
327
+ <td class="value"><?php echo $checker->renderBooleanField($checker->getSystem()->getMagento()->getDeveloperMode()) ?></td>
328
+ </tr>
329
+ <tr>
330
+ <td class="label"><label>Add Secret Key to URLs:</label></td>
331
+ <td class="value"><?php echo $checker->renderBooleanField($checker->getSystem()->getMagento()->getSecretKey()) ?></td>
332
+ </tr>
333
+ <tr>
334
+ <td class="label"><label>Use Flat Catalog Category:</label></td>
335
+ <td class="value"><?php echo $checker->renderBooleanField($checker->getSystem()->getMagento()->getFlatCatalogCategory()) ?></td>
336
+ </tr>
337
+ <tr>
338
+ <td class="label"><label>Use Flat Catalog Product:</label></td>
339
+ <td class="value"><?php echo $checker->renderBooleanField($checker->getSystem()->getMagento()->getFlatCatalogProduct()) ?></td>
340
+ </tr>
341
+ <tr>
342
+ <td class="label"><label>Cache status:</label></td>
343
+ <td class="value">
344
+ <?php echo $checker->getSystem()->getMagento()->getCacheStatus() ?><br/>
345
+ <a href="<?php echo Mage::helper("adminhtml")->getUrl('adminhtml/cache/') ?>">&raquo;Cache
346
+ Management</a>
347
+ </td>
348
+ </tr>
349
+ <tr>
350
+ <td class="label"><label>Index status:</label></td>
351
+ <td class="value">
352
+ <?php echo $checker->getSystem()->getMagento()->getIndexStatus() ?><br/>
353
+ <a href="<?php echo Mage::helper("adminhtml")->getUrl('adminhtml/process/list') ?>">&raquo;Index
354
+ Management</a>
355
+ </td>
356
+ </tr>
357
+ </table>
358
+ </div>
359
+ </div>
360
+ </div>
361
+
362
+ <span id="api-section"></span>
363
+ <div class="entry-edit">
364
+ <div class="entry-edit-head collapseable">
365
+ <a href="#" class="section-toggler-iceimport">Magento Core API Info</a>
366
+ </div>
367
+
368
+ <div class="fieldset iceimport-hidden">
369
+ <div class="hor-scroll">
370
+ <table class="form-list" cellspacing="0" cellpadding="0">
371
+ <tr>
372
+ <td class="label"><label><?php print $helper->__('Default Response Charset'); ?>:</label>
373
+ </td>
374
+ <td class="value"><?php echo $checker->getSystem()->getMagentoApi()->getCharset() ?></td>
375
+ </tr>
376
+ <tr>
377
+ <?php $magento_api_session_timeout = $checker->getSystem()->getMagentoApi()->getSessionTimeout() ?>
378
+ <td class="label"><label><?php print $magento_api_session_timeout['label']; ?>:</label></td>
379
+ <td class="value <?php echo $checker->renderRequirementValue($magento_api_session_timeout['result']) ?>"><?php echo $magento_api_session_timeout['current_value'] ?></td>
380
+ </tr>
381
+ <tr>
382
+ <td class="label"><label><?php print $helper->__('WS-I Compliance'); ?>:</label></td>
383
+ <td class="value"><?php echo $checker->renderBooleanField($checker->getSystem()->getMagentoApi()->getComplianceWsi()) ?></td>
384
+ </tr>
385
+ <tr>
386
+ <td class="label"><label><?php print $helper->__('WSDL Cache'); ?>:</label></td>
387
+ <td class="value"><?php echo $checker->renderBooleanField($checker->getSystem()->getMagentoApi()->getWsdlCacheEnabled()) ?></td>
388
+ </tr>
389
+ </table>
390
+ </div>
391
+ </div>
392
+ </div>
393
+
394
+ <span id="php-section"></span>
395
+ <div class="entry-edit">
396
+ <div class="entry-edit-head collapseable">
397
+ <a href="#" class="section-toggler-iceimport">PHP Info</a>
398
+ </div>
399
+
400
+ <div class="fieldset iceimport-hidden">
401
+ <div class="hor-scroll">
402
+ <table class="form-list" cellspacing="0" cellpadding="0">
403
+ <tr>
404
+ <td class="label"><label><?php print $helper->__('Version'); ?>:</label></td>
405
+ <td class="value"><?php echo $checker->getSystem()->getPhp()->getVersion() ?></td>
406
+ </tr>
407
+ <tr>
408
+ <td class="label"><label><?php print $helper->__('Server API'); ?>:</label></td>
409
+ <td class="value"><?php echo $checker->getSystem()->getPhp()->getServerApi() ?></td>
410
+ </tr>
411
+ <tr>
412
+ <td class="label"><label><?php print $helper->__('Memory Limit'); ?>:</label></td>
413
+ <td class="value"><?php echo $checker->getSystem()->getPhp()->getMemoryLimit() ?></td>
414
+ </tr>
415
+ <tr>
416
+ <td class="label"><label><?php print $helper->__('Max. Execution Time'); ?>:</label></td>
417
+ <td class="value"><?php echo $checker->getSystem()->getPhp()->getMaxExecutionTime() ?></td>
418
+ </tr>
419
+ </table>
420
+ </div>
421
+ </div>
422
+ </div>
423
+
424
+ <span id="mysql-section"></span>
425
+ <div class="entry-edit">
426
+ <div class="entry-edit-head collapseable">
427
+ <a href="#" class="section-toggler-iceimport">MySQL Info</a>
428
+ </div>
429
+
430
+ <div class="fieldset iceimport-hidden">
431
+ <div class="hor-scroll">
432
+ <table class="form-list" cellspacing="0" cellpadding="0">
433
+ <thead>
434
+ <tr>
435
+ <th class="label col1"><?php print $helper->__('Requirement'); ?></th>
436
+ <th class="value col2"><?php print $helper->__('Current Value'); ?></th>
437
+ <th class="value col3"><?php print $helper->__('Recommended Value'); ?></th>
438
+ </tr>
439
+ </thead>
440
+ <tbody>
441
+ <tr>
442
+ <td class="label"><label><?php print $helper->__('Version'); ?>:</label></td>
443
+ <td class="value"><?php echo $checker->getSystem()->getMysql()->getVersion() ?></td>
444
+ </tr>
445
+ <tr>
446
+ <td class="label"><label><?php print $helper->__('Server API'); ?>:</label></td>
447
+ <td class="value"><?php echo $checker->getSystem()->getMysql()->getServerApi() ?></td>
448
+ </tr>
449
+ <tr>
450
+ <td class="label"><label><?php print $helper->__('Database Name'); ?>:</label></td>
451
+ <td class="value"><?php echo $checker->getSystem()->getMysql()->getDatabaseName() ?></td>
452
+ </tr>
453
+ <tr>
454
+ <td class="label"><label><?php print $helper->__('Database Tables'); ?>:</label></td>
455
+ <td class="value"><?php echo $checker->getSystem()->getMysql()->getDatabaseTables() ?></td>
456
+ </tr>
457
+ <tr>
458
+ <td class="label"><label><?php print $helper->__('Database Table Prefix'); ?>:</label></td>
459
+ <td class="value"><?php echo $checker->getSystem()->getMysql()->getTablePrefix() ?></td>
460
+ </tr>
461
+ <tr>
462
+ <td class="label"><label><?php print $helper->__('Connection Timeout'); ?>:</label></td>
463
+ <td class="value"><?php echo $checker->getSystem()->getMysql()->getConnectionTimeout() ?></td>
464
+ </tr>
465
+ <tr>
466
+ <td class="label"><label><?php print $helper->__('Wait Timeout'); ?>:</label></td>
467
+ <td class="value"><?php echo $checker->getSystem()->getMysql()->getWaitTimeout() ?></td>
468
+ </tr>
469
+ <tr>
470
+ <?php $thread_stack = $checker->getSystem()->getMysql()->getThreadStack(); ?>
471
+ <td class="label col1">
472
+ <label><?php print $thread_stack['label']; ?><?php print $checker->renderAdvice($thread_stack); ?>
473
+ :</label></td>
474
+ <td class="value col2 <?php echo $checker->renderRequirementValue($thread_stack['result']) ?>"><?php echo $thread_stack['current_value'] ?></td>
475
+ <td class="value col3"><?php echo $thread_stack['recommended_value'] ?></td>
476
+ </tr>
477
+ <tr>
478
+ <?php $max_allowed_packet = $checker->getSystem()->getMysql()->getMaxAllowedPacket(); ?>
479
+ <td class="label col1">
480
+ <label><?php print $max_allowed_packet['label']; ?><?php print $checker->renderAdvice($max_allowed_packet); ?>
481
+ :</label>
482
+ </td>
483
+ <td class="value col2 <?php echo $checker->renderRequirementValue($max_allowed_packet['result']) ?>">
484
+ <?php echo $max_allowed_packet['current_value'] ?>
485
+ </td>
486
+ <td class="value col3"><?php echo $max_allowed_packet['recommended_value'] ?></td>
487
+ </tr>
488
+ </tbody>
489
+ </table>
490
+ </div>
491
+ </div>
492
+ </div>
493
+
494
+ <span id="mysql_conf-section"></span>
495
+ <div class="entry-edit">
496
+ <div class="entry-edit-head collapseable">
497
+ <a href="#" class="section-toggler-iceimport"><?php print $helper->__('MySQL Configuration'); ?></a>
498
+ </div>
499
+
500
+ <div class="fieldset iceimport-hidden">
501
+ <div class="hor-scroll">
502
+ <table class="form-list" cellspacing="0" cellpadding="0">
503
+ <?php
504
+ $mysql_vars = $checker->getSystem()->getMysqlVars()->getData();
505
+ foreach ($mysql_vars as $mysql_var_key => $mysql_var_value) {
506
+ print '<tr>';
507
+ print '<td><strong>' . $mysql_var_key . ':</strong></td>';
508
+ print '<td class="value">' . $mysql_var_value . '</td>';
509
+ print '</tr>';
510
+ }
511
+ ?>
512
+ </table>
513
+ </div>
514
+ </div>
515
+ </div>
516
+
517
+ <span id="server-section"></span>
518
+ <div class="entry-edit">
519
+ <div class="entry-edit-head collapseable">
520
+ <a href="#" class="section-toggler-iceimport"><?php print $helper->__('Server Info'); ?></a>
521
+ </div>
522
+
523
+ <div class="fieldset iceimport-hidden">
524
+ <div class="hor-scroll">
525
+ <table class="form-list" cellspacing="0" cellpadding="0">
526
+ <tr>
527
+ <td class="label"><label><?php print $helper->__('Info'); ?>:</label></td>
528
+ <td class="value"><?php echo $checker->getSystem()->getServer()->getInfo() ?></td>
529
+ </tr>
530
+ <tr>
531
+ <td class="label"><label><?php print $helper->__('Domain'); ?>:</label></td>
532
+ <td class="value"><?php echo $checker->getSystem()->getServer()->getDomain() ?></td>
533
+ </tr>
534
+ <tr>
535
+ <td class="label"><label><?php print $helper->__('Server IP'); ?>:</label></td>
536
+ <td class="value"><?php echo $checker->getSystem()->getServer()->getIp() ?></td>
537
+ </tr>
538
+ <tr>
539
+ <td class="label"><label><?php print $helper->__('Server Directory'); ?>:</label></td>
540
+ <td class="value"><?php echo $checker->getSystem()->getServer()->getDir() ?></td>
541
+ </tr>
542
+ </table>
543
+ </div>
544
+ </div>
545
+ </div>
546
+
547
+ <?php
548
+ $iceimport_log = $DB_checker->getLogByType('info', 'neq', 500);
549
+ ?>
550
+ <span id="iceimport_log-section"></span>
551
+ <div class="entry-edit">
552
+ <div class="entry-edit-head collapseable">
553
+ <a href="#" class="section-toggler-iceimport">Iceimport Log</a>
554
+ </div>
555
+
556
+ <div class="fieldset iceimport-hidden">
557
+ <div class="hor-scroll">
558
+ <table class="form-list" cellspacing="0" cellpadding="0">
559
+ <?php
560
+ if (!empty($iceimport_log) && count($iceimport_log) > 0) {
561
+ print '<thead>';
562
+ print '<tr>';
563
+ print "<th class=\"label col1\">{$helper->__('Time')}</th>";
564
+ print "<th class=\"value col2\">{$helper->__('Value')}</th>";
565
+ print '</tr>';
566
+ print '</thead>';
567
+ print '<tbody>';
568
+ foreach ($iceimport_log as $iceimport_log_item) {
569
+ print '<tr>';
570
+ print "<td class=\"label\"><label>{$iceimport_log_item['timecol']}</label></td>";
571
+ print "<td class=\"value full-width\"><label>{$iceimport_log_item['log_value']}</label></td>";
572
+ print '</tr>';
573
+ }
574
+ print '</tbody>';
575
+ } else {
576
+ print '<tbody>';
577
+ print '<tr>';
578
+ print "<td class=\"label\"><label>{$helper->__('Still empty')}</label></td>";
579
+ print '</tr>';
580
+ print '</tbody>';
581
+ }
582
+ ?>
583
+ </table>
584
+ </div>
585
+ </div>
586
+ </div>
587
+ <style>
588
+ .requirement-passed {
589
+ color: green;
590
+ }
591
+
592
+ .requirement-failed {
593
+ color: red;
594
+ }
595
+ </style>
596
+ <?php
597
+ $system_check_content = ob_get_contents();
598
+ ob_end_clean();
599
+
600
+ $reset_button_html = $helper->getButtonHtml(array(
601
+ 'id' => 'iceimport_check_system_refresh',
602
+ 'element_name' => 'iceimport_check_system_refresh',
603
+ 'title' => Mage::helper('catalog')->__('Refresh'),
604
+ 'type' => 'reset',
605
+ 'class' => 'save',
606
+ 'label' => Mage::helper('catalog')->__('Refresh'),
607
+ 'OnClick' => 'refreshIceimportSystemCheck(\'' . base64_encode(Mage::helper("adminhtml")->getUrl("adminhtml/iceimport/system/")) . '\');'
608
+ ));
609
+
610
+ $jsonData = json_encode(array('structure' => $system_check_content, 'refresh_btn' => $reset_button_html));
611
+ $this->getResponse()->setHeader('Content-type', 'application/json');
612
+ $this->getResponse()->setBody($jsonData);
613
+ }
614
+
615
+ public function phpinfoAction()
616
+ {
617
+ phpinfo(-1);
618
+ }
619
+
620
+ public function reportAction()
621
+ {
622
+ header("Content-Type: text/plain; charset=utf-8");
623
+ $report_filename = 'iceimport-report' . (string)Mage::getConfig()->getNode()->modules->ICEshop_Iceimport->version . '.txt';
624
+ header("Content-disposition: attachment; filename={$report_filename}");
625
+ header("Content-Transfer-Encoding: binary");
626
+ header("Pragma: no-cache");
627
+ header("Expires: 0");
628
+
629
+ //TODO add report content
630
+ $checker = Mage::helper('iceimport/system_systemcheck')->init();
631
+ $helper = Mage::helper('iceimport');
632
+
633
+ //========================================
634
+ //Problems Digest
635
+ //========================================
636
+ $problems_digest = $checker->getExtensionProblemsDigest();
637
+ if ($problems_digest->getCount() != 0) {
638
+ $problems = $problems_digest->getProblems();
639
+ print str_pad('', 100, '=') . "\n";
640
+ print 'Problems Digest' . "\n";
641
+ print str_pad('', 100, '=') . "\n";
642
+ foreach ($problems as $problem_name => $problem_value) {
643
+ print $problem_name . "\n";
644
+ print_r($problem_value);
645
+ }
646
+ print str_pad('', 100, '=') . "\n";
647
+ print "\n";
648
+ }
649
+ //========================================
650
+
651
+ //========================================
652
+ //Check module
653
+ //========================================
654
+ $check_module = $checker->getModulesCollection('ICEshop_Iceimport');
655
+ $check_module = $check_module->getLastItem()->getData();
656
+ print str_pad('', 100, '=') . "\n";
657
+ print 'Extension Diagnostic Info' . "\n";
658
+ print str_pad('', 100, '=') . "\n";
659
+ print str_pad('Name', 50) . ':' . str_pad('', 5);
660
+ print $check_module['name'] . "\n";
661
+
662
+ print str_pad('Version', 50) . ':' . str_pad('', 5);
663
+ print $check_module['version'] . "\n";
664
+
665
+ print str_pad('Code Pool', 50) . ':' . str_pad('', 5);
666
+ print $check_module['code_pool'] . "\n";
667
+
668
+ print str_pad('Path', 50) . ':' . str_pad('', 5);
669
+ print $check_module['path'] . "\n";
670
+
671
+ print str_pad('Path Exists', 50) . ':' . str_pad('', 5);
672
+ print $checker->renderBooleanField($check_module['path_exists']) . "\n";
673
+
674
+ print str_pad('Config Exists', 50) . ':' . str_pad('', 5);
675
+ print $checker->renderBooleanField($check_module['config_exists']) . "\n";
676
+
677
+ print str_pad('Dependencies', 50) . ':' . str_pad('', 5);
678
+ print $check_module['dependencies'] . "\n";
679
+ print str_pad('', 100, '=') . "\n";
680
+ print "\n";
681
+ //========================================
682
+
683
+
684
+ //========================================
685
+ //Check rewrites
686
+ //========================================
687
+ $check_rewrites = $checker->getRewriteCollection('ICEshop_Iceimport');
688
+ print str_pad('', 100, '=') . "\n";
689
+ print 'Extension Rewrites Status' . "\n";
690
+ print str_pad('', 100, '=') . "\n";
691
+ foreach ($check_rewrites as $rewrite) {
692
+ print str_pad('Path', 50) . ':' . str_pad('', 5);
693
+ print $rewrite['path'] . "\n";
694
+
695
+ print str_pad('Rewrite Class', 50) . ':' . str_pad('', 5);
696
+ print $rewrite['rewrite_class'] . "\n";
697
+
698
+ print str_pad('Active Class', 50) . ':' . str_pad('', 5);
699
+ print $rewrite['active_class'] . "\n";
700
+
701
+ print str_pad('Status', 50) . ':' . str_pad('', 5);
702
+ print $checker->renderStatusField($rewrite['status']) . "\n";
703
+ }
704
+ print str_pad('', 100, '=') . "\n";
705
+ print "\n";
706
+ //========================================
707
+
708
+ //========================================
709
+ //System Requirements
710
+ //========================================
711
+ $requirements = $checker->getSystem()->getRequirements()->getData();
712
+ print str_pad('', 100, '=') . "\n";
713
+ print 'System Requirements' . "\n";
714
+ print str_pad('', 100, '=') . "\n";
715
+ foreach ($requirements as $requirement) {
716
+ print str_pad($requirement['label'], 50) . ':' . str_pad('', 5);
717
+ print str_pad($requirement['recommended_value'], 30);
718
+ print $requirement['current_value'] . "\n";
719
+ }
720
+ print str_pad('', 100, '=') . "\n";
721
+ print "\n";
722
+ //========================================
723
+
724
+ //========================================
725
+ //Magento Info
726
+ //========================================
727
+ print str_pad('', 100, '=') . "\n";
728
+ print 'Magento Info' . "\n";
729
+ print str_pad('', 100, '=') . "\n";
730
+ print str_pad('Edition', 50) . ':' . str_pad('', 5);
731
+ print $checker->getSystem()->getMagento()->getEdition() . "\n";
732
+
733
+ print str_pad('Version', 50) . ':' . str_pad('', 5);
734
+ print $checker->getSystem()->getMagento()->getVersion() . "\n";
735
+
736
+ print str_pad('Developer Mode', 50) . ':' . str_pad('', 5);
737
+ print $checker->renderBooleanField($checker->getSystem()->getMagento()->getDeveloperMode()) . "\n";
738
+
739
+ print str_pad('Add Secret Key to URLs', 50) . ':' . str_pad('', 5);
740
+ print print $checker->renderBooleanField($checker->getSystem()->getMagento()->getSecretKey()) . "\n";
741
+
742
+ print str_pad('Use Flat Catalog Category', 50) . ':' . str_pad('', 5);
743
+ print $checker->renderBooleanField($checker->getSystem()->getMagento()->getFlatCatalogCategory()) . "\n";
744
+
745
+ print str_pad('Use Flat Catalog Product', 50) . ':' . str_pad('', 5);
746
+ print print $checker->renderBooleanField($checker->getSystem()->getMagento()->getFlatCatalogProduct()) . "\n";
747
+ print str_pad('', 100, '=') . "\n";
748
+ print "\n";
749
+ //========================================
750
+
751
+ //========================================
752
+ //Magento Core API Info
753
+ //========================================
754
+ print str_pad('', 100, '=') . "\n";
755
+ print 'Magento Core API Info' . "\n";
756
+ print str_pad('', 100, '=') . "\n";
757
+ print str_pad('Default Response Charset', 50) . ':' . str_pad('', 5);
758
+ print print $checker->getSystem()->getMagentoApi()->getCharset() . "\n";
759
+
760
+ print str_pad('Client Session Timeout (sec.)', 50) . ':' . str_pad('', 5);
761
+ $magento_api_session_timeout = $checker->getSystem()->getMagentoApi()->getSessionTimeout();
762
+ print $magento_api_session_timeout['current_value'] . "\n";
763
+
764
+ print str_pad('WS-I Compliance', 50) . ':' . str_pad('', 5);
765
+ print $checker->renderBooleanField($checker->getSystem()->getMagentoApi()->getComplianceWsi()) . "\n";
766
+
767
+ print str_pad('WSDL Cache', 50) . ':' . str_pad('', 5);
768
+ print $checker->renderBooleanField($checker->getSystem()->getMagentoApi()->getWsdlCacheEnabled()) . "\n";
769
+ print str_pad('', 100, '=') . "\n";
770
+ print "\n";
771
+ //========================================
772
+
773
+ //========================================
774
+ //PHP Info
775
+ //========================================
776
+ print str_pad('', 100, '=') . "\n";
777
+ print 'PHP Info' . "\n";
778
+ print str_pad('', 100, '=') . "\n";
779
+ print str_pad('Version', 50) . ':' . str_pad('', 5);
780
+ print $checker->getSystem()->getPhp()->getVersion() . "\n";
781
+
782
+ print str_pad('Server API', 50) . ':' . str_pad('', 5);
783
+ print $checker->getSystem()->getPhp()->getServerApi() . "\n";
784
+
785
+ print str_pad('Memory Limit', 50) . ':' . str_pad('', 5);
786
+ print $checker->getSystem()->getPhp()->getMemoryLimit() . "\n";
787
+
788
+ print str_pad('Max. Execution Time', 50) . ':' . str_pad('', 5);
789
+ print $checker->getSystem()->getPhp()->getMaxExecutionTime() . "\n";
790
+ print str_pad('', 100, '=') . "\n";
791
+ print "\n";
792
+ //========================================
793
+
794
+ //========================================
795
+ //MySQL Info
796
+ //========================================
797
+ print str_pad('', 100, '=') . "\n";
798
+ print 'MySQL Info' . "\n";
799
+ print str_pad('', 100, '=') . "\n";
800
+ print str_pad('Version', 50) . ':' . str_pad('', 5);
801
+ print $checker->getSystem()->getMysql()->getVersion() . "\n";
802
+
803
+ print str_pad('Server API', 50) . ':' . str_pad('', 5);
804
+ print $checker->getSystem()->getMysql()->getServerApi() . "\n";
805
+
806
+ print str_pad('Database Name', 50) . ':' . str_pad('', 5);
807
+ print $checker->getSystem()->getMysql()->getDatabaseName() . "\n";
808
+
809
+ print str_pad('Database Tables', 50) . ':' . str_pad('', 5);
810
+ print $checker->getSystem()->getMysql()->getDatabaseTables() . "\n";
811
+
812
+ print str_pad('Database Table Prefix', 50) . ':' . str_pad('', 5);
813
+ print $checker->getSystem()->getMysql()->getTablePrefix() . "\n";
814
+
815
+ print str_pad('Connection Timeout', 50) . ':' . str_pad('', 5);
816
+ print $checker->getSystem()->getMysql()->getConnectionTimeout() . "\n";
817
+
818
+ print str_pad('Wait Timeout', 50) . ':' . str_pad('', 5);
819
+ print $checker->getSystem()->getMysql()->getWaitTimeout() . "\n";
820
+
821
+ print str_pad('Thread stack', 50) . ':' . str_pad('', 5);
822
+ $thread_stack = $checker->getSystem()->getMysql()->getThreadStack();
823
+ print $thread_stack['current_value'] . "\n";
824
+
825
+ print str_pad('Max Allowed Packet', 50) . ':' . str_pad('', 5);
826
+ $max_allowed_packet = $checker->getSystem()->getMysql()->getMaxAllowedPacket();
827
+ print $max_allowed_packet['current_value'] . "\n";
828
+ print str_pad('', 100, '=') . "\n";
829
+ print "\n";
830
+ //========================================
831
+
832
+ //========================================
833
+ //Server Info
834
+ //========================================
835
+ print str_pad('', 100, '=') . "\n";
836
+ print 'Server Info' . "\n";
837
+ print str_pad('', 100, '=') . "\n";
838
+ print str_pad('Info', 50) . ':' . str_pad('', 5);
839
+ print $checker->getSystem()->getServer()->getInfo() . "\n";
840
+
841
+ print str_pad('Domain', 50) . ':' . str_pad('', 5);
842
+ print $checker->getSystem()->getServer()->getDomain() . "\n";
843
+
844
+ print str_pad('Server IP', 50) . ':' . str_pad('', 5);
845
+ print $checker->getSystem()->getServer()->getIp() . "\n";
846
+
847
+ print str_pad('Server Directory', 50) . ':' . str_pad('', 5);
848
+ print $checker->getSystem()->getServer()->getDir() . "\n";
849
+ print str_pad('', 100, '=') . "\n";
850
+ //========================================
851
+
852
+
853
+ //========================================
854
+ //phpinfo() full overview
855
+ //========================================
856
+ $formatter = Mage::helper('iceimport/format');
857
+ ob_start();
858
+ phpinfo();
859
+ $phpinfo = ob_get_contents();
860
+ ob_end_clean();
861
+
862
+ try {
863
+ print str_pad('', 100, '=') . "\n";
864
+ print 'phpinfo() full overview' . "\n";
865
+ print str_pad('', 100, '=') . "\n";
866
+ print $formatter->convert_html_to_text($phpinfo) . "\n";
867
+ print str_pad('', 100, '=') . "\n";
868
+ print "\n";
869
+ } catch (Exception $e) {
870
+ }
871
+ //========================================
872
+
873
+
874
+ //========================================
875
+ //MySQL Configuration
876
+ //========================================
877
+ print str_pad('', 100, '=') . "\n";
878
+ print 'MySQL Vars' . "\n";
879
+ print str_pad('', 100, '=') . "\n";
880
+ $mysql_vars = $checker->getSystem()->getMysqlVars()->getData();
881
+ foreach ($mysql_vars as $mysql_var_key => $mysql_var_value) {
882
+ print str_pad($mysql_var_key, 50) . ':' . str_pad('', 5);
883
+ print $mysql_var_value . "\n";
884
+ }
885
+ print str_pad('', 100, '=') . "\n";
886
+ //========================================
887
+ }
888
+ }
app/code/community/ICEshop/Iceimport/etc/adminhtml.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <importprod_root>
12
+ <title>iceimport Settings</title>
13
+ <sort_order>0</sort_order>
14
+ </importprod_root>
15
+ <iceimport_information>
16
+ <title>Iceimport Information</title>
17
+ <sort_order>30</sort_order>
18
+ </iceimport_information>
19
+ <iceshop_about>
20
+ <title>Iceshop Info</title>
21
+ <sort_order>40</sort_order>
22
+ </iceshop_about>
23
+ </children>
24
+ </config>
25
+ </children>
26
+ </system>
27
+ </children>
28
+ </admin>
29
+ </resources>
30
+ </acl>
31
+ </config>
app/code/community/{Iceshop → ICEshop}/Iceimport/etc/config.xml RENAMED
@@ -1,54 +1,75 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <Iceshop_Iceimport>
5
- <version>1.5.0</version>
6
- </Iceshop_Iceimport>
7
  </modules>
 
 
 
 
 
 
 
 
 
 
 
8
  <global>
9
  <events>
10
  <controller_action_predispatch_adminhtml_profile_batchfinish>
11
  <observers>
12
- <Iceshop_Iceimport>
13
- <class>Iceshop_Iceimport/Observer</class>
14
  <method>sortCategory</method>
15
- </Iceshop_Iceimport>
16
  </observers>
17
  </controller_action_predispatch_adminhtml_profile_batchfinish>
18
  <controller_action_postdispatch_adminhtml_profile_batchFinish>
19
  <observers>
20
- <Iceshop_Iceimport>
21
- <class>Iceshop_Iceimport/Observer</class>
22
  <method>sortCategory</method>
23
- </Iceshop_Iceimport>
24
  </observers>
25
  </controller_action_postdispatch_adminhtml_profile_batchFinish>
26
  </events>
 
 
 
 
 
27
  <models>
28
  <catalog>
29
  <rewrite>
30
  <!-- Override Mage_Catalog_Model_Convert_Adapter_Product -->
31
- <convert_adapter_product>Iceshop_Iceimport_Model_Convert_Adapter_Product</convert_adapter_product>
32
  </rewrite>
33
  </catalog>
34
  <dataflow>
35
  <rewrite>
36
  <!-- Override Mage_Catalog_Model_Convert_Adapter_Product -->
37
- <batch_import>Iceshop_Iceimport_Model_Dataflow_Batch_Import</batch_import>
38
  </rewrite>
39
  <rewrite>
40
  <!-- Override Mage_Catalog_Model_Convert_Adapter_Product -->
41
- <convert_parser_csv>Iceshop_Iceimport_Model_Dataflow_Convert_Parser_Csv</convert_parser_csv>
42
  </rewrite>
43
  </dataflow>
44
  <iceimport>
45
- <class>Iceshop_Iceimport_Model</class>
46
  </iceimport>
47
  </models>
 
 
 
 
 
48
  <resources>
49
  <iceimport_setup>
50
  <setup>
51
- <module>Iceshop_Iceimport</module>
52
  <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
53
  </setup>
54
  <connection>
@@ -68,42 +89,32 @@
68
  </resources>
69
  </global>
70
  <adminhtml>
71
- <acl>
72
- <resources>
73
- <admin>
74
- <children>
75
- <system>
76
- <children>
77
- <config>
78
- <children>
79
- <importprod_root>
80
- <title>IceImport module</title>
81
- </importprod_root>
82
- </children>
83
- </config>
84
- </children>
85
- </system>
86
- </children>
87
- </admin>
88
- </resources>
89
- </acl>
90
  </adminhtml>
91
  <crontab>
92
  <jobs>
93
- <iceimport>
94
  <schedule>
95
- <cron_expr>0 0 * * 0</cron_expr>
96
  </schedule>
97
  <run>
98
  <model>iceimport/observer::load</model>
99
  </run>
100
- </iceimport>
101
  </jobs>
102
  </crontab>
103
  <default>
104
  <importprod_root>
105
  <importprod>
106
  <category_active>1</category_active>
 
 
107
  <import_product_ean>1</import_product_ean>
108
  <import_product_mpn>1</import_product_mpn>
109
  <import_product_brand>1</import_product_brand>
@@ -116,6 +127,15 @@
116
  <import_stock>1</import_stock>
117
  <import_delivery_eta>1</import_delivery_eta>
118
  <import_images>1</import_images>
 
 
 
 
 
 
 
 
 
119
  </importprod>
120
  </importprod_root>
121
  </default>
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+ <ICEshop_Iceimport>
5
+ <version>1.7.5</version>
6
+ </ICEshop_Iceimport>
7
  </modules>
8
+ <admin>
9
+ <routers>
10
+ <adminhtml>
11
+ <args>
12
+ <modules>
13
+ <iceimport before="Mage_Adminhtml">ICEshop_Iceimport_Adminhtml</iceimport>
14
+ </modules>
15
+ </args>
16
+ </adminhtml>
17
+ </routers>
18
+ </admin>
19
  <global>
20
  <events>
21
  <controller_action_predispatch_adminhtml_profile_batchfinish>
22
  <observers>
23
+ <ICEshop_Iceimport>
24
+ <class>ICEshop_Iceimport/Observer</class>
25
  <method>sortCategory</method>
26
+ </ICEshop_Iceimport>
27
  </observers>
28
  </controller_action_predispatch_adminhtml_profile_batchfinish>
29
  <controller_action_postdispatch_adminhtml_profile_batchFinish>
30
  <observers>
31
+ <ICEshop_Iceimport>
32
+ <class>ICEshop_Iceimport/Observer</class>
33
  <method>sortCategory</method>
34
+ </ICEshop_Iceimport>
35
  </observers>
36
  </controller_action_postdispatch_adminhtml_profile_batchFinish>
37
  </events>
38
+ <blocks>
39
+ <iceimport>
40
+ <class>ICEshop_Iceimport_Block</class>
41
+ </iceimport>
42
+ </blocks>
43
  <models>
44
  <catalog>
45
  <rewrite>
46
  <!-- Override Mage_Catalog_Model_Convert_Adapter_Product -->
47
+ <convert_adapter_product>ICEshop_Iceimport_Model_Convert_Adapter_Product</convert_adapter_product>
48
  </rewrite>
49
  </catalog>
50
  <dataflow>
51
  <rewrite>
52
  <!-- Override Mage_Catalog_Model_Convert_Adapter_Product -->
53
+ <batch_import>ICEshop_Iceimport_Model_Dataflow_Batch_Import</batch_import>
54
  </rewrite>
55
  <rewrite>
56
  <!-- Override Mage_Catalog_Model_Convert_Adapter_Product -->
57
+ <convert_parser_csv>ICEshop_Iceimport_Model_Dataflow_Convert_Parser_Csv</convert_parser_csv>
58
  </rewrite>
59
  </dataflow>
60
  <iceimport>
61
+ <class>ICEshop_Iceimport_Model</class>
62
  </iceimport>
63
  </models>
64
+ <helpers>
65
+ <iceimport>
66
+ <class>ICEshop_Iceimport_Helper</class>
67
+ </iceimport>
68
+ </helpers>
69
  <resources>
70
  <iceimport_setup>
71
  <setup>
72
+ <module>ICEshop_Iceimport</module>
73
  <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
74
  </setup>
75
  <connection>
89
  </resources>
90
  </global>
91
  <adminhtml>
92
+ <layout>
93
+ <updates>
94
+ <ICEshop_Iceimport module="iceimport">
95
+ <file>ICEshop_Iceimport.xml</file>
96
+ </ICEshop_Iceimport>
97
+ </updates>
98
+ </layout>
 
 
 
 
 
 
 
 
 
 
 
 
99
  </adminhtml>
100
  <crontab>
101
  <jobs>
102
+ <iceshop_iceimport>
103
  <schedule>
104
+ <cron_expr>30 7 * * *</cron_expr>
105
  </schedule>
106
  <run>
107
  <model>iceimport/observer::load</model>
108
  </run>
109
+ </iceshop_iceimport>
110
  </jobs>
111
  </crontab>
112
  <default>
113
  <importprod_root>
114
  <importprod>
115
  <category_active>1</category_active>
116
+ <category_sort>1</category_sort>
117
+ <delete_old_products>1</delete_old_products>
118
  <import_product_ean>1</import_product_ean>
119
  <import_product_mpn>1</import_product_mpn>
120
  <import_product_brand>1</import_product_brand>
127
  <import_stock>1</import_stock>
128
  <import_delivery_eta>1</import_delivery_eta>
129
  <import_images>1</import_images>
130
+ <update_categories_from_csv>1</update_categories_from_csv>
131
+ <update_status_from_csv>1</update_status_from_csv>
132
+ <update_visibility_from_csv>1</update_visibility_from_csv>
133
+ <update_is_in_stock_from_csv>1</update_is_in_stock_from_csv>
134
+ <update_hide_category>1</update_hide_category>
135
+ <update_url_key_from_csv>1</update_url_key_from_csv>
136
+ <iceimport_batch_size>10</iceimport_batch_size>
137
+ <import_new_products>1</import_new_products>
138
+ <delete_old_products_tolerance>25</delete_old_products_tolerance>
139
  </importprod>
140
  </importprod_root>
141
  </default>
app/code/community/ICEshop/Iceimport/etc/system.xml ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <iceshop translate="label" module="iceimport">
5
+ <label>Iceshop</label>
6
+ <sort_order>150</sort_order>
7
+ </iceshop>
8
+ </tabs>
9
+ <sections>
10
+ <importprod_root translate="label" module="catalog">
11
+ <class>separator-top</class>
12
+ <label>IceImport Settings</label>
13
+ <tab>iceshop</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>30</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <importprod translate="label">
21
+ <label>IceImport Settings</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>50</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <basic_settings_heading translate="label">
29
+ <label>Content Settings</label>
30
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </basic_settings_heading>
36
+ <basic_settings_note translate="label">
37
+ <label><![CDATA[<strong>Caution!</strong>]]></label>
38
+ <comment><![CDATA[All the settings in this section are valid and used only for existing products, for new products the value is Yes and it can't be changed]]></comment>
39
+ <frontend_type>label</frontend_type>
40
+ <sort_order>1</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </basic_settings_note>
45
+ <import_product_ean translate="label">
46
+ <label>Update EAN</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>iceimport/system_config_yesno</source_model>
49
+ <sort_order>21</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </import_product_ean>
54
+ <import_product_mpn translate="label">
55
+ <label>Update MPN</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>iceimport/system_config_yesno</source_model>
58
+ <sort_order>22</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </import_product_mpn>
63
+ <import_product_brand translate="label">
64
+ <label>Update brand</label>
65
+ <frontend_type>select</frontend_type>
66
+ <source_model>iceimport/system_config_yesno</source_model>
67
+ <sort_order>23</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <enabled>1</enabled>
72
+ </import_product_brand>
73
+ <import_product_name translate="label">
74
+ <label>Update name</label>
75
+ <frontend_type>select</frontend_type>
76
+ <source_model>iceimport/system_config_yesno</source_model>
77
+ <sort_order>24</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ </import_product_name>
82
+ <import_product_short_description translate="label">
83
+ <label>Update short description</label>
84
+ <frontend_type>select</frontend_type>
85
+ <source_model>iceimport/system_config_yesno</source_model>
86
+ <sort_order>25</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ </import_product_short_description>
91
+ <import_product_description translate="label">
92
+ <label>Update description</label>
93
+ <frontend_type>select</frontend_type>
94
+ <source_model>iceimport/system_config_yesno</source_model>
95
+ <sort_order>26</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ </import_product_description>
100
+ <import_product_short_summary_description translate="label">
101
+ <label>Update short summary description</label>
102
+ <frontend_type>select</frontend_type>
103
+ <source_model>iceimport/system_config_yesno</source_model>
104
+ <sort_order>27</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ </import_product_short_summary_description>
109
+ <import_product_summary_description translate="label">
110
+ <label>Update summary description</label>
111
+ <frontend_type>select</frontend_type>
112
+ <source_model>iceimport/system_config_yesno</source_model>
113
+ <sort_order>28</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </import_product_summary_description>
118
+ <import_prices translate="label">
119
+ <label>Update prices</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>iceimport/system_config_yesno</source_model>
122
+ <sort_order>29</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ </import_prices>
127
+ <import_stock translate="label">
128
+ <label>Update stock</label>
129
+ <frontend_type>select</frontend_type>
130
+ <source_model>iceimport/system_config_yesno</source_model>
131
+ <sort_order>30</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>1</show_in_store>
135
+ </import_stock>
136
+ <import_delivery_eta translate="label">
137
+ <label>Update delivery eta</label>
138
+ <frontend_type>select</frontend_type>
139
+ <source_model>iceimport/system_config_yesno</source_model>
140
+ <sort_order>31</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ </import_delivery_eta>
145
+ <update_categories_from_csv translate="label">
146
+ <label><![CDATA[Update products category]]></label>
147
+ <comment><![CDATA[]]></comment>
148
+ <frontend_type>select</frontend_type>
149
+ <source_model>iceimport/system_config_yesno</source_model>
150
+ <sort_order>32</sort_order>
151
+ <show_in_default>1</show_in_default>
152
+ <show_in_website>1</show_in_website>
153
+ <show_in_store>1</show_in_store>
154
+ </update_categories_from_csv>
155
+ <update_status_from_csv translate="label">
156
+ <label><![CDATA[Update status]]></label>
157
+ <comment><![CDATA[]]></comment>
158
+ <frontend_type>select</frontend_type>
159
+ <source_model>iceimport/system_config_yesno</source_model>
160
+ <sort_order>33</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <show_in_store>1</show_in_store>
164
+ </update_status_from_csv>
165
+ <update_visibility_from_csv translate="label">
166
+ <label><![CDATA[Update visibility]]></label>
167
+ <comment><![CDATA[]]></comment>
168
+ <frontend_type>select</frontend_type>
169
+ <source_model>iceimport/system_config_yesno</source_model>
170
+ <sort_order>34</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>1</show_in_store>
174
+ </update_visibility_from_csv>
175
+ <update_is_in_stock_from_csv translate="label">
176
+ <label><![CDATA[Update stock availability]]></label>
177
+ <comment><![CDATA[]]></comment>
178
+ <frontend_type>select</frontend_type>
179
+ <source_model>iceimport/system_config_yesno</source_model>
180
+ <sort_order>35</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ </update_is_in_stock_from_csv>
185
+ <update_url_key_from_csv translate="label">
186
+ <label><![CDATA[Update URL key]]></label>
187
+ <comment><![CDATA[]]></comment>
188
+ <frontend_type>select</frontend_type>
189
+ <source_model>iceimport/system_config_yesno</source_model>
190
+ <sort_order>36</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>1</show_in_store>
194
+ </update_url_key_from_csv>
195
+ <import_images translate="label">
196
+ <label>Import product images (via Cron)</label>
197
+ <frontend_type>select</frontend_type>
198
+ <source_model>iceimport/system_config_yesno</source_model>
199
+ <sort_order>37</sort_order>
200
+ <show_in_default>1</show_in_default>
201
+ <show_in_website>1</show_in_website>
202
+ <show_in_store>1</show_in_store>
203
+ </import_images>
204
+ <refresh_settings_heading translate="label">
205
+ <label>Import Parameters</label>
206
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
207
+ <sort_order>120</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ </refresh_settings_heading>
212
+ <iceimport_batch_size translate="label">
213
+ <label><![CDATA[Batch size]]></label>
214
+ <comment><![CDATA[]]></comment>
215
+ <frontend_type>text</frontend_type>
216
+ <validate>validate-greater-than-zero</validate>
217
+ <sort_order>130</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>1</show_in_website>
220
+ <show_in_store>1</show_in_store>
221
+ </iceimport_batch_size>
222
+ <import_new_products translate="label">
223
+ <label>Import new products</label>
224
+ <comment><![CDATA[Add products from import file if they aren't presented in shop's assortment.]]></comment>
225
+ <frontend_type>select</frontend_type>
226
+ <source_model>iceimport/system_config_yesno</source_model>
227
+ <sort_order>138</sort_order>
228
+ <show_in_default>1</show_in_default>
229
+ <show_in_website>1</show_in_website>
230
+ <show_in_store>1</show_in_store>
231
+ </import_new_products>
232
+ <delete_old_products translate="label">
233
+ <label>Remove old products</label>
234
+ <comment><![CDATA[Remove products marked as <strong>"is_iceimport"</strong> and not presented in import file.]]></comment>
235
+ <frontend_type>select</frontend_type>
236
+ <source_model>iceimport/system_config_yesno</source_model>
237
+ <sort_order>139</sort_order>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>1</show_in_store>
241
+ </delete_old_products>
242
+ <delete_old_products_tolerance translate="label">
243
+ <label><![CDATA[Tolerance of difference (%)]]></label>
244
+ <comment><![CDATA[If difference is greater than this value - remove process will be cancelled.]]></comment>
245
+ <frontend_type>text</frontend_type>
246
+ <validate>validate-greater-than-zero validate-percents</validate>
247
+ <sort_order>140</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ <depends>
252
+ <delete_old_products>1</delete_old_products>
253
+ </depends>
254
+ </delete_old_products_tolerance>
255
+ <category_active translate="label">
256
+ <label>Set to active imported categories</label>
257
+ <frontend_type>select</frontend_type>
258
+ <source_model>iceimport/system_config_yesno</source_model>
259
+ <sort_order>141</sort_order>
260
+ <show_in_default>1</show_in_default>
261
+ <show_in_website>1</show_in_website>
262
+ <show_in_store>1</show_in_store>
263
+ </category_active>
264
+ <category_sort translate="label">
265
+ <label>Sort categories in ASC order</label>
266
+ <frontend_type>select</frontend_type>
267
+ <source_model>iceimport/system_config_yesno</source_model>
268
+ <sort_order>142</sort_order>
269
+ <show_in_default>1</show_in_default>
270
+ <show_in_website>1</show_in_website>
271
+ <show_in_store>1</show_in_store>
272
+ </category_sort>
273
+ <update_hide_category translate="label">
274
+ <label><![CDATA[Hide empty category]]></label>
275
+ <comment><![CDATA[]]></comment>
276
+ <frontend_type>select</frontend_type>
277
+ <source_model>iceimport/system_config_yesno</source_model>
278
+ <sort_order>143</sort_order>
279
+ <show_in_default>1</show_in_default>
280
+ <show_in_website>1</show_in_website>
281
+ <show_in_store>1</show_in_store>
282
+ </update_hide_category>
283
+ <default_tax translate="label">
284
+ <label>Default tax for product</label>
285
+ <frontend_type>select</frontend_type>
286
+ <source_model>iceimport/system_config_defaulttax</source_model>
287
+ <sort_order>144</sort_order>
288
+ <show_in_default>1</show_in_default>
289
+ <show_in_website>1</show_in_website>
290
+ <show_in_store>1</show_in_store>
291
+ </default_tax>
292
+ </fields>
293
+ </importprod>
294
+ </groups>
295
+ </importprod_root>
296
+ <iceimport_information translate="label" module="iceimport">
297
+ <label>IceImport Information</label>
298
+ <tab>iceshop</tab>
299
+ <sort_order>40</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>1</show_in_website>
302
+ <show_in_store>1</show_in_store>
303
+ <comment><![CDATA[]]></comment>
304
+ <groups>
305
+ <dashboard translate="label comment">
306
+ <label>Dashboard</label>
307
+ <sort_order>50</sort_order>
308
+ <show_in_default>1</show_in_default>
309
+ <show_in_website>1</show_in_website>
310
+ <show_in_store>1</show_in_store>
311
+ <comment><![CDATA[<span style="color: grey;">Loading...</span>]]></comment>
312
+ <fields>
313
+ <check_system_hidden translate="label comment">
314
+ <label></label>
315
+ <comment></comment>
316
+ <frontend_type>select</frontend_type>
317
+ <source_model>iceimport/system_config_checksystem</source_model>
318
+ <sort_order>10</sort_order>
319
+ <show_in_default>1</show_in_default>
320
+ <show_in_website>1</show_in_website>
321
+ <show_in_store>1</show_in_store>
322
+ </check_system_hidden>
323
+ </fields>
324
+ </dashboard>
325
+ </groups>
326
+ </iceimport_information>
327
+ <iceshop_about translate="label" module="iceimport">
328
+ <label>Iceshop</label>
329
+ <tab>iceshop</tab>
330
+ <class>iceshop-info-section</class>
331
+ <header_css>iceshop-info-header</header_css>
332
+ <frontend_type>text</frontend_type>
333
+ <sort_order>100</sort_order>
334
+ <show_in_default>1</show_in_default>
335
+ <show_in_website>1</show_in_website>
336
+ <show_in_store>1</show_in_store>
337
+ <comment><![CDATA[]]></comment>
338
+ <groups>
339
+ <iceshop_iframe translate="label comment">
340
+ <label>More about Iceshop</label>
341
+ <sort_order>50</sort_order>
342
+ <show_in_default>1</show_in_default>
343
+ <show_in_website>1</show_in_website>
344
+ <show_in_store>1</show_in_store>
345
+ <comment><![CDATA[<span style="color: grey;">Loading...</span>]]></comment>
346
+ <fields>
347
+ <iceshop_iframe_hidden translate="label comment">
348
+ <label></label>
349
+ <comment></comment>
350
+ <frontend_type>select</frontend_type>
351
+ <source_model>iceimport/system_config_iceshoplink</source_model>
352
+ <sort_order>10</sort_order>
353
+ <show_in_default>1</show_in_default>
354
+ <show_in_website>1</show_in_website>
355
+ <show_in_store>1</show_in_store>
356
+ </iceshop_iframe_hidden>
357
+ </fields>
358
+ </iceshop_iframe>
359
+ </groups>
360
+ </iceshop_about>
361
+ </sections>
362
+ </config>
app/code/community/ICEshop/Iceimport/sql/iceimport_setup/mysql4-install-1.7.3.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once 'uninstall-old-version.php';
3
+ $unistaller_old_version = new Uninstall_Capacitywebsolutions_Importproduct();
4
+ $unistaller_old_version->uninstall();
5
+ $installer = $this;
6
+ $installer->startSetup();
7
+
8
+ $entityTypeId = $installer->getEntityTypeId('catalog_category');
9
+ $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
10
+ $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
11
+
12
+ $installer->addAttribute('catalog_category', 'unspsc', array(
13
+ 'type' => 'varchar',
14
+ 'label' => 'unspsc',
15
+ 'input' => 'text',
16
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
17
+ 'visible' => true,
18
+ 'required' => false,
19
+ 'user_defined' => false,
20
+ 'default' => 0
21
+ ));
22
+
23
+ $installer->addAttributeToGroup(
24
+ $entityTypeId,
25
+ $attributeSetId,
26
+ $attributeGroupId,
27
+ 'unspsc',
28
+ '11'
29
+ );
30
+
31
+ $attributeId = $installer->getAttributeId($entityTypeId, 'unspsc');
32
+
33
+ $installer->run("
34
+
35
+ DROP TABLE IF EXISTS `{$installer->getTable('iceimport_imported_product_ids')}`;
36
+ DROP TABLE IF EXISTS `{$installer->getTable('capacity_product_image_queue')}`;
37
+
38
+
39
+ INSERT IGNORE INTO `{$installer->getTable('catalog_category_entity_varchar')}`
40
+ (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
41
+ SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
42
+ FROM `{$installer->getTable('catalog_category_entity')}`;
43
+
44
+ CREATE TABLE IF NOT EXISTS `{$installer->getTable('iceshop_iceimport_image_queue')}` (
45
+ `queue_id` INT(10) NOT NULL AUTO_INCREMENT,
46
+ `entity_id` INT(10) UNSIGNED NOT NULL,
47
+ `image_url` VARCHAR(255) NOT NULL,
48
+ `is_downloaded` TINYINT NOT NULL DEFAULT 0,
49
+ PRIMARY KEY(`queue_id`),
50
+ UNIQUE KEY (`entity_id`, `image_url`),
51
+ CONSTRAINT `FK_CAP_PRD_IMG_QUEUE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('catalog_product_entity')}` (`entity_id`) ON DELETE CASCADE
52
+ )ENGINE=InnoDB CHARSET=utf8 COMMENT='Table to manage product image import';
53
+
54
+ CREATE TABLE IF NOT EXISTS `{$installer->getTable('iceshop_iceimport_imported_product_ids')}` (
55
+ `product_id` int(11) NOT NULL,
56
+ `product_sku` varchar(255) DEFAULT NULL,
57
+ KEY `pi_idx` (`product_id`)
58
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
59
+
60
+ CREATE TABLE IF NOT EXISTS {$this->getTable('iceshop_extensions_logs')} (
61
+ `log_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
62
+ `log_key` VARCHAR(255) NOT NULL,
63
+ `log_value` TEXT,
64
+ `log_type` VARCHAR(10) NOT NULL DEFAULT 'info',
65
+ `timecol` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
66
+ UNIQUE KEY (`log_key`),
67
+ KEY `IDX_LOG_TYPE` (`log_type`),
68
+ KEY `IDX_TIMECOL` (`timecol`)
69
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector logs';
70
+ ");
71
+
72
+ $installer->endSetup();
app/code/community/{Iceshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.4.0-1.5.0.php → ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-0.1.0-1.7.0.php} RENAMED
@@ -57,9 +57,13 @@ $installer->run("
57
  `product_id` int(11) NOT NULL,
58
  `product_sku` varchar(255) DEFAULT NULL,
59
  KEY `pi_idx` (`product_id`)
60
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
 
 
 
 
 
 
61
  ");
62
 
63
  $installer->endSetup();
64
-
65
- ?>
57
  `product_id` int(11) NOT NULL,
58
  `product_sku` varchar(255) DEFAULT NULL,
59
  KEY `pi_idx` (`product_id`)
60
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
61
+
62
+ CREATE TABLE IF NOT EXISTS {$this->getTable('iceshop_extensions_logs')} (
63
+ `log_key` VARCHAR(255) NOT NULL,
64
+ `log_value` varchar(255) DEFAULT NULL,
65
+ UNIQUE KEY (`log_key`)
66
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector logs';
67
  ");
68
 
69
  $installer->endSetup();
 
 
app/code/community/{Iceshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-0.1.0-1.5.0.php → ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.4.0-1.7.0.php} RENAMED
@@ -57,7 +57,13 @@ $installer->run("
57
  `product_id` int(11) NOT NULL,
58
  `product_sku` varchar(255) DEFAULT NULL,
59
  KEY `pi_idx` (`product_id`)
60
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
 
 
 
 
 
 
61
  ");
62
 
63
- $installer->endSetup();
57
  `product_id` int(11) NOT NULL,
58
  `product_sku` varchar(255) DEFAULT NULL,
59
  KEY `pi_idx` (`product_id`)
60
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
61
+
62
+ CREATE TABLE IF NOT EXISTS {$this->getTable('iceshop_extensions_logs')} (
63
+ `log_key` VARCHAR(255) NOT NULL,
64
+ `log_value` varchar(255) DEFAULT NULL,
65
+ UNIQUE KEY (`log_key`)
66
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector logs';
67
  ");
68
 
69
+ $installer->endSetup();
app/code/community/{Iceshop/Iceimport/sql/iceimport_setup/mysql4-install-1.5.0.php → ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.5.0-1.7.0.php} RENAMED
@@ -1,41 +1,39 @@
1
  <?php
2
- include_once 'uninstall-old-version.php';
3
- $unistaller_old_version = new Uninstall_Capacitywebsolutions_Importproduct();
4
- $unistaller_old_version->uninstall();
5
- $installer = $this;
6
- $installer->startSetup();
7
 
8
- $entityTypeId = $installer->getEntityTypeId('catalog_category');
9
- $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
10
- $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
11
 
12
- $installer->addAttribute('catalog_category', 'unspsc', array(
13
- 'type' => 'varchar',
14
- 'label' => 'unspsc',
15
- 'input' => 'text',
16
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
17
- 'visible' => true,
18
- 'required' => false,
19
- 'user_defined' => false,
20
- 'default' => 0
21
- ));
22
 
23
- $installer->addAttributeToGroup(
24
- $entityTypeId,
25
- $attributeSetId,
26
- $attributeGroupId,
27
- 'unspsc',
28
- '11'
29
- );
30
 
31
- $attributeId = $installer->getAttributeId($entityTypeId, 'unspsc');
32
 
33
- $installer->run("
34
 
35
  DROP TABLE IF EXISTS `{$installer->getTable('iceimport_imported_product_ids')}`;
36
  DROP TABLE IF EXISTS `{$installer->getTable('capacity_product_image_queue')}`;
37
- DROP TABLE IF EXISTS `{$installer->getTable('iceshop_iceimport_imported_product_ids')}`;
38
- DROP TABLE IF EXISTS `{$installer->getTable('iceshop_iceimport_image_queue')}`;
39
 
40
  INSERT IGNORE INTO `{$installer->getTable('catalog_category_entity_varchar')}`
41
  (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
@@ -57,9 +55,13 @@
57
  `product_id` int(11) NOT NULL,
58
  `product_sku` varchar(255) DEFAULT NULL,
59
  KEY `pi_idx` (`product_id`)
60
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
61
- ");
62
 
63
- $installer->endSetup();
 
 
 
 
 
64
 
65
- ?>
1
  <?php
2
+ include_once 'uninstall-old-version.php';
3
+ $unistaller_old_version = new Uninstall_Capacitywebsolutions_Importproduct();
4
+ $unistaller_old_version->uninstall();
5
+ $installer = $this;
6
+ $installer->startSetup();
7
 
8
+ $entityTypeId = $installer->getEntityTypeId('catalog_category');
9
+ $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
10
+ $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
11
 
12
+ $installer->addAttribute('catalog_category', 'unspsc', array(
13
+ 'type' => 'varchar',
14
+ 'label' => 'unspsc',
15
+ 'input' => 'text',
16
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
17
+ 'visible' => true,
18
+ 'required' => false,
19
+ 'user_defined' => false,
20
+ 'default' => 0
21
+ ));
22
 
23
+ $installer->addAttributeToGroup(
24
+ $entityTypeId,
25
+ $attributeSetId,
26
+ $attributeGroupId,
27
+ 'unspsc',
28
+ '11'
29
+ );
30
 
31
+ $attributeId = $installer->getAttributeId($entityTypeId, 'unspsc');
32
 
33
+ $installer->run("
34
 
35
  DROP TABLE IF EXISTS `{$installer->getTable('iceimport_imported_product_ids')}`;
36
  DROP TABLE IF EXISTS `{$installer->getTable('capacity_product_image_queue')}`;
 
 
37
 
38
  INSERT IGNORE INTO `{$installer->getTable('catalog_category_entity_varchar')}`
39
  (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
55
  `product_id` int(11) NOT NULL,
56
  `product_sku` varchar(255) DEFAULT NULL,
57
  KEY `pi_idx` (`product_id`)
58
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
59
 
60
+ CREATE TABLE IF NOT EXISTS {$this->getTable('iceshop_extensions_logs')} (
61
+ `log_key` VARCHAR(255) NOT NULL,
62
+ `log_value` varchar(255) DEFAULT NULL,
63
+ UNIQUE KEY (`log_key`)
64
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector logs';
65
+ ");
66
 
67
+ $installer->endSetup();
app/code/community/ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.6.0-1.7.0.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once 'uninstall-old-version.php';
3
+ $unistaller_old_version = new Uninstall_Capacitywebsolutions_Importproduct();
4
+ $unistaller_old_version->uninstall();
5
+ $installer = $this;
6
+ $installer->startSetup();
7
+
8
+ $entityTypeId = $installer->getEntityTypeId('catalog_category');
9
+ $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
10
+ $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
11
+
12
+ $installer->addAttribute('catalog_category', 'unspsc', array(
13
+ 'type' => 'varchar',
14
+ 'label' => 'unspsc',
15
+ 'input' => 'text',
16
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
17
+ 'visible' => true,
18
+ 'required' => false,
19
+ 'user_defined' => false,
20
+ 'default' => 0
21
+ ));
22
+
23
+ $installer->addAttributeToGroup(
24
+ $entityTypeId,
25
+ $attributeSetId,
26
+ $attributeGroupId,
27
+ 'unspsc',
28
+ '11'
29
+ );
30
+
31
+ $attributeId = $installer->getAttributeId($entityTypeId, 'unspsc');
32
+
33
+ $installer->run("
34
+
35
+ DROP TABLE IF EXISTS `{$installer->getTable('iceimport_imported_product_ids')}`;
36
+ DROP TABLE IF EXISTS `{$installer->getTable('capacity_product_image_queue')}`;
37
+
38
+ INSERT IGNORE INTO `{$installer->getTable('catalog_category_entity_varchar')}`
39
+ (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
40
+ SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
41
+ FROM `{$installer->getTable('catalog_category_entity')}`;
42
+
43
+ CREATE TABLE IF NOT EXISTS `{$installer->getTable('iceshop_iceimport_image_queue')}`
44
+ (
45
+ `queue_id` INT(10) NOT NULL AUTO_INCREMENT,
46
+ `entity_id` INT(10) UNSIGNED NOT NULL,
47
+ `image_url` VARCHAR(255) NOT NULL,
48
+ `is_downloaded` TINYINT NOT NULL DEFAULT 0,
49
+ PRIMARY KEY(`queue_id`),
50
+ UNIQUE KEY (`entity_id`, `image_url`),
51
+ CONSTRAINT `FK_CAP_PRD_IMG_QUEUE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('catalog_product_entity')}` (`entity_id`) ON DELETE CASCADE
52
+ )ENGINE=InnoDB CHARSET=utf8 COMMENT='Table to manage product image import';
53
+
54
+ CREATE TABLE IF NOT EXISTS `{$installer->getTable('iceshop_iceimport_imported_product_ids')}` (
55
+ `product_id` int(11) NOT NULL,
56
+ `product_sku` varchar(255) DEFAULT NULL,
57
+ KEY `pi_idx` (`product_id`)
58
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
59
+
60
+ CREATE TABLE IF NOT EXISTS {$this->getTable('iceshop_extensions_logs')} (
61
+ `log_key` VARCHAR(255) NOT NULL,
62
+ `log_value` varchar(255) DEFAULT NULL,
63
+ UNIQUE KEY (`log_key`)
64
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector logs';
65
+ ");
66
+
67
+ $installer->endSetup();
app/code/community/ICEshop/Iceimport/sql/iceimport_setup/mysql4-upgrade-1.7.0-1.7.5.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once 'uninstall-old-version.php';
3
+ $unistaller_old_version = new Uninstall_Capacitywebsolutions_Importproduct();
4
+ $unistaller_old_version->uninstall();
5
+ $installer = $this;
6
+ $installer->startSetup();
7
+
8
+ $entityTypeId = $installer->getEntityTypeId('catalog_category');
9
+ $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
10
+ $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
11
+
12
+ $installer->addAttribute('catalog_category', 'unspsc', array(
13
+ 'type' => 'varchar',
14
+ 'label' => 'unspsc',
15
+ 'input' => 'text',
16
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
17
+ 'visible' => true,
18
+ 'required' => false,
19
+ 'user_defined' => false,
20
+ 'default' => 0
21
+ ));
22
+
23
+ $installer->addAttributeToGroup(
24
+ $entityTypeId,
25
+ $attributeSetId,
26
+ $attributeGroupId,
27
+ 'unspsc',
28
+ '11'
29
+ );
30
+
31
+ $attributeId = $installer->getAttributeId($entityTypeId, 'unspsc');
32
+
33
+ $installer->run("
34
+
35
+ DROP TABLE IF EXISTS `{$installer->getTable('iceimport_imported_product_ids')}`;
36
+ DROP TABLE IF EXISTS `{$installer->getTable('capacity_product_image_queue')}`;
37
+
38
+ INSERT IGNORE INTO `{$installer->getTable('catalog_category_entity_varchar')}`
39
+ (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
40
+ SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
41
+ FROM `{$installer->getTable('catalog_category_entity')}`;
42
+
43
+ CREATE TABLE IF NOT EXISTS `{$installer->getTable('iceshop_iceimport_image_queue')}`
44
+ (
45
+ `queue_id` INT(10) NOT NULL AUTO_INCREMENT,
46
+ `entity_id` INT(10) UNSIGNED NOT NULL,
47
+ `image_url` VARCHAR(255) NOT NULL,
48
+ `is_downloaded` TINYINT NOT NULL DEFAULT 0,
49
+ PRIMARY KEY(`queue_id`),
50
+ UNIQUE KEY (`entity_id`, `image_url`),
51
+ CONSTRAINT `FK_CAP_PRD_IMG_QUEUE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('catalog_product_entity')}` (`entity_id`) ON DELETE CASCADE
52
+ )ENGINE=InnoDB CHARSET=utf8 COMMENT='Table to manage product image import';
53
+
54
+ CREATE TABLE IF NOT EXISTS `{$installer->getTable('iceshop_iceimport_imported_product_ids')}` (
55
+ `product_id` int(11) NOT NULL,
56
+ `product_sku` varchar(255) DEFAULT NULL,
57
+ KEY `pi_idx` (`product_id`)
58
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
59
+
60
+ CREATE TABLE IF NOT EXISTS {$this->getTable('iceshop_extensions_logs')} (
61
+ `log_key` VARCHAR(255) NOT NULL,
62
+ `log_value` varchar(255) DEFAULT NULL,
63
+ UNIQUE KEY (`log_key`)
64
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector logs';
65
+
66
+ ALTER TABLE {$this->getTable('iceshop_extensions_logs')}
67
+ ADD COLUMN `log_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
68
+
69
+ ALTER TABLE {$this->getTable('iceshop_extensions_logs')}
70
+ ADD COLUMN `log_type` VARCHAR(10) NOT NULL DEFAULT 'info' AFTER `log_value`;
71
+
72
+ ALTER TABLE {$this->getTable('iceshop_extensions_logs')}
73
+ ADD KEY `IDX_LOG_TYPE`(`log_type`);
74
+
75
+ ALTER TABLE {$this->getTable('iceshop_extensions_logs')}
76
+ ADD COLUMN `timecol` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `log_type`;
77
+
78
+ ALTER TABLE {$this->getTable('iceshop_extensions_logs')}
79
+ ADD KEY `IDX_TIMECOL`(`timecol`);
80
+
81
+ ALTER TABLE {$this->getTable('iceshop_extensions_logs')}
82
+ MODIFY `log_value` TEXT;
83
+ ");
84
+
85
+ $installer->endSetup();
86
+
app/code/community/{Iceshop → ICEshop}/Iceimport/sql/iceimport_setup/uninstall-old-version.php RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  class Uninstall_Capacitywebsolutions_Importproduct
3
  {
4
  /**
1
  <?php
2
+
3
  class Uninstall_Capacitywebsolutions_Importproduct
4
  {
5
  /**
app/code/community/Iceshop/Iceimport/Model/Convert/Adapter/Product.php DELETED
@@ -1,1026 +0,0 @@
1
- <?php
2
- /**
3
- * Import Product with additional attributes
4
- *
5
- *
6
- */
7
-
8
-
9
- class Iceshop_Iceimport_Model_Convert_Adapter_Product extends Mage_Catalog_Model_Convert_Adapter_Product
10
- {
11
- protected $_categoryCache = array();
12
- protected $_connRes = null;
13
- protected $_tablePrefix = '';
14
-
15
- public function __construct()
16
- {
17
-
18
- $this->_connRes = Mage::getSingleton('core/resource')->getConnection('core_write');
19
- $tablePrefix = (array)Mage::getConfig()->getTablePrefix();
20
- if (!empty($tablePrefix)) {
21
- $this->_tablePrefix = $tablePrefix[0];
22
- }
23
-
24
- }
25
-
26
- public function saveRow(array $importData)
27
- {
28
- // separate import data to eav & static
29
- $sortedProductData = $this->_mapAttributes($importData);
30
- $productData = $sortedProductData['productData'];
31
- $iceimportAttributes = $sortedProductData['iceimportAttributes'];
32
- $failedAttributes = $sortedProductData['failedAttributes'];
33
-
34
- //Init session values to count total products and determine the last call of saveRow method
35
- $session = Mage::getSingleton("core/session");
36
- $import_total = $session->getData("import_total");
37
- $counter = $session->getData("counter");
38
-
39
- if (!isset($counter)) {
40
- $session->setData("counter", 1);
41
- $counter = $session->getData("counter");
42
- }
43
-
44
- if (!isset($import_total)) {
45
- $batchId = Mage::getSingleton('core/app')->getRequest()->getPost('batch_id', 0);
46
- $batchModel = Mage::getModel('dataflow/batch')->load($batchId);
47
- $batchImportModel = $batchModel->getBatchImportModel();
48
- $importIds = $batchImportModel->getIdCollection();
49
- $import_total = count($importIds);
50
- $session->setData("imqport_total", (int)$import_total);
51
- } else if (isset($counter) && isset($import_total)) {
52
- if ($counter < $import_total) {
53
- $session->setData("counter", (int)++$counter);
54
- }
55
- }
56
-
57
- // mark product ice_import generic
58
- $productData['varchar']['is_iceimport'] = 1;
59
- // set website id
60
- if (empty($iceimportAttributes['websites'])) {
61
- $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'website');
62
- Mage::throwException($message);
63
- }
64
- $website = Mage::app()->getWebsite(trim($iceimportAttributes['websites']));
65
- $websiteId = $website->getId();
66
-
67
- // set store id
68
- if (empty($iceimportAttributes['store'])) {
69
- if (!is_null($this->getBatchParams('store'))) {
70
- $store = $this->getStoreById($this->getBatchParams('store'));
71
- } else {
72
- $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'store');
73
- Mage::throwException($message);
74
- }
75
- }
76
- $store = $this->getStoreByCode($iceimportAttributes['store']);
77
- if ($store === false) {
78
- $message = Mage::helper('catalog')->__('Skip import row, store "%s" not exists', $iceimportAttributes['store']);
79
- Mage::throwException($message);
80
- }
81
- $storeId = $store->getId();
82
-
83
- // set type
84
- if (empty($iceimportAttributes['type'])) {
85
- $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'type');
86
- Mage::throwException($message);
87
- }
88
- $productType = $iceimportAttributes['type'];
89
-
90
- // set attribute set
91
- if (empty($iceimportAttributes['attribute_set'])) {
92
- $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'attribute_set');
93
- Mage::throwException($message);
94
- }
95
- $attribute_set = $iceimportAttributes['attribute_set'];
96
-
97
- // set sku
98
- if (empty($iceimportAttributes['sku'])) {
99
- $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'sku');
100
- Mage::throwException($message);
101
- }
102
- $sku = $iceimportAttributes['sku'];
103
-
104
- // set category, unspsc, unspsc path
105
- if (empty($iceimportAttributes['categories'])) {
106
- $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'categories');
107
- Mage::throwException($message);
108
- }
109
- if (!empty($iceimportAttributes['categories'])) {
110
- $cat_names = explode('/', $iceimportAttributes['categories']);
111
- foreach($cat_names as $cat_name){
112
- if(empty($cat_name)){
113
- $message = Mage::helper('catalog')->__('Skip import row, some of categories does not have name');
114
- Mage::throwException($message);
115
- }
116
- }
117
- }
118
- $category = $iceimportAttributes['categories'];
119
- if (empty($iceimportAttributes['unspsc'])) {
120
- $message = Mage::helper('catalog')->__('Skip import. Category UNSPSC not defined in store');
121
- Mage::throwException($message);
122
- }
123
- $unspsc = $iceimportAttributes['unspsc'];
124
- if (empty($iceimportAttributes['unspsc_path'])) {
125
- $message = Mage::helper('catalog')->__('Skip import. Category UNSPSC path not defined in store');
126
- Mage::throwException($message);
127
- }
128
- if (!empty($iceimportAttributes['unspsc_path'])) {
129
- $cat_unspscs = explode('/', $iceimportAttributes['unspsc_path']);
130
- foreach($cat_unspscs as $cat_unspsc){
131
- if(empty($cat_unspsc)){
132
- $message = Mage::helper('catalog')->__('Skip import row, some of categories does not have UNSPSC');
133
- Mage::throwException($message);
134
- }
135
- }
136
- }
137
- $unspscPath = $iceimportAttributes['unspsc_path'];
138
- if(!empty($cat_unspscs) && !empty($cat_names) && count($cat_names) != count($cat_unspscs)){
139
- $message = Mage::helper('catalog')->__('Skip import row, categories names does not match categories UNSPSC');
140
- Mage::throwException($message);
141
- }
142
- // set in / out of stock
143
- $isInStock = 0;
144
- if (!empty($iceimportAttributes['is_in_stock'])) {
145
- $isInStock = $iceimportAttributes['is_in_stock'];
146
- }
147
-
148
- // set qty
149
- $qty = 0;
150
- if (!empty($iceimportAttributes['qty'])) {
151
- $qty = $iceimportAttributes['qty'];
152
- }
153
-
154
- // set price
155
- $price = 0.00;
156
- if (!empty($iceimportAttributes['price'])) {
157
- $price = $iceimportAttributes['price'];
158
- }
159
-
160
- // set status value
161
- $statusValue = (!empty($iceimportAttributes['status']) && $iceimportAttributes['status'] == 'Enabled') ? 1 : 0;
162
- $productData['int']['status'] = $statusValue;
163
-
164
- // set visibility value
165
- $visibilityValue = 1;
166
- if (!empty($iceimportAttributes['visibility'])) {
167
- switch ($iceimportAttributes['visibility']) {
168
- case 'Not Visible Individually':
169
- $visibilityValue = 1;
170
- break;
171
- case 'Catalog':
172
- $visibilityValue = 2;
173
- break;
174
- case 'Search':
175
- $visibilityValue = 3;
176
- break;
177
- case 'Catalog, Search':
178
- $visibilityValue = 4;
179
- break;
180
- }
181
- }
182
- $productData['int']['visibility'] = $visibilityValue;
183
-
184
- // set product image
185
- $productImage = '';
186
- if (!empty($iceimportAttributes['image'])) {
187
- $productImage = $iceimportAttributes['image'];
188
- }
189
-
190
- // init general attributes query
191
- $initAttributes = "
192
- SELECT @product_entity_type_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
193
- entity_type_code = 'catalog_product';
194
- SELECT @category_entity_type_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
195
- entity_type_code = 'catalog_category';
196
- SELECT @attribute_set_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
197
- entity_type_code = 'catalog_product';
198
- SELECT @stock_id := `stock_id` FROM `" . $this->_tablePrefix . "cataloginventory_stock` WHERE
199
- stock_name = 'Default';
200
- SELECT @attribute_set_id := `attribute_set_id` FROM `" . $this->_tablePrefix . "eav_attribute_set`
201
- WHERE attribute_set_name = :attribute_set AND entity_type_id =
202
- @product_entity_type_id;
203
-
204
- SELECT @price_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
205
- `attribute_code` = 'price' AND entity_type_id = @product_entity_type_id;
206
-
207
- SELECT @unspcs_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
208
- `attribute_code` = 'unspsc' AND entity_type_id = @category_entity_type_id;
209
- SELECT @category_name_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
210
- `attribute_code` = 'name' AND entity_type_id = @category_entity_type_id;
211
- SELECT @category_active_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
212
- `attribute_code` = 'is_active' AND entity_type_id = @category_entity_type_id;
213
- SELECT @include_nav_bar_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
214
- `attribute_code` = 'include_in_menu' AND entity_type_id = @category_entity_type_id;
215
- SELECT @category_is_anchor_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
216
- `attribute_code` = 'is_anchor' AND entity_type_id = @category_entity_type_id;
217
- ";
218
-
219
-
220
- $this->_connRes->query($initAttributes, array(':attribute_set' => $iceimportAttributes['attribute_set']));
221
-
222
- $defaulttaxConf = (int)Mage::getStoreConfig('importprod_root/importprod/default_tax', $storeId);
223
-
224
- $productData['int']['tax_class_id'] = $defaulttaxConf;
225
-
226
- // get category id
227
- $categoriesToActiveConf = Mage::getStoreConfig('importprod_root/importprod/category_active', $storeId);
228
- $categoryIds = $this->_addCategories($category, $storeId, $unspsc, $unspscPath, $categoriesToActiveConf);
229
-
230
- // get url key
231
- $url = '';
232
- if (!empty($productData['varchar']['name'])) {
233
- $preUrl = explode(' ', strtolower($productData['varchar']['name']));
234
- $url = implode('-', $preUrl) . '-' . $iceimportAttributes['store'];
235
- }
236
- $productData['varchar']['url_key'] = $url;
237
-
238
- $prodIdFetch = $this->_connRes->fetchRow("SELECT entity_id FROM `" . $this->_tablePrefix . "catalog_product_entity` WHERE sku = :sku limit 1", array(
239
- ':sku' => $sku
240
- ));
241
- $productId = $prodIdFetch['entity_id'];
242
- if (!empty($productId)) {
243
- // check import type (Import only price & qty or all product info)
244
- $stockConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_stock', $storeId);
245
- $priceConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_prices', $storeId);
246
-
247
- $productId = $this->_coreSave($productData, $productId, $storeId, $sku, $categoryIds);
248
- $this->_corePriceStock($websiteId, $productId, $price, $qty, $sku, $isInStock, $stockConf, $priceConf);
249
- $this->_connRes->query('INSERT INTO ' . $this->_tablePrefix . 'iceshop_iceimport_imported_product_ids (product_id, product_sku) VALUES (:prod_id, :sku) ON DUPLICATE KEY UPDATE product_sku = :sku', array(':prod_id' => $productId, ':sku' => $sku));
250
- } else {
251
- $productId = $this->_coreSave($productData, $productId, $storeId, $sku, $categoryIds);
252
- // add price & stock
253
- $this->_corePriceStock($websiteId, $productId, $price, $qty, $sku, $isInStock);
254
- $this->_connRes->query('INSERT INTO ' . $this->_tablePrefix . 'iceshop_iceimport_imported_product_ids (product_id, product_sku) VALUES (:prod_id, :sku) ON DUPLICATE KEY UPDATE product_sku = :sku', array(':prod_id' => $productId, ':sku' => $sku));
255
- }
256
-
257
- // add product image to queue
258
- if (Mage::getStoreConfig('importprod_root/importprod/import_images')) {
259
- $this->_addImageToQueue($productId, $productImage);
260
- }
261
-
262
- // Check if this is last imported product
263
- // Do category sort and set categories without products to inactive
264
- if (isset($counter) && isset($import_total) && ($counter == $import_total)) {
265
- $catCollection = Mage::getModel('catalog/category')
266
- ->getCollection()
267
- ->addAttributeToSort('name', 'ASC');
268
- $position = 1;
269
-
270
- foreach ($catCollection as $category) {
271
-
272
- $query = $this->_connRes->query("UPDATE `" . $this->_tablePrefix . "catalog_category_entity` SET position = :position WHERE entity_id = :cat_id ", array(
273
- ':position' => $position,
274
- ':cat_id' => $category->getId()
275
- ));
276
-
277
- $query = "SELECT COUNT(*) FROM `" . $this->_tablePrefix . "catalog_category_product` WHERE category_id = :cat_id ";
278
- $cat_products = $this->_connRes->fetchRow($query, array(
279
- ':cat_id' => $category->getId()
280
- ));
281
-
282
- if ($cat_products['COUNT(*)'] == 0) {
283
- $query = "SELECT `entity_id` FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE parent_id = :cat_id";
284
- $child_cat = $this->_connRes->fetchAll($query, array(
285
- ':cat_id' => $category->getId()
286
- ));
287
-
288
- if (isset($child_cat) && count($child_cat) > 0) {
289
- //Count child categories products and set them to inactive if they have no
290
- $this->CountChildProd($child_cat);
291
- } else {
292
- $this->_connRes->query("UPDATE `" . $this->_tablePrefix . "catalog_category_entity_int`
293
- SET `value` = 0 WHERE `attribute_id` = @category_active_id AND entity_id = :cat_id", array(
294
- ':cat_id' => $category->getId()
295
- ));
296
- }
297
- }
298
- $position++;
299
- }
300
-
301
- $session->unsetData('import_total');
302
- $session->unsetData('counter');
303
- }
304
-
305
- return true;
306
- }
307
- public function getAttributeOptionValue($arg_attribute, $arg_value) {
308
- $attribute_model = Mage::getModel('eav/entity_attribute');
309
- $attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;
310
-
311
- $attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
312
- $attribute = $attribute_model->load($attribute_code);
313
-
314
- $attribute_table = $attribute_options_model->setAttribute($attribute);
315
-
316
- $options = $attribute_options_model->getAllOptions(false);
317
-
318
- foreach($options as $option) {
319
- if ($option['label'] == $arg_value) {
320
- return $option['value']; }
321
- }
322
- return false;
323
- }
324
-
325
-
326
- public function addAttributeOption($arg_attribute, $arg_value) {
327
- $attribute_model = Mage::getModel('eav/entity_attribute');
328
- $attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;
329
-
330
- $attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
331
- $attribute = $attribute_model->load($attribute_code);
332
-
333
- $attribute_table = $attribute_options_model->setAttribute($attribute);
334
- $options = $attribute_options_model->getAllOptions(false);
335
-
336
- $value['option'] = array($arg_value,$arg_value);
337
- $result = array('value' => $value);
338
-
339
- $attribute->setData('option',$result);
340
- $attribute->save();
341
-
342
- return $this->getAttributeOptionValue($arg_attribute, $arg_value);
343
- }
344
-
345
-
346
- protected function _coreSave(array $entityData, $productId = null, $storeId = 0, $sku, $categoryIds)
347
- {
348
- if ($productId === null) {
349
- // add product to store
350
- $coreSaveProduct = "INSERT INTO `" . $this->_tablePrefix . "catalog_product_entity` (`entity_type_id`, `attribute_set_id`, `type_id`, `sku`, `created_at`) VALUES
351
- (@product_entity_type_id, @attribute_set_id, 'simple', :sku, NOW());
352
- SELECT @product_id := LAST_INSERT_ID();
353
- ";
354
- $this->_connRes->query($coreSaveProduct, array(':sku' => $sku));
355
- // get product ID
356
- $prodFetch = $this->_connRes->fetchRow('SELECT @product_id AS prod_id');
357
- $productId = $prodFetch['prod_id'];
358
-
359
- } else {
360
- $coreSaveSQL .= "SELECT @product_id := " . (int)$productId . "; ";
361
- $producteanConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_ean', $storeId);
362
- $productmpnConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_mpn', $storeId);
363
- $productnameConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_name', $storeId);
364
- $productshdescriptionConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_short_description', $storeId);
365
- $productdescriptionConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_description', $storeId);
366
- $productshsudescriptionConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_short_summary_description', $storeId);
367
- $productsudescriptionConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_summary_description', $storeId);
368
- $productbrandConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_product_brand', $storeId);
369
- $deliveryetaConf = (int)Mage::getStoreConfig('importprod_root/importprod/import_delivery_eta', $storeId);
370
- foreach ($entityData as $type => $typeAttributes) {
371
- foreach ($typeAttributes as $attribute => $value) {
372
- if ((($attribute == 'mpn' && $productmpnConf == 0) || ($attribute == 'brand_name' && $productbrandConf == 0) || ($attribute == 'ean' && $producteanConf == 0) || ($attribute == 'name' && $productnameConf == 0) || ($attribute == 'short_description' && $productshdescriptionConf == 0) || ($attribute == 'description' && $productdescriptionConf == 0) || ($attribute == 'short_summary_description' && $productshsudescriptionConf == 0) || ($attribute == 'long_summary_description' && $productsudescriptionConf == 0) || ($attribute == 'delivery_eta' && $deliveryetaConf == 0))) {
373
- unset($entityData[$type][$attribute]);
374
- }
375
- }
376
- }
377
- }
378
-
379
- $bindArray[':store_id'] = $storeId;
380
-
381
- foreach ($entityData as $type => $typeAttributes) {
382
-
383
- if ($type != 'spec') {
384
- $tailCoreSaveSQL = '';
385
- $attributesInit = '';
386
- if($type == 'select'){
387
- $type = 'int';
388
- $is_select = 1;
389
- }else{
390
- $is_select = 0;
391
- }
392
- if (!empty($typeAttributes)) {
393
- $tailCoreSaveSQL .= "
394
- INSERT INTO `" . $this->_tablePrefix . "catalog_product_entity_" . $type . "` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ";
395
- foreach ($typeAttributes as $attribute => $value) {
396
- if($is_select == 1){
397
- $option_id = $this->getAttributeOptionValue($attribute, $value);
398
- if(empty($option_id)){
399
- $option_id = $this->addAttributeOption($attribute, $value);
400
- }
401
- $value = $option_id;
402
- }
403
- $attributesInit .= "
404
- SELECT @" . $attribute . "_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
405
- `attribute_code` = '" . $attribute . "' AND entity_type_id = @product_entity_type_id;
406
- ";
407
-
408
- $tailCoreSaveSQL .= "
409
- (@product_entity_type_id, @" . $attribute . "_id, 0, @product_id, :" . $attribute . " ),
410
- (@product_entity_type_id, @" . $attribute . "_id, :store_id, @product_id, :" . $attribute . " ), ";
411
- $bindArray[':' . $attribute] = $value;
412
-
413
- }
414
- $tailCoreSaveSQL = substr($tailCoreSaveSQL, 0, -2);
415
- $tailCoreSaveSQL .= "
416
- ON DUPLICATE KEY UPDATE
417
- `value` = VALUES (`value`);
418
- ";
419
- }
420
- $coreSaveSQL .= $attributesInit . $tailCoreSaveSQL;
421
- }else{
422
- foreach ($typeAttributes as $attribute => $attributeData) {
423
- $prod_id_field = $attributeData['prod_id_field'];
424
- $table = $attributeData['table'];
425
- $field = $attributeData['field'];
426
- $value = $attributeData['value'];
427
- if (!emptcy($table) && !empty($field)) {
428
- $coreSaveSQL .= "
429
- UPDATE `" . $this->_tablePrefix . $table . "` SET `" . $field . "` = :" . $attribute . " WHERE `" . $prod_id_field . "` = @product_id;
430
- ";
431
- $bindArray[':' . $attribute] = $value;
432
- }
433
- }
434
- }
435
- }
436
- // categories
437
- $coreSaveSQL .= "INSERT INTO `" . $this->_tablePrefix . "catalog_category_product` (`category_id`, `product_id`, `position`) VALUES ";
438
- $counter = 1;
439
-
440
- $mapCategoryIds = array();
441
- $mapCategoryIds[] = array_pop($categoryIds);
442
- $delCategoryIds = array_diff($categoryIds, $mapCategoryIds);
443
-
444
- foreach ($mapCategoryIds as $categoryId) {
445
- if ($counter < count($mapCategoryIds)) {
446
- $coreSaveSQL .= " (" . (int)$categoryId . ", @product_id, 1) , ";
447
- } else if ($counter == count($mapCategoryIds)) {
448
- $coreSaveSQL .= " (" . (int)$categoryId . ", @product_id, 1) ON DUPLICATE KEY UPDATE `position` = 1; ";
449
- }
450
- $counter++;
451
- }
452
- if(!empty($delCategoryIds)){
453
- foreach ($delCategoryIds as $delCategoryId) {
454
- $coreSaveSQL .= "DELETE FROM `" . $this->_tablePrefix . "catalog_category_product` WHERE `category_id` = ". (int)$delCategoryId ." AND `product_id` = @product_id;";
455
- }
456
- }
457
- try {
458
- $bindArray[':' . $attribute] = $value;
459
-
460
- $query = $this->_connRes->query($coreSaveSQL, $bindArray);
461
-
462
- } catch (Exception $e) {
463
- echo $e->getMessage();
464
- }
465
- return $productId;
466
- }
467
-
468
- protected function _corePriceStock($website = 0, $productId = false, $price = 0.00, $qty = 0.00, $sku = false, $isInStock = 0, $stockConf = 1, $priceConf = 1)
469
- {
470
-
471
- if (!$productId) {
472
- $message = Mage::helper('catalog')->__('Skip import row, product_id for product "%s" not defined ', $sku);
473
- Mage::throwException($message);
474
- }
475
- if ($stockConf == 1) {
476
- $stockSaveSQL = "
477
- INSERT INTO `" . $this->_tablePrefix . "cataloginventory_stock_item` (`product_id`, `stock_id`, `qty`, `is_in_stock`) VALUES
478
- (:product_id, @stock_id, :qty,1)
479
- ON DUPLICATE KEY UPDATE
480
- `product_id` = :product_id,
481
- `stock_id` = @stock_id,
482
- `qty` = :qty,
483
- `is_in_stock` = :is_in_stock;
484
-
485
- INSERT INTO `" . $this->_tablePrefix . "cataloginventory_stock_status` (`product_id`, `website_id`, `stock_id`, `qty`, `stock_status`) VALUES
486
- (:product_id, :webisteId, @stock_id, :qty, 1)
487
- ON DUPLICATE KEY UPDATE
488
- `product_id` = :product_id,
489
- `website_id` = :webisteId,
490
- `stock_id` = @stock_id,
491
- `qty` = :qty,
492
- `stock_status` = :is_in_stock;";
493
- }
494
- if ($priceConf == 1) {
495
- $stockSaveSQL .= "
496
- INSERT INTO `" . $this->_tablePrefix . "catalog_product_website` (`product_id`, `website_id`) VALUES
497
- (:product_id, :webisteId)
498
- ON DUPLICATE KEY UPDATE
499
- `product_id` = :product_id,
500
- `website_id` = :webisteId;
501
-
502
- INSERT INTO `" . $this->_tablePrefix . "catalog_product_entity_decimal` (`entity_type_id`,`attribute_id`,`store_id`, `entity_id`, `value`) VALUES
503
- (@product_entity_type_id, @price_id, 0, :product_id, :price)
504
- ON DUPLICATE KEY UPDATE
505
- `entity_type_id` = @product_entity_type_id,
506
- `attribute_id` = @price_id,
507
- `store_id` = 0,
508
- `entity_id` = :product_id,
509
- `value` = :price;
510
- ";
511
- }
512
- if ($priceConf == 1 || $stockConf == 1) {
513
- $this->_connRes->query($stockSaveSQL, array(
514
- ':webisteId' => $website,
515
- ':product_id' => $productId,
516
- ':price' => $price,
517
- ':qty' => $qty,
518
- ':is_in_stock' => $isInStock
519
- ));
520
- }
521
- }
522
-
523
- protected function _addImageToQueue($productId = false, $productImageUrl)
524
- {
525
- $productImageUrl = trim($productImageUrl);
526
- if ($productId && !empty($productImageUrl)) {
527
- // add image if not exists to queue
528
- $this->_connRes->query(" INSERT IGNORE INTO `" . $this->_tablePrefix . "iceshop_iceimport_image_queue` (`entity_id`, `image_url` ) VALUES
529
- (:product_id, :image_url)
530
- ", array(':product_id' => $productId,
531
- ':image_url' => $productImageUrl));
532
- }
533
- }
534
-
535
- public function getImageQueue()
536
- {
537
- return $this->_connRes->fetchAll("SELECT `queue_id`, `entity_id`, `image_url` FROM `" . $this->_tablePrefix . "iceshop_iceimport_image_queue`
538
- WHERE `is_downloaded` = 0
539
- ");
540
- }
541
-
542
- public function setImageAsDownloaded($queueId = false)
543
- {
544
- if ($queueId) {
545
- $this->_connRes->query("UPDATE `" . $this->_tablePrefix . "iceshop_iceimport_image_queue` SET is_downloaded = 1
546
- WHERE queue_id = :queue_id", array(':queue_id' => $queueId));
547
- }
548
- }
549
-
550
- protected function _addCategories($categories, $storeId, $unspsc, $unspscPath, $categoryActive = 1)
551
- {
552
-
553
- // check if product exists
554
- $categoryId = $this->_getCategoryIdByUnspsc($unspsc);
555
- $categoryIds = array();
556
- if (!empty($categoryId)) {
557
- // merge categories by unspsc
558
- $categoryMergedArray = $this->_categoryMapper($categories, $unspscPath);
559
- foreach ($categoryMergedArray as $category) {
560
- $categoryName = $category['name'];
561
- $categoryUnspsc = $category['unspsc'];
562
- $categoryTreeId = $this->_getCategoryIdByUnspsc($categoryUnspsc);
563
- // check category name to current store
564
- $categoryBindArray = array(
565
- ':store_id' => $storeId,
566
- ':category_id' => $categoryTreeId
567
- );
568
- $nameCheckerFetch = $this->_connRes->fetchRow("SELECT value_id FROM `" . $this->_tablePrefix . "catalog_category_entity_varchar` WHERE
569
- store_id = :store_id AND entity_id = :category_id AND attribute_id = @category_name_id
570
- ", $categoryBindArray);
571
- $nameChecker = $nameCheckerFetch['value_id'];
572
- if (!$nameChecker) {
573
- // add category name to current store
574
- $categoryBindArray[':category_name'] = $categoryName;
575
- if (!empty($categoryBindArray[':category_id'])) {
576
- $this->_connRes->query("
577
- INSERT INTO `" . $this->_tablePrefix . "catalog_category_entity_varchar` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
578
- (@category_entity_type_id, @category_name_id, :store_id, :category_id, :category_name)
579
- ", $categoryBindArray);
580
- }
581
- }
582
- }
583
- //
584
-
585
- // get current path of category
586
- $categoryPath = $this->_connRes->fetchRow("SELECT path FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE entity_id = :entity_id",
587
- array(':entity_id' => $categoryId));
588
- $categoryPathArray = explode('/', $categoryPath['path']);
589
- if ($categoryPathArray) {
590
- $activeSetter = "INSERT INTO `" . $this->_tablePrefix . "catalog_category_entity_int` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ";
591
- }
592
-
593
- $falseCounter = 0;
594
- foreach ($categoryPathArray as $categoryId) {
595
- $category = Mage::getModel('catalog/category')->load($categoryId);
596
- $cid = $category->getId();
597
- if (!empty($cid)) {
598
- if (!empty($categoryId)) {
599
- $categoryIds[] = (int)$categoryId;
600
- $activeSetter .= "(@category_entity_type_id, @category_active_id, :store_id, " . $categoryId . ", 1),
601
- (@category_entity_type_id, @category_active_id, 0, " . $categoryId . ", 1), ";
602
- } else {
603
- $falseCounter++;
604
- }
605
- } else {
606
- $falseCounter++;
607
- }
608
- }
609
- $activeSetter = substr($activeSetter, 0, -2);
610
- $activeSetter .= "
611
- ON DUPLICATE KEY UPDATE
612
- `value` = 1
613
- ";
614
- if (1 == $categoryActive) {
615
- if ($falseCounter < count($categoryPathArray)) {
616
- $this->_connRes->query($activeSetter, array(':store_id' => $storeId));
617
- }
618
- }
619
- return $categoryIds;
620
- } else {
621
-
622
- // merge unspcs to current name in unspcs & name path's
623
- $categoryMergedArray = $this->_categoryMapper($categories, $unspscPath);
624
- // get max created parrent category
625
- $categoryCreateArray = array();
626
- for ($i = count($categoryMergedArray) - 1; $i >= 0; $i--) {
627
- $category = $categoryMergedArray[$i];
628
- $checkCategoryId = $this->_getCategoryIdByUnspsc($category['unspsc']);
629
- if ($checkCategoryId != null) {
630
- $categoryId = $this->_buildCategoryTree($checkCategoryId, $storeId, $categoryCreateArray, $categoryActive);
631
- $categoryIds[] = (int)$categoryId;
632
- break;
633
- } else {
634
- $categoryCreateArray[] = $category;
635
- }
636
- }
637
- return $categoryIds;
638
- }
639
- }
640
-
641
- protected function _categoryMapper($categoryPath, $unspscPath)
642
- {
643
- $nameArray = explode('/', $categoryPath);
644
- $unspscArray = explode('/', $unspscPath);
645
-
646
- if (count($nameArray) != count($unspscArray)) {
647
- $message = Mage::helper('catalog')->__('Skip import row, @categories data is invaled');
648
- Mage::throwException($message);
649
- }
650
-
651
- $categoryMergedArray = array(
652
- array(
653
- 'unspsc' => 'default_root',
654
- 'name' => 'Default category'
655
- )
656
- );
657
-
658
- for ($i = 0; $i < count($unspscArray); $i++) {
659
- $categoryMergedArray[] = array('name' => $nameArray[$i],
660
- 'unspsc' => $unspscArray[$i]);
661
- }
662
-
663
- return $categoryMergedArray;
664
- }
665
-
666
- protected function _getCategoryIdByUnspsc($unspcs)
667
- {
668
- if ($unspcs == 'default_root') {
669
- return Mage::app()->getStore(1)->getRootCategoryId();
670
- } else {
671
- $categoryId = $this->_connRes->fetchRow("SELECT entity_id FROM `" . $this->_tablePrefix . "catalog_category_entity_varchar` WHERE
672
- `value` = :unspsc AND attribute_id = @unspcs_id", array(':unspsc' => $unspcs));
673
- return ($categoryId['entity_id']) ? $categoryId['entity_id'] : null;
674
- }
675
- }
676
-
677
- protected function _buildCategoryTree($parrentCategoryId, $storeId, $pathArray, $categoryActive = 0)
678
- {
679
- for ($i = count($pathArray) - 1; $i >= 0; $i--) {
680
- $category = $pathArray[$i];
681
- $parrentCategoryId = $this->_createCategory($parrentCategoryId, $category['unspsc'], $storeId, $category['name'], $categoryActive);
682
- }
683
-
684
- return $parrentCategoryId;
685
- }
686
-
687
- protected function _createCategory($parrentId, $unspsc, $storeId, $name, $categoryActive = 0)
688
- {
689
-
690
- $addCategory = "
691
- SELECT @tPath := `path`, @tLevel := `level` FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE `entity_id` = :parrent_id;
692
- SET @tLevel = @tLevel +1;
693
-
694
- SET @path := CONCAT(@tPath, '/',(SELECT MAX(entity_id) FROM `" . $this->_tablePrefix . "catalog_category_entity`) +1 );
695
-
696
- INSERT INTO `" . $this->_tablePrefix . "catalog_category_entity` (`entity_type_id`, `attribute_set_id`,
697
- `parent_id`, `created_at`,
698
- `path`, `position`,
699
- `level`, `children_count`)
700
- VALUES
701
- (@category_entity_type_id, 0, :parrent_id, NOW(), @path, 1, @tLevel, 0);
702
-
703
- SELECT @catId := LAST_INSERT_ID();
704
-
705
- UPDATE `" . $this->_tablePrefix . "catalog_category_entity` SET `path` = CONCAT(@tPath, '/', @catId) WHERE entity_id = LAST_INSERT_ID();
706
-
707
- UPDATE `" . $this->_tablePrefix . "catalog_category_entity` SET children_count = children_count +1 WHERE entity_id = :parrent_id;
708
-
709
- INSERT IGNORE INTO `" . $this->_tablePrefix . "catalog_category_entity_int` (`entity_type_id`, `attribute_id`,
710
- `store_id`, `entity_id`, `value`)
711
- VALUES
712
- (@category_entity_type_id, @category_active_id, 0, @catId, :category_active),
713
- (@category_entity_type_id, @category_active_id, :store, @catId, :category_active),
714
- (@category_entity_type_id, @category_is_anchor_id, 0, @catId, 1),
715
- (@category_entity_type_id, @category_is_anchor_id, :store, @catId, 1),
716
- (@category_entity_type_id, @include_nav_bar_id, 0, @catId, 1),
717
- (@category_entity_type_id, @include_nav_bar_id, :store, @catId, 1);
718
-
719
- INSERT IGNORE INTO `" . $this->_tablePrefix . "catalog_category_entity_varchar` (`entity_type_id`, `attribute_id`,
720
- `store_id`, `entity_id`, `value`)
721
- VALUES
722
- (@category_entity_type_id, @category_name_id, 0, @catId, :category_name),
723
- (@category_entity_type_id, @category_name_id, :store, @catId, :category_name),
724
- (@category_entity_type_id, @unspcs_id, 0, @catId, :unspsc_val),
725
- (@category_entity_type_id, @unspcs_id, :store, @catId, :unspsc_val);
726
- ";
727
-
728
- $this->_connRes->query($addCategory, array(
729
- ':store' => $storeId,
730
- ':parrent_id' => $parrentId,
731
- ':category_name' => $name,
732
- ':unspsc_val' => $unspsc,
733
- ':category_active' => (int)$categoryActive
734
- ));
735
-
736
- $categoryIdFetch = $this->_connRes->fetchRow('SELECT @catId AS category_id');
737
-
738
- return $categoryIdFetch['category_id'];
739
- }
740
-
741
- protected function _mapAttributes(array $importData)
742
- {
743
-
744
- // map iceimport attributes, skip some attributes
745
- $iceAttributes = array();
746
- foreach ($importData as $attribute => $value) {
747
- // map iceimport attributes
748
- if ($attribute == 'type' ||
749
- $attribute == 'sku' ||
750
- $attribute == 'attribute_set' ||
751
- $attribute == 'categories' ||
752
- $attribute == 'unspsc' ||
753
- $attribute == 'price' ||
754
- $attribute == 'qty' ||
755
- $attribute == 'status' ||
756
- $attribute == 'visibility' ||
757
- $attribute == 'store' ||
758
- $attribute == 'websites' ||
759
- $attribute == 'is_in_stock' ||
760
- $attribute == 'image' ||
761
- $attribute == 'unspsc_path'
762
- ) {
763
-
764
- $iceAttributes[$attribute] = $value;
765
- unset($importData[$attribute]);
766
-
767
- }
768
- // skip some attributes
769
- if ($attribute == 'supplier_product_code' ||
770
- $attribute == 'supplier' ||
771
- $attribute == 'leader_categories' ||
772
- $attribute == 'leader_store' ||
773
- $attribute == 'sprice' ||
774
- $attribute == 'euprice' ||
775
- $attribute == 'icecat_product_id' ||
776
- $attribute == 'icecat_category_id' ||
777
- $attribute == 'icecat_vendor_id' ||
778
- $attribute == 'icecat_quality' ||
779
- $attribute == 'icecat_url' ||
780
- $attribute == 'icecat_thumbnail_img' ||
781
- $attribute == 'icecat_low_res_img' ||
782
- $attribute == 'icecat_high_res_img' ||
783
- $attribute == 'tax1' ||
784
- $attribute == 'tax2' ||
785
- $attribute == 'tax3' ||
786
- $attribute == 'tax4' ||
787
- $attribute == 'min_quantity' ||
788
- $attribute == 'loms' ||
789
- $attribute == 'image_label' ||
790
- $attribute == 'links_title' ||
791
- $attribute == 'small_image_label' ||
792
- $attribute == 'tax_rate' ||
793
- $attribute == 'gallery' ||
794
- $attribute == 'weight_type' ||
795
- $attribute == 'sku_type' ||
796
- $attribute == 'manage_stock' ||
797
- $attribute == 'minimal_price' ||
798
- $attribute == 'required_options' ||
799
- $attribute == 'samples_title' ||
800
- $attribute == 'shipment_type' ||
801
- $attribute == 'url_path' ||
802
- $attribute == 'recurring_profile' ||
803
- $attribute == 'product_keys'
804
- ) {
805
-
806
- unset($importData[$attribute]);
807
-
808
- }
809
-
810
- }
811
-
812
- // map default attributes
813
- $productData = array();
814
- foreach ($this->_getDefaultAttributesList() as $backendType => $attributesList) {
815
- if ($backendType != 'spec') {
816
- foreach ($attributesList as $attribute) {
817
- if (isset($importData[$attribute]) && $importData[$attribute] != '') {
818
- $productData[$backendType][$attribute] = $importData[$attribute];
819
- unset($importData[$attribute]);
820
- }
821
- }
822
- } else {
823
- foreach ($attributesList as $attributeCode => $attributeSpecs) {
824
- if (isset($importData[$attributeCode]) && $importData[$attributeCode] != false) {
825
- $attributeSpecs['value'] = $importData[$attributeCode];
826
- $productData[$backendType][$attributeCode] = $attributeSpecs;
827
- unset($importData[$attributeCode]);
828
- }
829
- }
830
- }
831
- }
832
-
833
- if (!empty($importData)) {
834
- foreach ($importData as $attributeCode => $value) {
835
- $frontendTypeFetch = $this->_connRes->fetchRow("SELECT frontend_input FROM `" . $this->_tablePrefix . "eav_attribute` WHERE `attribute_code` = :code", array(':code' => $attributeCode));
836
- if($frontendTypeFetch['frontend_input'] == 'select'){
837
- $frontendType = $frontendTypeFetch['frontend_input'];
838
- if ($frontendType != 'static' && !empty($frontendType) && $value != '') {
839
- $productData[$frontendType][$attributeCode] = $value;
840
- unset($importData[$attributeCode]);
841
- }
842
- }
843
- }
844
- }
845
- // map custom attributes
846
- if (!empty($importData)) {
847
- foreach ($importData as $attributeCode => $value) {
848
- $backendTypeFetch = $this->_connRes->fetchRow("SELECT backend_type FROM `" . $this->_tablePrefix . "eav_attribute` WHERE `attribute_code` = :code", array(':code' => $attributeCode));
849
- $backendType = $backendTypeFetch['backend_type'];
850
- if (($backendType != 'static' && !empty($backendType) && $value != '')) {
851
- $productData[$backendType][$attributeCode] = $value;
852
- unset($importData[$attributeCode]);
853
- }
854
- }
855
- }
856
-
857
- $failedAttributes = array();
858
- if (count($importData) > 0) {
859
- $failedAttributes = array_keys($importData);
860
- }
861
-
862
- return array(
863
- 'iceimportAttributes' => $iceAttributes,
864
- 'productData' => $productData,
865
- 'failedAttributes' => $failedAttributes
866
- );
867
-
868
- }
869
-
870
- protected function _getDefaultAttributesList()
871
- {
872
-
873
- return array(
874
- 'varchar' => array(
875
- 'gift_message_available',
876
- 'custom_design',
877
- 'msrp_display_actual_price_type',
878
- 'msrp_enabled',
879
- 'options_container',
880
- 'page_layout',
881
- 'mpn',
882
- 'name',
883
- 'url_key',
884
- 'meta_description',
885
- 'meta_title'
886
- ),
887
- 'int' => array(
888
- 'enable_googlecheckout',
889
- 'is_recurring',
890
- 'links_purchased_separately',
891
- 'links_exist',
892
- 'status',
893
- 'visibility',
894
- 'tax_class_id',
895
- 'color',
896
- 'price_view',
897
- 'manufacturer'
898
- ),
899
- 'text' => array(
900
- 'recurring_profile',
901
- 'description',
902
- 'custom_layout_update',
903
- 'meta_keyword',
904
- 'short_description'
905
- ),
906
- 'decimal' => array(
907
- 'cost',
908
- 'group_price',
909
- 'weight',
910
- 'special_price',
911
- 'msrp'
912
- ),
913
- 'datetime' => array(
914
- 'custom_design_from',
915
- 'custom_design_to',
916
- 'news_from_date',
917
- 'news_to_date',
918
- 'special_from_date',
919
- 'special_to_date'
920
- ),
921
- 'spec' => array(
922
- 'is_qty_decimal' => array(
923
- 'prod_id_field' => 'product_id',
924
- 'table' => 'cataloginventory_stock_item',
925
- 'field' => 'is_qty_decimal'
926
- ),
927
- 'use_config_min_qty' => array(
928
- 'prod_id_field' => 'product_id',
929
- 'table' => 'cataloginventory_stock_item',
930
- 'field' => 'use_config_min_qty'
931
- ),
932
- 'use_config_min_sale_qty' => array(
933
- 'prod_id_field' => 'product_id',
934
- 'table' => 'cataloginventory_stock_item',
935
- 'field' => 'use_config_min_sale_qty'
936
- ),
937
- 'use_config_max_sale_qty' => array(
938
- 'prod_id_field' => 'product_id',
939
- 'table' => 'cataloginventory_stock_item',
940
- 'field' => 'use_config_max_sale_qty'
941
- ),
942
- 'use_config_manage_stock' => array(
943
- 'prod_id_field' => 'product_id',
944
- 'table' => 'cataloginventory_stock_item',
945
- 'field' => 'use_config_manage_stock'
946
- ),
947
- 'is_decimal_divided' => array(
948
- 'prod_id_field' => 'product_id',
949
- 'table' => 'cataloginventory_stock_item',
950
- 'field' => 'is_decimal_divided'
951
- ),
952
- 'use_config_backorders' => array(
953
- 'prod_id_field' => 'product_id',
954
- 'table' => 'cataloginventory_stock_item',
955
- 'field' => 'use_config_backorders'
956
- ),
957
- 'use_config_notify_stock_qty' => array(
958
- 'prod_id_field' => 'product_id',
959
- 'table' => 'cataloginventory_stock_item',
960
- 'field' => 'use_config_notify_stock_qty'
961
- ),
962
- 'max_sale_qty' => array(
963
- 'prod_id_field' => 'product_id',
964
- 'table' => 'cataloginventory_stock_item',
965
- 'field' => 'max_sale_qty'
966
- ),
967
- 'min_sale_qty' => array(
968
- 'prod_id_field' => 'product_id',
969
- 'table' => 'cataloginventory_stock_item',
970
- 'field' => 'min_sale_qty'
971
- ),
972
- 'notify_stock_qty' => array(
973
- 'prod_id_field' => 'product_id',
974
- 'table' => 'cataloginventory_stock_item',
975
- 'field' => 'notify_stock_qty'
976
- ),
977
- 'backorders' => array(
978
- 'prod_id_field' => 'product_id',
979
- 'table' => 'cataloginventory_stock_item',
980
- 'field' => 'backorders'
981
- ),
982
- 'created_at' => array(
983
- 'prod_id_field' => 'entity_id',
984
- 'table' => 'catalog_product_entity',
985
- 'field' => 'created_at'
986
- ),
987
- 'min_qty' => array(
988
- 'prod_id_field' => 'product_id',
989
- 'table' => 'cataloginventory_stock_item',
990
- 'field' => 'min_qty'
991
- ),
992
- 'updated_at' => array(
993
- 'prod_id_field' => 'entity_id',
994
- 'table' => 'catalog_product_entity',
995
- 'field' => 'updated_at'
996
- )
997
- )
998
- );
999
- }
1000
-
1001
- // Count child categories products and set them inactive if they have no products
1002
- public function CountChildProd($child_cat)
1003
- {
1004
- foreach ($child_cat as $cat) {
1005
- $query = "SELECT `entity_id` FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE parent_id = :cat_id";
1006
- $child_cat = $this->_connRes->fetchAll($query, array(
1007
- ':cat_id' => $cat['entity_id']
1008
- ));
1009
-
1010
- $query = "SELECT COUNT(*) FROM `" . $this->_tablePrefix . "catalog_category_product` WHERE category_id = :cat_id ";
1011
- $cat_products = $this->_connRes->fetchRow($query, array(
1012
- ':cat_id' => $cat['entity_id']
1013
- ));
1014
-
1015
- if ($cat_products['COUNT(*)'] == 0 && empty($child_cat)) {
1016
- $this->_connRes->query("UPDATE `" . $this->_tablePrefix . "catalog_category_entity_int`
1017
- SET `value` = 0 WHERE `attribute_id` = @category_active_id AND entity_id = :cat_id", array(
1018
- ':cat_id' => $cat['entity_id']
1019
- ));
1020
- } else if (!empty($child_cat)) {
1021
- $this->CountChildProd($child_cat);
1022
- }
1023
- }
1024
- }
1025
-
1026
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/Observer.php DELETED
@@ -1,225 +0,0 @@
1
- <?php
2
- class Iceshop_Iceimport_Model_Observer
3
- {
4
- /**
5
- * Our process ID.
6
- */
7
- private $process_id = 'iceshop_iceimport';
8
- private $indexProcess;
9
-
10
- protected function _construct()
11
- {
12
- $this->_init('iceimport/observer');
13
- }
14
-
15
-
16
- /**
17
- * load
18
- * @access publc
19
- */
20
- public function load()
21
- {
22
-
23
- $profileId = 3;
24
- $logFileName = 'test.log';
25
- $recordCount = 0;
26
- $this->indexProcess = new Mage_Index_Model_Process();
27
- $this->indexProcess->setId($this->process_id);
28
-
29
- if ($this->indexProcess->isLocked()) {
30
- echo 'Error! Another iceimport module cron process is running!';
31
- die();
32
- }
33
-
34
- $this->indexProcess->lockAndBlock();
35
-
36
- Mage::log("Import Started", null, $logFileName);
37
-
38
- $profile = Mage::getModel('dataflow/profile');
39
-
40
- $userModel = Mage::getModel('admin/user');
41
- $userModel->setUserId(0);
42
- Mage::getSingleton('admin/session')->setUser($userModel);
43
-
44
- if ($profileId) {
45
- $profile->load($profileId);
46
- if (!$profile->getId()) {
47
- Mage::getSingleton('adminhtml/session')->addError('The profile that you are trying to save no longer exists');
48
- }
49
- }
50
-
51
- $profile->run();
52
-
53
- $batchModel = Mage::getSingleton('dataflow/batch');
54
-
55
- if ($batchModel->getId()) {
56
- if ($batchModel->getAdapter()) {
57
- $batchId = $batchModel->getId();
58
- $batchImportModel = $batchModel->getBatchImportModel();
59
- $importIds = $batchImportModel->getIdCollection();
60
-
61
- $batchModel = Mage::getModel('dataflow/batch')->load($batchId);
62
-
63
- $adapter = Mage::getModel($batchModel->getAdapter());
64
- // delete previous products id
65
- $db_res = Mage::getSingleton('core/resource')->getConnection('core_write');
66
- $tablePrefix = '';
67
- $tPrefix = (array)Mage::getConfig()->getTablePrefix();
68
- if (!empty($tPrefix)) {
69
- $tablePrefix = $tPrefix[0];
70
- }
71
-
72
- try {
73
- $db_res->query('DELETE FROM ' . $tablePrefix . 'iceshop_iceimport_imported_product_ids');
74
- } catch (Exception $e) {
75
- throw new Exception($e->getMessage());
76
- }
77
- foreach ($importIds as $importId) {
78
-
79
- $recordCount++;
80
- try {
81
- $batchImportModel->load($importId);
82
- if (!$batchImportModel->getId()) {
83
- $errors[] = Mage::helper('dataflow')->__('Skip undefined row');
84
- continue;
85
- }
86
-
87
- $importData = $batchImportModel->getBatchData();
88
-
89
- try {
90
- $adapter->saveRow($importData);
91
- } catch (Exception $e) {
92
- Mage::log($e->getMessage(), null, $logFileName);
93
- continue;
94
- }
95
-
96
- } catch (Exeption $ex) {
97
- Mage::log('Record# ' . $recordCount . ' - SKU = ' . $importData['sku'] . ' - Error - ' . $ex->getMessage(), null, $logFileName);
98
- }
99
-
100
- }
101
-
102
- // delete old products
103
- try {
104
- $db_res->query("SELECT @is_iceimport_id := `attribute_id` FROM " . $tablePrefix . "eav_attribute WHERE attribute_code = 'is_iceimport'");
105
- $db_res->query("DELETE cpe FROM " . $tablePrefix . "catalog_product_entity AS cpe
106
- JOIN " . $tablePrefix . "catalog_product_entity_varchar AS cpev ON cpe.entity_id = cpev.entity_id AND cpev.value = 1 AND cpev.attribute_id = @is_iceimport_id
107
- LEFT JOIN " . $tablePrefix . "iceshop_iceimport_imported_product_ids AS iip ON cpe.entity_id = iip.product_id
108
- WHERE iip.product_id IS NULL");
109
-
110
- } catch (Exception $e) {
111
- throw new Exception($e->getMessage());
112
- }
113
-
114
-
115
- // download & set product images
116
- $queueList = $adapter->getImageQueue();
117
- if (count($queueList) > 0) {
118
- $mediaDir = Mage::getBaseDir('media');
119
- foreach ($queueList as $queue) {
120
- $queueId = $queue['queue_id'];
121
- $productId = $queue['entity_id'];
122
- $imageUrl = $queue['image_url'];
123
-
124
- $preImageName = explode('/', $imageUrl);
125
- $imageName = array_pop($preImageName);
126
- if (file_exists($mediaDir . DS . $imageName)) {
127
- $imageName = rand() . '_' . time() . $imageName;
128
- }
129
-
130
- if (file_put_contents($mediaDir . DS . $imageName, file_get_contents($imageUrl))) {
131
- $product = Mage::getModel('catalog/product')->load($productId);
132
- $product->addImageToMediaGallery($mediaDir . DS . $imageName,
133
- array('image', 'small_image', 'thumbnail'),
134
- true, true
135
- );
136
- $product->save();
137
- $adapter->setImageAsDownloaded($queueId);
138
- echo $product->getCategory() . '<br>';
139
- unset($product);
140
- } else {
141
- Mage::log('Unable download file to ' . $productId, $logFileName);
142
- continue;
143
- }
144
- }
145
- }
146
- // sort category in abc
147
-
148
- $catCollection = Mage::getModel('catalog/category')
149
- ->getCollection()
150
- ->addAttributeToSort('name', 'ASC');
151
- $position = 1;
152
- foreach ($catCollection as $category) {
153
- $catSource = Mage::getModel('catalog/category')->load($category->getId());
154
- $catSource->setData('position', $position);
155
- $catSource->save();
156
- $query = "SELECT COUNT(*) FROM `" . $tablePrefix . "catalog_category_product` WHERE category_id = :cat_id ";
157
- $cat_products = $db_res->fetchRow($query, array(
158
- ':cat_id' => $category->getId()
159
- ));
160
-
161
- if ($cat_products['COUNT(*)'] == 0) {
162
- $query = "SELECT `entity_id` FROM `" . $tablePrefix . "catalog_category_entity` WHERE parent_id = :cat_id";
163
- $child_cat = $db_res->fetchAll($query, array(
164
- ':cat_id' => $category->getId()
165
- ));
166
- $cat_prod = 0;
167
-
168
- if (isset($child_cat) && count($child_cat) > 0) {
169
-
170
- foreach ($child_cat as $cat) {
171
- $query = "SELECT COUNT(*) FROM `" . $tablePrefix . "catalog_category_product` WHERE category_id = :cat_id ";
172
- $cat_products = $db_res->fetchRow($query, array(
173
- ':cat_id' => $cat['entity_id']
174
- ));
175
-
176
- if ($cat_products['COUNT(*)'] != 0) {
177
- $cat_prod = 1;
178
- }
179
-
180
- }
181
-
182
- if ($cat_prod == 0) {
183
- $db_res->query("UPDATE `" . $tablePrefix . "catalog_category_entity_int`
184
- SET `value` = 0 WHERE `attribute_id` = @category_active_id AND entity_id = :cat_id", array(
185
- ':cat_id' => $category->getId()
186
- ));
187
- }
188
- } else {
189
- $db_res->query("UPDATE `" . $tablePrefix . "catalog_category_entity_int`
190
- SET `value` = 0 WHERE `attribute_id` = @category_active_id AND entity_id = :cat_id", array(
191
- ':cat_id' => $category->getId()
192
- ));
193
- }
194
- }
195
- $position++;
196
- }
197
-
198
-
199
- $processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
200
- $processes->walk('reindexAll');
201
-
202
- foreach ($profile->getExceptions() as $e) {
203
- Mage::log($e->getMessage(), null, $logFileName);
204
- }
205
-
206
- }
207
- }
208
-
209
- unset($db_res);
210
- echo 'Import Completed';
211
- $this->indexProcess->unlock();
212
- Mage::log("Import Completed", null, $logFileName);
213
-
214
- try {
215
- $import = Mage::getModel('importexport/import');
216
- } catch (Exeptint $e) {
217
- Mage::log($e->getMessage(), null, $logFileName);
218
- }
219
-
220
- // get prouct download queue
221
- }
222
-
223
- }
224
-
225
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Categoryactivity.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Categoryactivity
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- 1 => 'Yes',
9
- 0 => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Imageimport.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Imageimport
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importdeliveryeta.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importdeliveryeta
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importprices.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importprices
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductbrand.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importproductbrand
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductdescription.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importproductdescription
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductean.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importproductean
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductmpn.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importproductmpn
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductname.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importproductname
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductshdescription.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importproductshdescription
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductshsudescription.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importproductshsudescription
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Importproductsudescription.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Importproductsudescription
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- '1' => 'Yes',
9
- '0' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/Model/System/Config/Lockproddetails.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Iceshop_Iceimport_Model_System_Config_Lockproddetails
4
- {
5
- public function toOptionArray()
6
- {
7
- $paramsArray = array(
8
- 'import_price_stock' => 'Yes',
9
- 'import_info' => 'No'
10
- );
11
- return $paramsArray;
12
- }
13
- }
14
-
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Iceshop/Iceimport/etc/system.xml DELETED
@@ -1,154 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <sections>
4
- <importprod_root translate="label" module="catalog">
5
- <class>separator-top</class>
6
- <label>IceImport</label>
7
- <tab>catalog</tab>
8
- <frontend_type>text</frontend_type>
9
- <sort_order>300</sort_order>
10
- <show_in_default>1</show_in_default>
11
- <show_in_website>1</show_in_website>
12
- <show_in_store>1</show_in_store>
13
- <groups>
14
- <importprod translate="label">
15
- <label>IceImport Settings</label>
16
- <frontend_type>text</frontend_type>
17
- <sort_order>50</sort_order>
18
- <show_in_default>1</show_in_default>
19
- <show_in_website>1</show_in_website>
20
- <show_in_store>1</show_in_store>
21
- <fields>
22
- <category_active translate="label">
23
- <label>Set to active imported categories</label>
24
- <frontend_type>select</frontend_type>
25
- <source_model>iceimport/system_config_categoryactivity</source_model>
26
- <sort_order>10</sort_order>
27
- <show_in_default>1</show_in_default>
28
- <show_in_website>1</show_in_website>
29
- <show_in_store>1</show_in_store>
30
- </category_active>
31
- <import_product_ean translate="label">
32
- <label>Import product EAN</label>
33
- <frontend_type>select</frontend_type>
34
- <source_model>iceimport/system_config_importproductean</source_model>
35
- <sort_order>12</sort_order>
36
- <show_in_default>1</show_in_default>
37
- <show_in_website>1</show_in_website>
38
- <show_in_store>1</show_in_store>
39
- </import_product_ean>
40
- <import_product_mpn translate="label">
41
- <label>Import product MPN</label>
42
- <frontend_type>select</frontend_type>
43
- <source_model>iceimport/system_config_importproductmpn</source_model>
44
- <sort_order>13</sort_order>
45
- <show_in_default>1</show_in_default>
46
- <show_in_website>1</show_in_website>
47
- <show_in_store>1</show_in_store>
48
- </import_product_mpn>
49
- <import_product_brand translate="label">
50
- <label>Import product brand</label>
51
- <frontend_type>select</frontend_type>
52
- <source_model>iceimport/system_config_importproductbrand</source_model>
53
- <sort_order>14</sort_order>
54
- <show_in_default>1</show_in_default>
55
- <show_in_website>1</show_in_website>
56
- <show_in_store>1</show_in_store>
57
- <enabled>1</enabled>
58
- </import_product_brand>
59
- <import_product_name translate="label">
60
- <label>Import product name</label>
61
- <frontend_type>select</frontend_type>
62
- <source_model>iceimport/system_config_importproductname</source_model>
63
- <sort_order>15</sort_order>
64
- <show_in_default>1</show_in_default>
65
- <show_in_website>1</show_in_website>
66
- <show_in_store>1</show_in_store>
67
- </import_product_name>
68
- <import_product_short_description translate="label">
69
- <label>Import product short description</label>
70
- <frontend_type>select</frontend_type>
71
- <source_model>iceimport/system_config_importproductshdescription</source_model>
72
- <sort_order>16</sort_order>
73
- <show_in_default>1</show_in_default>
74
- <show_in_website>1</show_in_website>
75
- <show_in_store>1</show_in_store>
76
- </import_product_short_description>
77
- <import_product_description translate="label">
78
- <label>Import product description</label>
79
- <frontend_type>select</frontend_type>
80
- <source_model>iceimport/system_config_importproductdescription</source_model>
81
- <sort_order>17</sort_order>
82
- <show_in_default>1</show_in_default>
83
- <show_in_website>1</show_in_website>
84
- <show_in_store>1</show_in_store>
85
- </import_product_description>
86
- <import_product_short_summary_description translate="label">
87
- <label>Import product short summary description</label>
88
- <frontend_type>select</frontend_type>
89
- <source_model>iceimport/system_config_importproductshsudescription</source_model>
90
- <sort_order>18</sort_order>
91
- <show_in_default>1</show_in_default>
92
- <show_in_website>1</show_in_website>
93
- <show_in_store>1</show_in_store>
94
- </import_product_short_summary_description>
95
- <import_product_summary_description translate="label">
96
- <label>Import product summary description</label>
97
- <frontend_type>select</frontend_type>
98
- <source_model>iceimport/system_config_importproductsudescription</source_model>
99
- <sort_order>19</sort_order>
100
- <show_in_default>1</show_in_default>
101
- <show_in_website>1</show_in_website>
102
- <show_in_store>1</show_in_store>
103
- </import_product_summary_description>
104
- <import_prices translate="label">
105
- <label>Import prices</label>
106
- <frontend_type>select</frontend_type>
107
- <source_model>iceimport/system_config_importprices</source_model>
108
- <sort_order>20</sort_order>
109
- <show_in_default>1</show_in_default>
110
- <show_in_website>1</show_in_website>
111
- <show_in_store>1</show_in_store>
112
- </import_prices>
113
- <import_stock translate="label">
114
- <label>Import stock</label>
115
- <frontend_type>select</frontend_type>
116
- <source_model>iceimport/system_config_importstock</source_model>
117
- <sort_order>21</sort_order>
118
- <show_in_default>1</show_in_default>
119
- <show_in_website>1</show_in_website>
120
- <show_in_store>1</show_in_store>
121
- </import_stock>
122
- <import_delivery_eta translate="label">
123
- <label>Import delivery eta</label>
124
- <frontend_type>select</frontend_type>
125
- <source_model>iceimport/system_config_importdeliveryeta</source_model>
126
- <sort_order>22</sort_order>
127
- <show_in_default>1</show_in_default>
128
- <show_in_website>1</show_in_website>
129
- <show_in_store>1</show_in_store>
130
- </import_delivery_eta>
131
- <import_images translate="label">
132
- <label>Import product images (via Cron)</label>
133
- <frontend_type>select</frontend_type>
134
- <source_model>iceimport/system_config_imageimport</source_model>
135
- <sort_order>30</sort_order>
136
- <show_in_default>1</show_in_default>
137
- <show_in_website>1</show_in_website>
138
- <show_in_store>1</show_in_store>
139
- </import_images>
140
- <default_tax translate="label">
141
- <label>Default tax for product</label>
142
- <frontend_type>select</frontend_type>
143
- <source_model>iceimport/system_config_defaulttax</source_model>
144
- <sort_order>40</sort_order>
145
- <show_in_default>1</show_in_default>
146
- <show_in_website>1</show_in_website>
147
- <show_in_store>1</show_in_store>
148
- </default_tax>
149
- </fields>
150
- </importprod>
151
- </groups>
152
- </importprod_root>
153
- </sections>
154
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/ICEshop_Iceimport.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_system_config_edit>
4
+ <reference name="head">
5
+ <action method="addCss"><stylesheet>iceshop/iceimport/styles.css</stylesheet></action>
6
+ <action method="addJs"><script>ICEshop/Iceimport/jquery-1.9.1.min.js</script></action>
7
+ <action method="addJs"><script>ICEshop/Iceimport/script.js</script></action>
8
+ </reference>
9
+ </adminhtml_system_config_edit>
10
+ <default>
11
+ <reference name="notifications">
12
+ <reference name="head">
13
+ <action method="addCss"><stylesheet>iceshop/iceimport/styles.css</stylesheet></action>
14
+ </reference>
15
+ <block type="iceimport/adminhtml_notifications" name="iceimport_notifications" template="iceshop/iceimport/notifications.phtml"/>
16
+ </reference>
17
+ </default>
18
+ </layout>
app/design/adminhtml/default/default/template/iceshop/iceimport/notifications.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_problems = $this->getIceimportProblemsDigest()?>
2
+ <?php if(!empty($_problems) && is_array($_problems) && count($_problems) > 0):?>
3
+ <div class="notification-global" id="iceimport-warning">
4
+ <span class="f-right">
5
+ <a href="<?php print $this->getManageUrl(); ?>" title="<?php echo $this->helper('iceimport')->__('Open in new window'); ?>"><?php echo $this->helper('iceimport')->__('Go to system check section'); ?></a>
6
+ </span>
7
+ <strong class="label"><?php echo $this->helper('iceimport')->__('Warning'); ?></strong>
8
+ <?php echo $this->helper('iceimport')->__("The Iceimport extensions doesn't work properly, please go to configuration page and check the problems."); ?>
9
+ </div>
10
+ <?php endif;?>
app/etc/modules/{Iceshop_Iceimport.xml → ICEshop_Iceimport.xml} RENAMED
@@ -1,9 +1,9 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <Iceshop_Iceimport>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- </Iceshop_Iceimport>
8
  </modules>
9
  </config>
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+ <ICEshop_Iceimport>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ </ICEshop_Iceimport>
8
  </modules>
9
  </config>
js/ICEshop/Iceimport/jquery-1.9.1.min.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license */
2
+ (function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],p="1.9.1",f=c.concat,d=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^[\],:{}\s]*$/,E=/(?:^|:|,)(?:\s*\[)+/g,S=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,A=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,j=/^-ms-/,D=/-([\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,"@").replace(A,"]").replace(E,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,"ms-").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,"string"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement("div");if(d.setAttribute("className","t"),d.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav></:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",a=d.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(o.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(B,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(X," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(w)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;
3
+ return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x="sizzle"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=F.replace("w","w#"),B="([*^$|!~]?=)",P="\\["+_+"*("+F+")"+_+"*(?:"+B+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+O+")|)|)"+_+"*\\]",R=":("+F+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+P.replace(3,8)+")*)|.*)\\)|)",W=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),$=RegExp("^"+_+"*,"+_+"*"),I=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),z=RegExp(R),X=RegExp("^"+O+"$"),U={ID:RegExp("^#("+F+")"),CLASS:RegExp("^\\.("+F+")"),NAME:RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:RegExp("^("+F.replace("w","w*")+")"),ATTR:RegExp("^"+P),PSEUDO:RegExp("^"+R),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,Y=/^[^{]+\{\s*\[native code/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,K=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute("id"))?g=f.replace(K,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute("id")}}}return wt(e.replace(W,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),T.attributes=at(function(e){e.innerHTML="<select></select>";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),T.getByClassName=at(function(e){return e.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML="<a name='"+x+"'></a><div name='"+x+"'></div>",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="<a href='#'></a>",e.firstChild&&typeof e.firstChild.getAttribute!==A&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="<input type='hidden' i=''/>",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",R)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,"='$1']"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&&gt(f),u>1&&dt(e.slice(0,u-1)).replace(W,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG("*",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Nt=/^(?:checkbox|radio)$/i,Ct=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:b.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(o),Dt=jt.appendChild(o.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ot(l,"script"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?Lt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(St,"")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,"script"),r.length>0&&Mt(r,!u&&Ot(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l)
4
+ }b.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),"script"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+x+")(.*)$","i"),Yt=RegExp("^("+x+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+x+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===b.css(e,"display")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=b._data(r,"olddisplay",un(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&b._data(r,"olddisplay",i?n:b.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||b.cssNumber[u]||(r+="px"),b.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=b.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=b.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=b.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=b.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),"none"!==n&&n||(Pt=(Pt||b("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=ln(e,t),Pt.detach()),Gt[e]=n),n}function ln(e,t){var n=b(t.createElement(e)).appendTo(t.body),r=b.css(n[0],"display");return n.remove(),r}b.each(["height","width"],function(e,n){b.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(b.css(e,"display"))?b.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,i),i):0)}}}),b.support.opacity||(b.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=b.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===b.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),b(function(){b.support.reliableMarginRight||(b.cssHooks.marginRight={get:function(e,n){return n?b.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!b.support.pixelPosition&&b.fn.position&&b.each(["top","left"],function(e,n){b.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?b(e).position()[n]+"px":r):t}}})}),b.expr&&b.expr.filters&&(b.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!b.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||b.css(e,"display"))},b.expr.filters.visible=function(e){return!b.expr.filters.hidden(e)}),b.each({margin:"",padding:"",border:"Width"},function(e,t){b.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(b.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;b.fn.extend({serialize:function(){return b.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=b.prop(this,"elements");return e?b.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!b(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Nt.test(e))}).map(function(e,t){var n=b(this).val();return null==n?null:b.isArray(n)?b.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),b.param=function(e,n){var r,i=[],o=function(e,t){t=b.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=b.ajaxSettings&&b.ajaxSettings.traditional),b.isArray(e)||e.jquery&&!b.isPlainObject(e))b.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(b.isArray(t))b.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==b.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}b.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){b.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),b.fn.hover=function(e,t){return this.mouseenter(e).mouseleave(t||e)};var mn,yn,vn=b.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Nn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Cn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=b.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=a.href}catch(Ln){yn=o.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(w)||[];if(b.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(u){var l;return o[u]=!0,b.each(e[u]||[],function(e,u){var c=u(n,r,i);return"string"!=typeof c||a||o[c]?a?!(l=c):t:(n.dataTypes.unshift(c),s(c),!1)}),l}return s(n.dataTypes[0])||!o["*"]&&s("*")}function Mn(e,n){var r,i,o=b.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&b.extend(!0,e,r),e}b.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,u=e.indexOf(" ");return u>=0&&(i=e.slice(u,e.length),e=e.slice(0,u)),b.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&b.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?b("<div>").append(b.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},b.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){b.fn[t]=function(e){return this.on(t,e)}}),b.each(["get","post"],function(e,n){b[n]=function(e,r,i,o){return b.isFunction(r)&&(o=o||i,i=r,r=t),b.ajax({url:e,type:n,dataType:o,data:r,success:i})}}),b.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Nn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":b.parseJSON,"text xml":b.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Mn(Mn(e,b.ajaxSettings),t):Mn(b.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,u,l,c,p=b.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?b(f):b.event,h=b.Deferred(),g=b.Callbacks("once memory"),m=p.statusCode||{},y={},v={},x=0,T="canceled",N={readyState:0,getResponseHeader:function(e){var t;if(2===x){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===x?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return x||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return x||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>x)for(t in e)m[t]=[m[t],e[t]];else N.always(e[N.status]);return this},abort:function(e){var t=e||T;return l&&l.abort(t),k(0,t),this}};if(h.promise(N).complete=g.add,N.success=N.done,N.error=N.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=b.trim(p.dataType||"*").toLowerCase().match(w)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?80:443))==(mn[3]||("http:"===mn[1]?80:443)))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=b.param(p.data,p.traditional)),qn(An,p,n,N),2===x)return N;u=p.global,u&&0===b.active++&&b.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Cn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(b.lastModified[o]&&N.setRequestHeader("If-Modified-Since",b.lastModified[o]),b.etag[o]&&N.setRequestHeader("If-None-Match",b.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&N.setRequestHeader("Content-Type",p.contentType),N.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)N.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,N,p)===!1||2===x))return N.abort();T="abort";for(i in{success:1,error:1,complete:1})N[i](p[i]);if(l=qn(jn,p,n,N)){N.readyState=1,u&&d.trigger("ajaxSend",[N,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){N.abort("timeout")},p.timeout));try{x=1,l.send(y,k)}catch(C){if(!(2>x))throw C;k(-1,C)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,C=n;2!==x&&(x=2,s&&clearTimeout(s),l=t,a=i||"",N.readyState=e>0?4:0,r&&(w=_n(p,N,r)),e>=200&&300>e||304===e?(p.ifModified&&(T=N.getResponseHeader("Last-Modified"),T&&(b.lastModified[o]=T),T=N.getResponseHeader("etag"),T&&(b.etag[o]=T)),204===e?(c=!0,C="nocontent"):304===e?(c=!0,C="notmodified"):(c=Fn(p,w),C=c.state,y=c.data,v=c.error,c=!v)):(v=C,(e||!C)&&(C="error",0>e&&(e=0))),N.status=e,N.statusText=(n||C)+"",c?h.resolveWith(f,[y,C,N]):h.rejectWith(f,[N,C,v]),N.statusCode(m),m=t,u&&d.trigger(c?"ajaxSuccess":"ajaxError",[N,p,c?y:v]),g.fireWith(f,[N,C]),u&&(d.trigger("ajaxComplete",[N,p]),--b.active||b.event.trigger("ajaxStop")))}return N},getScript:function(e,n){return b.get(e,t,n,"script")},getJSON:function(e,t,n){return b.get(e,t,n,"json")}});function _n(e,n,r){var i,o,a,s,u=e.contents,l=e.dataTypes,c=e.responseFields;for(s in c)s in r&&(n[c[s]]=r[s]);while("*"===l[0])l.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in u)if(u[s]&&u[s].test(o)){l.unshift(s);break}if(l[0]in r)a=l[0];else{for(s in r){if(!l[0]||e.converters[s+" "+l[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==l[0]&&l.unshift(a),r[a]):t}function Fn(e,t){var n,r,i,o,a={},s=0,u=e.dataTypes.slice(),l=u[0];if(e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u[1])for(i in e.converters)a[i.toLowerCase()]=e.converters[i];for(;r=u[++s];)if("*"!==r){if("*"!==l&&l!==r){if(i=a[l+" "+r]||a["* "+r],!i)for(n in a)if(o=n.split(" "),o[1]===r&&(i=a[l+" "+o[0]]||a["* "+o[0]])){i===!0?i=a[n]:a[n]!==!0&&(r=o[0],u.splice(s--,0,r));break}if(i!==!0)if(i&&e["throws"])t=i(t);else try{t=i(t)}catch(c){return{state:"parsererror",error:i?c:"No conversion from "+l+" to "+r}}}l=r}return{state:"success",data:t}}b.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return b.globalEval(e),e}}}),b.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),b.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=o.head||b("head")[0]||o.documentElement;return{send:function(t,i){n=o.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var On=[],Bn=/(=)\?(?=&|$)|\?\?/;b.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=On.pop()||b.expando+"_"+vn++;return this[e]=!0,e}}),b.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,u=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return u||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=b.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,u?n[u]=n[u].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||b.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,On.push(o)),s&&b.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}b.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=b.ajaxSettings.xhr(),b.support.cors=!!Rn&&"withCredentials"in Rn,Rn=b.support.ajax=!!Rn,Rn&&b.ajaxTransport(function(n){if(!n.crossDomain||b.support.cors){var r;return{send:function(i,o){var a,s,u=n.xhr();if(n.username?u.open(n.type,n.url,n.async,n.username,n.password):u.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)u[s]=n.xhrFields[s];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)u.setRequestHeader(s,i[s])}catch(l){}u.send(n.hasContent&&n.data||null),r=function(e,i){var s,l,c,p;try{if(r&&(i||4===u.readyState))if(r=t,a&&(u.onreadystatechange=b.noop,$n&&delete Pn[a]),i)4!==u.readyState&&u.abort();else{p={},s=u.status,l=u.getAllResponseHeaders(),"string"==typeof u.responseText&&(p.text=u.responseText);try{c=u.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,l)},n.async?4===u.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},b(e).unload($n)),Pn[a]=r),u.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+x+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n,r,i=this.createTween(e,t),o=Yn.exec(t),a=i.cur(),s=+a||0,u=1,l=20;if(o){if(n=+o[2],r=o[3]||(b.cssNumber[e]?"":"px"),"px"!==r&&s){s=b.css(i.elem,e,!0)||n||1;do u=u||".5",s/=u,b.style(i.elem,e,s+r);while(u!==(u=i.cur()/a)&&1!==u&&--l)}i.unit=r,i.start=s,i.end=o[1]?s+(o[1]+1)*n:n}return i}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=b.now()}function Zn(e,t){b.each(t,function(t,n){var r=(Qn[t]||[]).concat(Qn["*"]),i=0,o=r.length;for(;o>i;i++)if(r[i].call(e,t,n))return})}function er(e,t,n){var r,i,o=0,a=Gn.length,s=b.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;for(;u>a;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),1>o&&u?n:(s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:b.extend({},t),opts:b.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=b.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)l.tweens[n].run(1);return t?s.resolveWith(e,[l,t]):s.rejectWith(e,[l,t]),this}}),c=l.props;for(tr(c,l.opts.specialEasing);a>o;o++)if(r=Gn[o].call(l,e,c,l.opts))return r;return Zn(l,c),b.isFunction(l.opts.start)&&l.opts.start.call(e,l),b.fx.timer(b.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always)}function tr(e,t){var n,r,i,o,a;for(i in e)if(r=b.camelCase(i),o=t[r],n=e[i],b.isArray(n)&&(o=n[1],n=e[i]=n[0]),i!==r&&(e[r]=n,delete e[i]),a=b.cssHooks[r],a&&"expand"in a){n=a.expand(n),delete e[r];for(i in n)i in e||(e[i]=n[i],t[i]=o)}else t[r]=o}b.Animation=b.extend(er,{tweener:function(e,t){b.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,u,l,c,p,f=this,d=e.style,h={},g=[],m=e.nodeType&&nn(e);n.queue||(c=b._queueHooks(e,"fx"),null==c.unqueued&&(c.unqueued=0,p=c.empty.fire,c.empty.fire=function(){c.unqueued||p()}),c.unqueued++,f.always(function(){f.always(function(){c.unqueued--,b.queue(e,"fx").length||c.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[d.overflow,d.overflowX,d.overflowY],"inline"===b.css(e,"display")&&"none"===b.css(e,"float")&&(b.support.inlineBlockNeedsLayout&&"inline"!==un(e.nodeName)?d.zoom=1:d.display="inline-block")),n.overflow&&(d.overflow="hidden",b.support.shrinkWrapBlocks||f.always(function(){d.overflow=n.overflow[0],d.overflowX=n.overflow[1],d.overflowY=n.overflow[2]}));for(i in t)if(a=t[i],Vn.exec(a)){if(delete t[i],u=u||"toggle"===a,a===(m?"hide":"show"))continue;g.push(i)}if(o=g.length){s=b._data(e,"fxshow")||b._data(e,"fxshow",{}),"hidden"in s&&(m=s.hidden),u&&(s.hidden=!m),m?b(e).show():f.done(function(){b(e).hide()}),f.done(function(){var t;b._removeData(e,"fxshow");for(t in h)b.style(e,t,h[t])});for(i=0;o>i;i++)r=g[i],l=f.createTween(r,m?s[r]:0),h[r]=s[r]||b.style(e,r),r in s||(s[r]=l.start,m&&(l.end=l.start,l.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}b.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(b.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?b.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=b.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){b.fx.step[e.prop]?b.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[b.cssProps[e.prop]]||b.cssHooks[e.prop])?b.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},b.each(["toggle","show","hide"],function(e,t){var n=b.fn[t];b.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),b.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=b.isEmptyObject(e),o=b.speed(t,n,r),a=function(){var t=er(this,b.extend({},e),o);a.finish=function(){t.stop(!0)},(i||b._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=b.timers,a=b._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&b.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=b._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=b.timers,a=r?r.length:0;for(n.finish=!0,b.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}b.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){b.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),b.speed=function(e,t,n){var r=e&&"object"==typeof e?b.extend({},e):{complete:n||!n&&t||b.isFunction(e)&&e,duration:e,easing:n&&t||t&&!b.isFunction(t)&&t};return r.duration=b.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in b.fx.speeds?b.fx.speeds[r.duration]:b.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){b.isFunction(r.old)&&r.old.call(this),r.queue&&b.dequeue(this,r.queue)},r},b.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},b.timers=[],b.fx=rr.prototype.init,b.fx.tick=function(){var e,n=b.timers,r=0;for(Xn=b.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||b.fx.stop(),Xn=t},b.fx.timer=function(e){e()&&b.timers.push(e)&&b.fx.start()},b.fx.interval=13,b.fx.start=function(){Un||(Un=setInterval(b.fx.tick,b.fx.interval))},b.fx.stop=function(){clearInterval(Un),Un=null},b.fx.speeds={slow:600,fast:200,_default:400},b.fx.step={},b.expr&&b.expr.filters&&(b.expr.filters.animated=function(e){return b.grep(b.timers,function(t){return e===t.elem}).length}),b.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){b.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,b.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},b.offset={setOffset:function(e,t,n){var r=b.css(e,"position");"static"===r&&(e.style.position="relative");var i=b(e),o=i.offset(),a=b.css(e,"top"),s=b.css(e,"left"),u=("absolute"===r||"fixed"===r)&&b.inArray("auto",[a,s])>-1,l={},c={},p,f;u?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),b.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(l.top=t.top-o.top+p),null!=t.left&&(l.left=t.left-o.left+f),"using"in t?t.using.call(e,l):i.css(l)}},b.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===b.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),b.nodeName(e[0],"html")||(n=e.offset()),n.top+=b.css(e[0],"borderTopWidth",!0),n.left+=b.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-b.css(r,"marginTop",!0),left:t.left-n.left-b.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||o.documentElement;while(e&&!b.nodeName(e,"html")&&"static"===b.css(e,"position"))e=e.offsetParent;return e||o.documentElement})}}),b.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);b.fn[e]=function(i){return b.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?b(a).scrollLeft():o,r?o:b(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return b.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}b.each({Height:"height",Width:"width"},function(e,n){b.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){b.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return b.access(this,function(n,r,i){var o;return b.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?b.css(n,r,s):b.style(n,r,i,s)},n,a?i:t,a,null)}})}),e.jQuery=e.$=b,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return b})})(window);
js/ICEshop/Iceimport/script.js ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //prevent conflict of Prototype and jQuery libraries
2
+ jQuery.noConflict();
3
+
4
+ //script which starts after page is loaded
5
+ jQuery(document).ready(function () {
6
+
7
+ jQuery('div#content').on('click', 'a.section-toggler-iceimport', function(e){
8
+ toggleIceimportFieldset(this);
9
+ e.preventDefault();
10
+ });
11
+
12
+ jQuery('div#content').on('click.go-to-section', 'a.section-toggler-trigger-iceimport', function(e){
13
+ var handler = jQuery(this);
14
+ var section = handler.data('href');
15
+ if (typeof section != 'undefined') {
16
+ toggleIceimportFieldset(jQuery(section).next('.entry-edit').find('.section-toggler-iceimport'), 'open');
17
+ }
18
+ });
19
+
20
+ refreshIceimportSystemCheck();
21
+
22
+ buildIceshopInfo();
23
+ });
24
+
25
+ function buildIceshopInfo()
26
+ {
27
+ var iceshop_info_handler = jQuery('#iceshop_about_iceshop_iframe');
28
+ if (iceshop_info_handler.length > 0) {
29
+ var iceshop_info_el = jQuery('#iceshop_about_iceshop_iframe_iceshop_iframe_hidden', iceshop_info_handler);
30
+ var iceshop_info_url = Base64.decode(iceshop_info_el.find('option')[0].innerHTML);
31
+ var wrapper = iceshop_info_el.closest('form#config_edit_form div.entry-edit');
32
+ wrapper.find('div.section-config').remove();
33
+ var iceshop_info_iframe_el = jQuery('<iframe></iframe>')
34
+ .attr('src', iceshop_info_url)
35
+ .attr('width', '100%')
36
+ .attr('height', '1000')
37
+ .text('Your browser doesn\'t work with iframe elements');
38
+ iceshop_info_iframe_el.appendTo(wrapper);
39
+ jQuery('div.entry-edit').closest('div.main-col-inner').find('div.content-header').find('table td.form-buttons').hide();
40
+ jQuery('div.content-header-floating').find('table td.form-buttons').html('');
41
+ }
42
+ }
43
+
44
+ function refreshIceimportSystemCheck(url_string) {
45
+ if (typeof url_string == 'undefined') {
46
+ var checking_dashboard = jQuery('#iceimport_information_dashboard');
47
+ if (checking_dashboard.length > 0) {
48
+ //we're on dashboard page, lod the code
49
+ var request_url_el = jQuery('#iceimport_information_dashboard_check_system_hidden', checking_dashboard);
50
+ var request_url = Base64.decode(request_url_el.find('option')[0].innerHTML);
51
+ request_url_el.closest('table').remove();
52
+ jQuery.getJSON(
53
+ request_url,
54
+ function (response) {
55
+ if (typeof response.structure != 'undefined') {
56
+ jQuery('div.entry-edit').html(response.structure);
57
+ }
58
+ if (typeof response.refresh_btn != 'undefined') {
59
+ jQuery('div.entry-edit').closest('div.main-col-inner').find('div.content-header').find('table td.form-buttons').html(response.refresh_btn);
60
+ jQuery('div.content-header-floating').find('table td.form-buttons').html(response.refresh_btn);
61
+ }
62
+ }
63
+ );
64
+ }
65
+ } else {
66
+ jQuery.getJSON(
67
+ Base64.decode(url_string),
68
+ function (response) {
69
+ if (typeof response.structure != 'undefined') {
70
+ jQuery('div.entry-edit').html(response.structure);
71
+ }
72
+ if (typeof response.refresh_btn != 'undefined') {
73
+ jQuery('div.entry-edit').closest('div.main-col-inner').find('div.content-header').find('table td.form-buttons').html(response.refresh_btn);
74
+ jQuery('div.content-header-floating').find('table td.form-buttons').html(response.refresh_btn);
75
+ }
76
+ }
77
+ );
78
+ }
79
+ }
80
+
81
+ function toggleIceimportFieldset(element, action_type)
82
+ {
83
+ if (typeof element != 'undefined') {
84
+ if (typeof action_type != 'undefined') {
85
+ switch(action_type) {
86
+ case 'open':
87
+ var handler = jQuery(element);
88
+ console.log(element);
89
+ if (!handler.hasClass('open')) {
90
+ handler.toggleClass('open');
91
+ handler.closest('.entry-edit').find('div.fieldset').toggleClass('iceimport-hidden');
92
+ }
93
+ return true;
94
+ break;
95
+ case 'close':
96
+ var handler = jQuery(element);
97
+ if (handler.hasClass('open')) {
98
+ handler.toggleClass('open');
99
+ handler.closest('.entry-edit').find('div.fieldset').toggleClass('iceimport-hidden');
100
+ }
101
+ return true;
102
+ break;
103
+ }
104
+ } else {
105
+ var handler = jQuery(element);
106
+ handler.toggleClass('open');
107
+ handler.closest('.entry-edit').find('div.fieldset').toggleClass('iceimport-hidden');
108
+ return true;
109
+ }
110
+ }
111
+ return false;
112
+ }
113
+
114
+ var Base64 = {
115
+ // private property
116
+ _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
117
+
118
+ // public method for encoding
119
+ encode: function (input) {
120
+ var output = "";
121
+ var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
122
+ var i = 0;
123
+
124
+ input = Base64._utf8_encode(input);
125
+
126
+ while (i < input.length) {
127
+
128
+ chr1 = input.charCodeAt(i++);
129
+ chr2 = input.charCodeAt(i++);
130
+ chr3 = input.charCodeAt(i++);
131
+
132
+ enc1 = chr1 >> 2;
133
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
134
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
135
+ enc4 = chr3 & 63;
136
+
137
+ if (isNaN(chr2)) {
138
+ enc3 = enc4 = 64;
139
+ } else if (isNaN(chr3)) {
140
+ enc4 = 64;
141
+ }
142
+
143
+ output = output +
144
+ Base64._keyStr.charAt(enc1) + Base64._keyStr.charAt(enc2) +
145
+ Base64._keyStr.charAt(enc3) + Base64._keyStr.charAt(enc4);
146
+
147
+ }
148
+
149
+ return output;
150
+ },
151
+
152
+ // public method for decoding
153
+ decode: function (input) {
154
+ var output = "";
155
+ var chr1, chr2, chr3;
156
+ var enc1, enc2, enc3, enc4;
157
+ var i = 0;
158
+
159
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
160
+
161
+ while (i < input.length) {
162
+
163
+ enc1 = Base64._keyStr.indexOf(input.charAt(i++));
164
+ enc2 = Base64._keyStr.indexOf(input.charAt(i++));
165
+ enc3 = Base64._keyStr.indexOf(input.charAt(i++));
166
+ enc4 = Base64._keyStr.indexOf(input.charAt(i++));
167
+
168
+ chr1 = (enc1 << 2) | (enc2 >> 4);
169
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
170
+ chr3 = ((enc3 & 3) << 6) | enc4;
171
+
172
+ output = output + String.fromCharCode(chr1);
173
+
174
+ if (enc3 != 64) {
175
+ output = output + String.fromCharCode(chr2);
176
+ }
177
+ if (enc4 != 64) {
178
+ output = output + String.fromCharCode(chr3);
179
+ }
180
+
181
+ }
182
+
183
+ output = Base64._utf8_decode(output);
184
+
185
+ return output;
186
+
187
+ },
188
+
189
+ // private method for UTF-8 encoding
190
+ _utf8_encode: function (string) {
191
+ string = string.replace(/\r\n/g, "\n");
192
+ var utftext = "";
193
+
194
+ for (var n = 0; n < string.length; n++) {
195
+
196
+ var c = string.charCodeAt(n);
197
+
198
+ if (c < 128) {
199
+ utftext += String.fromCharCode(c);
200
+ }
201
+ else if ((c > 127) && (c < 2048)) {
202
+ utftext += String.fromCharCode((c >> 6) | 192);
203
+ utftext += String.fromCharCode((c & 63) | 128);
204
+ }
205
+ else {
206
+ utftext += String.fromCharCode((c >> 12) | 224);
207
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
208
+ utftext += String.fromCharCode((c & 63) | 128);
209
+ }
210
+
211
+ }
212
+
213
+ return utftext;
214
+ },
215
+
216
+ // private method for UTF-8 decoding
217
+ _utf8_decode: function (utftext) {
218
+ var string = "";
219
+ var i = 0;
220
+ var c = 0;
221
+ var c2 = 0;
222
+ var c3 = 0;
223
+
224
+ while (i < utftext.length) {
225
+
226
+ c = utftext.charCodeAt(i);
227
+
228
+ if (c < 128) {
229
+ string += String.fromCharCode(c);
230
+ i++;
231
+ }
232
+ else if ((c > 191) && (c < 224)) {
233
+ c2 = utftext.charCodeAt(i + 1);
234
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
235
+ i += 2;
236
+ }
237
+ else {
238
+ c2 = utftext.charCodeAt(i + 1);
239
+ c3 = utftext.charCodeAt(i + 2);
240
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
241
+ i += 3;
242
+ }
243
+
244
+ }
245
+ return string;
246
+ }
247
+ }
package.xml CHANGED
@@ -1,23 +1,43 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ice_import</name>
4
- <version>1.6.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Import categories &amp;amp; products</summary>
10
  <description>This extension can use to import products with categories, multiple images and custom options from CSV file.</description>
11
- <notes>Bugfixes:&#xD;
12
- - fixed bug with database table prefix&#xD;
13
- - fixed bug with checking required attributes in default attribute set&#xD;
14
- Improvements:&#xD;
15
- - Changed logic of assigning categories, products assigned only to the last category in the tree&#xD;
16
- - Added ability to save data in dropdown fields as example "Brand", then it's possible to use in layered navigation</notes>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  <authors><author><name>Iceshop</name><user>Iceshop</user><email>support@iceshop.nl</email></author></authors>
18
- <date>2014-02-19</date>
19
- <time>12:18:02</time>
20
- <contents><target name="magecommunity"><dir name="Iceshop"><dir name="Iceimport"><dir name="Model"><dir name="Convert"><dir name="Adapter"><file name="Product.php" hash="7125fba31031669fb49188975581cf65"/></dir></dir><dir name="Dataflow"><dir name="Batch"><file name="Import.php" hash="90a3fdd194991e4b1a0c1e6dd2ba3db1"/></dir><dir name="Convert"><dir name="Parser"><file name="Csv.php" hash="9d655cf42f686084327f2e6de215d9fb"/></dir></dir></dir><file name="Observer.php" hash="b392ef90dec09ff51e3a0984f3523677"/><dir name="System"><dir name="Config"><file name="Categoryactivity.php" hash="c60f739b06f29e47f3098bf91bc0b8fd"/><file name="Defaulttax.php" hash="d5d3b7b5862ef1264ee4b960e8dbb627"/><file name="Imageimport.php" hash="d4f67a21d5b8731716c6246a30f7a01f"/><file name="Importdeliveryeta.php" hash="0807017f687f4adeb76129dcb7f5358c"/><file name="Importprices.php" hash="1367181841e8c93f67160dbc497fa658"/><file name="Importproductbrand.php" hash="5b210f5ae30bcd69c8215f0db15f873f"/><file name="Importproductdescription.php" hash="47e0df7a29e9eb9b35e6b9b85a94d757"/><file name="Importproductean.php" hash="4e5ba806f6c31705df6797e9703a714c"/><file name="Importproductmpn.php" hash="9dc525200e8782f9161e59ea20d97517"/><file name="Importproductname.php" hash="c9a6c970105bf3ce9a368351fa27d2d6"/><file name="Importproductshdescription.php" hash="86b361fe2a483757cbd3c37a7cd556bb"/><file name="Importproductshsudescription.php" hash="c0b75d1b619f39db30d4529cc2981652"/><file name="Importproductsudescription.php" hash="8b21d2e05ac3e8f47a6eda5380fb0f49"/><file name="Importstock.php" hash="dcd5838f2b8d21f374b621bc440d9a7c"/><file name="Lockproddetails.php" hash="66107a746bb9a50c8d74e3f27bdaaedf"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="9dd90caa78c5eeac27c8c02858b9738a"/><file name="system.xml" hash="17cbe85949a33a4eb3fa301092714fa0"/></dir><dir name="sql"><dir name="iceimport_setup"><file name="mysql4-install-1.5.0.php" hash="c90722a11b7de7d23d92f12bd37d3706"/><file name="mysql4-upgrade-0.1.0-1.5.0.php" hash="26cded28767c71f2d4945e9866b7feb0"/><file name="mysql4-upgrade-1.4.0-1.5.0.php" hash="07b4b6f1e01d253db017038bd1985170"/><file name="uninstall-old-version.php" hash="291f724845f8e62d51ccdf61baf81b37"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iceshop_Iceimport.xml" hash="c22b6e566abee45bbb2102b3239cd6a2"/></dir></target></contents>
21
  <compatible/>
22
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
23
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ice_import</name>
4
+ <version>1.7.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Import categories &amp; products</summary>
10
  <description>This extension can use to import products with categories, multiple images and custom options from CSV file.</description>
11
+ <notes>Release notes&#xD;
12
+ &#xD;
13
+ Dashboard:&#xD;
14
+ - Server setup requirements&#xD;
15
+ - Statistic information&#xD;
16
+ - Self problem detection&#xD;
17
+ - Errors notification&#xD;
18
+ &#xD;
19
+ New settings with Yes/No option:&#xD;
20
+ - Hide empty category&#xD;
21
+ - Sort categories in ASC order&#xD;
22
+ - Remove old products&#xD;
23
+ - Import new products&#xD;
24
+ - Update URL key&#xD;
25
+ - Update stock availability&#xD;
26
+ - Update visibility&#xD;
27
+ - Update status&#xD;
28
+ - Update products category&#xD;
29
+ &#xD;
30
+ New general settings:&#xD;
31
+ - Batch size&#xD;
32
+ - Tolerance of difference (%), If difference is greater than this value - remove process will be cancelled.&#xD;
33
+ &#xD;
34
+ Bugfixes:&#xD;
35
+ - Categories importing&#xD;
36
+ - Removing old products</notes>
37
  <authors><author><name>Iceshop</name><user>Iceshop</user><email>support@iceshop.nl</email></author></authors>
38
+ <date>2014-05-22</date>
39
+ <time>07:35:04</time>
40
+ <contents><target name="magecommunity"><dir name="ICEshop"><dir name="Iceimport"><dir><dir name="Block"><dir name="Adminhtml"><file name="Notifications.php" hash="72fb1436a56e3da023983a1c0e97c638"/></dir></dir><dir name="Helper"><file name="Data.php" hash="fd9775a248481ddd683926452affb9ff"/><file name="Db.php" hash="82a50791a03feb3ee634c1b60f2845da"/><file name="Format.php" hash="5c56ce9db24076c52b198325fb637758"/><dir name="System"><file name="System.php" hash="ff58fc97338b95e165de85ef640147de"/><file name="Systemcheck.php" hash="76b96485beefaf17bca4f40dcdce78b3"/></dir></dir><dir name="Model"><dir name="Convert"><dir name="Adapter"><file name="Product.php" hash="8b205686944f8f2934d4de504f9f51ea"/></dir></dir><dir name="Dataflow"><dir name="Batch"><file name="Import.php" hash="52c0ed7367b2200a17a48103e953ae58"/></dir><dir name="Convert"><dir name="Parser"><file name="Csv.php" hash="c9dfbfe575d6f730911bf7da4c977c31"/></dir></dir></dir><file name="Observer.php" hash="4f1fbf6630b6ab49d89376bb0f9dbdd6"/><dir name="System"><dir name="Config"><file name="Checksystem.php" hash="260200dc8cecfa718b32fa47468282df"/><file name="Defaulttax.php" hash="2baea942efcc3880d785da9f021f04fc"/><file name="Iceshoplink.php" hash="e77e62b0c00e2569ea5fdb0fb91ff90a"/><file name="Yesno.php" hash="59e349561a36e02f44b47301fce99ef5"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IceimportController.php" hash="10440af0556f950fbdf9f32c7f8bc2ef"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ccc6e54f97814cd40e75ee93b7b242a8"/><file name="config.xml" hash="04350f0961ae19bcd06d1aaeb3bfb7a4"/><file name="system.xml" hash="9138d8496f65c89565483caa0ff7b735"/></dir><dir name="sql"><dir name="iceimport_setup"><file name="mysql4-install-1.7.3.php" hash="7d38ce5d3ff7a8e519acdd06bea107ff"/><file name="mysql4-upgrade-0.1.0-1.7.0.php" hash="9d3c6b645fd4546552eec4d65ba41275"/><file name="mysql4-upgrade-1.4.0-1.7.0.php" hash="9d3c6b645fd4546552eec4d65ba41275"/><file name="mysql4-upgrade-1.5.0-1.7.0.php" hash="8ec0593b60ff13ffdf4afdf3ca74634d"/><file name="mysql4-upgrade-1.6.0-1.7.0.php" hash="8ec0593b60ff13ffdf4afdf3ca74634d"/><file name="mysql4-upgrade-1.7.0-1.7.5.php" hash="aac071b5334697f4fac119c533582c19"/><file name="uninstall-old-version.php" hash="4269e8547005958b044946d5e2d670e9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ICEshop_Iceimport.xml" hash="b94f339b79303bf7e78ba89290c66ada"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="ICEshop_Iceimport.xml" hash="fee9d6f2980b94e1c79dae0088dbda0f"/></dir><dir name="template"><dir name="iceshop"><dir name="iceimport"><file name="notifications.phtml" hash="ca9e0e2082c659a684e5ab79c432e25f"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="ICEshop"><dir name="Iceimport"><file name="jquery-1.9.1.min.js" hash="fee4c9e0129fb2b8830a3c17638c44b0"/><file name="script.js" hash="fff12088d0453e7bc0d254ce81fb4793"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="iceshop"><dir name="iceimport"><dir><dir name="images"><file name="iceshop_logo_small_16px.png" hash="4ef632b4b89a047789307b301b9dfb6e"/></dir></dir><file name="styles.css" hash="9d9d5064de683afaff19446b908cb711"/></dir></dir></dir></dir></dir></target></contents>
41
  <compatible/>
42
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
43
  </package>
skin/adminhtml/default/default/iceshop/iceimport/images/iceshop_logo_small_16px.png ADDED
Binary file
skin/adminhtml/default/default/iceshop/iceimport/styles.css ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #iceimport-warning {
2
+ background-color: #ef672f;
3
+ background-image: none;
4
+ border-bottom: none;
5
+ border-color: #c14800;
6
+ border-top: none;
7
+ color: #ffffff;
8
+ font-weight: bold;
9
+ }
10
+
11
+ #iceimport-warning .f-right {
12
+ background-color: #31302b;
13
+ display: inline-block;
14
+ height: 17px;
15
+ margin: -5px 0 -5px 0;
16
+ padding: 5px 10px 5px 10px;
17
+ }
18
+
19
+ #iceimport-warning .f-right a {
20
+ color: #ffffff;
21
+ font-weight: bold;
22
+ text-decoration: none;
23
+ }
24
+
25
+ #iceimport-warning .f-right a:hover {
26
+ color: #ef672f;
27
+ }
28
+
29
+ #iceimport-warning strong {
30
+ background-color: #31302b;
31
+ color: #ffffff;
32
+ display: inline-block;
33
+ font-weight: bold;
34
+ height: 17px;
35
+ margin: -5px 10px -5px 0;
36
+ padding: 5px 10px 5px 10px;
37
+ text-transform: uppercase;
38
+ }
39
+
40
+ .iceimport-hidden {
41
+ display: none;
42
+ }
43
+
44
+ #iceimport-digest td.label {
45
+ width: 105px;
46
+ }
47
+
48
+ #iceimport-digest td.label label {
49
+ width: 70px;
50
+ }
51
+
52
+ #iceimport-digest td.label label.problem-digest {
53
+ background: url(../../images/error_msg_icon.gif) 0px 1px no-repeat;
54
+ color: #ef672f;
55
+ font-weight: bold;
56
+ padding-left: 20px;
57
+ }
58
+
59
+ .full-width,
60
+ #iceimport-digest td.value {
61
+ width: 100% !important;
62
+ }
63
+
64
+ .iceimport-label-bold {
65
+ font-weight: bold;
66
+ }
67
+
68
+ .iceimport-label-uppercase {
69
+ text-transform: uppercase;
70
+ }
71
+
72
+ .iceimport-label-rewrite {
73
+ display: inline-block;
74
+ width: 120px;
75
+ }
76
+
77
+ .requirement-passed {
78
+ color: green;
79
+ }
80
+
81
+ .requirement-failed {
82
+ color: #ef672f;
83
+ }
84
+
85
+ a.iceimport-advice {
86
+ background: url(../../images/fam_help.gif) 0px 0px no-repeat;
87
+ display: inline-block;
88
+ height: 16px;
89
+ margin: -4px 0 -4px 4px;
90
+ width: 16px;
91
+ }
92
+
93
+ span.iceimport-pad-label {
94
+ display: inline-block;
95
+ width: 120px;
96
+ }
97
+
98
+ ul.tabs a.iceshop-info-section,
99
+ ul.tabs a.iceshop-info-section:hover {
100
+ background: url(../../images/tabs_span_bg.gif) repeat-x 0 100%;
101
+ border-bottom: none;
102
+ padding: 0.5em 0.5em 0.28em 1.5em;
103
+ }
104
+
105
+ ul.tabs a.iceshop-info-section:hover {
106
+ background-color: #d8e6e6;
107
+ }
108
+
109
+ ul.tabs a.iceshop-info-section.active, ul.tabs a.iceshop-info-section.active:hover {
110
+ background-color: #fff;
111
+ }
112
+
113
+ ul.tabs a.iceshop-info-section span,
114
+ ul.tabs a.iceshop-info-section:hover span {
115
+ background: url(./images/iceshop_logo_small_16px.png) no-repeat 0 0;
116
+ height: 0;
117
+ overflow: hidden;
118
+ padding: 16px 0 0;
119
+ width: 65px;
120
+ }
121
+
122
+ #row_iceshop_about_iceshop_iframe_iceshop_iframe_hidden {
123
+ display: none;
124
+ }