stockinthechannel2012 - Version 2.0.6

Version Notes

Version 2.0.6:
* Update available servers to reflect new regions

Download this release

Release Info

Developer stockinchannel
Extension stockinthechannel2012
Version 2.0.6
Comparing to
See all releases


Code changes from version 2.0.5 to 2.0.6

Files changed (23) hide show
  1. app/code/local/Bintime/Sinchimport/Block/Adminhtml/Catalog/Product/Sinchdistributors.php +25 -25
  2. app/code/local/Bintime/Sinchimport/Block/Importenvironment.php +210 -210
  3. app/code/local/Bintime/Sinchimport/Block/Importhistory.php +386 -386
  4. app/code/local/Bintime/Sinchimport/Block/Layer/Filter/Feature.php +17 -17
  5. app/code/local/Bintime/Sinchimport/Block/Layer/View.php +48 -48
  6. app/code/local/Bintime/Sinchimport/Block/List.php +159 -159
  7. app/code/local/Bintime/Sinchimport/Block/Product/View/Media.php +19 -19
  8. app/code/local/Bintime/Sinchimport/Block/Startimportbutton.php +344 -344
  9. app/code/local/Bintime/Sinchimport/Block/Startstockpriceimportbutton.php +138 -138
  10. app/code/local/Bintime/Sinchimport/Helper/Data.php +6 -6
  11. app/code/local/Bintime/Sinchimport/Helper/Getdata.php +186 -186
  12. app/code/local/Bintime/Sinchimport/Helper/Image.php +73 -73
  13. app/code/local/Bintime/Sinchimport/Model/Api.php +86 -86
  14. app/code/local/Bintime/Sinchimport/Model/Category.php +20 -20
  15. app/code/local/Bintime/Sinchimport/Model/Image.php +118 -118
  16. app/code/local/Bintime/Sinchimport/Model/Layer.php +49 -49
  17. app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Feature.php +260 -260
  18. app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Price.php +194 -194
  19. app/code/local/Bintime/Sinchimport/Model/Product.php +74 -74
  20. app/code/local/Bintime/Sinchimport/Model/Resource/Layer/Filter/Price.php +80 -80
  21. app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php +384 -384
  22. app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Setup.php +4 -4
  23. app/code/local/Bintime/Sinchimport/Model/Sinch.php +9292 -9939
app/code/local/Bintime/Sinchimport/Block/Adminhtml/Catalog/Product/Sinchdistributors.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
- class Bintime_Sinchimport_Block_Adminhtml_Catalog_Product_Sinchdistributors extends Mage_Core_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
3
- {
4
- public function __construct(){
5
- $this->setTemplate('sinchimport/sinchdistributors.phtml');
6
- parent::__construct();
7
- }
8
-
9
- //Label to be shown in the tab
10
- public function getTabLabel(){
11
- return Mage::helper('core')->__('Suppliers');
12
- }
13
-
14
- public function getTabTitle(){
15
- return Mage::helper('core')->__('Suppliers');
16
- }
17
-
18
- public function canShowTab(){
19
- return true;
20
- }
21
-
22
- public function isHidden(){
23
- return false;
24
- }
25
- }
1
+ <?php
2
+ class Bintime_Sinchimport_Block_Adminhtml_Catalog_Product_Sinchdistributors extends Mage_Core_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
3
+ {
4
+ public function __construct(){
5
+ $this->setTemplate('sinchimport/sinchdistributors.phtml');
6
+ parent::__construct();
7
+ }
8
+
9
+ //Label to be shown in the tab
10
+ public function getTabLabel(){
11
+ return Mage::helper('core')->__('Suppliers');
12
+ }
13
+
14
+ public function getTabTitle(){
15
+ return Mage::helper('core')->__('Suppliers');
16
+ }
17
+
18
+ public function canShowTab(){
19
+ return true;
20
+ }
21
+
22
+ public function isHidden(){
23
+ return false;
24
+ }
25
+ }
app/code/local/Bintime/Sinchimport/Block/Importenvironment.php CHANGED
@@ -1,210 +1,210 @@
1
- <?php
2
-
3
-
4
-
5
-
6
- class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field {
7
-
8
-
9
-
10
-
11
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
12
- $this->setElement($element);
13
- $url = $this->getUrl('sinchimport/index');
14
- $this->setElement($element);
15
-
16
- $html = '';
17
-
18
- //$html .= '<div class="comment"><H3>'.("Your Stock In The Channel Environment Check Summary" ).'</H3></div>';
19
-
20
- //$html .= '<div class="comment"><H3>'.("In order for this extension to work, your server needs to be configured in a particular way and have sufficient memory." ).'</H3></div>';
21
-
22
-
23
- $html .= '
24
- <table class="history">
25
- <thead>
26
- <tr>
27
- <th>Checked</th>
28
- <th>Necessary, Error And Fix</th>
29
-
30
- </tr>
31
- </thead><tbody>';
32
- // <th>Necessary</th>
33
- // <th>Fix</th>
34
-
35
- $errors_count = 0;
36
-
37
- // Memory total
38
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkMemory();
39
- if ($status == 'error') $errors_count++;
40
- if ($status == 'error') {
41
- $html .= // $caption: $value $measure
42
- "
43
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
44
- <tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
45
- <tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
46
- <tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
47
- ";
48
- };
49
-
50
-
51
-
52
- // Mysql parameter LOCAL DATA LOCAL
53
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkLoaddata();
54
- if ($status == 'error') $errors_count++;
55
- if ($status == 'error') {
56
- $html .= // $caption: $value $measure
57
- "
58
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
59
- <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
60
- <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
61
- <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
62
- ";
63
- };
64
-
65
-
66
- // PHP safe mode
67
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhpsafemode();
68
- if ($status == 'error') $errors_count++;
69
- if ($status == 'error') {
70
- $html .= // $caption: $value $measure
71
- "
72
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
73
- <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
74
- <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
75
- <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
76
- ";
77
- };
78
-
79
-
80
- // Mysql parameter wait_timeout
81
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkWaittimeout();
82
- if ($status == 'error') $errors_count++;
83
- if ($status == 'error') {
84
- $html .= // $caption: $value $measure
85
- "
86
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
87
- <tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
88
- <tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
89
- <tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
90
- ";
91
- };
92
-
93
-
94
- // Mysql parameter innodb_buffer_pool_size
95
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkInnodbbufferpoolsize();
96
- if ($status == 'error') $errors_count++;
97
- if ($status == 'error') {
98
- $html .= // $caption: $value $measure
99
- "
100
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
101
- <tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
102
- <tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
103
- <tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
104
- ";
105
- };
106
-
107
-
108
- // Conflict with installed module
109
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkConflictsWithInstalledModules();
110
- if ($status == 'error') $errors_count++;
111
- if ($status == 'error') {
112
- $html .= // $caption: $value $measure
113
- "
114
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
115
- <tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
116
- <tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
117
- <tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
118
- ";
119
- };
120
-
121
-
122
- // PHP run string
123
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhprunstring();
124
- if ($status == 'error') $errors_count++;
125
- if ($status == 'error') {
126
- $html .= // $caption: $value $measure
127
- "
128
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
129
- <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
130
- <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
131
- <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
132
- ";
133
- };
134
-
135
-
136
- // Chmod wget file
137
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetdatafile();
138
- if ($status == 'error') $errors_count++;
139
- if ($status == 'error') {
140
- $html .= // $caption: $value $measure
141
- "
142
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
143
- <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
144
- <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
145
- <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
146
- ";
147
- };
148
-
149
-
150
- // Chmod wget cron.php file
151
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronphpfile();
152
- if ($status == 'error') $errors_count++;
153
- if ($status == 'error') {
154
- $html .= // $caption: $value $measure
155
- "
156
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
157
- <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
158
- <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
159
- <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
160
- ";
161
- };
162
-
163
- // Chmod wget cron.sh file
164
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronshfile();
165
- if ($status == 'error') $errors_count++;
166
- if ($status == 'error') {
167
- $html .= // $caption: $value $measure
168
- "
169
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
170
- <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
171
- <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
172
- <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
173
- ";
174
- };
175
-
176
- // Mysql stored procedure filter_sinch_products_s
177
- list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkProcedure();
178
- if ($status == 'error') $errors_count++;
179
- if ($status == 'error') {
180
- $html .= // $caption: $value $measure
181
- "
182
- <tr> <td nowrap rowspan=4> $caption </td> </tr>
183
- <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
184
- <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
185
- <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
186
- ";
187
- };
188
-
189
-
190
- $html .= '
191
- </tbody>
192
- </table>';
193
-
194
- $html .= '<div class="comment"><H3>'.("There are $errors_count notices." ).'</H3></div>';
195
-
196
- // all checks
197
- return $html;
198
-
199
- } // protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
200
-
201
- protected function _colored($str, $color){
202
- return "<b><span style='color:{$color}'>{$str}</span></b>";
203
- }
204
-
205
-
206
- } // class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field
207
-
208
-
209
-
210
-
1
+ <?php
2
+
3
+
4
+
5
+
6
+ class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field {
7
+
8
+
9
+
10
+
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
12
+ $this->setElement($element);
13
+ $url = $this->getUrl('sinchimport/index');
14
+ $this->setElement($element);
15
+
16
+ $html = '';
17
+
18
+ //$html .= '<div class="comment"><H3>'.("Your Stock In The Channel Environment Check Summary" ).'</H3></div>';
19
+
20
+ //$html .= '<div class="comment"><H3>'.("In order for this extension to work, your server needs to be configured in a particular way and have sufficient memory." ).'</H3></div>';
21
+
22
+
23
+ $html .= '
24
+ <table class="history">
25
+ <thead>
26
+ <tr>
27
+ <th>Checked</th>
28
+ <th>Necessary, Error And Fix</th>
29
+
30
+ </tr>
31
+ </thead><tbody>';
32
+ // <th>Necessary</th>
33
+ // <th>Fix</th>
34
+
35
+ $errors_count = 0;
36
+
37
+ // Memory total
38
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkMemory();
39
+ if ($status == 'error') $errors_count++;
40
+ if ($status == 'error') {
41
+ $html .= // $caption: $value $measure
42
+ "
43
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
44
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
45
+ <tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
46
+ <tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
47
+ ";
48
+ };
49
+
50
+
51
+
52
+ // Mysql parameter LOCAL DATA LOCAL
53
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkLoaddata();
54
+ if ($status == 'error') $errors_count++;
55
+ if ($status == 'error') {
56
+ $html .= // $caption: $value $measure
57
+ "
58
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
59
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
60
+ <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
61
+ <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
62
+ ";
63
+ };
64
+
65
+
66
+ // PHP safe mode
67
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhpsafemode();
68
+ if ($status == 'error') $errors_count++;
69
+ if ($status == 'error') {
70
+ $html .= // $caption: $value $measure
71
+ "
72
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
73
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
74
+ <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
75
+ <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
76
+ ";
77
+ };
78
+
79
+
80
+ // Mysql parameter wait_timeout
81
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkWaittimeout();
82
+ if ($status == 'error') $errors_count++;
83
+ if ($status == 'error') {
84
+ $html .= // $caption: $value $measure
85
+ "
86
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
87
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
88
+ <tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
89
+ <tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
90
+ ";
91
+ };
92
+
93
+
94
+ // Mysql parameter innodb_buffer_pool_size
95
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkInnodbbufferpoolsize();
96
+ if ($status == 'error') $errors_count++;
97
+ if ($status == 'error') {
98
+ $html .= // $caption: $value $measure
99
+ "
100
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
101
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
102
+ <tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
103
+ <tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
104
+ ";
105
+ };
106
+
107
+
108
+ // Conflict with installed module
109
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkConflictsWithInstalledModules();
110
+ if ($status == 'error') $errors_count++;
111
+ if ($status == 'error') {
112
+ $html .= // $caption: $value $measure
113
+ "
114
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
115
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
116
+ <tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
117
+ <tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
118
+ ";
119
+ };
120
+
121
+
122
+ // PHP run string
123
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhprunstring();
124
+ if ($status == 'error') $errors_count++;
125
+ if ($status == 'error') {
126
+ $html .= // $caption: $value $measure
127
+ "
128
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
129
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
130
+ <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
131
+ <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
132
+ ";
133
+ };
134
+
135
+
136
+ // Chmod wget file
137
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetdatafile();
138
+ if ($status == 'error') $errors_count++;
139
+ if ($status == 'error') {
140
+ $html .= // $caption: $value $measure
141
+ "
142
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
143
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
144
+ <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
145
+ <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
146
+ ";
147
+ };
148
+
149
+
150
+ // Chmod wget cron.php file
151
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronphpfile();
152
+ if ($status == 'error') $errors_count++;
153
+ if ($status == 'error') {
154
+ $html .= // $caption: $value $measure
155
+ "
156
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
157
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
158
+ <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
159
+ <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
160
+ ";
161
+ };
162
+
163
+ // Chmod wget cron.sh file
164
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronshfile();
165
+ if ($status == 'error') $errors_count++;
166
+ if ($status == 'error') {
167
+ $html .= // $caption: $value $measure
168
+ "
169
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
170
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
171
+ <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
172
+ <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
173
+ ";
174
+ };
175
+
176
+ // Mysql stored procedure filter_sinch_products_s
177
+ list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkProcedure();
178
+ if ($status == 'error') $errors_count++;
179
+ if ($status == 'error') {
180
+ $html .= // $caption: $value $measure
181
+ "
182
+ <tr> <td nowrap rowspan=4> $caption </td> </tr>
183
+ <tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
184
+ <tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
185
+ <tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
186
+ ";
187
+ };
188
+
189
+
190
+ $html .= '
191
+ </tbody>
192
+ </table>';
193
+
194
+ $html .= '<div class="comment"><H3>'.("There are $errors_count notices." ).'</H3></div>';
195
+
196
+ // all checks
197
+ return $html;
198
+
199
+ } // protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
200
+
201
+ protected function _colored($str, $color){
202
+ return "<b><span style='color:{$color}'>{$str}</span></b>";
203
+ }
204
+
205
+
206
+ } // class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field
207
+
208
+
209
+
210
+
app/code/local/Bintime/Sinchimport/Block/Importhistory.php CHANGED
@@ -1,386 +1,386 @@
1
- <?php
2
- class Bintime_Sinchimport_Block_Importhistory extends Mage_Adminhtml_Block_System_Config_Form_Field
3
- {
4
-
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $this->setElement($element);
8
- $url = $this->getUrl('sinchimport/index'); //
9
- $this->setElement($element);
10
-
11
- $html = $this->_appendJs();
12
-
13
- $html .= '<div id="sinchimport_status_template" name="sinchimport_status_template" style="display:none">';//none
14
- $html .= $this->_getStatusTemplateHtml();
15
- $html .= '</div>';
16
-
17
- $start_import_button = $this->getLayout()->createBlock('adminhtml/widget_button')
18
- ->setType('button')
19
- ->setClass('scalable')
20
- ->setLabel('Force Import now')
21
- ->setOnClick("start_sinch_import()") //setLocation('$url')
22
- ->toHtml();
23
-
24
- $html .= $start_import_button;
25
- // $html .= $url;
26
- $dataConf = Mage::getConfig();//('sinchimport_root');//getConfig()->getNode()->asXML();
27
- // $html .= "<pre>".var_export($dataConf, true)."</pre>";
28
-
29
-
30
-
31
- $import=Mage::getModel('sinchimport/sinch');
32
- if($import->is_imort_not_run()){
33
- $import->set_imports_failed();
34
- }
35
- $last_success_import=$import->getDateOfLatestSuccessImport();
36
- $import_history=$import->getImportStatusHistory();
37
-
38
- $css_arr=array(
39
- 'Failed' => 'sinch-error',
40
- 'Run' => 'sinch-run',
41
- 'Successful' => 'sinch-success'
42
- );
43
-
44
- $html=
45
- '
46
- <style type="text/css">
47
- .sinch-error {
48
- font-weight: bold;
49
- color: #D40707 ;
50
- text-align: center;
51
- margin: 5px 0;
52
- }
53
-
54
- .sinch-success {
55
- color: green;
56
- font-weight: bold;
57
- text-align: center;
58
- margin: 5px 0;
59
- }
60
-
61
- .sinch-run {
62
- color: blue;
63
- font-weight: bold;
64
- text-align: center;
65
- margin: 5px 0;
66
- }
67
-
68
-
69
- table.history {
70
- border-collapse: collapse;
71
- width: 100%;
72
- }
73
-
74
- table.history th {
75
- border: solid 1px #6F8992;
76
- background-color: #6F8992;
77
- color: #fff;
78
- font-weight: bold;
79
- padding: 2px 3px;
80
- }
81
-
82
- table.history td {
83
- border: 1px solid #333;
84
- padding: 2px 3px;
85
- }
86
- </style>
87
-
88
- <!--Table for import history-->
89
- <div class="comment">'.($last_success_import? "Your last successful feed import was at ".$last_success_import: "Your import never finished with success" ).'</div>
90
- <table class="history">
91
- <thead>
92
- <tr>
93
- <th>Import Start</th>
94
- <th>Import Finish</th>
95
- <th nowrap>Import Type</th>
96
- <th>Status</th>
97
-
98
- <th nowrap>Number of products</th>
99
- </tr>
100
- </thead>
101
- <tbody>';
102
- foreach($import_history as $item){
103
- $html.='
104
- <tr>
105
- <td nowrap>'.$item['start_import'].'</td>
106
- <td nowrap>'.$item['finish_import'].'</td>
107
- <td nowrap>'.$item['import_type'].'</td>
108
- <td class="'.$css_arr[$item['global_status_import']].'">'.$item['global_status_import'].'</td>
109
-
110
- <td>'.$item['number_of_products'].'</td>
111
- </tr>
112
- ';
113
- }
114
- $html.='
115
- </tbody>
116
- </table>
117
- ';
118
-
119
-
120
- return $html;
121
- }
122
-
123
- protected function _getStatusTemplateHtml()
124
- {
125
- $run_pic=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif";
126
- $html="
127
- <ul>
128
- <li>
129
- Start Import
130
- &nbsp
131
- <span id='sinchimport_start_import'>
132
- <img src='".$run_pic."'
133
- alt='Sinch Import run' />
134
- </span>
135
- </li>
136
- <li>
137
- Upload Files
138
- &nbsp
139
- <span id='sinchimport_upload_files'>
140
- <img src='".$run_pic."'
141
- alt='Upload Files' />
142
- </span>
143
- </li>
144
- <li>
145
- Parse Categories
146
- &nbsp
147
- <span id='sinchimport_parse_categories'>
148
- <img src='".$run_pic."'
149
- alt='Parse Categories' />
150
- </span>
151
- </li>
152
- <li>
153
- Parse Category Features
154
- &nbsp
155
- <span id='sinchimport_parse_category_features'>
156
- <img src='".$run_pic."'
157
- alt='Parse Category Features' />
158
- </span>
159
- </li>
160
- <li>
161
- Parse Distributors
162
- &nbsp
163
- <span id='sinchimport_parse_distributors'>
164
- <img src='".$run_pic."'
165
- alt='Parse Distributors' />
166
- </span>
167
- </li>
168
- <li>
169
- Parse EAN Codes
170
- &nbsp
171
- <span id='sinchimport_parse_ean_codes'>
172
- <img src='".$run_pic."'
173
- alt='Parse EAN Codes' />
174
- </span>
175
- </li>
176
- <li>
177
- Parse Manufacturers
178
- &nbsp
179
- <span id='sinchimport_parse_manufacturers'>
180
- <img src='".$run_pic."'
181
- alt='Parse Manufacturers'' />
182
- </span>
183
- </li>
184
- <li>
185
- Parse Related Products
186
- &nbsp
187
- <span id='sinchimport_parse_related_products'>
188
- <img src='".$run_pic."'
189
- alt='Parse Related Products' />
190
- </span>
191
- </li>
192
- <li>
193
- Parse Product Features
194
- &nbsp
195
- <span id='sinchimport_parse_product_features'>
196
- <img src='".$run_pic."'
197
- alt='Parse Product Features' />
198
- </span>
199
- </li>
200
- <li>
201
- Parse Products
202
- &nbsp
203
- <span id='sinchimport_parse_products'>
204
- <img src='".$run_pic."'
205
- alt='Parse Products' />
206
- </span>
207
- </li>
208
- <li>
209
- Parse Pictures Gallery
210
- &nbsp
211
- <span id='sinchimport_parse_pictures_gallery'>
212
- <img src='".$run_pic."'
213
- alt='Parse Pictures Gallery' />
214
- </span>
215
- </li>
216
- <li>
217
- Parse Restricted Values
218
- &nbsp
219
- <span id='sinchimport_parse_restricted_values'>
220
- <img src='".$run_pic."'
221
- alt='Parse Restricted Values' />
222
- </span>
223
- </li>
224
- <li>
225
- Parse Stock And Prices
226
- &nbsp
227
- <span id='sinchimport_parse_stock_and_prices'>
228
- <img src='".$run_pic."'
229
- alt='Parse Stock And Prices' />
230
- </span>
231
- </li>
232
- <li>
233
- Generate category filters
234
- &nbsp
235
- <span id='sinchimport_generate_category_filters'>
236
- <img src='".$run_pic."'
237
- alt='Generate category filters' />
238
- </span>
239
- </li>
240
- <li>
241
- Import finished
242
- &nbsp
243
- <span id='sinchimport_import_finished'>
244
- <img src='".$run_pic."'
245
- alt='Import finished' />
246
- </span>
247
- </li>
248
-
249
- </ul>
250
- ";
251
- return $html;
252
- }
253
-
254
- protected function _appendJs()
255
- {
256
- $post_url=$this->getUrl('sinchimport/ajax');
257
- $post_url_upd=$this->getUrl('sinchimport/ajax/UpdateStatus');
258
- $html = "
259
- <script>
260
- function start_sinch_import(){
261
- status_div=document.getElementById('sinchimport_status_template');
262
- status_div.style.display='';
263
- // status_div.innerHTML='';
264
- sinch = new Sinch('$post_url','$post_url_upd');
265
- sinch.startSinchImport();
266
-
267
- //
268
- }
269
- var Sinch = Class.create();
270
- Sinch.prototype = {
271
-
272
- initialize: function(postUrl, postUrlUpd) {
273
- this.postUrl = postUrl; //'https://techatcost.com/purchases/ajax/';
274
- this.postUrlUpd = postUrlUpd;
275
- this.failureUrl = document.URL;
276
- // unique user session ID
277
- this.SID = null;
278
- // object with event message data
279
- this.objectMsg = null;
280
- this.prevMsg = '';
281
- // interval object
282
- this.updateTimer = null;
283
- // default shipping code. Display on errors
284
-
285
- elem = 'checkoutSteps';
286
- clickableEntity = '.head';
287
-
288
- // overwrite Accordion class method
289
- var headers = $$('#' + elem + ' .section ' + clickableEntity);
290
- headers.each(function(header) {
291
- Event.observe(header,'click',this.sectionClicked.bindAsEventListener(this));
292
- }.bind(this));
293
- },
294
- startSinchImport: function () {
295
- _this = this;
296
- new Ajax.Request(this.postUrl,
297
- {
298
- method:'post',
299
- parameters: '',
300
- requestTimeout: 10,
301
- /*
302
- onLoading:function(){
303
- alert('onLoading');
304
- },
305
- onLoaded:function(){
306
- alert('onLoaded');
307
- },
308
- */
309
- onSuccess: function(transport) {
310
- var response = transport.responseText || null;
311
- _this.SID = response;
312
- if (_this.SID) {
313
- _this.updateTimer = setInterval(function(){_this.updateEvent();},20000);
314
- $('session_id').value = _this.SID;
315
- } else {
316
- alert('Can not get your session ID. Please reload the page!');
317
- }
318
- },
319
- onTimeout: function() { alert('Can not get your session ID. Timeout!'); },
320
- onFailure: function() { alert('Something went wrong...') }
321
- });
322
-
323
- },
324
-
325
- updateEvent: function () {
326
- _this = this;
327
- new Ajax.Request(this.postUrlUpd,
328
- {
329
- method: 'post',
330
- parameters: {session_id: this.SID},
331
- onSuccess: function(transport) {
332
- _this.objectMsg = transport.responseText.evalJSON();
333
- _this.prevMsg = _this.objectMsg.message;
334
- if(_this.prevMsg!=''){
335
- _this.updateStatusHtml();
336
- }
337
-
338
- if (_this.objectMsg.error == 1) {
339
- // Do something on error
340
- _this.clearUpdateInterval();
341
- }
342
-
343
- if (_this.objectMsg.finished == 1) {
344
- _this.objectMsg.message='Import finished';
345
- _this.updateStatusHtml();
346
- _this.clearUpdateInterval();
347
-
348
- }
349
-
350
- },
351
- onFailure: this.ajaxFailure.bind(),
352
- });
353
- },
354
-
355
- updateStatusHtml: function(){
356
- message=this.objectMsg.message.toLowerCase();
357
- mess_id='sinchimport_'+message.replace(/\s+/g, '_');
358
- if(!document.getElementById(mess_id)){
359
- alert(mess_id+' - not exist');
360
- }
361
- else{
362
- // alert (mess_id+' - exist');
363
- $(mess_id).innerHTML='<img src=\"".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_yes.gif"."\"/>'
364
- }
365
- htm=$('sinchimport_status_template').innerHTML;
366
- // $('sinchimport_status_template').innerHTML=htm+'<br>'+this.objectMsg.message;
367
- },
368
-
369
- ajaxFailure: function(){
370
- this.clearUpdateInterval();
371
- location.href = this.failureUrl;
372
- },
373
-
374
- clearUpdateInterval: function () {
375
- clearInterval(this.updateTimer);
376
- },
377
-
378
-
379
- }
380
- </script>
381
- ";
382
- return $html;
383
- }
384
-
385
- }
386
- ?>
1
+ <?php
2
+ class Bintime_Sinchimport_Block_Importhistory extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $this->setElement($element);
8
+ $url = $this->getUrl('sinchimport/index'); //
9
+ $this->setElement($element);
10
+
11
+ $html = $this->_appendJs();
12
+
13
+ $html .= '<div id="sinchimport_status_template" name="sinchimport_status_template" style="display:none">';//none
14
+ $html .= $this->_getStatusTemplateHtml();
15
+ $html .= '</div>';
16
+
17
+ $start_import_button = $this->getLayout()->createBlock('adminhtml/widget_button')
18
+ ->setType('button')
19
+ ->setClass('scalable')
20
+ ->setLabel('Force Import now')
21
+ ->setOnClick("start_sinch_import()") //setLocation('$url')
22
+ ->toHtml();
23
+
24
+ $html .= $start_import_button;
25
+ // $html .= $url;
26
+ $dataConf = Mage::getConfig();//('sinchimport_root');//getConfig()->getNode()->asXML();
27
+ // $html .= "<pre>".var_export($dataConf, true)."</pre>";
28
+
29
+
30
+
31
+ $import=Mage::getModel('sinchimport/sinch');
32
+ if($import->is_imort_not_run()){
33
+ $import->set_imports_failed();
34
+ }
35
+ $last_success_import=$import->getDateOfLatestSuccessImport();
36
+ $import_history=$import->getImportStatusHistory();
37
+
38
+ $css_arr=array(
39
+ 'Failed' => 'sinch-error',
40
+ 'Run' => 'sinch-run',
41
+ 'Successful' => 'sinch-success'
42
+ );
43
+
44
+ $html=
45
+ '
46
+ <style type="text/css">
47
+ .sinch-error {
48
+ font-weight: bold;
49
+ color: #D40707 ;
50
+ text-align: center;
51
+ margin: 5px 0;
52
+ }
53
+
54
+ .sinch-success {
55
+ color: green;
56
+ font-weight: bold;
57
+ text-align: center;
58
+ margin: 5px 0;
59
+ }
60
+
61
+ .sinch-run {
62
+ color: blue;
63
+ font-weight: bold;
64
+ text-align: center;
65
+ margin: 5px 0;
66
+ }
67
+
68
+
69
+ table.history {
70
+ border-collapse: collapse;
71
+ width: 100%;
72
+ }
73
+
74
+ table.history th {
75
+ border: solid 1px #6F8992;
76
+ background-color: #6F8992;
77
+ color: #fff;
78
+ font-weight: bold;
79
+ padding: 2px 3px;
80
+ }
81
+
82
+ table.history td {
83
+ border: 1px solid #333;
84
+ padding: 2px 3px;
85
+ }
86
+ </style>
87
+
88
+ <!--Table for import history-->
89
+ <div class="comment">'.($last_success_import? "Your last successful feed import was at ".$last_success_import: "Your import never finished with success" ).'</div>
90
+ <table class="history">
91
+ <thead>
92
+ <tr>
93
+ <th>Import Start</th>
94
+ <th>Import Finish</th>
95
+ <th nowrap>Import Type</th>
96
+ <th>Status</th>
97
+
98
+ <th nowrap>Number of products</th>
99
+ </tr>
100
+ </thead>
101
+ <tbody>';
102
+ foreach($import_history as $item){
103
+ $html.='
104
+ <tr>
105
+ <td nowrap>'.$item['start_import'].'</td>
106
+ <td nowrap>'.$item['finish_import'].'</td>
107
+ <td nowrap>'.$item['import_type'].'</td>
108
+ <td class="'.$css_arr[$item['global_status_import']].'">'.$item['global_status_import'].'</td>
109
+
110
+ <td>'.$item['number_of_products'].'</td>
111
+ </tr>
112
+ ';
113
+ }
114
+ $html.='
115
+ </tbody>
116
+ </table>
117
+ ';
118
+
119
+
120
+ return $html;
121
+ }
122
+
123
+ protected function _getStatusTemplateHtml()
124
+ {
125
+ $run_pic=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif";
126
+ $html="
127
+ <ul>
128
+ <li>
129
+ Start Import
130
+ &nbsp
131
+ <span id='sinchimport_start_import'>
132
+ <img src='".$run_pic."'
133
+ alt='Sinch Import run' />
134
+ </span>
135
+ </li>
136
+ <li>
137
+ Upload Files
138
+ &nbsp
139
+ <span id='sinchimport_upload_files'>
140
+ <img src='".$run_pic."'
141
+ alt='Upload Files' />
142
+ </span>
143
+ </li>
144
+ <li>
145
+ Parse Categories
146
+ &nbsp
147
+ <span id='sinchimport_parse_categories'>
148
+ <img src='".$run_pic."'
149
+ alt='Parse Categories' />
150
+ </span>
151
+ </li>
152
+ <li>
153
+ Parse Category Features
154
+ &nbsp
155
+ <span id='sinchimport_parse_category_features'>
156
+ <img src='".$run_pic."'
157
+ alt='Parse Category Features' />
158
+ </span>
159
+ </li>
160
+ <li>
161
+ Parse Distributors
162
+ &nbsp
163
+ <span id='sinchimport_parse_distributors'>
164
+ <img src='".$run_pic."'
165
+ alt='Parse Distributors' />
166
+ </span>
167
+ </li>
168
+ <li>
169
+ Parse EAN Codes
170
+ &nbsp
171
+ <span id='sinchimport_parse_ean_codes'>
172
+ <img src='".$run_pic."'
173
+ alt='Parse EAN Codes' />
174
+ </span>
175
+ </li>
176
+ <li>
177
+ Parse Manufacturers
178
+ &nbsp
179
+ <span id='sinchimport_parse_manufacturers'>
180
+ <img src='".$run_pic."'
181
+ alt='Parse Manufacturers'' />
182
+ </span>
183
+ </li>
184
+ <li>
185
+ Parse Related Products
186
+ &nbsp
187
+ <span id='sinchimport_parse_related_products'>
188
+ <img src='".$run_pic."'
189
+ alt='Parse Related Products' />
190
+ </span>
191
+ </li>
192
+ <li>
193
+ Parse Product Features
194
+ &nbsp
195
+ <span id='sinchimport_parse_product_features'>
196
+ <img src='".$run_pic."'
197
+ alt='Parse Product Features' />
198
+ </span>
199
+ </li>
200
+ <li>
201
+ Parse Products
202
+ &nbsp
203
+ <span id='sinchimport_parse_products'>
204
+ <img src='".$run_pic."'
205
+ alt='Parse Products' />
206
+ </span>
207
+ </li>
208
+ <li>
209
+ Parse Pictures Gallery
210
+ &nbsp
211
+ <span id='sinchimport_parse_pictures_gallery'>
212
+ <img src='".$run_pic."'
213
+ alt='Parse Pictures Gallery' />
214
+ </span>
215
+ </li>
216
+ <li>
217
+ Parse Restricted Values
218
+ &nbsp
219
+ <span id='sinchimport_parse_restricted_values'>
220
+ <img src='".$run_pic."'
221
+ alt='Parse Restricted Values' />
222
+ </span>
223
+ </li>
224
+ <li>
225
+ Parse Stock And Prices
226
+ &nbsp
227
+ <span id='sinchimport_parse_stock_and_prices'>
228
+ <img src='".$run_pic."'
229
+ alt='Parse Stock And Prices' />
230
+ </span>
231
+ </li>
232
+ <li>
233
+ Generate category filters
234
+ &nbsp
235
+ <span id='sinchimport_generate_category_filters'>
236
+ <img src='".$run_pic."'
237
+ alt='Generate category filters' />
238
+ </span>
239
+ </li>
240
+ <li>
241
+ Import finished
242
+ &nbsp
243
+ <span id='sinchimport_import_finished'>
244
+ <img src='".$run_pic."'
245
+ alt='Import finished' />
246
+ </span>
247
+ </li>
248
+
249
+ </ul>
250
+ ";
251
+ return $html;
252
+ }
253
+
254
+ protected function _appendJs()
255
+ {
256
+ $post_url=$this->getUrl('sinchimport/ajax');
257
+ $post_url_upd=$this->getUrl('sinchimport/ajax/UpdateStatus');
258
+ $html = "
259
+ <script>
260
+ function start_sinch_import(){
261
+ status_div=document.getElementById('sinchimport_status_template');
262
+ status_div.style.display='';
263
+ // status_div.innerHTML='';
264
+ sinch = new Sinch('$post_url','$post_url_upd');
265
+ sinch.startSinchImport();
266
+
267
+ //
268
+ }
269
+ var Sinch = Class.create();
270
+ Sinch.prototype = {
271
+
272
+ initialize: function(postUrl, postUrlUpd) {
273
+ this.postUrl = postUrl; //'https://techatcost.com/purchases/ajax/';
274
+ this.postUrlUpd = postUrlUpd;
275
+ this.failureUrl = document.URL;
276
+ // unique user session ID
277
+ this.SID = null;
278
+ // object with event message data
279
+ this.objectMsg = null;
280
+ this.prevMsg = '';
281
+ // interval object
282
+ this.updateTimer = null;
283
+ // default shipping code. Display on errors
284
+
285
+ elem = 'checkoutSteps';
286
+ clickableEntity = '.head';
287
+
288
+ // overwrite Accordion class method
289
+ var headers = $$('#' + elem + ' .section ' + clickableEntity);
290
+ headers.each(function(header) {
291
+ Event.observe(header,'click',this.sectionClicked.bindAsEventListener(this));
292
+ }.bind(this));
293
+ },
294
+ startSinchImport: function () {
295
+ _this = this;
296
+ new Ajax.Request(this.postUrl,
297
+ {
298
+ method:'post',
299
+ parameters: '',
300
+ requestTimeout: 10,
301
+ /*
302
+ onLoading:function(){
303
+ alert('onLoading');
304
+ },
305
+ onLoaded:function(){
306
+ alert('onLoaded');
307
+ },
308
+ */
309
+ onSuccess: function(transport) {
310
+ var response = transport.responseText || null;
311
+ _this.SID = response;
312
+ if (_this.SID) {
313
+ _this.updateTimer = setInterval(function(){_this.updateEvent();},20000);
314
+ $('session_id').value = _this.SID;
315
+ } else {
316
+ alert('Can not get your session ID. Please reload the page!');
317
+ }
318
+ },
319
+ onTimeout: function() { alert('Can not get your session ID. Timeout!'); },
320
+ onFailure: function() { alert('Something went wrong...') }
321
+ });
322
+
323
+ },
324
+
325
+ updateEvent: function () {
326
+ _this = this;
327
+ new Ajax.Request(this.postUrlUpd,
328
+ {
329
+ method: 'post',
330
+ parameters: {session_id: this.SID},
331
+ onSuccess: function(transport) {
332
+ _this.objectMsg = transport.responseText.evalJSON();
333
+ _this.prevMsg = _this.objectMsg.message;
334
+ if(_this.prevMsg!=''){
335
+ _this.updateStatusHtml();
336
+ }
337
+
338
+ if (_this.objectMsg.error == 1) {
339
+ // Do something on error
340
+ _this.clearUpdateInterval();
341
+ }
342
+
343
+ if (_this.objectMsg.finished == 1) {
344
+ _this.objectMsg.message='Import finished';
345
+ _this.updateStatusHtml();
346
+ _this.clearUpdateInterval();
347
+
348
+ }
349
+
350
+ },
351
+ onFailure: this.ajaxFailure.bind(),
352
+ });
353
+ },
354
+
355
+ updateStatusHtml: function(){
356
+ message=this.objectMsg.message.toLowerCase();
357
+ mess_id='sinchimport_'+message.replace(/\s+/g, '_');
358
+ if(!document.getElementById(mess_id)){
359
+ alert(mess_id+' - not exist');
360
+ }
361
+ else{
362
+ // alert (mess_id+' - exist');
363
+ $(mess_id).innerHTML='<img src=\"".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_yes.gif"."\"/>'
364
+ }
365
+ htm=$('sinchimport_status_template').innerHTML;
366
+ // $('sinchimport_status_template').innerHTML=htm+'<br>'+this.objectMsg.message;
367
+ },
368
+
369
+ ajaxFailure: function(){
370
+ this.clearUpdateInterval();
371
+ location.href = this.failureUrl;
372
+ },
373
+
374
+ clearUpdateInterval: function () {
375
+ clearInterval(this.updateTimer);
376
+ },
377
+
378
+
379
+ }
380
+ </script>
381
+ ";
382
+ return $html;
383
+ }
384
+
385
+ }
386
+ ?>
app/code/local/Bintime/Sinchimport/Block/Layer/Filter/Feature.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
-
3
- class Bintime_Sinchimport_Block_Layer_Filter_Feature extends Mage_Catalog_Block_Layer_Filter_Abstract
4
- {
5
-
6
- public function __construct()
7
- {
8
- parent::__construct();
9
- $this->_filterModelName = 'sinchimport/layer_filter_feature';
10
- }
11
-
12
- protected function _prepareFilter()
13
- {
14
- $this->_filter->setAttributeModel($this->getAttributeModel());
15
- return $this;
16
- }
17
- }
1
+ <?php
2
+
3
+ class Bintime_Sinchimport_Block_Layer_Filter_Feature extends Mage_Catalog_Block_Layer_Filter_Abstract
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->_filterModelName = 'sinchimport/layer_filter_feature';
10
+ }
11
+
12
+ protected function _prepareFilter()
13
+ {
14
+ $this->_filter->setAttributeModel($this->getAttributeModel());
15
+ return $this;
16
+ }
17
+ }
app/code/local/Bintime/Sinchimport/Block/Layer/View.php CHANGED
@@ -1,48 +1,48 @@
1
- <?php
2
-
3
- class Bintime_Sinchimport_Block_Layer_View extends Mage_Catalog_Block_Layer_View
4
- {
5
-
6
- protected $filterableFeatures = array();
7
-
8
- /**
9
- * Prepare child blocks
10
- *
11
- * @return Mage_Catalog_Block_Layer_View
12
- */
13
- protected function _prepareLayout()
14
- {
15
- //получение списка фич, по которым строися навигация
16
- $filterableFeatures = $this->getLayer()->getFilterableFeatures();
17
- $filterBlockName = 'sinchimport/layer_filter_feature'; //block
18
- foreach ($filterableFeatures as $feature) {
19
- $this->filterableFeatures[] = $feature;
20
- $featureBlock = $this->getLayout()->createBlock($filterBlockName)
21
- ->setLayer($this->getLayer())
22
- ->setAttributeModel($feature)
23
- ->init();
24
- $this->setChild('feature_' . $feature['feature_id'] . '_filter',
25
- $featureBlock
26
- );
27
- }
28
- /* ------------ */
29
- return parent::_prepareLayout();
30
- }
31
-
32
- /**
33
- * Get all layer filters
34
- *
35
- * @return array
36
- */
37
- public function getFilters()
38
- {
39
- $filters = parent::getFilters();
40
- /* ------------ */
41
- foreach ($this->filterableFeatures as $feature) {
42
- $filters[] = $this->getChild('feature_' . $feature['feature_id'] . '_filter');
43
- }
44
- /* ------------ */
45
-
46
- return $filters;
47
- }
48
- }
1
+ <?php
2
+
3
+ class Bintime_Sinchimport_Block_Layer_View extends Mage_Catalog_Block_Layer_View
4
+ {
5
+
6
+ protected $filterableFeatures = array();
7
+
8
+ /**
9
+ * Prepare child blocks
10
+ *
11
+ * @return Mage_Catalog_Block_Layer_View
12
+ */
13
+ protected function _prepareLayout()
14
+ {
15
+ //получение списка фич, по которым строися навигация
16
+ $filterableFeatures = $this->getLayer()->getFilterableFeatures();
17
+ $filterBlockName = 'sinchimport/layer_filter_feature'; //block
18
+ foreach ($filterableFeatures as $feature) {
19
+ $this->filterableFeatures[] = $feature;
20
+ $featureBlock = $this->getLayout()->createBlock($filterBlockName)
21
+ ->setLayer($this->getLayer())
22
+ ->setAttributeModel($feature)
23
+ ->init();
24
+ $this->setChild('feature_' . $feature['feature_id'] . '_filter',
25
+ $featureBlock
26
+ );
27
+ }
28
+ /* ------------ */
29
+ return parent::_prepareLayout();
30
+ }
31
+
32
+ /**
33
+ * Get all layer filters
34
+ *
35
+ * @return array
36
+ */
37
+ public function getFilters()
38
+ {
39
+ $filters = parent::getFilters();
40
+ /* ------------ */
41
+ foreach ($this->filterableFeatures as $feature) {
42
+ $filters[] = $this->getChild('feature_' . $feature['feature_id'] . '_filter');
43
+ }
44
+ /* ------------ */
45
+
46
+ return $filters;
47
+ }
48
+ }
app/code/local/Bintime/Sinchimport/Block/List.php CHANGED
@@ -1,159 +1,159 @@
1
- <?php
2
- class Bintime_Sinchimport_Block_List extends Mage_Catalog_Block_Product_Compare_List
3
- {
4
- var $goods;
5
- var $_compareSinchStoreProd;
6
- public function getSinchAttributes()
7
- {
8
- $items = array();
9
- foreach ($this->getItems() as $_item) {
10
- $items[] = $_item->getId();
11
- }
12
- $to_compare=implode(',', $items);
13
- $tmp_table_sorted = Mage::getSingleton('core/resource')->getTableName('$tmp_table_sorted_').time();
14
- $this->tep_db_query("DROP TABLE IF EXISTS $tmp_table_sorted");
15
- $this->tep_db_query("CREATE TABLE $tmp_table_sorted (
16
- id int(11) not null PRIMARY KEY AUTO_INCREMENT,
17
- store_category_id int(11) not null default 0,
18
- store_product_id int(11) not null default 0,
19
- sinch_product_id int(11) not null default 0,
20
- category_feature_id int(11) not null default 0,
21
- feature_name varchar(255) not null default '',
22
- restricted_value_id int(11) not null default 0,
23
- text varchar(255) not null default '',
24
- KEY(category_feature_id),
25
- KEY(store_product_id),
26
- unique key(sinch_product_id, feature_name)
27
- )");
28
-
29
-
30
- $query = "SELECT p.sinch_product_id, p.store_product_id, p.specifications, pm.entity_id
31
- FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." p
32
- JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')." pm
33
- ON pm.shop_store_product_id = p.store_product_id AND
34
- pm.shop_sinch_product_id=p.sinch_product_id
35
- WHERE pm.entity_id IN ( $to_compare )";
36
- $sinch = $this->tep_db_query($query);
37
- while($data = $sinch->fetch(PDO::FETCH_ASSOC)){
38
- $this->ins_from_htm($data['sinch_product_id'],$data['store_product_id'],$data['specifications'],$tmp_table_sorted);
39
- $sinch_products_array[] = $data['sinch_product_id'];
40
- $this->_compareSinchStoreProd[$data['entity_id']]=$data['sinch_product_id'];
41
- }
42
- $sinch_products = implode(',', $sinch_products_array);
43
- if(!$sinch_products){
44
- $sinch_products = "''";
45
- }
46
- $this->tep_db_query("INSERT IGNORE INTO $tmp_table_sorted (
47
- store_category_id,
48
- sinch_product_id,
49
- category_feature_id,
50
- feature_name,
51
- restricted_value_id,
52
- text
53
- )(SELECT
54
- cf.store_category_id,
55
- pf.sinch_product_id,
56
- cf.category_feature_id,
57
- cf.feature_name,
58
- rv.restricted_value_id,
59
- rv.text
60
- FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features')." cf
61
- JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values')." rv
62
- ON cf.category_feature_id=rv.category_feature_id
63
- JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features')." pf
64
- ON rv.restricted_value_id=pf.restricted_value_id
65
- WHERE sinch_product_id in (".$sinch_products.")
66
- ORDER BY
67
- cf.display_order_number,
68
- pf.sinch_product_id)
69
- ");
70
- $this->tep_db_query("UPDATE $tmp_table_sorted t
71
- JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." p
72
- ON t.sinch_product_id=p.sinch_product_id
73
- SET t.store_product_id=p.store_product_id");
74
-
75
- $this->goods = array();
76
-
77
- $product_query = $this->tep_db_query("select store_product_id, sinch_product_id, category_feature_id, store_category_id, feature_name, text
78
- FROM $tmp_table_sorted
79
- ORDER BY id ASC");
80
- while($data = $product_query->fetch(PDO::FETCH_ASSOC)){
81
- $this->goods[$data['sinch_product_id']]['category_features'][$data['feature_name']] = array(
82
-
83
-
84
- 'category_feature_id' => $data['category_feature_id'],
85
- 'value' => $data['text'],
86
-
87
-
88
- 'feature_name' => $data['feature_name'],
89
- );
90
- }
91
- $catfeats = $this->tep_db_query("SELECT category_feature_id, feature_name FROM $tmp_table_sorted
92
- GROUP BY feature_name
93
- ORDER BY category_feature_id");
94
- while($fdata = $catfeats->fetch(PDO::FETCH_ASSOC)){
95
- $cf[] = $fdata;
96
- }
97
- return $cf;
98
- }
99
-
100
- public function GetSinchCompareProdAttributes(){
101
- return $this->goods;
102
- }
103
-
104
- public function getSinchAttributeName($cf)
105
- {
106
- return $cf['feature_name'];
107
- }
108
-
109
- public function getSinchProductAttributeValue($product, $cf)
110
- {
111
-
112
- $prod = $this->_compareSinchStoreProd[$product->getID()];
113
- $feature_name = $cf['feature_name'];
114
- $data = $this->goods[$prod]['category_features'][$feature_name]['value'];
115
- $data = Mage::getModel('sinchimport/sinch')->valid_utf($data);
116
- return $data;
117
- }
118
-
119
- private function ins_from_htm($sinch_product_id, $store_product_id, $htm, $tmp_table_sorted){
120
- if($htm){
121
- /** создаем новый dom-объект **/
122
- $dom = new domDocument;
123
- /** загружаем html в объект **/
124
- $dom->loadHTML($htm);
125
- $dom->preserveWhiteSpace = false;
126
-
127
- /** элемент по тэгу **/
128
- $tables = $dom->getElementsByTagName('table');
129
-
130
- /** получаем все строки таблицы **/
131
- $rows = $tables->item(0)->getElementsByTagName('tr');
132
-
133
- /** цикл по строкам **/
134
- $i=0;
135
- foreach ($rows as $row)
136
- {
137
- /** все ячейки по тэгу **/
138
- $cols = $row->getElementsByTagName('td');
139
- /** выводим значения **/
140
- $name = $cols->item(0)->nodeValue;
141
- $value = $cols->item(1)->nodeValue;
142
-
143
- if($value && $i){
144
- $q=" insert ignore into ".$tmp_table_sorted." (store_product_id, sinch_product_id, feature_name, text) values(".$store_product_id.",".$sinch_product_id.",'".$name."','".$value."')";
145
- $this->tep_db_query($q);
146
- }
147
- //mysqli_real_escape_string($name)
148
- $i++;
149
- }
150
- }
151
- }
152
- private function tep_db_query($q){
153
- $resource = Mage::getResourceSingleton('catalog/product');
154
- $connection = $resource->getReadConnection();
155
- $result = $connection->query($q);
156
- return($result);
157
- }
158
-
159
- }
1
+ <?php
2
+ class Bintime_Sinchimport_Block_List extends Mage_Catalog_Block_Product_Compare_List
3
+ {
4
+ var $goods;
5
+ var $_compareSinchStoreProd;
6
+ public function getSinchAttributes()
7
+ {
8
+ $items = array();
9
+ foreach ($this->getItems() as $_item) {
10
+ $items[] = $_item->getId();
11
+ }
12
+ $to_compare=implode(',', $items);
13
+ $tmp_table_sorted = Mage::getSingleton('core/resource')->getTableName('$tmp_table_sorted_').time();
14
+ $this->tep_db_query("DROP TABLE IF EXISTS $tmp_table_sorted");
15
+ $this->tep_db_query("CREATE TABLE $tmp_table_sorted (
16
+ id int(11) not null PRIMARY KEY AUTO_INCREMENT,
17
+ store_category_id int(11) not null default 0,
18
+ store_product_id int(11) not null default 0,
19
+ sinch_product_id int(11) not null default 0,
20
+ category_feature_id int(11) not null default 0,
21
+ feature_name varchar(255) not null default '',
22
+ restricted_value_id int(11) not null default 0,
23
+ text varchar(255) not null default '',
24
+ KEY(category_feature_id),
25
+ KEY(store_product_id),
26
+ unique key(sinch_product_id, feature_name)
27
+ )");
28
+
29
+
30
+ $query = "SELECT p.sinch_product_id, p.store_product_id, p.specifications, pm.entity_id
31
+ FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." p
32
+ JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')." pm
33
+ ON pm.shop_store_product_id = p.store_product_id AND
34
+ pm.shop_sinch_product_id=p.sinch_product_id
35
+ WHERE pm.entity_id IN ( $to_compare )";
36
+ $sinch = $this->tep_db_query($query);
37
+ while($data = $sinch->fetch(PDO::FETCH_ASSOC)){
38
+ $this->ins_from_htm($data['sinch_product_id'],$data['store_product_id'],$data['specifications'],$tmp_table_sorted);
39
+ $sinch_products_array[] = $data['sinch_product_id'];
40
+ $this->_compareSinchStoreProd[$data['entity_id']]=$data['sinch_product_id'];
41
+ }
42
+ $sinch_products = implode(',', $sinch_products_array);
43
+ if(!$sinch_products){
44
+ $sinch_products = "''";
45
+ }
46
+ $this->tep_db_query("INSERT IGNORE INTO $tmp_table_sorted (
47
+ store_category_id,
48
+ sinch_product_id,
49
+ category_feature_id,
50
+ feature_name,
51
+ restricted_value_id,
52
+ text
53
+ )(SELECT
54
+ cf.store_category_id,
55
+ pf.sinch_product_id,
56
+ cf.category_feature_id,
57
+ cf.feature_name,
58
+ rv.restricted_value_id,
59
+ rv.text
60
+ FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features')." cf
61
+ JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values')." rv
62
+ ON cf.category_feature_id=rv.category_feature_id
63
+ JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features')." pf
64
+ ON rv.restricted_value_id=pf.restricted_value_id
65
+ WHERE sinch_product_id in (".$sinch_products.")
66
+ ORDER BY
67
+ cf.display_order_number,
68
+ pf.sinch_product_id)
69
+ ");
70
+ $this->tep_db_query("UPDATE $tmp_table_sorted t
71
+ JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." p
72
+ ON t.sinch_product_id=p.sinch_product_id
73
+ SET t.store_product_id=p.store_product_id");
74
+
75
+ $this->goods = array();
76
+
77
+ $product_query = $this->tep_db_query("select store_product_id, sinch_product_id, category_feature_id, store_category_id, feature_name, text
78
+ FROM $tmp_table_sorted
79
+ ORDER BY id ASC");
80
+ while($data = $product_query->fetch(PDO::FETCH_ASSOC)){
81
+ $this->goods[$data['sinch_product_id']]['category_features'][$data['feature_name']] = array(
82
+
83
+
84
+ 'category_feature_id' => $data['category_feature_id'],
85
+ 'value' => $data['text'],
86
+
87
+
88
+ 'feature_name' => $data['feature_name'],
89
+ );
90
+ }
91
+ $catfeats = $this->tep_db_query("SELECT category_feature_id, feature_name FROM $tmp_table_sorted
92
+ GROUP BY feature_name
93
+ ORDER BY category_feature_id");
94
+ while($fdata = $catfeats->fetch(PDO::FETCH_ASSOC)){
95
+ $cf[] = $fdata;
96
+ }
97
+ return $cf;
98
+ }
99
+
100
+ public function GetSinchCompareProdAttributes(){
101
+ return $this->goods;
102
+ }
103
+
104
+ public function getSinchAttributeName($cf)
105
+ {
106
+ return $cf['feature_name'];
107
+ }
108
+
109
+ public function getSinchProductAttributeValue($product, $cf)
110
+ {
111
+
112
+ $prod = $this->_compareSinchStoreProd[$product->getID()];
113
+ $feature_name = $cf['feature_name'];
114
+ $data = $this->goods[$prod]['category_features'][$feature_name]['value'];
115
+ $data = Mage::getModel('sinchimport/sinch')->valid_utf($data);
116
+ return $data;
117
+ }
118
+
119
+ private function ins_from_htm($sinch_product_id, $store_product_id, $htm, $tmp_table_sorted){
120
+ if($htm){
121
+ /** создаем новый dom-объект **/
122
+ $dom = new domDocument;
123
+ /** загружаем html в объект **/
124
+ $dom->loadHTML($htm);
125
+ $dom->preserveWhiteSpace = false;
126
+
127
+ /** элемент по тэгу **/
128
+ $tables = $dom->getElementsByTagName('table');
129
+
130
+ /** получаем все строки таблицы **/
131
+ $rows = $tables->item(0)->getElementsByTagName('tr');
132
+
133
+ /** цикл по строкам **/
134
+ $i=0;
135
+ foreach ($rows as $row)
136
+ {
137
+ /** все ячейки по тэгу **/
138
+ $cols = $row->getElementsByTagName('td');
139
+ /** выводим значения **/
140
+ $name = $cols->item(0)->nodeValue;
141
+ $value = $cols->item(1)->nodeValue;
142
+
143
+ if($value && $i){
144
+ $q=" insert ignore into ".$tmp_table_sorted." (store_product_id, sinch_product_id, feature_name, text) values(".$store_product_id.",".$sinch_product_id.",'".$name."','".$value."')";
145
+ $this->tep_db_query($q);
146
+ }
147
+ //mysqli_real_escape_string($name)
148
+ $i++;
149
+ }
150
+ }
151
+ }
152
+ private function tep_db_query($q){
153
+ $resource = Mage::getResourceSingleton('catalog/product');
154
+ $connection = $resource->getReadConnection();
155
+ $result = $connection->query($q);
156
+ return($result);
157
+ }
158
+
159
+ }
app/code/local/Bintime/Sinchimport/Block/Product/View/Media.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
- class Bintime_Sinchimport_Block_Product_View_Media extends Mage_Catalog_Block_Product_View_Media
3
- {
4
- public function getGalleryUrl($image=null)
5
- {
6
- if (substr($image['url'],0,4) != 'http') {
7
- $params = array('id'=>$this->getProduct()->getId());
8
- if ($image) {
9
- $params['image'] = $image->getValueId();
10
- return $this->getUrl('*/*/gallery', $params);
11
- }
12
- return $this->getUrl('*/*/gallery', $params);
13
- }else{
14
- return $image['url'];
15
- }
16
- }
17
-
18
- }
19
- ?>
1
+ <?php
2
+ class Bintime_Sinchimport_Block_Product_View_Media extends Mage_Catalog_Block_Product_View_Media
3
+ {
4
+ public function getGalleryUrl($image=null)
5
+ {
6
+ if (substr($image['url'],0,4) != 'http') {
7
+ $params = array('id'=>$this->getProduct()->getId());
8
+ if ($image) {
9
+ $params['image'] = $image->getValueId();
10
+ return $this->getUrl('*/*/gallery', $params);
11
+ }
12
+ return $this->getUrl('*/*/gallery', $params);
13
+ }else{
14
+ return $image['url'];
15
+ }
16
+ }
17
+
18
+ }
19
+ ?>
app/code/local/Bintime/Sinchimport/Block/Startimportbutton.php CHANGED
@@ -1,344 +1,344 @@
1
- <?php
2
- class Bintime_Sinchimport_Block_Startimportbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
3
- {
4
-
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $this->setElement($element);
8
- $url = $this->getUrl('sinchimport/index'); //
9
- $this->setElement($element);
10
-
11
- $html = $this->_appendJs();
12
-
13
- $html .= '<div id="sinchimport_status_template" name="sinchimport_status_template" style="display:none">';//none
14
- $html .= $this->_getStatusTemplateHtml();
15
- $html .= '</div>';
16
-
17
- $start_import_button = $this->getLayout()->createBlock('adminhtml/widget_button')
18
- ->setType('button')
19
- ->setClass('scalable')
20
- ->setLabel('Force Import now')
21
- ->setOnClick("start_sinch_import()") //setLocation('$url')
22
- ->toHtml();
23
- $safe_mode_set = ini_get('safe_mode');
24
- if($safe_mode_set){
25
- $html .="<p class='sinch-error'><b>You can't start import (safe_mode is 'On'. set safe_mode = Off in php.ini )<b></p>";
26
- }else{
27
- $html .= $start_import_button;
28
- }
29
- // $html .= $url;
30
- $dataConf = Mage::getConfig();//('sinchimport_root');//getConfig()->getNode()->asXML();
31
- // $html .= "<pre>".var_export($dataConf, true)."</pre>";
32
- $import=Mage::getModel('sinchimport/sinch');
33
- $last_import=$import->getDataOfLatestImport();
34
- $last_imp_status=$last_import['global_status_import'];
35
- if($last_imp_status=='Failed'){
36
- $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p class="sinch-error">The import has failed. Please ensure that you are using the correct settings. Last step was "'.$last_import['detail_status_import'].'"<br> Error reporting : "'.$last_import['error_report_message'].'"</p></div>';
37
- }elseif($last_imp_status=='Successful'){
38
- $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p class="sinch-success">'.$last_import['number_of_products'].' products imported succesfully!</p></div>';
39
- }elseif($last_imp_status=='Run'){
40
- $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p>Import is running now</p></div>';
41
- }else{
42
- $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"></div>';
43
- }
44
-
45
- return $html;
46
- }
47
-
48
- protected function _getStatusTemplateHtml()
49
- {
50
- $run_pic=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif";
51
- $html="
52
- <ul>
53
- <li>
54
- Start Import
55
- &nbsp
56
- <span id='sinchimport_start_import'>
57
- <img src='".$run_pic."'
58
- alt='Sinch Import run' />
59
- </span>
60
- </li>
61
- <li>
62
- Download files
63
- &nbsp
64
- <span id='sinchimport_upload_files'>
65
- <img src='".$run_pic."'
66
- alt='Download files' />
67
- </span>
68
- </li>
69
- <li>
70
- Parse Categories
71
- &nbsp
72
- <span id='sinchimport_parse_categories'>
73
- <img src='".$run_pic."'
74
- alt='Parse Categories' />
75
- </span>
76
- </li>
77
- <li>
78
- Parse Category Features
79
- &nbsp
80
- <span id='sinchimport_parse_category_features'>
81
- <img src='".$run_pic."'
82
- alt='Parse Category Features' />
83
- </span>
84
- </li>
85
- <li>
86
- Parse Distributors
87
- &nbsp
88
- <span id='sinchimport_parse_distributors'>
89
- <img src='".$run_pic."'
90
- alt='Parse Distributors' />
91
- </span>
92
- </li>
93
- <li>
94
- Parse EAN Codes
95
- &nbsp
96
- <span id='sinchimport_parse_ean_codes'>
97
- <img src='".$run_pic."'
98
- alt='Parse EAN Codes' />
99
- </span>
100
- </li>
101
- <li>
102
- Parse Manufacturers
103
- &nbsp
104
- <span id='sinchimport_parse_manufacturers'>
105
- <img src='".$run_pic."'
106
- alt='Parse Manufacturers'' />
107
- </span>
108
- </li>
109
- <li>
110
- Parse Related Products
111
- &nbsp
112
- <span id='sinchimport_parse_related_products'>
113
- <img src='".$run_pic."'
114
- alt='Parse Related Products' />
115
- </span>
116
- </li>
117
- <li>
118
- Parse Product Features
119
- &nbsp
120
- <span id='sinchimport_parse_product_features'>
121
- <img src='".$run_pic."'
122
- alt='Parse Product Features' />
123
- </span>
124
- </li>
125
- <li>
126
- Parse Products
127
- &nbsp
128
- <span id='sinchimport_parse_products'>
129
- <img src='".$run_pic."'
130
- alt='Parse Products' />
131
- </span>
132
- </li>
133
- <li>
134
- Parse Pictures Gallery
135
- &nbsp
136
- <span id='sinchimport_parse_pictures_gallery'>
137
- <img src='".$run_pic."'
138
- alt='Parse Pictures Gallery' />
139
- </span>
140
- </li>
141
- <li>
142
- Parse Restricted Values
143
- &nbsp
144
- <span id='sinchimport_parse_restricted_values'>
145
- <img src='".$run_pic."'
146
- alt='Parse Restricted Values' />
147
- </span>
148
- </li>
149
- <li>
150
- Parse Stock And Prices
151
- &nbsp
152
- <span id='sinchimport_parse_stock_and_prices'>
153
- <img src='".$run_pic."'
154
- alt='Parse Stock And Prices' />
155
- </span>
156
- </li>
157
- <li>
158
- Generate category filters
159
- &nbsp
160
- <span id='sinchimport_generate_category_filters'>
161
- <img src='".$run_pic."'
162
- alt='Generate category filters' />
163
- </span>
164
- </li>
165
- <li>
166
- Indexing data
167
- &nbsp
168
- <span id='sinchimport_indexing_data'>
169
- <img src='".$run_pic."'
170
- alt='Indexing data' />
171
- </span>
172
- </li>
173
- <li>
174
- Import finished
175
- &nbsp
176
- <span id='sinchimport_import_finished'>
177
- <img src='".$run_pic."'
178
- alt='Import finished' />
179
- </span>
180
- </li>
181
-
182
- </ul>
183
- ";
184
- return $html;
185
- }
186
-
187
- protected function _appendJs()
188
- {
189
- $post_url=$this->getUrl('sinchimport/ajax');
190
- $post_url_upd=$this->getUrl('sinchimport/ajax/UpdateStatus');
191
- $html = "
192
- <script>
193
- function start_sinch_import(){
194
- set_run_icon();
195
- status_div=document.getElementById('sinchimport_status_template');
196
- curr_status_div=document.getElementById('sinchimport_current_status_message');
197
- curr_status_div.style.display='none';
198
- status_div.style.display='';
199
- // status_div.innerHTML='';
200
- sinch = new Sinch('$post_url','$post_url_upd');
201
- sinch.startSinchImport();
202
-
203
- //
204
- }
205
- function set_run_icon(){
206
- run_pic='<img src=\"".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif\""."/>';
207
- document.getElementById('sinchimport_start_import').innerHTML=run_pic;
208
- document.getElementById('sinchimport_upload_files').innerHTML=run_pic;
209
- document.getElementById('sinchimport_parse_categories').innerHTML=run_pic;
210
- document.getElementById('sinchimport_parse_category_features').innerHTML=run_pic;
211
- document.getElementById('sinchimport_parse_distributors').innerHTML=run_pic;
212
- document.getElementById('sinchimport_parse_ean_codes').innerHTML=run_pic;
213
- document.getElementById('sinchimport_parse_manufacturers').innerHTML=run_pic;
214
- document.getElementById('sinchimport_parse_related_products').innerHTML=run_pic;
215
- document.getElementById('sinchimport_parse_product_features').innerHTML=run_pic;
216
- document.getElementById('sinchimport_parse_products').innerHTML=run_pic;
217
- document.getElementById('sinchimport_parse_pictures_gallery').innerHTML=run_pic;
218
- document.getElementById('sinchimport_parse_restricted_values').innerHTML=run_pic;
219
- document.getElementById('sinchimport_parse_stock_and_prices').innerHTML=run_pic;
220
- document.getElementById('sinchimport_generate_category_filters').innerHTML=run_pic;
221
- document.getElementById('sinchimport_indexing_data').innerHTML=run_pic;
222
- document.getElementById('sinchimport_import_finished').innerHTML=run_pic;
223
-
224
-
225
-
226
- }
227
- var Sinch = Class.create();
228
- Sinch.prototype = {
229
-
230
- initialize: function(postUrl, postUrlUpd) {
231
- this.postUrl = postUrl; //'https://techatcost.com/purchases/ajax/';
232
- this.postUrlUpd = postUrlUpd;
233
- this.failureUrl = document.URL;
234
- // unique user session ID
235
- this.SID = null;
236
- // object with event message data
237
- this.objectMsg = null;
238
- this.prevMsg = '';
239
- // interval object
240
- this.updateTimer = null;
241
- // default shipping code. Display on errors
242
-
243
- elem = 'checkoutSteps';
244
- clickableEntity = '.head';
245
-
246
- // overwrite Accordion class method
247
- var headers = $$('#' + elem + ' .section ' + clickableEntity);
248
- headers.each(function(header) {
249
- Event.observe(header,'click',this.sectionClicked.bindAsEventListener(this));
250
- }.bind(this));
251
- },
252
- startSinchImport: function () {
253
- _this = this;
254
- new Ajax.Request(this.postUrl,
255
- {
256
- method:'post',
257
- parameters: '',
258
- requestTimeout: 10,
259
- /*
260
- onLoading:function(){
261
- alert('onLoading');
262
- },
263
- onLoaded:function(){
264
- alert('onLoaded');
265
- },
266
- */
267
- onSuccess: function(transport) {
268
- var response = transport.responseText || null;
269
- _this.SID = response;
270
- if (_this.SID) {
271
- _this.updateTimer = setInterval(function(){_this.updateEvent();},20000);
272
- $('session_id').value = _this.SID;
273
- } else {
274
- alert('Can not get your session ID. Please reload the page!');
275
- }
276
- },
277
- onTimeout: function() { alert('Can not get your session ID. Timeout!'); },
278
- onFailure: function() { alert('Something went wrong...') }
279
- });
280
-
281
- },
282
-
283
- updateEvent: function () {
284
- _this = this;
285
- new Ajax.Request(this.postUrlUpd,
286
- {
287
- method: 'post',
288
- parameters: {session_id: this.SID},
289
- onSuccess: function(transport) {
290
- _this.objectMsg = transport.responseText.evalJSON();
291
- _this.prevMsg = _this.objectMsg.message;
292
- if(_this.prevMsg!=''){
293
- _this.updateStatusHtml();
294
- }
295
-
296
- if (_this.objectMsg.error == 1) {
297
- // Do something on error
298
- _this.clearUpdateInterval();
299
- }
300
-
301
- if (_this.objectMsg.finished == 1) {
302
- _this.objectMsg.message='Import finished';
303
- _this.updateStatusHtml();
304
- _this.clearUpdateInterval();
305
-
306
- }
307
-
308
- },
309
- onFailure: this.ajaxFailure.bind(),
310
- });
311
- },
312
-
313
- updateStatusHtml: function(){
314
- message=this.objectMsg.message.toLowerCase();
315
- mess_id='sinchimport_'+message.replace(/\s+/g, '_');
316
- if(!document.getElementById(mess_id)){
317
- // alert(mess_id+' - not exist');
318
- }
319
- else{
320
- // alert (mess_id+' - exist');
321
- $(mess_id).innerHTML='<img src=\"".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_yes.gif"."\"/>'
322
- }
323
- htm=$('sinchimport_status_template').innerHTML;
324
- // $('sinchimport_status_template').innerHTML=htm+'<br>'+this.objectMsg.message;
325
- },
326
-
327
- ajaxFailure: function(){
328
- this.clearUpdateInterval();
329
- location.href = this.failureUrl;
330
- },
331
-
332
- clearUpdateInterval: function () {
333
- clearInterval(this.updateTimer);
334
- },
335
-
336
-
337
- }
338
- </script>
339
- ";
340
- return $html;
341
- }
342
-
343
- }
344
- ?>
1
+ <?php
2
+ class Bintime_Sinchimport_Block_Startimportbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $this->setElement($element);
8
+ $url = $this->getUrl('sinchimport/index'); //
9
+ $this->setElement($element);
10
+
11
+ $html = $this->_appendJs();
12
+
13
+ $html .= '<div id="sinchimport_status_template" name="sinchimport_status_template" style="display:none">';//none
14
+ $html .= $this->_getStatusTemplateHtml();
15
+ $html .= '</div>';
16
+
17
+ $start_import_button = $this->getLayout()->createBlock('adminhtml/widget_button')
18
+ ->setType('button')
19
+ ->setClass('scalable')
20
+ ->setLabel('Force Import now')
21
+ ->setOnClick("start_sinch_import()") //setLocation('$url')
22
+ ->toHtml();
23
+ $safe_mode_set = ini_get('safe_mode');
24
+ if($safe_mode_set){
25
+ $html .="<p class='sinch-error'><b>You can't start import (safe_mode is 'On'. set safe_mode = Off in php.ini )<b></p>";
26
+ }else{
27
+ $html .= $start_import_button;
28
+ }
29
+ // $html .= $url;
30
+ $dataConf = Mage::getConfig();//('sinchimport_root');//getConfig()->getNode()->asXML();
31
+ // $html .= "<pre>".var_export($dataConf, true)."</pre>";
32
+ $import=Mage::getModel('sinchimport/sinch');
33
+ $last_import=$import->getDataOfLatestImport();
34
+ $last_imp_status=$last_import['global_status_import'];
35
+ if($last_imp_status=='Failed'){
36
+ $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p class="sinch-error">The import has failed. Please ensure that you are using the correct settings. Last step was "'.$last_import['detail_status_import'].'"<br> Error reporting : "'.$last_import['error_report_message'].'"</p></div>';
37
+ }elseif($last_imp_status=='Successful'){
38
+ $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p class="sinch-success">'.$last_import['number_of_products'].' products imported succesfully!</p></div>';
39
+ }elseif($last_imp_status=='Run'){
40
+ $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p>Import is running now</p></div>';
41
+ }else{
42
+ $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"></div>';
43
+ }
44
+
45
+ return $html;
46
+ }
47
+
48
+ protected function _getStatusTemplateHtml()
49
+ {
50
+ $run_pic=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif";
51
+ $html="
52
+ <ul>
53
+ <li>
54
+ Start Import
55
+ &nbsp
56
+ <span id='sinchimport_start_import'>
57
+ <img src='".$run_pic."'
58
+ alt='Sinch Import run' />
59
+ </span>
60
+ </li>
61
+ <li>
62
+ Download files
63
+ &nbsp
64
+ <span id='sinchimport_upload_files'>
65
+ <img src='".$run_pic."'
66
+ alt='Download files' />
67
+ </span>
68
+ </li>
69
+ <li>
70
+ Parse Categories
71
+ &nbsp
72
+ <span id='sinchimport_parse_categories'>
73
+ <img src='".$run_pic."'
74
+ alt='Parse Categories' />
75
+ </span>
76
+ </li>
77
+ <li>
78
+ Parse Category Features
79
+ &nbsp
80
+ <span id='sinchimport_parse_category_features'>
81
+ <img src='".$run_pic."'
82
+ alt='Parse Category Features' />
83
+ </span>
84
+ </li>
85
+ <li>
86
+ Parse Distributors
87
+ &nbsp
88
+ <span id='sinchimport_parse_distributors'>
89
+ <img src='".$run_pic."'
90
+ alt='Parse Distributors' />
91
+ </span>
92
+ </li>
93
+ <li>
94
+ Parse EAN Codes
95
+ &nbsp
96
+ <span id='sinchimport_parse_ean_codes'>
97
+ <img src='".$run_pic."'
98
+ alt='Parse EAN Codes' />
99
+ </span>
100
+ </li>
101
+ <li>
102
+ Parse Manufacturers
103
+ &nbsp
104
+ <span id='sinchimport_parse_manufacturers'>
105
+ <img src='".$run_pic."'
106
+ alt='Parse Manufacturers'' />
107
+ </span>
108
+ </li>
109
+ <li>
110
+ Parse Related Products
111
+ &nbsp
112
+ <span id='sinchimport_parse_related_products'>
113
+ <img src='".$run_pic."'
114
+ alt='Parse Related Products' />
115
+ </span>
116
+ </li>
117
+ <li>
118
+ Parse Product Features
119
+ &nbsp
120
+ <span id='sinchimport_parse_product_features'>
121
+ <img src='".$run_pic."'
122
+ alt='Parse Product Features' />
123
+ </span>
124
+ </li>
125
+ <li>
126
+ Parse Products
127
+ &nbsp
128
+ <span id='sinchimport_parse_products'>
129
+ <img src='".$run_pic."'
130
+ alt='Parse Products' />
131
+ </span>
132
+ </li>
133
+ <li>
134
+ Parse Pictures Gallery
135
+ &nbsp
136
+ <span id='sinchimport_parse_pictures_gallery'>
137
+ <img src='".$run_pic."'
138
+ alt='Parse Pictures Gallery' />
139
+ </span>
140
+ </li>
141
+ <li>
142
+ Parse Restricted Values
143
+ &nbsp
144
+ <span id='sinchimport_parse_restricted_values'>
145
+ <img src='".$run_pic."'
146
+ alt='Parse Restricted Values' />
147
+ </span>
148
+ </li>
149
+ <li>
150
+ Parse Stock And Prices
151
+ &nbsp
152
+ <span id='sinchimport_parse_stock_and_prices'>
153
+ <img src='".$run_pic."'
154
+ alt='Parse Stock And Prices' />
155
+ </span>
156
+ </li>
157
+ <li>
158
+ Generate category filters
159
+ &nbsp
160
+ <span id='sinchimport_generate_category_filters'>
161
+ <img src='".$run_pic."'
162
+ alt='Generate category filters' />
163
+ </span>
164
+ </li>
165
+ <li>
166
+ Indexing data
167
+ &nbsp
168
+ <span id='sinchimport_indexing_data'>
169
+ <img src='".$run_pic."'
170
+ alt='Indexing data' />
171
+ </span>
172
+ </li>
173
+ <li>
174
+ Import finished
175
+ &nbsp
176
+ <span id='sinchimport_import_finished'>
177
+ <img src='".$run_pic."'
178
+ alt='Import finished' />
179
+ </span>
180
+ </li>
181
+
182
+ </ul>
183
+ ";
184
+ return $html;
185
+ }
186
+
187
+ protected function _appendJs()
188
+ {
189
+ $post_url=$this->getUrl('sinchimport/ajax');
190
+ $post_url_upd=$this->getUrl('sinchimport/ajax/UpdateStatus');
191
+ $html = "
192
+ <script>
193
+ function start_sinch_import(){
194
+ set_run_icon();
195
+ status_div=document.getElementById('sinchimport_status_template');
196
+ curr_status_div=document.getElementById('sinchimport_current_status_message');
197
+ curr_status_div.style.display='none';
198
+ status_div.style.display='';
199
+ // status_div.innerHTML='';
200
+ sinch = new Sinch('$post_url','$post_url_upd');
201
+ sinch.startSinchImport();
202
+
203
+ //
204
+ }
205
+ function set_run_icon(){
206
+ run_pic='<img src=\"".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif\""."/>';
207
+ document.getElementById('sinchimport_start_import').innerHTML=run_pic;
208
+ document.getElementById('sinchimport_upload_files').innerHTML=run_pic;
209
+ document.getElementById('sinchimport_parse_categories').innerHTML=run_pic;
210
+ document.getElementById('sinchimport_parse_category_features').innerHTML=run_pic;
211
+ document.getElementById('sinchimport_parse_distributors').innerHTML=run_pic;
212
+ document.getElementById('sinchimport_parse_ean_codes').innerHTML=run_pic;
213
+ document.getElementById('sinchimport_parse_manufacturers').innerHTML=run_pic;
214
+ document.getElementById('sinchimport_parse_related_products').innerHTML=run_pic;
215
+ document.getElementById('sinchimport_parse_product_features').innerHTML=run_pic;
216
+ document.getElementById('sinchimport_parse_products').innerHTML=run_pic;
217
+ document.getElementById('sinchimport_parse_pictures_gallery').innerHTML=run_pic;
218
+ document.getElementById('sinchimport_parse_restricted_values').innerHTML=run_pic;
219
+ document.getElementById('sinchimport_parse_stock_and_prices').innerHTML=run_pic;
220
+ document.getElementById('sinchimport_generate_category_filters').innerHTML=run_pic;
221
+ document.getElementById('sinchimport_indexing_data').innerHTML=run_pic;
222
+ document.getElementById('sinchimport_import_finished').innerHTML=run_pic;
223
+
224
+
225
+
226
+ }
227
+ var Sinch = Class.create();
228
+ Sinch.prototype = {
229
+
230
+ initialize: function(postUrl, postUrlUpd) {
231
+ this.postUrl = postUrl; //'https://techatcost.com/purchases/ajax/';
232
+ this.postUrlUpd = postUrlUpd;
233
+ this.failureUrl = document.URL;
234
+ // unique user session ID
235
+ this.SID = null;
236
+ // object with event message data
237
+ this.objectMsg = null;
238
+ this.prevMsg = '';
239
+ // interval object
240
+ this.updateTimer = null;
241
+ // default shipping code. Display on errors
242
+
243
+ elem = 'checkoutSteps';
244
+ clickableEntity = '.head';
245
+
246
+ // overwrite Accordion class method
247
+ var headers = $$('#' + elem + ' .section ' + clickableEntity);
248
+ headers.each(function(header) {
249
+ Event.observe(header,'click',this.sectionClicked.bindAsEventListener(this));
250
+ }.bind(this));
251
+ },
252
+ startSinchImport: function () {
253
+ _this = this;
254
+ new Ajax.Request(this.postUrl,
255
+ {
256
+ method:'post',
257
+ parameters: '',
258
+ requestTimeout: 10,
259
+ /*
260
+ onLoading:function(){
261
+ alert('onLoading');
262
+ },
263
+ onLoaded:function(){
264
+ alert('onLoaded');
265
+ },
266
+ */
267
+ onSuccess: function(transport) {
268
+ var response = transport.responseText || null;
269
+ _this.SID = response;
270
+ if (_this.SID) {
271
+ _this.updateTimer = setInterval(function(){_this.updateEvent();},20000);
272
+ $('session_id').value = _this.SID;
273
+ } else {
274
+ alert('Can not get your session ID. Please reload the page!');
275
+ }
276
+ },
277
+ onTimeout: function() { alert('Can not get your session ID. Timeout!'); },
278
+ onFailure: function() { alert('Something went wrong...') }
279
+ });
280
+
281
+ },
282
+
283
+ updateEvent: function () {
284
+ _this = this;
285
+ new Ajax.Request(this.postUrlUpd,
286
+ {
287
+ method: 'post',
288
+ parameters: {session_id: this.SID},
289
+ onSuccess: function(transport) {
290
+ _this.objectMsg = transport.responseText.evalJSON();
291
+ _this.prevMsg = _this.objectMsg.message;
292
+ if(_this.prevMsg!=''){
293
+ _this.updateStatusHtml();
294
+ }
295
+
296
+ if (_this.objectMsg.error == 1) {
297
+ // Do something on error
298
+ _this.clearUpdateInterval();
299
+ }
300
+
301
+ if (_this.objectMsg.finished == 1) {
302
+ _this.objectMsg.message='Import finished';
303
+ _this.updateStatusHtml();
304
+ _this.clearUpdateInterval();
305
+
306
+ }
307
+
308
+ },
309
+ onFailure: this.ajaxFailure.bind(),
310
+ });
311
+ },
312
+
313
+ updateStatusHtml: function(){
314
+ message=this.objectMsg.message.toLowerCase();
315
+ mess_id='sinchimport_'+message.replace(/\s+/g, '_');
316
+ if(!document.getElementById(mess_id)){
317
+ // alert(mess_id+' - not exist');
318
+ }
319
+ else{
320
+ // alert (mess_id+' - exist');
321
+ $(mess_id).innerHTML='<img src=\"".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_yes.gif"."\"/>'
322
+ }
323
+ htm=$('sinchimport_status_template').innerHTML;
324
+ // $('sinchimport_status_template').innerHTML=htm+'<br>'+this.objectMsg.message;
325
+ },
326
+
327
+ ajaxFailure: function(){
328
+ this.clearUpdateInterval();
329
+ location.href = this.failureUrl;
330
+ },
331
+
332
+ clearUpdateInterval: function () {
333
+ clearInterval(this.updateTimer);
334
+ },
335
+
336
+
337
+ }
338
+ </script>
339
+ ";
340
+ return $html;
341
+ }
342
+
343
+ }
344
+ ?>
app/code/local/Bintime/Sinchimport/Block/Startstockpriceimportbutton.php CHANGED
@@ -1,138 +1,138 @@
1
- <?php
2
- class Bintime_Sinchimport_Block_Startstockpriceimportbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
3
- {
4
-
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $this->setElement($element);
8
- $url = $this->getUrl('sinchimport/index'); //
9
- $this->setElement($element);
10
-
11
- $html = $this->_appendJs();
12
-
13
- $html .= '<div id="sinchimport_stock_price_status_template" name="sinchimport_stock_price_status_template" style="display:none">';//none
14
- $html .= $this->_getStatusTemplateHtml();
15
- $html .= '</div>';
16
-
17
- $start_import_button = $this->getLayout()->createBlock('adminhtml/widget_button')
18
- ->setType('button')
19
- ->setClass('scalable')
20
- ->setLabel('Force Stock & Prices Import now')
21
- ->setOnClick("start_stock_price_sinch_import()") //setLocation('$url')
22
- ->toHtml();
23
- // $html .= $url;
24
- $dataConf = Mage::getConfig();//('sinchimport_root');//getConfig()->getNode()->asXML();
25
- // $html .= "<pre>".var_export($dataConf, true)."</pre>";
26
- $import=Mage::getModel('sinchimport/sinch');
27
-
28
- $safe_mode_set = ini_get('safe_mode');
29
- if($safe_mode_set){
30
- $html .="<p class='sinch-error'><b>You can't start import (safe_mode is 'On'. set safe_mode = Off in php.ini )<b></p>";
31
- }elseif(!$import->is_full_import_have_been_run()){
32
- $html .="Full import have never finished with success";
33
- }else{
34
- $html .= $start_import_button;
35
- }
36
-
37
- $last_import=$import->getDataOfLatestImport();
38
- $last_imp_status=$last_import['global_status_import'];
39
- if($last_imp_status=='Failed'){
40
- $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p class="sinch-error">The import has failed. Please ensure that you are using the correct settings. Last step was "'.$last_import['detail_status_import'].'"<br> Error reporting : "'.$last_import['error_report_message'].'"</p></div>';
41
- }elseif($last_imp_status=='Successful'){
42
- $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p class="sinch-success">'.$last_import['number_of_products'].' products imported succesfully!</p></div>';
43
- }elseif($last_imp_status=='Run'){
44
- $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p>Import is running now</p></div>';
45
- }else{
46
- $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"></div>';
47
- }
48
-
49
- return $html;
50
- }
51
-
52
- protected function _getStatusTemplateHtml()
53
- {
54
- $run_pic=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif";
55
- $html="
56
- <ul>
57
- <li>
58
- Start Import
59
- &nbsp
60
- <span id='sinchimport_stock_price_start_import'>
61
- <img src='".$run_pic."'
62
- alt='Sinch Import run' />
63
- </span>
64
- </li>
65
- <li>
66
- Download files
67
- &nbsp
68
- <span id='sinchimport_stock_price_upload_files'>
69
- <img src='".$run_pic."'
70
- alt='Download files' />
71
- </span>
72
- </li>
73
- <li>
74
- Parse Stock And Prices
75
- &nbsp
76
- <span id='sinchimport_stock_price_parse_products'>
77
- <img src='".$run_pic."'
78
- alt='Parse Stock And Prices' />
79
- </span>
80
- </li>
81
- <li>
82
- Indexing data
83
- &nbsp
84
- <span id='sinchimport_stock_price_indexing_data'>
85
- <img src='".$run_pic."'
86
- alt='Indexing data' />
87
- </span>
88
- </li>
89
- <li>
90
- Import finished
91
- &nbsp
92
- <span id='sinchimport_stock_price_finish_import'>
93
- <img src='".$run_pic."'
94
- alt='Import finished' />
95
- </span>
96
- </li>
97
-
98
- </ul>
99
- ";
100
- return $html;
101
- }
102
-
103
- protected function _appendJs()
104
- {
105
- $post_url=$this->getUrl('sinchimport/ajax/stockPrice');
106
- $post_url_upd=$this->getUrl('sinchimport/ajax/UpdateStatus');
107
- $html = "
108
- <script>
109
- function start_stock_price_sinch_import(){
110
- set_stock_price_run_icon();
111
- st_pr_status_div=document.getElementById('sinchimport_stock_price_status_template');
112
- curr_status_div=document.getElementById('sinchimport_current_status_message');
113
- curr_status_div.style.display='none';
114
- st_pr_status_div.style.display='';
115
- // status_div.innerHTML='';
116
- sinch = new Sinch('$post_url','$post_url_upd');
117
- sinch.startSinchImport();
118
-
119
- //
120
- }
121
-
122
- function set_stock_price_run_icon(){
123
- run_pic='<img src=\"".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif\""."/>';
124
- document.getElementById('sinchimport_stock_price_start_import').innerHTML=run_pic;
125
- document.getElementById('sinchimport_stock_price_upload_files').innerHTML=run_pic;
126
- document.getElementById('sinchimport_stock_price_parse_products').innerHTML=run_pic;
127
- document.getElementById('sinchimport_stock_price_indexing_data').innerHTML=run_pic;
128
- document.getElementById('sinchimport_stock_price_finish_import').innerHTML=run_pic;
129
-
130
- }
131
-
132
- </script>
133
- ";
134
- return $html;
135
- }
136
-
137
- }
138
- ?>
1
+ <?php
2
+ class Bintime_Sinchimport_Block_Startstockpriceimportbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $this->setElement($element);
8
+ $url = $this->getUrl('sinchimport/index'); //
9
+ $this->setElement($element);
10
+
11
+ $html = $this->_appendJs();
12
+
13
+ $html .= '<div id="sinchimport_stock_price_status_template" name="sinchimport_stock_price_status_template" style="display:none">';//none
14
+ $html .= $this->_getStatusTemplateHtml();
15
+ $html .= '</div>';
16
+
17
+ $start_import_button = $this->getLayout()->createBlock('adminhtml/widget_button')
18
+ ->setType('button')
19
+ ->setClass('scalable')
20
+ ->setLabel('Force Stock & Prices Import now')
21
+ ->setOnClick("start_stock_price_sinch_import()") //setLocation('$url')
22
+ ->toHtml();
23
+ // $html .= $url;
24
+ $dataConf = Mage::getConfig();//('sinchimport_root');//getConfig()->getNode()->asXML();
25
+ // $html .= "<pre>".var_export($dataConf, true)."</pre>";
26
+ $import=Mage::getModel('sinchimport/sinch');
27
+
28
+ $safe_mode_set = ini_get('safe_mode');
29
+ if($safe_mode_set){
30
+ $html .="<p class='sinch-error'><b>You can't start import (safe_mode is 'On'. set safe_mode = Off in php.ini )<b></p>";
31
+ }elseif(!$import->is_full_import_have_been_run()){
32
+ $html .="Full import have never finished with success";
33
+ }else{
34
+ $html .= $start_import_button;
35
+ }
36
+
37
+ $last_import=$import->getDataOfLatestImport();
38
+ $last_imp_status=$last_import['global_status_import'];
39
+ if($last_imp_status=='Failed'){
40
+ $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p class="sinch-error">The import has failed. Please ensure that you are using the correct settings. Last step was "'.$last_import['detail_status_import'].'"<br> Error reporting : "'.$last_import['error_report_message'].'"</p></div>';
41
+ }elseif($last_imp_status=='Successful'){
42
+ $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p class="sinch-success">'.$last_import['number_of_products'].' products imported succesfully!</p></div>';
43
+ }elseif($last_imp_status=='Run'){
44
+ $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"><br><br><hr/><p>Import is running now</p></div>';
45
+ }else{
46
+ $html.='<div id="sinchimport_current_status_message" name="sinchimport_current_status_message" style="display:true"></div>';
47
+ }
48
+
49
+ return $html;
50
+ }
51
+
52
+ protected function _getStatusTemplateHtml()
53
+ {
54
+ $run_pic=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif";
55
+ $html="
56
+ <ul>
57
+ <li>
58
+ Start Import
59
+ &nbsp
60
+ <span id='sinchimport_stock_price_start_import'>
61
+ <img src='".$run_pic."'
62
+ alt='Sinch Import run' />
63
+ </span>
64
+ </li>
65
+ <li>
66
+ Download files
67
+ &nbsp
68
+ <span id='sinchimport_stock_price_upload_files'>
69
+ <img src='".$run_pic."'
70
+ alt='Download files' />
71
+ </span>
72
+ </li>
73
+ <li>
74
+ Parse Stock And Prices
75
+ &nbsp
76
+ <span id='sinchimport_stock_price_parse_products'>
77
+ <img src='".$run_pic."'
78
+ alt='Parse Stock And Prices' />
79
+ </span>
80
+ </li>
81
+ <li>
82
+ Indexing data
83
+ &nbsp
84
+ <span id='sinchimport_stock_price_indexing_data'>
85
+ <img src='".$run_pic."'
86
+ alt='Indexing data' />
87
+ </span>
88
+ </li>
89
+ <li>
90
+ Import finished
91
+ &nbsp
92
+ <span id='sinchimport_stock_price_finish_import'>
93
+ <img src='".$run_pic."'
94
+ alt='Import finished' />
95
+ </span>
96
+ </li>
97
+
98
+ </ul>
99
+ ";
100
+ return $html;
101
+ }
102
+
103
+ protected function _appendJs()
104
+ {
105
+ $post_url=$this->getUrl('sinchimport/ajax/stockPrice');
106
+ $post_url_upd=$this->getUrl('sinchimport/ajax/UpdateStatus');
107
+ $html = "
108
+ <script>
109
+ function start_stock_price_sinch_import(){
110
+ set_stock_price_run_icon();
111
+ st_pr_status_div=document.getElementById('sinchimport_stock_price_status_template');
112
+ curr_status_div=document.getElementById('sinchimport_current_status_message');
113
+ curr_status_div.style.display='none';
114
+ st_pr_status_div.style.display='';
115
+ // status_div.innerHTML='';
116
+ sinch = new Sinch('$post_url','$post_url_upd');
117
+ sinch.startSinchImport();
118
+
119
+ //
120
+ }
121
+
122
+ function set_stock_price_run_icon(){
123
+ run_pic='<img src=\"".Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)."adminhtml/default/default/images/sinchimport_run.gif\""."/>';
124
+ document.getElementById('sinchimport_stock_price_start_import').innerHTML=run_pic;
125
+ document.getElementById('sinchimport_stock_price_upload_files').innerHTML=run_pic;
126
+ document.getElementById('sinchimport_stock_price_parse_products').innerHTML=run_pic;
127
+ document.getElementById('sinchimport_stock_price_indexing_data').innerHTML=run_pic;
128
+ document.getElementById('sinchimport_stock_price_finish_import').innerHTML=run_pic;
129
+
130
+ }
131
+
132
+ </script>
133
+ ";
134
+ return $html;
135
+ }
136
+
137
+ }
138
+ ?>
app/code/local/Bintime/Sinchimport/Helper/Data.php CHANGED
@@ -1,6 +1,6 @@
1
- <?php
2
- class Bintime_Sinchimport_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
-
5
- }
6
- ?>
1
+ <?php
2
+ class Bintime_Sinchimport_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
6
+ ?>
app/code/local/Bintime/Sinchimport/Helper/Getdata.php CHANGED
@@ -1,186 +1,186 @@
1
- <?php
2
- /**
3
- *
4
- * Class achieves icecat description from Model by recieved SKU and manufacturer
5
- * @author Sergey Gozhedrianov <info@bintime.com>
6
- *
7
- */
8
- class Bintime_Sinchimport_Helper_Getdata extends Mage_Core_Helper_Abstract
9
- {
10
- private $iceCatModel;
11
- private $sinchModel;
12
- private $error;
13
- private $systemError;
14
-
15
- /**
16
- * Gets product Data and delegates it to Model
17
- * @param Mage_Catalog_Model_Product $_product
18
- * @return Bintime_Icecatimport_Helper_Getdata
19
- */
20
- public function getProductDescription($_product){
21
- $entityId = $_product->getEntityId();
22
- /* $sku = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
23
- $manufacturerId = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
24
- if (Mage::getStoreConfig('icecat_root/icecat/manufacturer') == 'manufacturer'){
25
- $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
26
- ->setEntityTypeFilter($_product->getResource()->getTypeId())
27
- ->addFieldToFilter('attribute_code', 'manufacturer');
28
- $attribute = $attributes->getFirstItem()->setEntity($_product->getResource());
29
- $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
30
- }
31
- else {
32
- $manufacturer = $manufacturerId;
33
- }
34
- $locale = Mage::getStoreConfig('icecat_root/icecat/language');
35
-
36
- if ($locale == '0'){
37
- $systemLocale = explode("_", Mage::app()->getLocale()->getLocaleCode());
38
- $locale = $systemLocale[0];
39
- }
40
- $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
41
- $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
42
-
43
- $this->iceCatModel = Mage::getSingleton('icecatimport/import');
44
-
45
- if (!$this->iceCatModel->getProductDescription($sku, $manufacturer, $locale, $userLogin, $userPass, $entityId)){
46
- $this->error = $this->iceCatModel->getErrorMessage();
47
- $this->systemError = $this->iceCatModel->getSystemError();
48
- return $this;
49
- }
50
- */
51
- $this->sinchModel = Mage::getSingleton('sinchimport/sinch');
52
- if(!$this->sinchModel->getProductDescription($entityId)){
53
- $this->error = $this->sinchModel->getErrorMessage();
54
- $this->systemError = $this->sinchModel->getSystemError();
55
- }
56
- return $this;
57
- }
58
- /**
59
- * returns true if error during data fetch occured else false
60
- */
61
- public function hasError(){
62
- if ($this->error || $this->systemError){
63
- return true;
64
- }
65
- return false;
66
- }
67
-
68
- /**
69
- * return error message
70
- */
71
- public function getError(){
72
- //show icecat error on product page return $this->error;
73
- }
74
-
75
- /**
76
- * return system error
77
- */
78
- public function hasSystemError(){
79
- if ($this->systemError){
80
- return $this->systemError;
81
- }
82
- return false;
83
- }