Version Notes
Version 2.2.1:
* Category Description database table type limit extended
*EAN N/A fix
* Fixed Unknown column 'sku' in 'field list error message for stINch_products_mapping_temp
Download this release
Release Info
Developer | stockinchannel |
Extension | stockinthechannel2012 |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2.0 to 2.2.1
- app/code/local/Bintime/Sinchimport/Block/Adminhtml/Catalog/Product/Sinchdistributors.php +25 -25
- app/code/local/Bintime/Sinchimport/Block/Backupbutton.php +23 -22
- app/code/local/Bintime/Sinchimport/Block/Importenvironment.php +210 -210
- app/code/local/Bintime/Sinchimport/Block/Importhistory.php +385 -385
- app/code/local/Bintime/Sinchimport/Block/Layer/Filter/Feature.php +17 -17
- app/code/local/Bintime/Sinchimport/Block/Layer/View.php +48 -48
- app/code/local/Bintime/Sinchimport/Block/List.php +159 -159
- app/code/local/Bintime/Sinchimport/Block/Product/View/Media.php +18 -18
- app/code/local/Bintime/Sinchimport/Block/Startimportbutton.php +343 -343
- app/code/local/Bintime/Sinchimport/Block/Startstockpriceimportbutton.php +137 -137
- app/code/local/Bintime/Sinchimport/Helper/Data.php +5 -5
- app/code/local/Bintime/Sinchimport/Helper/Getdata.php +185 -185
- app/code/local/Bintime/Sinchimport/Helper/Image.php +73 -73
- app/code/local/Bintime/Sinchimport/Model/Api.php +85 -85
- app/code/local/Bintime/Sinchimport/Model/Backup.php +79 -79
- app/code/local/Bintime/Sinchimport/Model/Category.php +19 -19
- app/code/local/Bintime/Sinchimport/Model/Image.php +118 -118
- app/code/local/Bintime/Sinchimport/Model/Layer.php +49 -49
- app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Feature.php +248 -248
- app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Price.php +141 -192
- app/code/local/Bintime/Sinchimport/Model/Product.php +64 -64
- app/code/local/Bintime/Sinchimport/Model/Resource/Layer/Filter/Price.php +78 -78
- app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php +372 -399
- app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Setup.php +3 -3
- app/code/local/Bintime/Sinchimport/Model/Sinch.php +6907 -10266
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/Backupbutton.php
CHANGED
@@ -1,22 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
$
|
7 |
-
$this->
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
->
|
14 |
-
->
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
}
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bintime_Sinchimport_Block_Backupbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
6 |
+
$this->setElement($element);
|
7 |
+
$url = $this->getUrl('sinchimport/backup');
|
8 |
+
$this->setElement($element);
|
9 |
+
|
10 |
+
$html = '';
|
11 |
+
|
12 |
+
$start_import_button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
13 |
+
->setType('button')
|
14 |
+
->setClass('scalable')
|
15 |
+
->setLabel('Backup Now')
|
16 |
+
->setOnClick("setLocation('$url')")
|
17 |
+
->toHtml();
|
18 |
+
|
19 |
+
$html .= $start_import_button;
|
20 |
+
|
21 |
+
return $html;
|
22 |
+
}
|
23 |
+
}
|
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,385 +1,385 @@
|
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
}
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
}
|
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,18 +1,18 @@
|
|
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 |
-
}
|
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 |
+
}
|
app/code/local/Bintime/Sinchimport/Block/Startimportbutton.php
CHANGED
@@ -1,343 +1,343 @@
|
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
}
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
}
|
app/code/local/Bintime/Sinchimport/Block/Startstockpriceimportbutton.php
CHANGED
@@ -1,137 +1,137 @@
|
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
 
|
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 |
-
}
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
 
|
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 |
+
}
|
app/code/local/Bintime/Sinchimport/Helper/Data.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
<?php
|
2 |
-
class Bintime_Sinchimport_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
-
{
|
4 |
-
|
5 |
-
}
|
1 |
+
<?php
|
2 |
+
class Bintime_Sinchimport_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
}
|
app/code/local/Bintime/Sinchimport/Helper/Getdata.php
CHANGED
@@ -1,185 +1,185 @@
|
|
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 |
-
}
|
84 |
-
|
85 |
-
public function getProductDescriptionList(){
|
86 |
-
return $this->sinchModel->getProductDescriptionList();
|
87 |
-
}
|
88 |
-
public function getProductSpecifications(){
|
89 |
-
return $this->sinchModel->getProductSpecifications();
|
90 |
-
}
|
91 |
-
|
92 |
-
public function getShortProductDescription(){
|
93 |
-
return $this->sinchModel->getShortProductDescription();
|
94 |
-
}
|
95 |
-
|
96 |
-
public function getLowPicUrl(){
|
97 |
-
return $this->sinchModel->getLowPicUrl();
|
98 |
-
}
|
99 |
-
|
100 |
-
public function getGalleryPhotos(){
|
101 |
-
return $this->sinchModel->getGalleryPhotos();
|
102 |
-
}
|
103 |
-
|
104 |
-
public function getProductName(){
|
105 |
-
return $this->sinchModel->getProductName();
|
106 |
-
}
|
107 |
-
public function getVendor(){
|
108 |
-
return $this->sinchModel->getVendor();
|
109 |
-
}
|
110 |
-
|
111 |
-
public function getFullProductDescription(){
|
112 |
-
return $this->sinchModel->getFullProductDescription();
|
113 |
-
}
|
114 |
-
|
115 |
-
public function getMPN(){
|
116 |
-
return $this->sinchModel->getMPN();
|
117 |
-
}
|
118 |
-
public function getEAN(){
|
119 |
-
return $this->sinchModel->getEAN();
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Form related products list according to store products
|
124 |
-
*/
|
125 |
-
public function getRelatedProducts(){
|
126 |
-
$relatedProducts =$this->sinchModel->getRelatedProducts();
|
127 |
-
if (empty($relatedProducts)){
|
128 |
-
return array();
|
129 |
-
}
|
130 |
-
$sku = 'sku';
|
131 |
-
$collection = Mage::getModel('catalog/product')->getCollection();
|
132 |
-
|
133 |
-
$filterArray = array();
|
134 |
-
foreach($relatedProducts as $mpn => $valueArray){
|
135 |
-
array_push($filterArray, array('attribute'=>$sku,'eq'=>$mpn));
|
136 |
-
}
|
137 |
-
$collection->addFieldToFilter($filterArray);
|
138 |
-
|
139 |
-
$collection->addAttributeToSelect($sku);
|
140 |
-
$collection->addAttributeToSelect('category_ids');
|
141 |
-
|
142 |
-
$relatedProductsList = array();
|
143 |
-
foreach ($collection as $product) {
|
144 |
-
$categoryIds = $product->getCategoryIds();
|
145 |
-
if(!empty($categoryIds)){
|
146 |
-
if (is_array($categoryIds)){
|
147 |
-
$catogoriesArray = $categoryIds;
|
148 |
-
}
|
149 |
-
if (is_string($categoryIds)){
|
150 |
-
$catogoriesArray = explode(",",$product->getCategoryIds());
|
151 |
-
}
|
152 |
-
foreach($catogoriesArray as $categoryId){
|
153 |
-
if (!array_key_exists($product->getData($sku), $relatedProducts)){
|
154 |
-
continue;
|
155 |
-
}
|
156 |
-
$relatedProductInfo = $relatedProducts[$product->getData($sku)];
|
157 |
-
$relatedProductInfo['mpn'] = $product->getData($sku);
|
158 |
-
$relatedProductInfo['url'] = $product->getProductUrl();//preg_replace( '/\/\d+\/$/',"/".$categoryId."/",$product->getProductUrl());;
|
159 |
-
if (!array_key_exists($categoryId, $relatedProductsList)){
|
160 |
-
$relatedProductsList[$categoryId]= array();
|
161 |
-
}
|
162 |
-
|
163 |
-
array_push($relatedProductsList[$categoryId], $relatedProductInfo);
|
164 |
-
}
|
165 |
-
}
|
166 |
-
else {
|
167 |
-
if (!array_key_exists($product->getData($sku), $relatedProducts)){
|
168 |
-
continue;
|
169 |
-
}
|
170 |
-
$relatedProductInfo = $relatedProducts[$product->getData($sku)];
|
171 |
-
$relatedProductInfo['mpn'] = $product->getData($sku);
|
172 |
-
$relatedProductInfo['url'] = $product->getProductUrl();//preg_replace( '/category\/\d+\/$/','',$product->getProductUrl());;
|
173 |
-
if (!array_key_exists('a', $relatedProductsList)){
|
174 |
-
$relatedProductsList['a']= array();
|
175 |
-
}
|
176 |
-
|
177 |
-
array_push($relatedProductsList['a'], $relatedProductInfo);
|
178 |
-
}
|
179 |
-
}
|
180 |
-
|
181 |
-
return $relatedProductsList;
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
}
|
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 |
+
}
|
84 |
+
|
85 |
+
public function getProductDescriptionList(){
|
86 |
+
return $this->sinchModel->getProductDescriptionList();
|
87 |
+
}
|
88 |
+
public function getProductSpecifications(){
|
89 |
+
return $this->sinchModel->getProductSpecifications();
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getShortProductDescription(){
|
93 |
+
return $this->sinchModel->getShortProductDescription();
|
94 |
+
}
|
95 |
+
|
96 |
+
public function getLowPicUrl(){
|
97 |
+
return $this->sinchModel->getLowPicUrl();
|
98 |
+
}
|
99 |
+
|
100 |
+
public function getGalleryPhotos(){
|
101 |
+
return $this->sinchModel->getGalleryPhotos();
|
102 |
+
}
|
103 |
+
|
104 |
+
public function getProductName(){
|
105 |
+
return $this->sinchModel->getProductName();
|
106 |
+
}
|
107 |
+
public function getVendor(){
|
108 |
+
return $this->sinchModel->getVendor();
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getFullProductDescription(){
|
112 |
+
return $this->sinchModel->getFullProductDescription();
|
113 |
+
}
|
114 |
+
|
115 |
+
public function getMPN(){
|
116 |
+
return $this->sinchModel->getMPN();
|
117 |
+
}
|
118 |
+
public function getEAN(){
|
119 |
+
return $this->sinchModel->getEAN();
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Form related products list according to store products
|
124 |
+
*/
|
125 |
+
public function getRelatedProducts(){
|
126 |
+
$relatedProducts =$this->sinchModel->getRelatedProducts();
|
127 |
+
if (empty($relatedProducts)){
|
128 |
+
return array();
|
129 |
+
}
|
130 |
+
$sku = 'sku';
|
131 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
132 |
+
|
133 |
+
$filterArray = array();
|
134 |
+
foreach($relatedProducts as $mpn => $valueArray){
|
135 |
+
array_push($filterArray, array('attribute'=>$sku,'eq'=>$mpn));
|
136 |
+
}
|
137 |
+
$collection->addFieldToFilter($filterArray);
|
138 |
+
|
139 |
+
$collection->addAttributeToSelect($sku);
|
140 |
+
$collection->addAttributeToSelect('category_ids');
|
141 |
+
|
142 |
+
$relatedProductsList = array();
|
143 |
+
foreach ($collection as $product) {
|
144 |
+
$categoryIds = $product->getCategoryIds();
|
145 |
+
if(!empty($categoryIds)){
|
146 |
+
if (is_array($categoryIds)){
|
147 |
+
$catogoriesArray = $categoryIds;
|
148 |
+
}
|
149 |
+
if (is_string($categoryIds)){
|
150 |
+
$catogoriesArray = explode(",",$product->getCategoryIds());
|
151 |
+
}
|
152 |
+
foreach($catogoriesArray as $categoryId){
|
153 |
+
if (!array_key_exists($product->getData($sku), $relatedProducts)){
|
154 |
+
continue;
|
155 |
+
}
|
156 |
+
$relatedProductInfo = $relatedProducts[$product->getData($sku)];
|
157 |
+
$relatedProductInfo['mpn'] = $product->getData($sku);
|
158 |
+
$relatedProductInfo['url'] = $product->getProductUrl();//preg_replace( '/\/\d+\/$/',"/".$categoryId."/",$product->getProductUrl());;
|
159 |
+
if (!array_key_exists($categoryId, $relatedProductsList)){
|
160 |
+
$relatedProductsList[$categoryId]= array();
|
161 |
+
}
|
162 |
+
|
163 |
+
array_push($relatedProductsList[$categoryId], $relatedProductInfo);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
else {
|
167 |
+
if (!array_key_exists($product->getData($sku), $relatedProducts)){
|
168 |
+
continue;
|
169 |
+
}
|
170 |
+
$relatedProductInfo = $relatedProducts[$product->getData($sku)];
|
171 |
+
$relatedProductInfo['mpn'] = $product->getData($sku);
|
172 |
+
$relatedProductInfo['url'] = $product->getProductUrl();//preg_replace( '/category\/\d+\/$/','',$product->getProductUrl());;
|
173 |
+
if (!array_key_exists('a', $relatedProductsList)){
|
174 |
+
$relatedProductsList['a']= array();
|
175 |
+
}
|
176 |
+
|
177 |
+
array_push($relatedProductsList['a'], $relatedProductInfo);
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
return $relatedProductsList;
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
}
|
app/code/local/Bintime/Sinchimport/Helper/Image.php
CHANGED
@@ -1,73 +1,73 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_Catalog
|
23 |
-
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Catalog image helper
|
29 |
-
*
|
30 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
31 |
-
*/
|
32 |
-
class Bintime_Sinchimport_Helper_Image extends Mage_Catalog_Helper_Image
|
33 |
-
{
|
34 |
-
|
35 |
-
public function __toString()
|
36 |
-
{
|
37 |
-
try {
|
38 |
-
if( $this->getImageFile() ) {
|
39 |
-
$this->_getModel()->setBaseFile( $this->getImageFile() );
|
40 |
-
} else {
|
41 |
-
$this->_getModel()->setBaseFile( $this->getProduct()->getData($this->_getModel()->getDestinationSubdir()) );
|
42 |
-
}
|
43 |
-
if (substr($this->_getModel()->getNewFile(),0,4) != 'http') {
|
44 |
-
if( $this->_getModel()->isCached() ) {
|
45 |
-
return $this->_getModel()->getUrl();
|
46 |
-
} else {
|
47 |
-
if( $this->_scheduleRotate ) {
|
48 |
-
$this->_getModel()->rotate( $this->getAngle() );
|
49 |
-
}
|
50 |
-
|
51 |
-
if ($this->_scheduleResize) {
|
52 |
-
$this->_getModel()->resize();
|
53 |
-
}
|
54 |
-
|
55 |
-
if( $this->getWatermark() ) {
|
56 |
-
$this->_getModel()->setWatermark($this->getWatermark());
|
57 |
-
}
|
58 |
-
|
59 |
-
$url = $this->_getModel()->saveFile()->getUrl();
|
60 |
-
}
|
61 |
-
}
|
62 |
-
else {
|
63 |
-
return $this->_getModel()->getNewFile();
|
64 |
-
}
|
65 |
-
} catch( Exception $e ) {
|
66 |
-
$url = Mage::getDesign()->getSkinUrl($this->getPlaceholder());
|
67 |
-
}
|
68 |
-
return $url;
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Catalog
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Catalog image helper
|
29 |
+
*
|
30 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
31 |
+
*/
|
32 |
+
class Bintime_Sinchimport_Helper_Image extends Mage_Catalog_Helper_Image
|
33 |
+
{
|
34 |
+
|
35 |
+
public function __toString()
|
36 |
+
{
|
37 |
+
try {
|
38 |
+
if( $this->getImageFile() ) {
|
39 |
+
$this->_getModel()->setBaseFile( $this->getImageFile() );
|
40 |
+
} else {
|
41 |
+
$this->_getModel()->setBaseFile( $this->getProduct()->getData($this->_getModel()->getDestinationSubdir()) );
|
42 |
+
}
|
43 |
+
if (substr($this->_getModel()->getNewFile(),0,4) != 'http') {
|
44 |
+
if( $this->_getModel()->isCached() ) {
|
45 |
+
return $this->_getModel()->getUrl();
|
46 |
+
} else {
|
47 |
+
if( $this->_scheduleRotate ) {
|
48 |
+
$this->_getModel()->rotate( $this->getAngle() );
|
49 |
+
}
|
50 |
+
|
51 |
+
if ($this->_scheduleResize) {
|
52 |
+
$this->_getModel()->resize();
|
53 |
+
}
|
54 |
+
|
55 |
+
if( $this->getWatermark() ) {
|
56 |
+
$this->_getModel()->setWatermark($this->getWatermark());
|
57 |
+
}
|
58 |
+
|
59 |
+
$url = $this->_getModel()->saveFile()->getUrl();
|
60 |
+
}
|
61 |
+
}
|
62 |
+
else {
|
63 |
+
return $this->_getModel()->getNewFile();
|
64 |
+
}
|
65 |
+
} catch( Exception $e ) {
|
66 |
+
$url = Mage::getDesign()->getSkinUrl($this->getPlaceholder());
|
67 |
+
}
|
68 |
+
return $url;
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Api.php
CHANGED
@@ -1,85 +1,85 @@
|
|
1 |
-
<?php
|
2 |
-
class Bintime_Sinchimport_Model_Api extends Mage_Api_Model_Resource_Abstract
|
3 |
-
{
|
4 |
-
public function test($arg)
|
5 |
-
{
|
6 |
-
return "!!!!!!!!!!Hello World! My argument is : ".$arg;
|
7 |
-
}
|
8 |
-
|
9 |
-
public function run_full_import($arg)
|
10 |
-
{
|
11 |
-
$import=Mage::getModel('sinchimport/sinch');
|
12 |
-
|
13 |
-
if($import->is_imort_not_run()){
|
14 |
-
$dir = dirname(__FILE__);
|
15 |
-
exec("nohup ".$import->php_run_string.$dir."/../sinch_import_start_ajax.php > /dev/null & echo $!");
|
16 |
-
sleep(5);
|
17 |
-
if($import->is_imort_not_run()){
|
18 |
-
$message_arr = $import->getDataOfLatestImport();
|
19 |
-
$satus_arr=array('NOT OK', "Last Import finish with ".$message_arr['global_status_import']." at ".$message_arr['finish_import']."; Last status - ".$message_arr['detail_status_import']." ".$message_arr['error_report_message']);
|
20 |
-
}else{
|
21 |
-
$satus_arr=array('OK', "Import started");
|
22 |
-
}
|
23 |
-
|
24 |
-
}else{
|
25 |
-
$message_arr = $import->getDataOfLatestImport();
|
26 |
-
$satus_arr=array('NOT OK', "Import already started at ".$message_arr['start_import']." current_status - ".$message_arr['detail_status_import']);
|
27 |
-
}
|
28 |
-
|
29 |
-
return $satus_arr;
|
30 |
-
}
|
31 |
-
public function run_ps_import($arg)
|
32 |
-
{
|
33 |
-
$import=Mage::getModel('sinchimport/sinch');
|
34 |
-
|
35 |
-
if($import->is_imort_not_run()){
|
36 |
-
$dir = dirname(__FILE__);
|
37 |
-
exec("nohup ".$import->php_run_string.$dir."/../stock_price_sinch_import_start_ajax.php > /dev/null & echo $!");
|
38 |
-
sleep(5);
|
39 |
-
if($import->is_imort_not_run()){
|
40 |
-
$message_arr = $import->getDataOfLatestImport();
|
41 |
-
$satus_arr=array('NOT OK', "Last ".$message_arr['import_type']." import finish with ".$message_arr['global_status_import']."; Last status '".$message_arr['detail_status_import']."' ".$message_arr['error_report_message']);
|
42 |
-
}else{
|
43 |
-
$satus_arr=array('OK', "Price Stock Import started");
|
44 |
-
}
|
45 |
-
|
46 |
-
}else{
|
47 |
-
$message_arr = $import->getDataOfLatestImport();
|
48 |
-
$satus_arr=array('NOT OK', $message_arr['import_type']." import already started at ".$message_arr['start_import']." current_status - '".$message_arr['detail_status_import']."'");
|
49 |
-
}
|
50 |
-
|
51 |
-
return $satus_arr;
|
52 |
-
}
|
53 |
-
|
54 |
-
public function get_import_status()
|
55 |
-
{
|
56 |
-
$import=Mage::getModel('sinchimport/sinch');
|
57 |
-
$message_arr = $import->getDataOfLatestImport();
|
58 |
-
if($import->is_imort_not_run()){
|
59 |
-
if($message_arr['global_status_import']=='Successful'){
|
60 |
-
$status=$message_arr['detail_status_import'];
|
61 |
-
}elseif($message_arr['global_status_import']=='Failed'){
|
62 |
-
$status=$message_arr['error_report_message'];
|
63 |
-
}
|
64 |
-
$satus_arr=array(
|
65 |
-
'is_import_running' => 'Not Running',
|
66 |
-
'status' => $status,
|
67 |
-
'last_finish_date' => $message_arr['finish_import'],
|
68 |
-
'count_of_products' => $message_arr['number_of_products'],
|
69 |
-
'import_type' => $message_arr['import_type'],
|
70 |
-
'message' => "Last ".$message_arr['import_type'].' import finished at '.$message_arr['finish_import'].' with '.$message_arr['global_status_import']."; Last status '".$message_arr['detail_status_import']."' ".$message_arr['error_report_message']
|
71 |
-
|
72 |
-
);
|
73 |
-
}else{
|
74 |
-
$satus_arr=array( 'is_import_running' =>'Running',
|
75 |
-
'status' => '',
|
76 |
-
'last_finish_date' => $message_arr['finish_import'],
|
77 |
-
'count_of_products' => $message_arr['number_of_products'],
|
78 |
-
'import_type' => $message_arr['import_type'],
|
79 |
-
'message' =>$message_arr['import_type']." import already started at ".$message_arr['start_import']." current_status - '".$message_arr['detail_status_import']."'");
|
80 |
-
}
|
81 |
-
|
82 |
-
return $satus_arr;
|
83 |
-
}
|
84 |
-
|
85 |
-
}
|
1 |
+
<?php
|
2 |
+
class Bintime_Sinchimport_Model_Api extends Mage_Api_Model_Resource_Abstract
|
3 |
+
{
|
4 |
+
public function test($arg)
|
5 |
+
{
|
6 |
+
return "!!!!!!!!!!Hello World! My argument is : ".$arg;
|
7 |
+
}
|
8 |
+
|
9 |
+
public function run_full_import($arg)
|
10 |
+
{
|
11 |
+
$import=Mage::getModel('sinchimport/sinch');
|
12 |
+
|
13 |
+
if($import->is_imort_not_run()){
|
14 |
+
$dir = dirname(__FILE__);
|
15 |
+
exec("nohup ".$import->php_run_string.$dir."/../sinch_import_start_ajax.php > /dev/null & echo $!");
|
16 |
+
sleep(5);
|
17 |
+
if($import->is_imort_not_run()){
|
18 |
+
$message_arr = $import->getDataOfLatestImport();
|
19 |
+
$satus_arr=array('NOT OK', "Last Import finish with ".$message_arr['global_status_import']." at ".$message_arr['finish_import']."; Last status - ".$message_arr['detail_status_import']." ".$message_arr['error_report_message']);
|
20 |
+
}else{
|
21 |
+
$satus_arr=array('OK', "Import started");
|
22 |
+
}
|
23 |
+
|
24 |
+
}else{
|
25 |
+
$message_arr = $import->getDataOfLatestImport();
|
26 |
+
$satus_arr=array('NOT OK', "Import already started at ".$message_arr['start_import']." current_status - ".$message_arr['detail_status_import']);
|
27 |
+
}
|
28 |
+
|
29 |
+
return $satus_arr;
|
30 |
+
}
|
31 |
+
public function run_ps_import($arg)
|
32 |
+
{
|
33 |
+
$import=Mage::getModel('sinchimport/sinch');
|
34 |
+
|
35 |
+
if($import->is_imort_not_run()){
|
36 |
+
$dir = dirname(__FILE__);
|
37 |
+
exec("nohup ".$import->php_run_string.$dir."/../stock_price_sinch_import_start_ajax.php > /dev/null & echo $!");
|
38 |
+
sleep(5);
|
39 |
+
if($import->is_imort_not_run()){
|
40 |
+
$message_arr = $import->getDataOfLatestImport();
|
41 |
+
$satus_arr=array('NOT OK', "Last ".$message_arr['import_type']." import finish with ".$message_arr['global_status_import']."; Last status '".$message_arr['detail_status_import']."' ".$message_arr['error_report_message']);
|
42 |
+
}else{
|
43 |
+
$satus_arr=array('OK', "Price Stock Import started");
|
44 |
+
}
|
45 |
+
|
46 |
+
}else{
|
47 |
+
$message_arr = $import->getDataOfLatestImport();
|
48 |
+
$satus_arr=array('NOT OK', $message_arr['import_type']." import already started at ".$message_arr['start_import']." current_status - '".$message_arr['detail_status_import']."'");
|
49 |
+
}
|
50 |
+
|
51 |
+
return $satus_arr;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function get_import_status()
|
55 |
+
{
|
56 |
+
$import=Mage::getModel('sinchimport/sinch');
|
57 |
+
$message_arr = $import->getDataOfLatestImport();
|
58 |
+
if($import->is_imort_not_run()){
|
59 |
+
if($message_arr['global_status_import']=='Successful'){
|
60 |
+
$status=$message_arr['detail_status_import'];
|
61 |
+
}elseif($message_arr['global_status_import']=='Failed'){
|
62 |
+
$status=$message_arr['error_report_message'];
|
63 |
+
}
|
64 |
+
$satus_arr=array(
|
65 |
+
'is_import_running' => 'Not Running',
|
66 |
+
'status' => $status,
|
67 |
+
'last_finish_date' => $message_arr['finish_import'],
|
68 |
+
'count_of_products' => $message_arr['number_of_products'],
|
69 |
+
'import_type' => $message_arr['import_type'],
|
70 |
+
'message' => "Last ".$message_arr['import_type'].' import finished at '.$message_arr['finish_import'].' with '.$message_arr['global_status_import']."; Last status '".$message_arr['detail_status_import']."' ".$message_arr['error_report_message']
|
71 |
+
|
72 |
+
);
|
73 |
+
}else{
|
74 |
+
$satus_arr=array( 'is_import_running' =>'Running',
|
75 |
+
'status' => '',
|
76 |
+
'last_finish_date' => $message_arr['finish_import'],
|
77 |
+
'count_of_products' => $message_arr['number_of_products'],
|
78 |
+
'import_type' => $message_arr['import_type'],
|
79 |
+
'message' =>$message_arr['import_type']." import already started at ".$message_arr['start_import']." current_status - '".$message_arr['detail_status_import']."'");
|
80 |
+
}
|
81 |
+
|
82 |
+
return $satus_arr;
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Backup.php
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
<?php
|
2 |
-
ini_set('memory_limit','256M');
|
3 |
-
$dir = Mage::getBaseDir('code')."/local/Bintime/Sinchimport/Model";//dirname(__FILE__);
|
4 |
-
require_once ($dir.'/config.php');
|
5 |
-
|
6 |
-
class Bintime_Sinchimport_Model_Backup extends Mage_Core_Model_Abstract {
|
7 |
-
var $connection, $db;
|
8 |
-
|
9 |
-
function __construct() {
|
10 |
-
$this->connection=$this->db_connect();
|
11 |
-
$this->backupProductIds();
|
12 |
-
$this->backupCategoryIds();
|
13 |
-
}
|
14 |
-
|
15 |
-
private function backupProductIds() {
|
16 |
-
$this->db_do("TRUNCATE ".Mage::getSingleton('core/resource')->getTableName('sinch_product_backup'));
|
17 |
-
$result = $this->db_do("
|
18 |
-
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('sinch_product_backup')." (
|
19 |
-
entity_id,
|
20 |
-
sku,
|
21 |
-
store_product_id,
|
22 |
-
sinch_product_id
|
23 |
-
)(SELECT
|
24 |
-
entity_id,
|
25 |
-
sku,
|
26 |
-
store_product_id,
|
27 |
-
sinch_product_id
|
28 |
-
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')."
|
29 |
-
)
|
30 |
-
");
|
31 |
-
}
|
32 |
-
|
33 |
-
private function backupCategoryIds() {
|
34 |
-
$this->db_do("TRUNCATE ".Mage::getSingleton('core/resource')->getTableName('sinch_category_backup'));
|
35 |
-
$result = $this->db_do("
|
36 |
-
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('sinch_category_backup')." (
|
37 |
-
entity_id,
|
38 |
-
entity_type_id,
|
39 |
-
attribute_set_id,
|
40 |
-
parent_id,
|
41 |
-
store_category_id,
|
42 |
-
parent_store_category_id
|
43 |
-
)(SELECT
|
44 |
-
entity_id,
|
45 |
-
entity_type_id,
|
46 |
-
attribute_set_id,
|
47 |
-
parent_id,
|
48 |
-
store_category_id,
|
49 |
-
parent_store_category_id
|
50 |
-
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
51 |
-
)
|
52 |
-
");
|
53 |
-
}
|
54 |
-
|
55 |
-
////// Utility functions
|
56 |
-
private function db_connect() {
|
57 |
-
$dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
|
58 |
-
$dbConn = mysqli_init();
|
59 |
-
mysqli_options($dbConn, MYSQLI_OPT_LOCAL_INFILE, true);
|
60 |
-
if (mysqli_real_connect($dbConn, $dbConf->host, $dbConf->username, $dbConf->password)) {
|
61 |
-
$this->db = $dbConn;
|
62 |
-
if(!mysqli_select_db($this->db, $dbConf->dbname)) {
|
63 |
-
die("Can't select the database: " . mysqli_error($this->db));
|
64 |
-
}
|
65 |
-
} else {
|
66 |
-
die("Could not connect: " . mysqli_error($this->db));
|
67 |
-
}
|
68 |
-
|
69 |
-
}
|
70 |
-
|
71 |
-
private function db_do($query) {
|
72 |
-
$result = mysqli_query($this->db, $query) or die("Query failed: " . mysqli_error($this->db));
|
73 |
-
if (!$result) {
|
74 |
-
throw new Exception("Invalid query: $sql\n" . mysqli_error($this->db));
|
75 |
-
} else {
|
76 |
-
return $result;
|
77 |
-
}
|
78 |
-
return $result;
|
79 |
-
}
|
80 |
}
|
1 |
+
<?php
|
2 |
+
ini_set('memory_limit','256M');
|
3 |
+
$dir = Mage::getBaseDir('code')."/local/Bintime/Sinchimport/Model";//dirname(__FILE__);
|
4 |
+
require_once ($dir.'/config.php');
|
5 |
+
|
6 |
+
class Bintime_Sinchimport_Model_Backup extends Mage_Core_Model_Abstract {
|
7 |
+
var $connection, $db;
|
8 |
+
|
9 |
+
function __construct() {
|
10 |
+
$this->connection=$this->db_connect();
|
11 |
+
$this->backupProductIds();
|
12 |
+
$this->backupCategoryIds();
|
13 |
+
}
|
14 |
+
|
15 |
+
private function backupProductIds() {
|
16 |
+
$this->db_do("TRUNCATE ".Mage::getSingleton('core/resource')->getTableName('sinch_product_backup'));
|
17 |
+
$result = $this->db_do("
|
18 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('sinch_product_backup')." (
|
19 |
+
entity_id,
|
20 |
+
sku,
|
21 |
+
store_product_id,
|
22 |
+
sinch_product_id
|
23 |
+
)(SELECT
|
24 |
+
entity_id,
|
25 |
+
sku,
|
26 |
+
store_product_id,
|
27 |
+
sinch_product_id
|
28 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')."
|
29 |
+
)
|
30 |
+
");
|
31 |
+
}
|
32 |
+
|
33 |
+
private function backupCategoryIds() {
|
34 |
+
$this->db_do("TRUNCATE ".Mage::getSingleton('core/resource')->getTableName('sinch_category_backup'));
|
35 |
+
$result = $this->db_do("
|
36 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('sinch_category_backup')." (
|
37 |
+
entity_id,
|
38 |
+
entity_type_id,
|
39 |
+
attribute_set_id,
|
40 |
+
parent_id,
|
41 |
+
store_category_id,
|
42 |
+
parent_store_category_id
|
43 |
+
)(SELECT
|
44 |
+
entity_id,
|
45 |
+
entity_type_id,
|
46 |
+
attribute_set_id,
|
47 |
+
parent_id,
|
48 |
+
store_category_id,
|
49 |
+
parent_store_category_id
|
50 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
51 |
+
)
|
52 |
+
");
|
53 |
+
}
|
54 |
+
|
55 |
+
////// Utility functions
|
56 |
+
private function db_connect() {
|
57 |
+
$dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
|
58 |
+
$dbConn = mysqli_init();
|
59 |
+
mysqli_options($dbConn, MYSQLI_OPT_LOCAL_INFILE, true);
|
60 |
+
if (mysqli_real_connect($dbConn, $dbConf->host, $dbConf->username, $dbConf->password)) {
|
61 |
+
$this->db = $dbConn;
|
62 |
+
if(!mysqli_select_db($this->db, $dbConf->dbname)) {
|
63 |
+
die("Can't select the database: " . mysqli_error($this->db));
|
64 |
+
}
|
65 |
+
} else {
|
66 |
+
die("Could not connect: " . mysqli_error($this->db));
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
private function db_do($query) {
|
72 |
+
$result = mysqli_query($this->db, $query) or die("Query failed: " . mysqli_error($this->db));
|
73 |
+
if (!$result) {
|
74 |
+
throw new Exception("Invalid query: $sql\n" . mysqli_error($this->db));
|
75 |
+
} else {
|
76 |
+
return $result;
|
77 |
+
}
|
78 |
+
return $result;
|
79 |
+
}
|
80 |
}
|
app/code/local/Bintime/Sinchimport/Model/Category.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bintime_Sinchimport_Model_Category extends Mage_Catalog_Model_Category {
|
4 |
-
|
5 |
-
public function getImageUrl()
|
6 |
-
{
|
7 |
-
$url = false;
|
8 |
-
if ($image = $this->getImage()) {
|
9 |
-
if (substr($image,0,4) != 'http'){
|
10 |
-
$url = Mage::getBaseUrl('media').'catalog/category/'.$image;
|
11 |
-
}else{
|
12 |
-
$url = $image;
|
13 |
-
}
|
14 |
-
}
|
15 |
-
return $url;
|
16 |
-
}
|
17 |
-
|
18 |
-
|
19 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bintime_Sinchimport_Model_Category extends Mage_Catalog_Model_Category {
|
4 |
+
|
5 |
+
public function getImageUrl()
|
6 |
+
{
|
7 |
+
$url = false;
|
8 |
+
if ($image = $this->getImage()) {
|
9 |
+
if (substr($image,0,4) != 'http'){
|
10 |
+
$url = Mage::getBaseUrl('media').'catalog/category/'.$image;
|
11 |
+
}else{
|
12 |
+
$url = $image;
|
13 |
+
}
|
14 |
+
}
|
15 |
+
return $url;
|
16 |
+
}
|
17 |
+
|
18 |
+
|
19 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Image.php
CHANGED
@@ -1,118 +1,118 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bintime_Sinchimport_Model_Image extends Mage_Catalog_Model_Product_Image {
|
4 |
-
|
5 |
-
public function setBaseFile($file)
|
6 |
-
{
|
7 |
-
$this->_isBaseFilePlaceholder = false;
|
8 |
-
if (substr($file,0,4) != 'http') {
|
9 |
-
if (($file) && (0 !== strpos($file, '/', 0))) {
|
10 |
-
$file = '/' . $file;
|
11 |
-
}
|
12 |
-
$baseDir = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath();
|
13 |
-
if ('/no_selection' == $file) {
|
14 |
-
$file = null;
|
15 |
-
}
|
16 |
-
if ($file) {
|
17 |
-
if ((!file_exists($baseDir . $file)) || !$this->_checkMemory($baseDir . $file)) {
|
18 |
-
$file = null;
|
19 |
-
}
|
20 |
-
}
|
21 |
-
if (!$file) {
|
22 |
-
// check if placeholder defined in config
|
23 |
-
$isConfigPlaceholder = Mage::getStoreConfig("catalog/placeholder/{$this->getDestinationSubdir()}_placeholder");
|
24 |
-
$configPlaceholder = '/placeholder/' . $isConfigPlaceholder;
|
25 |
-
if ($isConfigPlaceholder && file_exists($baseDir . $configPlaceholder)) {
|
26 |
-
$file = $configPlaceholder;
|
27 |
-
}
|
28 |
-
else {
|
29 |
-
// replace file with skin or default skin placeholder
|
30 |
-
$skinBaseDir = Mage::getDesign()->getSkinBaseDir();
|
31 |
-
$skinPlaceholder = "/images/catalog/product/placeholder/{$this->getDestinationSubdir()}.jpg";
|
32 |
-
$file = $skinPlaceholder;
|
33 |
-
if (file_exists($skinBaseDir . $file)) {
|
34 |
-
$baseDir = $skinBaseDir;
|
35 |
-
}
|
36 |
-
else {
|
37 |
-
$baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default'));
|
38 |
-
if (!file_exists($baseDir . $file)) {
|
39 |
-
$baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default', '_package' => 'base'));
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
43 |
-
$this->_isBaseFilePlaceholder = true;
|
44 |
-
}
|
45 |
-
|
46 |
-
$baseFile = $baseDir . $file;
|
47 |
-
}
|
48 |
-
else {
|
49 |
-
$baseFile =$file;
|
50 |
-
}
|
51 |
-
if ((!$file) AND (!file_exists($baseFile)) AND substr($baseFile,0,4) != 'http') {
|
52 |
-
throw new Exception(Mage::helper('catalog')->__('Image file not found'));
|
53 |
-
}
|
54 |
-
|
55 |
-
$this->_baseFile = $baseFile;
|
56 |
-
if (substr($baseFile,0,4) != 'http') {
|
57 |
-
// build new filename (most important params)
|
58 |
-
$path = array(
|
59 |
-
Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
|
60 |
-
'cache',
|
61 |
-
Mage::app()->getStore()->getId(),
|
62 |
-
$path[] = $this->getDestinationSubdir()
|
63 |
-
);
|
64 |
-
if((!empty($this->_width)) || (!empty($this->_height)))
|
65 |
-
$path[] = "{$this->_width}x{$this->_height}";
|
66 |
-
|
67 |
-
// add misk params as a hash
|
68 |
-
$miscParams = array(
|
69 |
-
($this->_keepAspectRatio ? '' : 'non') . 'proportional',
|
70 |
-
($this->_keepFrame ? '' : 'no') . 'frame',
|
71 |
-
($this->_keepTransparency ? '' : 'no') . 'transparency',
|
72 |
-
($this->_constrainOnly ? 'do' : 'not') . 'constrainonly',
|
73 |
-
$this->_rgbToString($this->_backgroundColor),
|
74 |
-
'angle' . $this->_angle,
|
75 |
-
'quality' . $this->_quality
|
76 |
-
);
|
77 |
-
|
78 |
-
// if has watermark add watermark params to hash
|
79 |
-
if ($this->getWatermarkFile()) {
|
80 |
-
$miscParams[] = $this->getWatermarkFile();
|
81 |
-
$miscParams[] = $this->getWatermarkImageOpacity();
|
82 |
-
$miscParams[] = $this->getWatermarkPosition();
|
83 |
-
$miscParams[] = $this->getWatermarkWidth();
|
84 |
-
$miscParams[] = $this->getWatermarkHeigth();
|
85 |
-
}
|
86 |
-
|
87 |
-
$path[] = md5(implode('_', $miscParams));
|
88 |
-
}
|
89 |
-
else {
|
90 |
-
$path[] = $file;
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
// append prepared filename
|
95 |
-
if (substr($file,0,4) != 'http') {
|
96 |
-
$this->_newFile = implode('/', $path) . $file; // the $file contains heading slash
|
97 |
-
}
|
98 |
-
else {
|
99 |
-
$this->_newFile = $file;
|
100 |
-
}
|
101 |
-
return $this;
|
102 |
-
}
|
103 |
-
|
104 |
-
protected function _rgbToString($rgbArray)
|
105 |
-
{
|
106 |
-
$result = array();
|
107 |
-
foreach ($rgbArray as $value) {
|
108 |
-
if (null === $value) {
|
109 |
-
$result[] = 'null';
|
110 |
-
}
|
111 |
-
else {
|
112 |
-
$result[] = sprintf('%02s', dechex($value));
|
113 |
-
}
|
114 |
-
}
|
115 |
-
return implode($result);
|
116 |
-
}
|
117 |
-
|
118 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bintime_Sinchimport_Model_Image extends Mage_Catalog_Model_Product_Image {
|
4 |
+
|
5 |
+
public function setBaseFile($file)
|
6 |
+
{
|
7 |
+
$this->_isBaseFilePlaceholder = false;
|
8 |
+
if (substr($file,0,4) != 'http') {
|
9 |
+
if (($file) && (0 !== strpos($file, '/', 0))) {
|
10 |
+
$file = '/' . $file;
|
11 |
+
}
|
12 |
+
$baseDir = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath();
|
13 |
+
if ('/no_selection' == $file) {
|
14 |
+
$file = null;
|
15 |
+
}
|
16 |
+
if ($file) {
|
17 |
+
if ((!file_exists($baseDir . $file)) || !$this->_checkMemory($baseDir . $file)) {
|
18 |
+
$file = null;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
if (!$file) {
|
22 |
+
// check if placeholder defined in config
|
23 |
+
$isConfigPlaceholder = Mage::getStoreConfig("catalog/placeholder/{$this->getDestinationSubdir()}_placeholder");
|
24 |
+
$configPlaceholder = '/placeholder/' . $isConfigPlaceholder;
|
25 |
+
if ($isConfigPlaceholder && file_exists($baseDir . $configPlaceholder)) {
|
26 |
+
$file = $configPlaceholder;
|
27 |
+
}
|
28 |
+
else {
|
29 |
+
// replace file with skin or default skin placeholder
|
30 |
+
$skinBaseDir = Mage::getDesign()->getSkinBaseDir();
|
31 |
+
$skinPlaceholder = "/images/catalog/product/placeholder/{$this->getDestinationSubdir()}.jpg";
|
32 |
+
$file = $skinPlaceholder;
|
33 |
+
if (file_exists($skinBaseDir . $file)) {
|
34 |
+
$baseDir = $skinBaseDir;
|
35 |
+
}
|
36 |
+
else {
|
37 |
+
$baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default'));
|
38 |
+
if (!file_exists($baseDir . $file)) {
|
39 |
+
$baseDir = Mage::getDesign()->getSkinBaseDir(array('_theme' => 'default', '_package' => 'base'));
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
$this->_isBaseFilePlaceholder = true;
|
44 |
+
}
|
45 |
+
|
46 |
+
$baseFile = $baseDir . $file;
|
47 |
+
}
|
48 |
+
else {
|
49 |
+
$baseFile =$file;
|
50 |
+
}
|
51 |
+
if ((!$file) AND (!file_exists($baseFile)) AND substr($baseFile,0,4) != 'http') {
|
52 |
+
throw new Exception(Mage::helper('catalog')->__('Image file not found'));
|
53 |
+
}
|
54 |
+
|
55 |
+
$this->_baseFile = $baseFile;
|
56 |
+
if (substr($baseFile,0,4) != 'http') {
|
57 |
+
// build new filename (most important params)
|
58 |
+
$path = array(
|
59 |
+
Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
|
60 |
+
'cache',
|
61 |
+
Mage::app()->getStore()->getId(),
|
62 |
+
$path[] = $this->getDestinationSubdir()
|
63 |
+
);
|
64 |
+
if((!empty($this->_width)) || (!empty($this->_height)))
|
65 |
+
$path[] = "{$this->_width}x{$this->_height}";
|
66 |
+
|
67 |
+
// add misk params as a hash
|
68 |
+
$miscParams = array(
|
69 |
+
($this->_keepAspectRatio ? '' : 'non') . 'proportional',
|
70 |
+
($this->_keepFrame ? '' : 'no') . 'frame',
|
71 |
+
($this->_keepTransparency ? '' : 'no') . 'transparency',
|
72 |
+
($this->_constrainOnly ? 'do' : 'not') . 'constrainonly',
|
73 |
+
$this->_rgbToString($this->_backgroundColor),
|
74 |
+
'angle' . $this->_angle,
|
75 |
+
'quality' . $this->_quality
|
76 |
+
);
|
77 |
+
|
78 |
+
// if has watermark add watermark params to hash
|
79 |
+
if ($this->getWatermarkFile()) {
|
80 |
+
$miscParams[] = $this->getWatermarkFile();
|
81 |
+
$miscParams[] = $this->getWatermarkImageOpacity();
|
82 |
+
$miscParams[] = $this->getWatermarkPosition();
|
83 |
+
$miscParams[] = $this->getWatermarkWidth();
|
84 |
+
$miscParams[] = $this->getWatermarkHeigth();
|
85 |
+
}
|
86 |
+
|
87 |
+
$path[] = md5(implode('_', $miscParams));
|
88 |
+
}
|
89 |
+
else {
|
90 |
+
$path[] = $file;
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
// append prepared filename
|
95 |
+
if (substr($file,0,4) != 'http') {
|
96 |
+
$this->_newFile = implode('/', $path) . $file; // the $file contains heading slash
|
97 |
+
}
|
98 |
+
else {
|
99 |
+
$this->_newFile = $file;
|
100 |
+
}
|
101 |
+
return $this;
|
102 |
+
}
|
103 |
+
|
104 |
+
protected function _rgbToString($rgbArray)
|
105 |
+
{
|
106 |
+
$result = array();
|
107 |
+
foreach ($rgbArray as $value) {
|
108 |
+
if (null === $value) {
|
109 |
+
$result[] = 'null';
|
110 |
+
}
|
111 |
+
else {
|
112 |
+
$result[] = sprintf('%02s', dechex($value));
|
113 |
+
}
|
114 |
+
}
|
115 |
+
return implode($result);
|
116 |
+
}
|
117 |
+
|
118 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Layer.php
CHANGED
@@ -1,49 +1,49 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bintime_Sinchimport_Model_Layer extends Mage_Catalog_Model_Layer
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Возвращает фичи, по которым следует строить навигацию для данной категории.
|
7 |
-
*
|
8 |
-
* @return mixed
|
9 |
-
*/
|
10 |
-
public function getFilterableFeatures()
|
11 |
-
{
|
12 |
-
Varien_Profiler::start(__METHOD__);
|
13 |
-
|
14 |
-
$category = Mage::registry('current_category');
|
15 |
-
if( empty($category) ) { $category = Mage::getModel('catalog/category')->load( Mage::app()->getStore()->getRootCategoryId() ); }
|
16 |
-
$categoryId = $category->getEntityId();
|
17 |
-
$resource = Mage::getSingleton('core/resource');
|
18 |
-
$tCategor = $resource->getTableName('stINch_categories');
|
19 |
-
$tCatFeature = $resource->getTableName('stINch_categories_features');
|
20 |
-
$tRestrictedVal = $resource->getTableName('stINch_restricted_values');
|
21 |
-
$tCategMapp = $resource->getTableName('stINch_categories_mapping');
|
22 |
-
|
23 |
-
$select = new Varien_Db_Select(Mage::getSingleton('core/resource')->getConnection('core_read'));
|
24 |
-
$select->from(array('cf' => $tCatFeature))
|
25 |
-
->joinInner(
|
26 |
-
array('rv' => $tRestrictedVal),
|
27 |
-
'cf.category_feature_id = rv.category_feature_id'
|
28 |
-
)
|
29 |
-
->joinInner(
|
30 |
-
array('cm' => $tCategMapp),
|
31 |
-
'cf.store_category_id = cm.store_category_id'
|
32 |
-
)
|
33 |
-
->where('cm.shop_entity_id = '.$categoryId)
|
34 |
-
->group('cf.feature_name')
|
35 |
-
->order('cf.display_order_number', 'asc')
|
36 |
-
->order('cf.feature_name', 'asc')
|
37 |
-
->order('rv.display_order_number', 'asc');
|
38 |
-
;
|
39 |
-
$select->columns('cf.feature_name AS name');
|
40 |
-
$select->columns('cf.category_feature_id as feature_id');
|
41 |
-
$select->columns('GROUP_CONCAT(`rv`.`text` SEPARATOR "\n") as restricted_values');
|
42 |
-
$result = $select->query();
|
43 |
-
// echo $select->__toString();
|
44 |
-
//exit;
|
45 |
-
Varien_Profiler::stop(__METHOD__);
|
46 |
-
return $result;
|
47 |
-
}
|
48 |
-
|
49 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bintime_Sinchimport_Model_Layer extends Mage_Catalog_Model_Layer
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Возвращает фичи, по которым следует строить навигацию для данной категории.
|
7 |
+
*
|
8 |
+
* @return mixed
|
9 |
+
*/
|
10 |
+
public function getFilterableFeatures()
|
11 |
+
{
|
12 |
+
Varien_Profiler::start(__METHOD__);
|
13 |
+
|
14 |
+
$category = Mage::registry('current_category');
|
15 |
+
if( empty($category) ) { $category = Mage::getModel('catalog/category')->load( Mage::app()->getStore()->getRootCategoryId() ); }
|
16 |
+
$categoryId = $category->getEntityId();
|
17 |
+
$resource = Mage::getSingleton('core/resource');
|
18 |
+
$tCategor = $resource->getTableName('stINch_categories');
|
19 |
+
$tCatFeature = $resource->getTableName('stINch_categories_features');
|
20 |
+
$tRestrictedVal = $resource->getTableName('stINch_restricted_values');
|
21 |
+
$tCategMapp = $resource->getTableName('stINch_categories_mapping');
|
22 |
+
|
23 |
+
$select = new Varien_Db_Select(Mage::getSingleton('core/resource')->getConnection('core_read'));
|
24 |
+
$select->from(array('cf' => $tCatFeature))
|
25 |
+
->joinInner(
|
26 |
+
array('rv' => $tRestrictedVal),
|
27 |
+
'cf.category_feature_id = rv.category_feature_id'
|
28 |
+
)
|
29 |
+
->joinInner(
|
30 |
+
array('cm' => $tCategMapp),
|
31 |
+
'cf.store_category_id = cm.store_category_id'
|
32 |
+
)
|
33 |
+
->where('cm.shop_entity_id = '.$categoryId)
|
34 |
+
->group('cf.feature_name')
|
35 |
+
->order('cf.display_order_number', 'asc')
|
36 |
+
->order('cf.feature_name', 'asc')
|
37 |
+
->order('rv.display_order_number', 'asc');
|
38 |
+
;
|
39 |
+
$select->columns('cf.feature_name AS name');
|
40 |
+
$select->columns('cf.category_feature_id as feature_id');
|
41 |
+
$select->columns('GROUP_CONCAT(`rv`.`text` SEPARATOR "\n") as restricted_values');
|
42 |
+
$result = $select->query();
|
43 |
+
// echo $select->__toString();
|
44 |
+
//exit;
|
45 |
+
Varien_Profiler::stop(__METHOD__);
|
46 |
+
return $result;
|
47 |
+
}
|
48 |
+
|
49 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Feature.php
CHANGED
@@ -1,248 +1,248 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bintime_Sinchimport_Model_Layer_Filter_Feature extends Mage_Catalog_Model_Layer_Filter_Abstract
|
4 |
-
{
|
5 |
-
protected $_resource;
|
6 |
-
|
7 |
-
protected $dont_panic = true;
|
8 |
-
|
9 |
-
const LESS = 1;
|
10 |
-
const GREATER = 2;
|
11 |
-
/**
|
12 |
-
* Construct attribute filter
|
13 |
-
*
|
14 |
-
*/
|
15 |
-
public function __construct()
|
16 |
-
{
|
17 |
-
parent::__construct();
|
18 |
-
$this->_requestVar = 'ice_feature';
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Задаёт атрибут и строку запроса для текущего фильтра
|
23 |
-
* @param Фича из Icecat'a
|
24 |
-
* @return Bintime_Icelayered_Model_Layer_Filter_Feature
|
25 |
-
*/
|
26 |
-
public function setAttributeModel($attribute)
|
27 |
-
{
|
28 |
-
$this->setRequestVar('feature_' . $attribute['category_feature_id']);
|
29 |
-
$this->setData('attribute_model', $attribute);
|
30 |
-
return $this;
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getName()
|
34 |
-
{
|
35 |
-
$attribute = $this->getAttributeModel();
|
36 |
-
return $attribute['name'];
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Retrieve resource instance
|
41 |
-
*
|
42 |
-
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute
|
43 |
-
*/
|
44 |
-
protected function _getResource()
|
45 |
-
{
|
46 |
-
|
47 |
-
if (is_null($this->_resource)) {
|
48 |
-
$this->_resource = Mage::getResourceModel('sinchimport/layer_filter_feature');
|
49 |
-
}
|
50 |
-
return $this->_resource;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Get option text from frontend model by option id
|
55 |
-
*
|
56 |
-
* @param int $optionId
|
57 |
-
* @return unknown
|
58 |
-
*/
|
59 |
-
protected function _getOptionText($optionId)
|
60 |
-
{
|
61 |
-
$feature = $this->getAttributeModel();
|
62 |
-
return $optionId;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Apply attribute option filter to product collection
|
67 |
-
*
|
68 |
-
* @param Zend_Controller_Request_Abstract $request
|
69 |
-
* @param Varien_Object $filterBlock
|
70 |
-
* @return Mage_Catalog_Model_Layer_Filter_Attribute
|
71 |
-
*/
|
72 |
-
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
73 |
-
{
|
74 |
-
$filter = $request->getParam($this->_requestVar);
|
75 |
-
if (is_array($filter)) {
|
76 |
-
return $this;
|
77 |
-
}
|
78 |
-
|
79 |
-
$text = $this->_getOptionText($filter);
|
80 |
-
if ($filter && $text) {
|
81 |
-
$this->_getResource()->applyFilterToCollection($this, $filter);
|
82 |
-
$this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
|
83 |
-
$this->_items = array();
|
84 |
-
}
|
85 |
-
|
86 |
-
return $this;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Check whether specified attribute can be used in LN
|
91 |
-
*
|
92 |
-
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
93 |
-
* @return bool
|
94 |
-
*/
|
95 |
-
protected function _getIsFilterableAttribute($attribute)
|
96 |
-
{
|
97 |
-
if ($this->dont_panic) return null;
|
98 |
-
die(__METHOD__);
|
99 |
-
return $attribute->getIsFilterable();
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Возвращает массив с информацией по опциям фильтра.
|
104 |
-
* @return array
|
105 |
-
*/
|
106 |
-
protected function _getItemsData()
|
107 |
-
{
|
108 |
-
Varien_Profiler::start(__METHOD__);
|
109 |
-
|
110 |
-
$feature = $this->getAttributeModel();
|
111 |
-
$this->_requestVar = 'feature_' . $feature['category_feature_id'];
|
112 |
-
$limitDirection = isset($feature['limit_direction']) ? $feature['limit_direction'] : 0;
|
113 |
-
|
114 |
-
$data = array();
|
115 |
-
$options = explode("\n", $feature['restricted_values']);
|
116 |
-
if (count($options) == 0) {
|
117 |
-
Varien_Profiler::stop(__METHOD__);
|
118 |
-
return $data;
|
119 |
-
}
|
120 |
-
if (isset($feature['order_val']) && $feature['order_val'] == '2') {
|
121 |
-
$options = array_reverse($options);
|
122 |
-
}
|
123 |
-
if ($limitDirection != self::LESS && $limitDirection != self::GREATER) {
|
124 |
-
|
125 |
-
$optionsCount = $this->_getResource()->getCount($this);
|
126 |
-
foreach ($options as $option) {
|
127 |
-
if ($pos = strpos($option, '::')) {
|
128 |
-
$value = substr($option, 0, $pos);
|
129 |
-
$presentation_value = substr($option, $pos + 2);
|
130 |
-
}
|
131 |
-
else {
|
132 |
-
$value = $presentation_value = $option;
|
133 |
-
}
|
134 |
-
if (isset($optionsCount[$value]) && $optionsCount[$value] > 0) {
|
135 |
-
$data[] = array(
|
136 |
-
'label' => $presentation_value,
|
137 |
-
'value' => $value,
|
138 |
-
'count' => $optionsCount[$value],
|
139 |
-
);
|
140 |
-
}
|
141 |
-
}
|
142 |
-
} else {
|
143 |
-
$oCount = count($options);
|
144 |
-
$intervals = array();
|
145 |
-
if ($feature['order_val'] == '2') {
|
146 |
-
for ($i = 0; $i < $oCount -1; $i++) {
|
147 |
-
$intervals[$i]['high'] = $options[$i];
|
148 |
-
$intervals[$i]['low'] = $options[$i +1];
|
149 |
-
}
|
150 |
-
} else {
|
151 |
-
for ($i = 0; $i < $oCount -1; $i++) {
|
152 |
-
$intervals[$i]['low'] = $options[$i];
|
153 |
-
$intervals[$i]['high'] = $options[$i +1];
|
154 |
-
}
|
155 |
-
}
|
156 |
-
//FIXME: this is ugly
|
157 |
-
if ($feature['order_val'] == '2') {
|
158 |
-
array_push ($intervals, array(
|
159 |
-
'high' => $options[$oCount -1],
|
160 |
-
));
|
161 |
-
array_unshift($intervals, array(
|
162 |
-
'low' => $options[0],
|
163 |
-
));
|
164 |
-
} else {
|
165 |
-
array_push ($intervals, array(
|
166 |
-
'low' => $options[$oCount -1],
|
167 |
-
));
|
168 |
-
array_unshift($intervals, array(
|
169 |
-
'high' => $options[0],
|
170 |
-
));
|
171 |
-
}
|
172 |
-
|
173 |
-
$this->setData('intervals', $intervals);
|
174 |
-
|
175 |
-
$defaultSign = $feature['default_sign'];
|
176 |
-
for($i = 0; $i < count($intervals); $i++) {
|
177 |
-
if ($feature['order_val'] == '2') {
|
178 |
-
$interval = $intervals[$i];
|
179 |
-
$label = isset($interval['high']) ? $interval['high'] . " $defaultSign" : '>';
|
180 |
-
if ($label == '>' && isset($intervals[$i + 1])) {
|
181 |
-
$pad = strlen($intervals[$i + 1]['high'] . $defaultSign) + 2;
|
182 |
-
$label = str_pad($label, $pad*2, ' ', STR_PAD_LEFT);
|
183 |
-
$label = str_replace(' ', ' ', $label);
|
184 |
-
}
|
185 |
-
$label .= isset($interval['high'], $interval['high']) ? ' - ' : ' ';
|
186 |
-
$label .= isset($interval['low']) ? $interval['low'] . " $defaultSign" : '>';
|
187 |
-
$value = isset($interval['low']) ? $interval['low'] : '-';
|
188 |
-
$value .= ',';
|
189 |
-
$value .= isset($interval['high']) ? $interval['high'] : '-';
|
190 |
-
if (isset($interval['high']) AND !isset($interval['low'])) { $value = '-,'.$interval['high'];}
|
191 |
-
if ($this->_getResource()->getIntervalsCountDescending($this, $interval) > 0){
|
192 |
-
$data[] = array(
|
193 |
-
'label' => $label,
|
194 |
-
'value' => $value,
|
195 |
-
'count' => $this->_getResource()->getIntervalsCountDescending($this, $interval),
|
196 |
-
);
|
197 |
-
}
|
198 |
-
} else {
|
199 |
-
$interval = $intervals[$i];
|
200 |
-
$label = isset($interval['low']) ? $interval['low'] . " $defaultSign" : '<';
|
201 |
-
if ($label == '<' && isset($intervals[$i + 1])) {
|
202 |
-
$pad = strlen($intervals[$i + 1]['low'] . $defaultSign) + 2;
|
203 |
-
$label = str_pad($label, $pad*2, ' ', STR_PAD_LEFT);
|
204 |
-
$label = str_replace(' ', ' ', $label);
|
205 |
-
}
|
206 |
-
$label .= isset($interval['low'], $interval['high']) ? ' - ' : ' ';
|
207 |
-
$label .= isset($interval['high']) ? $interval['high'] . " $defaultSign" : '<';
|
208 |
-
|
209 |
-
$value = isset($interval['low']) ? $interval['low'] : '-';
|
210 |
-
$value .= ',';
|
211 |
-
$value .= isset($interval['high']) ? $interval['high'] : '-';
|
212 |
-
if ($this->_getResource()->getIntervalsCount($this, $interval) > 0){
|
213 |
-
$data[] = array(
|
214 |
-
'label' => $label,
|
215 |
-
'value' => $value,
|
216 |
-
'count' => $this->_getResource()->getIntervalsCount($this, $interval),
|
217 |
-
);
|
218 |
-
}
|
219 |
-
}
|
220 |
-
}
|
221 |
-
}
|
222 |
-
|
223 |
-
Varien_Profiler::stop(__METHOD__);
|
224 |
-
return $data;
|
225 |
-
}
|
226 |
-
|
227 |
-
/*public function getOrderValues($category_feature_id,$categoryId)
|
228 |
-
{
|
229 |
-
$select = "
|
230 |
-
SELECT COUNT(e.entity_id) AS count
|
231 |
-
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." AS e
|
232 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." AS cat_index
|
233 |
-
ON cat_index.product_id=e.entity_id
|
234 |
-
AND cat_index.store_id='1'
|
235 |
-
AND cat_index.visibility IN(2, 4)
|
236 |
-
AND cat_index.category_id='".$categoryId."'
|
237 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
238 |
-
ON price_index.entity_id = e.entity_id
|
239 |
-
AND price_index.website_id = '1'
|
240 |
-
AND price_index.customer_group_id = 0
|
241 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_feature_'.$feature['category_feature_id'])." AS idx_".$category_feature_id."
|
242 |
-
ON idx_".$category_feature_id.".entity_id = e.icecat_product_id;
|
243 |
-
";
|
244 |
-
|
245 |
-
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($select);
|
246 |
-
}*/
|
247 |
-
|
248 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bintime_Sinchimport_Model_Layer_Filter_Feature extends Mage_Catalog_Model_Layer_Filter_Abstract
|
4 |
+
{
|
5 |
+
protected $_resource;
|
6 |
+
|
7 |
+
protected $dont_panic = true;
|
8 |
+
|
9 |
+
const LESS = 1;
|
10 |
+
const GREATER = 2;
|
11 |
+
/**
|
12 |
+
* Construct attribute filter
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
$this->_requestVar = 'ice_feature';
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Задаёт атрибут и строку запроса для текущего фильтра
|
23 |
+
* @param Фича из Icecat'a
|
24 |
+
* @return Bintime_Icelayered_Model_Layer_Filter_Feature
|
25 |
+
*/
|
26 |
+
public function setAttributeModel($attribute)
|
27 |
+
{
|
28 |
+
$this->setRequestVar('feature_' . $attribute['category_feature_id']);
|
29 |
+
$this->setData('attribute_model', $attribute);
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getName()
|
34 |
+
{
|
35 |
+
$attribute = $this->getAttributeModel();
|
36 |
+
return $attribute['name'];
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Retrieve resource instance
|
41 |
+
*
|
42 |
+
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute
|
43 |
+
*/
|
44 |
+
protected function _getResource()
|
45 |
+
{
|
46 |
+
|
47 |
+
if (is_null($this->_resource)) {
|
48 |
+
$this->_resource = Mage::getResourceModel('sinchimport/layer_filter_feature');
|
49 |
+
}
|
50 |
+
return $this->_resource;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get option text from frontend model by option id
|
55 |
+
*
|
56 |
+
* @param int $optionId
|
57 |
+
* @return unknown
|
58 |
+
*/
|
59 |
+
protected function _getOptionText($optionId)
|
60 |
+
{
|
61 |
+
$feature = $this->getAttributeModel();
|
62 |
+
return $optionId;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Apply attribute option filter to product collection
|
67 |
+
*
|
68 |
+
* @param Zend_Controller_Request_Abstract $request
|
69 |
+
* @param Varien_Object $filterBlock
|
70 |
+
* @return Mage_Catalog_Model_Layer_Filter_Attribute
|
71 |
+
*/
|
72 |
+
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
73 |
+
{
|
74 |
+
$filter = $request->getParam($this->_requestVar);
|
75 |
+
if (is_array($filter)) {
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
$text = $this->_getOptionText($filter);
|
80 |
+
if ($filter && $text) {
|
81 |
+
$this->_getResource()->applyFilterToCollection($this, $filter);
|
82 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
|
83 |
+
$this->_items = array();
|
84 |
+
}
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Check whether specified attribute can be used in LN
|
91 |
+
*
|
92 |
+
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
93 |
+
* @return bool
|
94 |
+
*/
|
95 |
+
protected function _getIsFilterableAttribute($attribute)
|
96 |
+
{
|
97 |
+
if ($this->dont_panic) return null;
|
98 |
+
die(__METHOD__);
|
99 |
+
return $attribute->getIsFilterable();
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Возвращает массив с информацией по опциям фильтра.
|
104 |
+
* @return array
|
105 |
+
*/
|
106 |
+
protected function _getItemsData()
|
107 |
+
{
|
108 |
+
Varien_Profiler::start(__METHOD__);
|
109 |
+
|
110 |
+
$feature = $this->getAttributeModel();
|
111 |
+
$this->_requestVar = 'feature_' . $feature['category_feature_id'];
|
112 |
+
$limitDirection = isset($feature['limit_direction']) ? $feature['limit_direction'] : 0;
|
113 |
+
|
114 |
+
$data = array();
|
115 |
+
$options = explode("\n", $feature['restricted_values']);
|
116 |
+
if (count($options) == 0) {
|
117 |
+
Varien_Profiler::stop(__METHOD__);
|
118 |
+
return $data;
|
119 |
+
}
|
120 |
+
if (isset($feature['order_val']) && $feature['order_val'] == '2') {
|
121 |
+
$options = array_reverse($options);
|
122 |
+
}
|
123 |
+
if ($limitDirection != self::LESS && $limitDirection != self::GREATER) {
|
124 |
+
|
125 |
+
$optionsCount = $this->_getResource()->getCount($this);
|
126 |
+
foreach ($options as $option) {
|
127 |
+
if ($pos = strpos($option, '::')) {
|
128 |
+
$value = substr($option, 0, $pos);
|
129 |
+
$presentation_value = substr($option, $pos + 2);
|
130 |
+
}
|
131 |
+
else {
|
132 |
+
$value = $presentation_value = $option;
|
133 |
+
}
|
134 |
+
if (isset($optionsCount[$value]) && $optionsCount[$value] > 0) {
|
135 |
+
$data[] = array(
|
136 |
+
'label' => $presentation_value,
|
137 |
+
'value' => $value,
|
138 |
+
'count' => $optionsCount[$value],
|
139 |
+
);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
} else {
|
143 |
+
$oCount = count($options);
|
144 |
+
$intervals = array();
|
145 |
+
if ($feature['order_val'] == '2') {
|
146 |
+
for ($i = 0; $i < $oCount -1; $i++) {
|
147 |
+
$intervals[$i]['high'] = $options[$i];
|
148 |
+
$intervals[$i]['low'] = $options[$i +1];
|
149 |
+
}
|
150 |
+
} else {
|
151 |
+
for ($i = 0; $i < $oCount -1; $i++) {
|
152 |
+
$intervals[$i]['low'] = $options[$i];
|
153 |
+
$intervals[$i]['high'] = $options[$i +1];
|
154 |
+
}
|
155 |
+
}
|
156 |
+
//FIXME: this is ugly
|
157 |
+
if ($feature['order_val'] == '2') {
|
158 |
+
array_push ($intervals, array(
|
159 |
+
'high' => $options[$oCount -1],
|
160 |
+
));
|
161 |
+
array_unshift($intervals, array(
|
162 |
+
'low' => $options[0],
|
163 |
+
));
|
164 |
+
} else {
|
165 |
+
array_push ($intervals, array(
|
166 |
+
'low' => $options[$oCount -1],
|
167 |
+
));
|
168 |
+
array_unshift($intervals, array(
|
169 |
+
'high' => $options[0],
|
170 |
+
));
|
171 |
+
}
|
172 |
+
|
173 |
+
$this->setData('intervals', $intervals);
|
174 |
+
|
175 |
+
$defaultSign = $feature['default_sign'];
|
176 |
+
for($i = 0; $i < count($intervals); $i++) {
|
177 |
+
if ($feature['order_val'] == '2') {
|
178 |
+
$interval = $intervals[$i];
|
179 |
+
$label = isset($interval['high']) ? $interval['high'] . " $defaultSign" : '>';
|
180 |
+
if ($label == '>' && isset($intervals[$i + 1])) {
|
181 |
+
$pad = strlen($intervals[$i + 1]['high'] . $defaultSign) + 2;
|
182 |
+
$label = str_pad($label, $pad*2, ' ', STR_PAD_LEFT);
|
183 |
+
$label = str_replace(' ', ' ', $label);
|
184 |
+
}
|
185 |
+
$label .= isset($interval['high'], $interval['high']) ? ' - ' : ' ';
|
186 |
+
$label .= isset($interval['low']) ? $interval['low'] . " $defaultSign" : '>';
|
187 |
+
$value = isset($interval['low']) ? $interval['low'] : '-';
|
188 |
+
$value .= ',';
|
189 |
+
$value .= isset($interval['high']) ? $interval['high'] : '-';
|
190 |
+
if (isset($interval['high']) AND !isset($interval['low'])) { $value = '-,'.$interval['high'];}
|
191 |
+
if ($this->_getResource()->getIntervalsCountDescending($this, $interval) > 0){
|
192 |
+
$data[] = array(
|
193 |
+
'label' => $label,
|
194 |
+
'value' => $value,
|
195 |
+
'count' => $this->_getResource()->getIntervalsCountDescending($this, $interval),
|
196 |
+
);
|
197 |
+
}
|
198 |
+
} else {
|
199 |
+
$interval = $intervals[$i];
|
200 |
+
$label = isset($interval['low']) ? $interval['low'] . " $defaultSign" : '<';
|
201 |
+
if ($label == '<' && isset($intervals[$i + 1])) {
|
202 |
+
$pad = strlen($intervals[$i + 1]['low'] . $defaultSign) + 2;
|
203 |
+
$label = str_pad($label, $pad*2, ' ', STR_PAD_LEFT);
|
204 |
+
$label = str_replace(' ', ' ', $label);
|
205 |
+
}
|
206 |
+
$label .= isset($interval['low'], $interval['high']) ? ' - ' : ' ';
|
207 |
+
$label .= isset($interval['high']) ? $interval['high'] . " $defaultSign" : '<';
|
208 |
+
|
209 |
+
$value = isset($interval['low']) ? $interval['low'] : '-';
|
210 |
+
$value .= ',';
|
211 |
+
$value .= isset($interval['high']) ? $interval['high'] : '-';
|
212 |
+
if ($this->_getResource()->getIntervalsCount($this, $interval) > 0){
|
213 |
+
$data[] = array(
|
214 |
+
'label' => $label,
|
215 |
+
'value' => $value,
|
216 |
+
'count' => $this->_getResource()->getIntervalsCount($this, $interval),
|
217 |
+
);
|
218 |
+
}
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
Varien_Profiler::stop(__METHOD__);
|
224 |
+
return $data;
|
225 |
+
}
|
226 |
+
|
227 |
+
/*public function getOrderValues($category_feature_id,$categoryId)
|
228 |
+
{
|
229 |
+
$select = "
|
230 |
+
SELECT COUNT(e.entity_id) AS count
|
231 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." AS e
|
232 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." AS cat_index
|
233 |
+
ON cat_index.product_id=e.entity_id
|
234 |
+
AND cat_index.store_id='1'
|
235 |
+
AND cat_index.visibility IN(2, 4)
|
236 |
+
AND cat_index.category_id='".$categoryId."'
|
237 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
238 |
+
ON price_index.entity_id = e.entity_id
|
239 |
+
AND price_index.website_id = '1'
|
240 |
+
AND price_index.customer_group_id = 0
|
241 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_feature_'.$feature['category_feature_id'])." AS idx_".$category_feature_id."
|
242 |
+
ON idx_".$category_feature_id.".entity_id = e.icecat_product_id;
|
243 |
+
";
|
244 |
+
|
245 |
+
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($select);
|
246 |
+
}*/
|
247 |
+
|
248 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Price.php
CHANGED
@@ -1,192 +1,141 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* price filter - override price breaks for customer price grouping
|
5 |
-
*
|
6 |
-
* @category Mage
|
7 |
-
* @package
|
8 |
-
* @author Sergey Stepanchuk
|
9 |
-
*/
|
10 |
-
class Bintime_Sinchimport_Model_Layer_Filter_Price extends Mage_Catalog_Model_Layer_Filter_Price
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
$
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
*
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
list($minPrice, $maxPrice) = $price_range_value;
|
143 |
-
if(is_numeric($minPrice) && (is_numeric($maxPrice) || $maxPrice=='*')){
|
144 |
-
$count=$this->_getResource()->getCountMinMaxPrice($this, $minPrice, $maxPrice);
|
145 |
-
$fromPrice = $minPrice;
|
146 |
-
$toPrice = ($maxPrice == '*') ? '' : ($maxPrice);
|
147 |
-
if($count){
|
148 |
-
$data[] = array(
|
149 |
-
'label' => $this->_renderItemLabelMinMaxPrice($minPrice, $maxPrice),
|
150 |
-
'value' =>$price_range_value,
|
151 |
-
'value' =>$minPrice . '-' . $maxPrice,
|
152 |
-
'count' => $count,
|
153 |
-
);
|
154 |
-
}
|
155 |
-
}
|
156 |
-
}
|
157 |
-
if($data){
|
158 |
-
return $data;
|
159 |
-
}
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
$range = $this->getPriceRange();
|
164 |
-
$dbRanges = $this->getRangeItemCounts($range);
|
165 |
-
$data = array();
|
166 |
-
|
167 |
-
foreach ($dbRanges as $index=>$count) {
|
168 |
-
$data[] = array(
|
169 |
-
'label' => $this->_renderItemLabel($range, $index),
|
170 |
-
'value' => $index . ',' . $range,
|
171 |
-
'count' => $count,
|
172 |
-
);
|
173 |
-
}
|
174 |
-
|
175 |
-
return $data;
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Apply filter value to product collection based on customer price breaks and selected value
|
180 |
-
*
|
181 |
-
* @param int $minPrice
|
182 |
-
* @param int $maxPrice
|
183 |
-
* @return Mage_Catalog_Model_Layer_Filter_Price
|
184 |
-
*/
|
185 |
-
|
186 |
-
protected function _applyToCollectionMinMaxPrice($minPrice, $maxPrice)
|
187 |
-
{
|
188 |
-
$this->_getResource()->applyFilterToCollectionMinMaxPrice($this, $minPrice, $maxPrice);
|
189 |
-
return $this;
|
190 |
-
}
|
191 |
-
|
192 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* price filter - override price breaks for customer price grouping
|
5 |
+
*
|
6 |
+
* @category Mage
|
7 |
+
* @package Mage_Catalog
|
8 |
+
* @author Sergey Stepanchuk
|
9 |
+
*/
|
10 |
+
class Bintime_Sinchimport_Model_Layer_Filter_Price extends Mage_Catalog_Model_Layer_Filter_Price
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Apply price range filter to collection
|
14 |
+
*
|
15 |
+
* @param Zend_Controller_Request_Abstract $request
|
16 |
+
* @param $filterBlock
|
17 |
+
*
|
18 |
+
* @return Mage_Catalog_Model_Layer_Filter_Price
|
19 |
+
*/
|
20 |
+
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Filter must be string: $index,$range
|
24 |
+
*/
|
25 |
+
$filter = $request->getParam($this->getRequestVar());
|
26 |
+
if (!$filter) {
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
if (strstr($filter, ',')) {
|
31 |
+
$filter = explode(',', $filter);
|
32 |
+
if (count($filter) != 2) {
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
list($index, $range) = $filter;
|
36 |
+
|
37 |
+
if ((int) $index && (int) $range) {
|
38 |
+
$this->setPriceRange((int) $range);
|
39 |
+
|
40 |
+
$this->_applyToCollection($range, $index);
|
41 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($this->_renderItemLabel($range, $index), $filter));
|
42 |
+
|
43 |
+
$this->_items = array();
|
44 |
+
}
|
45 |
+
|
46 |
+
} elseif (strstr($filter, '-')) {
|
47 |
+
$filter = explode('-', $filter);
|
48 |
+
if (count($filter) != 2) {
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
list($minPrice, $maxPrice) = $filter;
|
53 |
+
|
54 |
+
if (((int) $minPrice || $minPrice == 0) && ((int) $maxPrice || $maxPrice == '*')) {
|
55 |
+
$this->_applyToCollectionMinMaxPrice($minPrice, $maxPrice);
|
56 |
+
|
57 |
+
$this->getLayer()->getState()->addFilter($this->_createItem($this->_renderItemLabelMinMaxPrice($minPrice, $maxPrice), $filter));
|
58 |
+
|
59 |
+
$this->_items = array();
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Prepare text of item label
|
69 |
+
*
|
70 |
+
* @param int $fromPrice
|
71 |
+
* @param int
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
protected function _renderItemLabelMinMaxPrice($fromPrice, $toPrice)
|
75 |
+
{
|
76 |
+
$store = Mage::app()->getStore();
|
77 |
+
$toPriceLabel = $toPrice;
|
78 |
+
$fromPrice = $store->formatPrice($fromPrice);
|
79 |
+
$toPrice = $store->formatPrice($toPrice);
|
80 |
+
$label = Mage::helper('catalog')->__('%s - %s', $fromPrice, $toPrice);
|
81 |
+
if ($toPriceLabel == '' || $toPriceLabel == '*') {
|
82 |
+
$label = $fromPrice . " + ";
|
83 |
+
}
|
84 |
+
|
85 |
+
return $label;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Get data for build price filter items
|
90 |
+
*
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
protected function _getItemsData()
|
94 |
+
{
|
95 |
+
$import = Mage::getModel('sinchimport/sinch');
|
96 |
+
$price_breaks = $import->price_breaks_filter;
|
97 |
+
|
98 |
+
$data = array();
|
99 |
+
|
100 |
+
if (strpos($price_breaks, ';') !== false) {
|
101 |
+
$price_ranges = explode(';', $price_breaks);
|
102 |
+
foreach ($price_ranges as $price_range) {
|
103 |
+
$price_range_value = trim($price_range);
|
104 |
+
if ($price_range_value == '' || strpos($price_range_value, "-") === false)
|
105 |
+
continue;
|
106 |
+
$price_range_value = explode('-', $price_range_value);
|
107 |
+
list($minPrice, $maxPrice) = $price_range_value;
|
108 |
+
if (is_numeric($minPrice) && (is_numeric($maxPrice) || $maxPrice == '*')) {
|
109 |
+
$count = $this->_getResource()->getCountMinMaxPrice($this, $minPrice, $maxPrice);
|
110 |
+
if ($count) {
|
111 |
+
$data[] = array(
|
112 |
+
'label' => $this->_renderItemLabelMinMaxPrice($minPrice, $maxPrice),
|
113 |
+
'value' => implode('-', $price_range_value),
|
114 |
+
'count' => $count
|
115 |
+
);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
if ($data) {
|
120 |
+
return $data;
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
return parent::_getItemsData();
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Apply filter value to product collection based on customer price breaks and selected value
|
130 |
+
*
|
131 |
+
* @param int $minPrice
|
132 |
+
* @param int $maxPrice
|
133 |
+
* @return Mage_Catalog_Model_Layer_Filter_Price
|
134 |
+
*/
|
135 |
+
protected function _applyToCollectionMinMaxPrice($minPrice, $maxPrice)
|
136 |
+
{
|
137 |
+
$this->_getResource()->applyFilterToCollectionMinMaxPrice($this, $minPrice, $maxPrice);
|
138 |
+
return $this;
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Bintime/Sinchimport/Model/Product.php
CHANGED
@@ -1,64 +1,64 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bintime_Sinchimport_Model_Product extends Mage_Catalog_Model_Product
|
4 |
-
{
|
5 |
-
public function getIcecatId()
|
6 |
-
{
|
7 |
-
|
8 |
-
$resource = $this->getResource();
|
9 |
-
$connection = $resource->getReadConnection();
|
10 |
-
$result = $connection->query("
|
11 |
-
SELECT product_id FROM icecat_products WHERE mpn = '" . $this->getVendorProductId() . "' ");
|
12 |
-
$id = 0;
|
13 |
-
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
14 |
-
$id = $row['product_id'];
|
15 |
-
}
|
16 |
-
// echo 'rewrite!';
|
17 |
-
return $id;
|
18 |
-
}
|
19 |
-
public function getMediaGalleryImages()
|
20 |
-
{
|
21 |
-
$entity_id=$this->getEntityId();
|
22 |
-
$sinch=Mage::getModel('sinchimport/sinch');
|
23 |
-
$sinch->loadGalleryPhotos($this->getEntityId());
|
24 |
-
$gallery_photos=$sinch->getGalleryPhotos();
|
25 |
-
if(is_array($gallery_photos)){
|
26 |
-
$images = new Varien_Data_Collection();
|
27 |
-
foreach($gallery_photos as $photo){
|
28 |
-
$image['file']=$photo['thumb'];
|
29 |
-
$image['url']=$photo['pic'];
|
30 |
-
$images->addItem(new Varien_Object($image));
|
31 |
-
}
|
32 |
-
$this->setData('media_gallery_images', $images);
|
33 |
-
}else{
|
34 |
-
if(!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) {
|
35 |
-
$images = new Varien_Data_Collection();
|
36 |
-
foreach ($this->getMediaGallery('images') as $image) {
|
37 |
-
if ($image['disabled']) {
|
38 |
-
continue;
|
39 |
-
}
|
40 |
-
$image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']);
|
41 |
-
$image['id'] = isset($image['value_id']) ? $image['value_id'] : null;
|
42 |
-
$image['path'] = $this->getMediaConfig()->getMediaPath($image['file']);
|
43 |
-
$images->addItem(new Varien_Object($image));
|
44 |
-
}
|
45 |
-
$this->setData('media_gallery_images', $images);
|
46 |
-
}
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
return $this->getData('media_gallery_images');
|
51 |
-
}
|
52 |
-
|
53 |
-
function afterCommitCallback(){
|
54 |
-
parent::afterCommitCallback();
|
55 |
-
Mage::getSingleton('index/indexer')->processEntityAction(
|
56 |
-
$this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE
|
57 |
-
);
|
58 |
-
$entity_id=$this->getEntityId();
|
59 |
-
$sinch=Mage::getModel('sinchimport/sinch');
|
60 |
-
$sinch->reloadProductImage($entity_id);
|
61 |
-
return $this;
|
62 |
-
|
63 |
-
}
|
64 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bintime_Sinchimport_Model_Product extends Mage_Catalog_Model_Product
|
4 |
+
{
|
5 |
+
public function getIcecatId()
|
6 |
+
{
|
7 |
+
|
8 |
+
$resource = $this->getResource();
|
9 |
+
$connection = $resource->getReadConnection();
|
10 |
+
$result = $connection->query("
|
11 |
+
SELECT product_id FROM icecat_products WHERE mpn = '" . $this->getVendorProductId() . "' ");
|
12 |
+
$id = 0;
|
13 |
+
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
14 |
+
$id = $row['product_id'];
|
15 |
+
}
|
16 |
+
// echo 'rewrite!';
|
17 |
+
return $id;
|
18 |
+
}
|
19 |
+
public function getMediaGalleryImages()
|
20 |
+
{
|
21 |
+
$entity_id=$this->getEntityId();
|
22 |
+
$sinch=Mage::getModel('sinchimport/sinch');
|
23 |
+
$sinch->loadGalleryPhotos($this->getEntityId());
|
24 |
+
$gallery_photos=$sinch->getGalleryPhotos();
|
25 |
+
if(is_array($gallery_photos)){
|
26 |
+
$images = new Varien_Data_Collection();
|
27 |
+
foreach($gallery_photos as $photo){
|
28 |
+
$image['file']=$photo['thumb'];
|
29 |
+
$image['url']=$photo['pic'];
|
30 |
+
$images->addItem(new Varien_Object($image));
|
31 |
+
}
|
32 |
+
$this->setData('media_gallery_images', $images);
|
33 |
+
}else{
|
34 |
+
if(!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) {
|
35 |
+
$images = new Varien_Data_Collection();
|
36 |
+
foreach ($this->getMediaGallery('images') as $image) {
|
37 |
+
if ($image['disabled']) {
|
38 |
+
continue;
|
39 |
+
}
|
40 |
+
$image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']);
|
41 |
+
$image['id'] = isset($image['value_id']) ? $image['value_id'] : null;
|
42 |
+
$image['path'] = $this->getMediaConfig()->getMediaPath($image['file']);
|
43 |
+
$images->addItem(new Varien_Object($image));
|
44 |
+
}
|
45 |
+
$this->setData('media_gallery_images', $images);
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
return $this->getData('media_gallery_images');
|
51 |
+
}
|
52 |
+
|
53 |
+
function afterCommitCallback(){
|
54 |
+
parent::afterCommitCallback();
|
55 |
+
Mage::getSingleton('index/indexer')->processEntityAction(
|
56 |
+
$this, self::ENTITY, Mage_Index_Model_Event::TYPE_SAVE
|
57 |
+
);
|
58 |
+
$entity_id=$this->getEntityId();
|
59 |
+
$sinch=Mage::getModel('sinchimport/sinch');
|
60 |
+
$sinch->reloadProductImage($entity_id);
|
61 |
+
return $this;
|
62 |
+
|
63 |
+
}
|
64 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Resource/Layer/Filter/Price.php
CHANGED
@@ -1,78 +1,78 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Catalog Layer Price Filter resource model
|
4 |
-
*
|
5 |
-
* @category Mage
|
6 |
-
* @package Mage_Catalog
|
7 |
-
* @author Sergey Stepanchuk
|
8 |
-
*/
|
9 |
-
class
|
10 |
-
{
|
11 |
-
public function applyFilterToCollectionMinMaxPrice($filter, $minPrice, $maxPrice)
|
12 |
-
{
|
13 |
-
$collection = $filter->getLayer()->getProductCollection();
|
14 |
-
$collection->addPriceData($filter->getCustomerGroupId(), $filter->getWebsiteId());
|
15 |
-
|
16 |
-
$select
|
17 |
-
$response
|
18 |
-
|
19 |
-
$table = $this->_getIndexTableAlias();
|
20 |
-
$additional = join('', $response->getAdditionalCalculations());
|
21 |
-
$rate = $filter->getCurrencyRate();
|
22 |
-
$priceExpr = new Zend_Db_Expr("(({$table}.min_price {$additional}) * {$rate})");
|
23 |
-
|
24 |
-
$select->where($priceExpr . ' >= ?', $minPrice);
|
25 |
-
if($maxPrice!='*'){
|
26 |
-
|
27 |
-
}
|
28 |
-
return $this;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getCountMinMaxPrice($filter, $minPrice, $maxPrice)
|
32 |
-
{
|
33 |
-
$select = $this->_getSelect($filter);
|
34 |
-
$connection = $this->_getReadAdapter();
|
35 |
-
$response = $this->_dispatchPreparePriceEvent($filter, $select);
|
36 |
-
$table = $this->_getIndexTableAlias();
|
37 |
-
|
38 |
-
$additional = join('', $response->getAdditionalCalculations());
|
39 |
-
$rate = $filter->getCurrencyRate();
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Check and set correct variable values to prevent SQL-injections
|
43 |
-
*/
|
44 |
-
$rate
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
$
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Catalog Layer Price Filter resource model
|
4 |
+
*
|
5 |
+
* @category Mage
|
6 |
+
* @package Mage_Catalog
|
7 |
+
* @author Sergey Stepanchuk
|
8 |
+
*/
|
9 |
+
class Bintime_Sinchimport_Model_Resource_Layer_Filter_Price extends Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Price
|
10 |
+
{
|
11 |
+
public function applyFilterToCollectionMinMaxPrice($filter, $minPrice, $maxPrice)
|
12 |
+
{
|
13 |
+
$collection = $filter->getLayer()->getProductCollection();
|
14 |
+
$collection->addPriceData($filter->getCustomerGroupId(), $filter->getWebsiteId());
|
15 |
+
|
16 |
+
$select = $collection->getSelect();
|
17 |
+
$response = $this->_dispatchPreparePriceEvent($filter, $select);
|
18 |
+
|
19 |
+
$table = $this->_getIndexTableAlias();
|
20 |
+
$additional = join('', $response->getAdditionalCalculations());
|
21 |
+
$rate = $filter->getCurrencyRate();
|
22 |
+
$priceExpr = new Zend_Db_Expr("(({$table}.min_price {$additional}) * {$rate})");
|
23 |
+
|
24 |
+
$select->where($priceExpr . ' >= ?', $minPrice);
|
25 |
+
if ($maxPrice != '*') {
|
26 |
+
$select->where($priceExpr . ' < ?', $maxPrice);
|
27 |
+
}
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getCountMinMaxPrice($filter, $minPrice, $maxPrice)
|
32 |
+
{
|
33 |
+
$select = $this->_getSelect($filter, true);
|
34 |
+
$connection = $this->_getReadAdapter();
|
35 |
+
$response = $this->_dispatchPreparePriceEvent($filter, $select);
|
36 |
+
$table = $this->_getIndexTableAlias();
|
37 |
+
|
38 |
+
$additional = join('', $response->getAdditionalCalculations());
|
39 |
+
$rate = $filter->getCurrencyRate();
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Check and set correct variable values to prevent SQL-injections
|
43 |
+
*/
|
44 |
+
$rate = floatval($rate);
|
45 |
+
|
46 |
+
$countExpr = new Zend_Db_Expr('COUNT(*)');
|
47 |
+
$rangeExpr = new Zend_Db_Expr("FLOOR(({$table}.min_price {$additional}) * {$rate}) ");
|
48 |
+
$select->where($rangeExpr . ' >= ?', $minPrice);
|
49 |
+
if ($maxPrice != '*') {
|
50 |
+
$select->where($rangeExpr . ' < ?', $maxPrice);
|
51 |
+
}
|
52 |
+
$select->columns(array(
|
53 |
+
'count' => $countExpr
|
54 |
+
));
|
55 |
+
|
56 |
+
return $connection->fetchOne($select);
|
57 |
+
}
|
58 |
+
|
59 |
+
protected function _getSelect($filter, $isCountMinMax = false)
|
60 |
+
{
|
61 |
+
if ($isCountMinMax) {
|
62 |
+
$collection = $filter->getLayer()->getProductCollection();
|
63 |
+
$collection->addPriceData($filter->getCustomerGroupId(), $filter->getWebsiteId());
|
64 |
+
|
65 |
+
// clone select from collection with filters
|
66 |
+
$select = clone $collection->getSelect();
|
67 |
+
// reset columns, order and limitation conditions
|
68 |
+
$select->reset(Zend_Db_Select::COLUMNS);
|
69 |
+
$select->reset(Zend_Db_Select::ORDER);
|
70 |
+
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
71 |
+
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
72 |
+
|
73 |
+
return $select;
|
74 |
+
}
|
75 |
+
|
76 |
+
return parent::_getSelect($filter);
|
77 |
+
}
|
78 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php
CHANGED
@@ -1,399 +1,372 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bintime_Sinchimport_Model_Resource_Mysql4_Layer_Filter_Feature extends Mage_Core_Model_Mysql4_Abstract
|
4 |
-
{
|
5 |
-
protected $resultTable = 'SinchFilterResult';
|
6 |
-
|
7 |
-
protected static $lastResultTable = false;
|
8 |
-
|
9 |
-
protected $filterAplied = false;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Initialize connection and define main table name
|
13 |
-
*
|
14 |
-
*/
|
15 |
-
protected function _construct()
|
16 |
-
{
|
17 |
-
$this->_init('catalog/ice_feature', 'category_feature_id');
|
18 |
-
}
|
19 |
-
|
20 |
-
protected function _getTableName($type, $id = 0)
|
21 |
-
{
|
22 |
-
$tablePrefix = (string)Mage::getConfig()->getTablePrefix();
|
23 |
-
switch ($type) {
|
24 |
-
case 'result':
|
25 |
-
$id = (int)$id;
|
26 |
-
return $tablePrefix . $this->resultTable . "_$id";
|
27 |
-
break;
|
28 |
-
|
29 |
-
case 'search':
|
30 |
-
return $tablePrefix . $this->searchTable;
|
31 |
-
break;
|
32 |
-
default:
|
33 |
-
$resource = Mage::getSingleton('core/resource');
|
34 |
-
return $resource->getTableName($type);
|
35 |
-
}
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Подготавливает фильтр к поиску
|
41 |
-
*
|
42 |
-
* @param Bintime_Icelayered_Model_Layer_Filter_Feature $filter
|
43 |
-
* @param string $value Значение, которму должен соответствовать атрибут
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
protected function _prepareSearch($filter, $value = null)
|
47 |
-
{
|
48 |
-
Varien_Profiler::start(__METHOD__);
|
49 |
-
$catId = $filter->getLayer()->getCurrentCategory()->getId();
|
50 |
-
$connection = $this->_getWriteAdapter();
|
51 |
-
|
52 |
-
$cfid = 0;
|
53 |
-
if (!is_null($value)) {
|
54 |
-
$feature = $filter->getAttributeModel();
|
55 |
-
$cfid = $feature['category_feature_id'];
|
56 |
-
}
|
57 |
-
$resultTable = $this->_getTableName('result', $cfid);
|
58 |
-
// Toàn Handsome đã thêm đoạn code này để kiểm tra bảng dữ liệu đã tồn tại hay chưa
|
59 |
-
$result = $connection->fetchPairs("SHOW TABLES LIKE '$resultTable'");
|
60 |
-
if ($result) {
|
61 |
-
return $resultTable;
|
62 |
-
}
|
63 |
-
|
64 |
-
//TODO: this table must be temporary
|
65 |
-
$sql = "
|
66 |
-
CREATE TABLE IF NOT EXISTS `{$resultTable}`(
|
67 |
-
|
68 |
-
`category_id` int(10) unsigned,
|
69 |
-
`product_id` int,
|
70 |
-
`sinch_category_id` int,
|
71 |
-
`name` varchar(255),
|
72 |
-
`image` varchar(255),
|
73 |
-
`supplier_id` int,
|
74 |
-
`category_feature_id` int,
|
75 |
-
`feature_id` int,
|
76 |
-
`feature_name` varchar(255),
|
77 |
-
`feature_value`
|
78 |
-
);
|
79 |
-
";
|
80 |
-
$connection->exec($sql);
|
81 |
-
|
82 |
-
$
|
83 |
-
|
84 |
-
$
|
85 |
-
|
86 |
-
$
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
$params
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
$
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
$select->
|
154 |
-
|
155 |
-
|
156 |
-
$
|
157 |
-
$
|
158 |
-
$
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
->
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
$select->
|
190 |
-
|
191 |
-
|
192 |
-
$
|
193 |
-
$
|
194 |
-
$select->
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
->
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
$select->
|
238 |
-
|
239 |
-
|
240 |
-
$
|
241 |
-
$
|
242 |
-
|
243 |
-
$select->
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
->
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
$
|
295 |
-
$
|
296 |
-
$
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
$
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
$connection
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
$
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
ON (E.entity_id = PCind.product_id AND PCind.store_id='{$storeId}' AND PCind.visibility IN(2,4))
|
374 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
375 |
-
ON price_index.entity_id = E.entity_id AND price_index.website_id = '{$websiteId}' AND price_index.customer_group_id = 0
|
376 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." PR
|
377 |
-
ON (PR.store_product_id = E.store_product_id)
|
378 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features')." PF
|
379 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
380 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values')." RV
|
381 |
-
ON (PF.restricted_value_id=RV.restricted_value_id AND RV.category_feature_id= $featureId)
|
382 |
-
GROUP BY E.entity_id;
|
383 |
-
";
|
384 |
-
$connection->exec($query);
|
385 |
-
}
|
386 |
-
Mage::log(__METHOD__ . " end at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
387 |
-
}
|
388 |
-
|
389 |
-
private function getProductFeatures4indexig()
|
390 |
-
{
|
391 |
-
$connection = $this->_getReadAdapter();
|
392 |
-
|
393 |
-
$tCatFeature = Mage::getSingleton('core/resource')->getTableName('stINch_categories_features');
|
394 |
-
$query = "SELECT category_feature_id FROM $tCatFeature ";
|
395 |
-
|
396 |
-
return $connection->fetchCol($query);
|
397 |
-
}
|
398 |
-
*/
|
399 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bintime_Sinchimport_Model_Resource_Mysql4_Layer_Filter_Feature extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
protected $resultTable = 'SinchFilterResult';
|
6 |
+
|
7 |
+
protected static $lastResultTable = false;
|
8 |
+
|
9 |
+
protected $filterAplied = false;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Initialize connection and define main table name
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('catalog/ice_feature', 'category_feature_id');
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _getTableName($type, $id = 0)
|
21 |
+
{
|
22 |
+
$tablePrefix = (string)Mage::getConfig()->getTablePrefix();
|
23 |
+
switch ($type) {
|
24 |
+
case 'result':
|
25 |
+
$id = (int)$id;
|
26 |
+
return $tablePrefix . $this->resultTable . "_$id";
|
27 |
+
break;
|
28 |
+
|
29 |
+
case 'search':
|
30 |
+
return $tablePrefix . $this->searchTable;
|
31 |
+
break;
|
32 |
+
default:
|
33 |
+
$resource = Mage::getSingleton('core/resource');
|
34 |
+
return $resource->getTableName($type);
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Подготавливает фильтр к поиску
|
41 |
+
*
|
42 |
+
* @param Bintime_Icelayered_Model_Layer_Filter_Feature $filter
|
43 |
+
* @param string $value Значение, которму должен соответствовать атрибут
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
protected function _prepareSearch($filter, $value = null)
|
47 |
+
{
|
48 |
+
Varien_Profiler::start(__METHOD__);
|
49 |
+
$catId = $filter->getLayer()->getCurrentCategory()->getId();
|
50 |
+
$connection = $this->_getWriteAdapter();
|
51 |
+
|
52 |
+
$cfid = 0;
|
53 |
+
if (!is_null($value)) {
|
54 |
+
$feature = $filter->getAttributeModel();
|
55 |
+
$cfid = $feature['category_feature_id'];
|
56 |
+
}
|
57 |
+
$resultTable = $this->_getTableName('result', $cfid);
|
58 |
+
// Toàn Handsome đã thêm đoạn code này để kiểm tra bảng dữ liệu đã tồn tại hay chưa
|
59 |
+
$result = $connection->fetchPairs("SHOW TABLES LIKE '$resultTable'");
|
60 |
+
if ($result) {
|
61 |
+
return $resultTable;
|
62 |
+
}
|
63 |
+
|
64 |
+
//TODO: this table must be temporary
|
65 |
+
$sql = "
|
66 |
+
CREATE TABLE IF NOT EXISTS `{$resultTable}`(
|
67 |
+
`entity_id` int(10) unsigned,
|
68 |
+
`category_id` int(10) unsigned,
|
69 |
+
`product_id` int,
|
70 |
+
`sinch_category_id` int,
|
71 |
+
`name` varchar(255),
|
72 |
+
`image` varchar(255),
|
73 |
+
`supplier_id` int,
|
74 |
+
`category_feature_id` int,
|
75 |
+
`feature_id` int,
|
76 |
+
`feature_name` varchar(255),
|
77 |
+
`feature_value` varchar(255)
|
78 |
+
);
|
79 |
+
";
|
80 |
+
$connection->exec($sql);
|
81 |
+
|
82 |
+
$addUniqueSql = "ALTER TABLE `{$resultTable}` ADD UNIQUE KEY (`entity_id`, `feature_id`, `feature_value`);";
|
83 |
+
|
84 |
+
$connection->exec($addUniqueSql);
|
85 |
+
|
86 |
+
$truncateSql = "TRUNCATE TABLE {$resultTable}";
|
87 |
+
$connection->exec($truncateSql);
|
88 |
+
|
89 |
+
$featuresTable = $this->_getTableName('FilterListOfFeatures');
|
90 |
+
$sql = "TRUNCATE TABLE `$featuresTable`";
|
91 |
+
$connection->exec($sql);
|
92 |
+
|
93 |
+
$feature = $filter->getAttributeModel();
|
94 |
+
if (!isset($feature['limit_direction']) || ($feature['limit_direction'] != 1 && $feature['limit_direction'] != 2)) {
|
95 |
+
if (!is_null($value)) {
|
96 |
+
$sql = "INSERT INTO `$featuresTable` (category_feature_id, feature_value) VALUES (?)";
|
97 |
+
$sql = $connection->quoteInto($sql, array($cfid, $value));
|
98 |
+
$connection->exec($sql);
|
99 |
+
}
|
100 |
+
$params = 'null, null';
|
101 |
+
} else {
|
102 |
+
$bounds = explode(',', $value);
|
103 |
+
|
104 |
+
$params = $bounds[0] != '-' ? (int)$bounds[0] : 'null';
|
105 |
+
$params .= ', ';
|
106 |
+
$params .= $bounds[1] != '-' ? (int)$bounds[1] : 'null';
|
107 |
+
}
|
108 |
+
$tablePrefix = (string)Mage::app()->getConfig()->getTablePrefix();
|
109 |
+
$result = $connection->raw_query("CALL ".$this->_getTableName('filter_sinch_products_s')."($cfid, $catId,0, $cfid, $params, '$tablePrefix')");
|
110 |
+
Varien_Profiler::stop(__METHOD__);
|
111 |
+
return $resultTable;
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Apply attribute filter to product collection
|
117 |
+
*
|
118 |
+
* @param Bintime_Icelayered_Model_Layer_Filter_Feature $filter
|
119 |
+
* @param string $value
|
120 |
+
* @return Bintime_Icelayered_Model_Resource_Mysql4_Layer_Filter_Feature
|
121 |
+
*/
|
122 |
+
public function applyFilterToCollection($filter, $value)
|
123 |
+
{
|
124 |
+
Varien_Profiler::start(__METHOD__);
|
125 |
+
$searchTable = $this->_prepareSearch($filter, $value);
|
126 |
+
self::$lastResultTable = $searchTable;
|
127 |
+
|
128 |
+
$collection = $filter->getLayer()->getProductCollection();
|
129 |
+
$feature = $filter->getAttributeModel();
|
130 |
+
$connection = $this->_getReadAdapter();
|
131 |
+
|
132 |
+
$collection->getSelect()->join(
|
133 |
+
$searchTable,
|
134 |
+
"{$searchTable}.entity_id = e.entity_id AND {$searchTable}.feature_value = '$value'",
|
135 |
+
array()
|
136 |
+
);
|
137 |
+
|
138 |
+
Varien_Profiler::stop(__METHOD__);
|
139 |
+
return $this;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Retrieve array with products counts per attribute option
|
144 |
+
*
|
145 |
+
* @param Bintime_Icelayered_Model_Layer_Filter_Feature $filter
|
146 |
+
* @return array
|
147 |
+
*/
|
148 |
+
public function getCount($filter)
|
149 |
+
{
|
150 |
+
Varien_Profiler::start(__METHOD__);
|
151 |
+
|
152 |
+
// clone select from collection with filters
|
153 |
+
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
154 |
+
|
155 |
+
// reset columns, order and limitation conditions
|
156 |
+
$select->reset(Zend_Db_Select::COLUMNS);
|
157 |
+
$select->reset(Zend_Db_Select::ORDER);
|
158 |
+
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
159 |
+
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
160 |
+
|
161 |
+
$connection = $this->_getReadAdapter();
|
162 |
+
$feature = $filter->getAttributeModel();
|
163 |
+
$featureId = $feature['category_feature_id'];
|
164 |
+
|
165 |
+
$select->joinInner(
|
166 |
+
array('sp' => $this->_getTableName('stINch_products')),
|
167 |
+
"sp.store_product_id = e.store_product_id",
|
168 |
+
array()
|
169 |
+
)->joinInner(
|
170 |
+
array('spf' => $this->_getTableName('stINch_product_features')),
|
171 |
+
"spf.sinch_product_id = e.sinch_product_id",
|
172 |
+
array()
|
173 |
+
)->joinInner(
|
174 |
+
array('srv' => $this->_getTableName('stINch_restricted_values')),
|
175 |
+
"spf.restricted_value_id = srv.restricted_value_id AND srv.category_feature_id = $featureId",
|
176 |
+
array('value' => 'srv.text', 'count' => 'COUNT(DISTINCT e.entity_id)')
|
177 |
+
)
|
178 |
+
->group("srv.text");
|
179 |
+
|
180 |
+
Varien_Profiler::stop(__METHOD__);
|
181 |
+
return $connection->fetchPairs($select);
|
182 |
+
}
|
183 |
+
|
184 |
+
public function getIntervalsCount($filter, $interval)
|
185 |
+
{
|
186 |
+
Varien_Profiler::start(__METHOD__);
|
187 |
+
|
188 |
+
// clone select from collection with filters
|
189 |
+
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
190 |
+
|
191 |
+
// reset columns, order and limitation conditions
|
192 |
+
$select->reset(Zend_Db_Select::COLUMNS);
|
193 |
+
$select->reset(Zend_Db_Select::ORDER);
|
194 |
+
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
195 |
+
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
196 |
+
|
197 |
+
$connection = $this->_getReadAdapter();
|
198 |
+
$feature = $filter->getAttributeModel();
|
199 |
+
$select->joinInner(
|
200 |
+
array('spf' => $this->_getTableName('stINch_product_features')),
|
201 |
+
"spf.sinch_product_id = e.sinch_product_id",
|
202 |
+
array()
|
203 |
+
)->joinLeft(
|
204 |
+
array('srv' => $this->_getTableName('stINch_restricted_values')),
|
205 |
+
"srv.restricted_value_id = spf.restricted_value_id",
|
206 |
+
array('value' => 'srv.text')
|
207 |
+
)->joinLeft(
|
208 |
+
array('scf' => $this->_getTableName('stINch_categories_features')),
|
209 |
+
"scf.category_feature_id = srv.category_feature_id",
|
210 |
+
array()
|
211 |
+
)->joinLeft(
|
212 |
+
array('scm' => $this->_getTableName('stINch_categories_mapping')),
|
213 |
+
"scm.shop_store_category_id = scf.store_category_id",
|
214 |
+
array('count' => "COUNT(DISTINCT e.entity_id)")
|
215 |
+
)
|
216 |
+
->where('srv.category_feature_id = ?', $feature['category_feature_id']);
|
217 |
+
|
218 |
+
if (isset($interval['low'], $interval['high'])) {
|
219 |
+
$select->where('CAST(srv.text AS SIGNED) >= ?', $interval['low'])->where('CAST(srv.text AS SIGNED) < ?', $interval['high']);
|
220 |
+
}
|
221 |
+
else if (isset($interval['low'])) {
|
222 |
+
$select->where('CAST(srv.text AS SIGNED) >= ?', $interval['low']);
|
223 |
+
}
|
224 |
+
else if (isset($interval['high'])) {
|
225 |
+
$select->where('CAST(srv.text AS SIGNED) < ?', $interval['high']);
|
226 |
+
}
|
227 |
+
$count = $connection->fetchOne($select);
|
228 |
+
Varien_Profiler::stop(__METHOD__);
|
229 |
+
return $count;
|
230 |
+
}
|
231 |
+
|
232 |
+
function getIntervalsCountDescending($filter, $interval)
|
233 |
+
{
|
234 |
+
Varien_Profiler::start(__METHOD__);
|
235 |
+
|
236 |
+
// clone select from collection with filters
|
237 |
+
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
238 |
+
|
239 |
+
// reset columns, order and limitation conditions
|
240 |
+
$select->reset(Zend_Db_Select::COLUMNS);
|
241 |
+
$select->reset(Zend_Db_Select::ORDER);
|
242 |
+
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
243 |
+
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
244 |
+
|
245 |
+
$connection = $this->_getReadAdapter();
|
246 |
+
$feature = $filter->getAttributeModel();
|
247 |
+
|
248 |
+
$select->joinInner(
|
249 |
+
array('spf' => $this->_getTableName('stINch_product_features')),
|
250 |
+
"spf.sinch_product_id = e.sinch_product_id",
|
251 |
+
array()
|
252 |
+
)->joinLeft(
|
253 |
+
array('srv' => $this->_getTableName('stINch_restricted_values')),
|
254 |
+
"srv.restricted_value_id = spf.restricted_value_id",
|
255 |
+
array('value' => 'srv.text')
|
256 |
+
)->joinLeft(
|
257 |
+
array('scf' => $this->_getTableName('stINch_categories_features')),
|
258 |
+
"scf.category_feature_id = srv.category_feature_id",
|
259 |
+
array()
|
260 |
+
)->joinLeft(
|
261 |
+
array('scm' => $this->_getTableName('stINch_categories_mapping')),
|
262 |
+
"scm.shop_store_category_id = scf.store_category_id",
|
263 |
+
array('count' => "COUNT(DISTINCT e.entity_id)")
|
264 |
+
)
|
265 |
+
->where('srv.category_feature_id = ?', $feature['category_feature_id']);
|
266 |
+
|
267 |
+
if (isset($interval['low'], $interval['high'])) {
|
268 |
+
$select->where('CAST(srv.text AS SIGNED) >= ?', $interval['low'])->where('CAST(srv.text AS SIGNED) < ?', $interval['high']);
|
269 |
+
}
|
270 |
+
else if (isset($interval['low'])) {
|
271 |
+
$select->where('CAST(srv.text AS SIGNED) >= ?', $interval['low']);
|
272 |
+
}
|
273 |
+
else if (isset($interval['high'])) {
|
274 |
+
$select->where('CAST(srv.text AS SIGNED) < ?', $interval['high']);
|
275 |
+
}
|
276 |
+
$count = $connection->fetchOne($select);
|
277 |
+
|
278 |
+
Varien_Profiler::stop(__METHOD__);
|
279 |
+
return $count;
|
280 |
+
}
|
281 |
+
|
282 |
+
// Toàn Handsome đã rào đoạn mã này
|
283 |
+
/**
|
284 |
+
public function splitProductsFeature()
|
285 |
+
{
|
286 |
+
Mage::log(__METHOD__ . " start at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
287 |
+
$featureIds = $this->getProductFeatures4indexig();
|
288 |
+
|
289 |
+
$resource = Mage::getSingleton('core/resource');
|
290 |
+
//$tProudctsFeature = $resource->getTableName("icecat_products_feature");
|
291 |
+
$connection = $this->_getWriteAdapter();
|
292 |
+
|
293 |
+
//удаление таблиц с фичами не используемыми больше для навигации.
|
294 |
+
$tablePattern = $resource->getTableName('stINch_products_feature_');
|
295 |
+
$query = "SHOW TABLES LIKE '%$tablePattern%'";
|
296 |
+
$featureTables = $connection->fetchCol($query);
|
297 |
+
$presentFeatures = array();
|
298 |
+
foreach($featureTables as $t) {
|
299 |
+
if (preg_match("#$tablePattern(\d+)#", $t, $matches)) {
|
300 |
+
$presentFeatures[] = $matches[1];
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
$features2delete = array_diff($presentFeatures, $featureIds);
|
305 |
+
if (count($features2delete)) {
|
306 |
+
foreach ($features2delete as & $drop) {
|
307 |
+
$drop = $tablePattern . $drop;
|
308 |
+
}
|
309 |
+
$dropSql = "DROP TABLE " . implode(',', $features2delete);
|
310 |
+
$connection->exec($dropSql);
|
311 |
+
}
|
312 |
+
|
313 |
+
//Создание таблиц с фичами используемыми в навигации.
|
314 |
+
$i = 0; $storeId = Mage::app()->getStore()->getId(); $websiteId = Mage::app()->getStore(true)->getWebsite()->getId();
|
315 |
+
foreach ($featureIds as $featureId) {
|
316 |
+
$tFeature = $resource->getTableName("stINch_products_feature_$featureId");
|
317 |
+
$query = "DROP TABLE IF EXISTS $tFeature";
|
318 |
+
$connection->exec($query);
|
319 |
+
|
320 |
+
$query = "CREATE TABLE IF NOT EXISTS $tFeature (
|
321 |
+
`entity_id` int(11) default NULL,
|
322 |
+
`feature_id` int(11) NOT NULL,
|
323 |
+
`product_id` int(11) default NULL,
|
324 |
+
`category_feature_id` int(11) default NULL,
|
325 |
+
`value` text,
|
326 |
+
`presentation_value` text,
|
327 |
+
INDEX (`feature_id`),
|
328 |
+
KEY `category_feature_id` (`category_feature_id`)
|
329 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8
|
330 |
+
";
|
331 |
+
$connection->exec($query);
|
332 |
+
|
333 |
+
$query = "TRUNCATE TABLE $tFeature";
|
334 |
+
$connection->exec($query);
|
335 |
+
|
336 |
+
$query = "
|
337 |
+
INSERT INTO $tFeature (feature_id, product_id, category_feature_id, value, presentation_value)
|
338 |
+
SELECT feature_id, product_id, category_feature_id, value, presentation_value FROM $tProudctsFeature
|
339 |
+
WHERE category_feature_id = $featureId
|
340 |
+
";
|
341 |
+
$query = "
|
342 |
+
REPLACE INTO $tFeature (entity_id,feature_id, product_id, category_feature_id, value, presentation_value)
|
343 |
+
SELECT E.entity_id, RV.category_feature_id,E.entity_id, RV.category_feature_id, RV.text , RV.text
|
344 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." E
|
345 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." PCind
|
346 |
+
ON (E.entity_id = PCind.product_id AND PCind.store_id='{$storeId}' AND PCind.visibility IN(2,4))
|
347 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
348 |
+
ON price_index.entity_id = E.entity_id AND price_index.website_id = '{$websiteId}' AND price_index.customer_group_id = 0
|
349 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." PR
|
350 |
+
ON (PR.store_product_id = E.store_product_id)
|
351 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features')." PF
|
352 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
353 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values')." RV
|
354 |
+
ON (PF.restricted_value_id=RV.restricted_value_id AND RV.category_feature_id= $featureId)
|
355 |
+
GROUP BY E.entity_id;
|
356 |
+
";
|
357 |
+
$connection->exec($query);
|
358 |
+
}
|
359 |
+
Mage::log(__METHOD__ . " end at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
360 |
+
}
|
361 |
+
|
362 |
+
private function getProductFeatures4indexig()
|
363 |
+
{
|
364 |
+
$connection = $this->_getReadAdapter();
|
365 |
+
|
366 |
+
$tCatFeature = Mage::getSingleton('core/resource')->getTableName('stINch_categories_features');
|
367 |
+
$query = "SELECT category_feature_id FROM $tCatFeature ";
|
368 |
+
|
369 |
+
return $connection->fetchCol($query);
|
370 |
+
}
|
371 |
+
*/
|
372 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Setup.php
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
<?php
|
2 |
-
class Bintime_Sinchimport_Model_Resource_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup{
|
3 |
-
}
|
1 |
+
<?php
|
2 |
+
class Bintime_Sinchimport_Model_Resource_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup{
|
3 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Sinch.php
CHANGED
@@ -1,10266 +1,9385 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
$dir
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
$
|
11 |
-
$
|
12 |
-
$
|
13 |
-
$
|
14 |
-
$
|
15 |
-
$
|
16 |
-
$
|
17 |
-
|
18 |
-
public $
|
19 |
-
public $
|
20 |
-
|
21 |
-
|
22 |
-
private $
|
23 |
-
private $
|
24 |
-
private $
|
25 |
-
private $
|
26 |
-
private $
|
27 |
-
private $
|
28 |
-
private $galleryPhotos = array();
|
29 |
-
private $productName;
|
30 |
-
private $relatedProducts = array();
|
31 |
-
private $
|
32 |
-
|
33 |
-
private $_productEntityTypeId = 0;
|
34 |
-
private $defaultAttributeSetId = 0;
|
35 |
-
private $
|
36 |
-
|
37 |
-
private $
|
38 |
-
private $
|
39 |
-
private $import_log_table;
|
40 |
-
|
41 |
-
private $
|
42 |
-
private $
|
43 |
-
private $
|
44 |
-
private $
|
45 |
-
private $
|
46 |
-
private $
|
47 |
-
private $
|
48 |
-
|
49 |
-
private $
|
50 |
-
private $
|
51 |
-
private $
|
52 |
-
private $
|
53 |
-
private $
|
54 |
-
private $
|
55 |
-
private $
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
$this->import_status_table = Mage::getSingleton('core/resource')->getTableName('stINch_import_status');
|
64 |
-
$this->import_status_statistic_table = Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic');
|
65 |
-
$this->import_log_table = "stINch_import_log";
|
66 |
-
|
67 |
-
$this->php_run_string = PHP_RUN_STRING;
|
68 |
-
$this->php_run_strings = PHP_RUN_STRINGS;
|
69 |
-
|
70 |
-
$this->price_breaks_filter = PRICE_BREAKS;
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$this->
|
80 |
-
|
81 |
-
$this->
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
$this->attributes['
|
105 |
-
$this->attributes['
|
106 |
-
$this->attributes['
|
107 |
-
$this->attributes['
|
108 |
-
$this->attributes['
|
109 |
-
$this->attributes['
|
110 |
-
$this->attributes['
|
111 |
-
$this->attributes['
|
112 |
-
|
113 |
-
$
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
$
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
$this->
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
if ($
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
if ($
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
$
|
254 |
-
|
255 |
-
|
256 |
-
$import->
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
$
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
$
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
echo "
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
echo "
|
297 |
-
$import->
|
298 |
-
$import->
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
echo "
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
$
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
$
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
return
|
459 |
-
}
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
$this->db_do(
|
468 |
-
$
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
$
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
$this->
|
495 |
-
$
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
$this->
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
function
|
603 |
-
{
|
604 |
-
|
605 |
-
$
|
606 |
-
$
|
607 |
-
|
608 |
-
$
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
$
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
$this->
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
$
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
$this->
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
$
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
{
|
1025 |
-
$
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
$
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
entity_type_id,
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
$
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
$q
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
$
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
c.
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
$
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
ON
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
$
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
)
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
$this->db_do($
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
(
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
)
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
(
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
$
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
$
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
$
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
private function
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
$
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
$
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
$
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
$
|
2368 |
-
$
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
JOIN $
|
2397 |
-
ON
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
ON DUPLICATE KEY UPDATE
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
|
2547 |
-
$
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
$
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
$
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
c.
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
$
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
$
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
$
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
(
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
";
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
$this->db_do($q);
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
|
3098 |
-
|
3099 |
-
$
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
|
3119 |
-
|
3120 |
-
|
3121 |
-
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
-
|
3127 |
-
|
3128 |
-
|
3129 |
-
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
3149 |
-
|
3150 |
-
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
|
3172 |
-
|
3173 |
-
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
|
3196 |
-
|
3197 |
-
|
3198 |
-
|
3199 |
-
|
3200 |
-
(
|
3201 |
-
|
3202 |
-
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
ON
|
3211 |
-
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
|
3263 |
-
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
c
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
|
3355 |
-
|
3356 |
-
|
3357 |
-
|
3358 |
-
|
3359 |
-
|
3360 |
-
|
3361 |
-
|
3362 |
-
|
3363 |
-
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
3370 |
-
|
3371 |
-
|
3372 |
-
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
|
3383 |
-
|
3384 |
-
|
3385 |
-
|
3386 |
-
|
3387 |
-
|
3388 |
-
|
3389 |
-
|
3390 |
-
|
3391 |
-
|
3392 |
-
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
|
3404 |
-
|
3405 |
-
|
3406 |
-
|
3407 |
-
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
|
3425 |
-
|
3426 |
-
|
3427 |
-
|
3428 |
-
|
3429 |
-
|
3430 |
-
|
3431 |
-
|
3432 |
-
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
|
3437 |
-
|
3438 |
-
|
3439 |
-
|
3440 |
-
|
3441 |
-
|
3442 |
-
|
3443 |
-
|
3444 |
-
|
3445 |
-
|
3446 |
-
|
3447 |
-
|
3448 |
-
|
3449 |
-
|
3450 |
-
|
3451 |
-
|
3452 |
-
|
3453 |
-
|
3454 |
-
|
3455 |
-
|
3456 |
-
|
3457 |
-
|
3458 |
-
|
3459 |
-
|
3460 |
-
|
3461 |
-
|
3462 |
-
|
3463 |
-
|
3464 |
-
|
3465 |
-
|
3466 |
-
|
3467 |
-
|
3468 |
-
|
3469 |
-
|
3470 |
-
|
3471 |
-
|
3472 |
-
|
3473 |
-
|
3474 |
-
|
3475 |
-
|
3476 |
-
|
3477 |
-
|
3478 |
-
|
3479 |
-
|
3480 |
-
|
3481 |
-
|
3482 |
-
|
3483 |
-
|
3484 |
-
|
3485 |
-
|
3486 |
-
|
3487 |
-
|
3488 |
-
|
3489 |
-
|
3490 |
-
|
3491 |
-
|
3492 |
-
|
3493 |
-
|
3494 |
-
|
3495 |
-
|
3496 |
-
|
3497 |
-
|
3498 |
-
|
3499 |
-
|
3500 |
-
|
3501 |
-
|
3502 |
-
|
3503 |
-
|
3504 |
-
|
3505 |
-
|
3506 |
-
|
3507 |
-
|
3508 |
-
|
3509 |
-
|
3510 |
-
|
3511 |
-
|
3512 |
-
|
3513 |
-
|
3514 |
-
|
3515 |
-
|
3516 |
-
|
3517 |
-
$
|
3518 |
-
|
3519 |
-
|
3520 |
-
|
3521 |
-
|
3522 |
-
|
3523 |
-
|
3524 |
-
|
3525 |
-
|
3526 |
-
|
3527 |
-
|
3528 |
-
|
3529 |
-
|
3530 |
-
|
3531 |
-
|
3532 |
-
|
3533 |
-
|
3534 |
-
|
3535 |
-
|
3536 |
-
|
3537 |
-
|
3538 |
-
|
3539 |
-
|
3540 |
-
|
3541 |
-
|
3542 |
-
|
3543 |
-
|
3544 |
-
|
3545 |
-
|
3546 |
-
|
3547 |
-
|
3548 |
-
|
3549 |
-
|
3550 |
-
|
3551 |
-
|
3552 |
-
|
3553 |
-
|
3554 |
-
|
3555 |
-
|
3556 |
-
|
3557 |
-
|
3558 |
-
|
3559 |
-
|
3560 |
-
|
3561 |
-
|
3562 |
-
|
3563 |
-
|
3564 |
-
|
3565 |
-
|
3566 |
-
|
3567 |
-
|
3568 |
-
|
3569 |
-
|
3570 |
-
|
3571 |
-
|
3572 |
-
|
3573 |
-
|
3574 |
-
|
3575 |
-
|
3576 |
-
|
3577 |
-
|
3578 |
-
|
3579 |
-
|
3580 |
-
|
3581 |
-
|
3582 |
-
|
3583 |
-
|
3584 |
-
|
3585 |
-
|
3586 |
-
$
|
3587 |
-
|
3588 |
-
|
3589 |
-
|
3590 |
-
|
3591 |
-
|
3592 |
-
|
3593 |
-
|
3594 |
-
|
3595 |
-
|
3596 |
-
|
3597 |
-
|
3598 |
-
|
3599 |
-
|
3600 |
-
|
3601 |
-
|
3602 |
-
|
3603 |
-
|
3604 |
-
|
3605 |
-
|
3606 |
-
|
3607 |
-
|
3608 |
-
|
3609 |
-
$
|
3610 |
-
|
3611 |
-
|
3612 |
-
|
3613 |
-
|
3614 |
-
|
3615 |
-
|
3616 |
-
|
3617 |
-
|
3618 |
-
|
3619 |
-
|
3620 |
-
|
3621 |
-
|
3622 |
-
|
3623 |
-
|
3624 |
-
|
3625 |
-
|
3626 |
-
|
3627 |
-
|
3628 |
-
|
3629 |
-
|
3630 |
-
|
3631 |
-
|
3632 |
-
|
3633 |
-
|
3634 |
-
|
3635 |
-
|
3636 |
-
|
3637 |
-
|
3638 |
-
|
3639 |
-
|
3640 |
-
|
3641 |
-
|
3642 |
-
|
3643 |
-
|
3644 |
-
|
3645 |
-
|
3646 |
-
|
3647 |
-
|
3648 |
-
|
3649 |
-
|
3650 |
-
|
3651 |
-
|
3652 |
-
|
3653 |
-
|
3654 |
-
|
3655 |
-
|
3656 |
-
|
3657 |
-
|
3658 |
-
|
3659 |
-
|
3660 |
-
|
3661 |
-
|
3662 |
-
|
3663 |
-
|
3664 |
-
|
3665 |
-
|
3666 |
-
|
3667 |
-
|
3668 |
-
|
3669 |
-
|
3670 |
-
|
3671 |
-
|
3672 |
-
|
3673 |
-
|
3674 |
-
|
3675 |
-
|
3676 |
-
|
3677 |
-
|
3678 |
-
|
3679 |
-
|
3680 |
-
|
3681 |
-
|
3682 |
-
$q = "
|
3683 |
-
|
3684 |
-
|
3685 |
-
|
3686 |
-
|
3687 |
-
|
3688 |
-
|
3689 |
-
|
3690 |
-
|
3691 |
-
|
3692 |
-
|
3693 |
-
|
3694 |
-
|
3695 |
-
|
3696 |
-
|
3697 |
-
|
3698 |
-
|
3699 |
-
|
3700 |
-
|
3701 |
-
|
3702 |
-
|
3703 |
-
|
3704 |
-
|
3705 |
-
|
3706 |
-
|
3707 |
-
|
3708 |
-
|
3709 |
-
|
3710 |
-
|
3711 |
-
|
3712 |
-
|
3713 |
-
(
|
3714 |
-
|
3715 |
-
|
3716 |
-
|
3717 |
-
|
3718 |
-
|
3719 |
-
|
3720 |
-
|
3721 |
-
|
3722 |
-
|
3723 |
-
|
3724 |
-
|
3725 |
-
|
3726 |
-
|
3727 |
-
|
3728 |
-
|
3729 |
-
|
3730 |
-
|
3731 |
-
|
3732 |
-
|
3733 |
-
|
3734 |
-
|
3735 |
-
(
|
3736 |
-
|
3737 |
-
|
3738 |
-
|
3739 |
-
|
3740 |
-
|
3741 |
-
|
3742 |
-
|
3743 |
-
|
3744 |
-
|
3745 |
-
|
3746 |
-
|
3747 |
-
|
3748 |
-
|
3749 |
-
|
3750 |
-
|
3751 |
-
|
3752 |
-
|
3753 |
-
|
3754 |
-
|
3755 |
-
|
3756 |
-
|
3757 |
-
|
3758 |
-
|
3759 |
-
|
3760 |
-
|
3761 |
-
|
3762 |
-
|
3763 |
-
|
3764 |
-
|
3765 |
-
|
3766 |
-
|
3767 |
-
|
3768 |
-
|
3769 |
-
|
3770 |
-
|
3771 |
-
|
3772 |
-
|
3773 |
-
|
3774 |
-
|
3775 |
-
|
3776 |
-
|
3777 |
-
|
3778 |
-
|
3779 |
-
|
3780 |
-
|
3781 |
-
|
3782 |
-
|
3783 |
-
|
3784 |
-
|
3785 |
-
|
3786 |
-
|
3787 |
-
|
3788 |
-
|
3789 |
-
|
3790 |
-
|
3791 |
-
|
3792 |
-
|
3793 |
-
|
3794 |
-
|
3795 |
-
|
3796 |
-
|
3797 |
-
|
3798 |
-
|
3799 |
-
|
3800 |
-
|
3801 |
-
|
3802 |
-
|
3803 |
-
|
3804 |
-
|
3805 |
-
|
3806 |
-
|
3807 |
-
|
3808 |
-
|
3809 |
-
|
3810 |
-
|
3811 |
-
|
3812 |
-
|
3813 |
-
|
3814 |
-
|
3815 |
-
|
3816 |
-
|
3817 |
-
|
3818 |
-
|
3819 |
-
|
3820 |
-
|
3821 |
-
$this->
|
3822 |
-
|
3823 |
-
|
3824 |
-
|
3825 |
-
|
3826 |
-
|
3827 |
-
|
3828 |
-
|
3829 |
-
|
3830 |
-
|
3831 |
-
|
3832 |
-
|
3833 |
-
|
3834 |
-
|
3835 |
-
|
3836 |
-
|
3837 |
-
|
3838 |
-
|
3839 |
-
|
3840 |
-
|
3841 |
-
|
3842 |
-
|
3843 |
-
|
3844 |
-
|
3845 |
-
|
3846 |
-
|
3847 |
-
|
3848 |
-
|
3849 |
-
|
3850 |
-
|
3851 |
-
|
3852 |
-
|
3853 |
-
|
3854 |
-
|
3855 |
-
|
3856 |
-
|
3857 |
-
|
3858 |
-
|
3859 |
-
|
3860 |
-
;
|
3861 |
-
|
3862 |
-
|
3863 |
-
$this->
|
3864 |
-
|
3865 |
-
|
3866 |
-
|
3867 |
-
|
3868 |
-
|
3869 |
-
|
3870 |
-
|
3871 |
-
|
3872 |
-
|
3873 |
-
|
3874 |
-
|
3875 |
-
|
3876 |
-
|
3877 |
-
|
3878 |
-
|
3879 |
-
|
3880 |
-
|
3881 |
-
|
3882 |
-
|
3883 |
-
|
3884 |
-
|
3885 |
-
|
3886 |
-
|
3887 |
-
|
3888 |
-
|
3889 |
-
|
3890 |
-
|
3891 |
-
|
3892 |
-
|
3893 |
-
|
3894 |
-
|
3895 |
-
|
3896 |
-
|
3897 |
-
|
3898 |
-
|
3899 |
-
|
3900 |
-
|
3901 |
-
|
3902 |
-
|
3903 |
-
|
3904 |
-
|
3905 |
-
|
3906 |
-
|
3907 |
-
|
3908 |
-
|
3909 |
-
|
3910 |
-
|
3911 |
-
|
3912 |
-
|
3913 |
-
|
3914 |
-
|
3915 |
-
|
3916 |
-
|
3917 |
-
|
3918 |
-
|
3919 |
-
|
3920 |
-
|
3921 |
-
|
3922 |
-
|
3923 |
-
|
3924 |
-
|
3925 |
-
|
3926 |
-
|
3927 |
-
|
3928 |
-
|
3929 |
-
|
3930 |
-
|
3931 |
-
|
3932 |
-
|
3933 |
-
|
3934 |
-
|
3935 |
-
|
3936 |
-
|
3937 |
-
|
3938 |
-
|
3939 |
-
|
3940 |
-
|
3941 |
-
|
3942 |
-
|
3943 |
-
|
3944 |
-
|
3945 |
-
|
3946 |
-
|
3947 |
-
|
3948 |
-
|
3949 |
-
|
3950 |
-
|
3951 |
-
|
3952 |
-
|
3953 |
-
|
3954 |
-
|
3955 |
-
|
3956 |
-
|
3957 |
-
|
3958 |
-
|
3959 |
-
|
3960 |
-
|
3961 |
-
|
3962 |
-
|
3963 |
-
|
3964 |
-
|
3965 |
-
|
3966 |
-
|
3967 |
-
|
3968 |
-
|
3969 |
-
|
3970 |
-
|
3971 |
-
|
3972 |
-
|
3973 |
-
|
3974 |
-
|
3975 |
-
|
3976 |
-
|
3977 |
-
|
3978 |
-
|
3979 |
-
$this->db_do("
|
3980 |
-
|
3981 |
-
|
3982 |
-
|
3983 |
-
|
3984 |
-
|
3985 |
-
|
3986 |
-
|
3987 |
-
|
3988 |
-
|
3989 |
-
|
3990 |
-
|
3991 |
-
|
3992 |
-
|
3993 |
-
|
3994 |
-
|
3995 |
-
|
3996 |
-
|
3997 |
-
|
3998 |
-
|
3999 |
-
|
4000 |
-
|
4001 |
-
|
4002 |
-
|
4003 |
-
|
4004 |
-
|
4005 |
-
|
4006 |
-
$this->db_do("
|
4007 |
-
|
4008 |
-
|
4009 |
-
|
4010 |
-
|
4011 |
-
|
4012 |
-
|
4013 |
-
|
4014 |
-
|
4015 |
-
|
4016 |
-
|
4017 |
-
|
4018 |
-
|
4019 |
-
|
4020 |
-
|
4021 |
-
|
4022 |
-
|
4023 |
-
|
4024 |
-
|
4025 |
-
|
4026 |
-
|
4027 |
-
|
4028 |
-
|
4029 |
-
|
4030 |
-
|
4031 |
-
$this->
|
4032 |
-
|
4033 |
-
|
4034 |
-
|
4035 |
-
|
4036 |
-
|
4037 |
-
|
4038 |
-
|
4039 |
-
|
4040 |
-
|
4041 |
-
|
4042 |
-
|
4043 |
-
|
4044 |
-
|
4045 |
-
|
4046 |
-
|
4047 |
-
|
4048 |
-
|
4049 |
-
|
4050 |
-
|
4051 |
-
|
4052 |
-
|
4053 |
-
|
4054 |
-
|
4055 |
-
|
4056 |
-
|
4057 |
-
|
4058 |
-
|
4059 |
-
|
4060 |
-
|
4061 |
-
|
4062 |
-
|
4063 |
-
|
4064 |
-
|
4065 |
-
|
4066 |
-
|
4067 |
-
|
4068 |
-
|
4069 |
-
|
4070 |
-
|
4071 |
-
|
4072 |
-
|
4073 |
-
|
4074 |
-
|
4075 |
-
|
4076 |
-
|
4077 |
-
|
4078 |
-
|
4079 |
-
|
4080 |
-
|
4081 |
-
$this->db_do(
|
4082 |
-
|
4083 |
-
|
4084 |
-
|
4085 |
-
|
4086 |
-
|
4087 |
-
|
4088 |
-
|
4089 |
-
|
4090 |
-
|
4091 |
-
|
4092 |
-
|
4093 |
-
|
4094 |
-
|
4095 |
-
|
4096 |
-
|
4097 |
-
|
4098 |
-
|
4099 |
-
|
4100 |
-
|
4101 |
-
|
4102 |
-
|
4103 |
-
|
4104 |
-
|
4105 |
-
|
4106 |
-
|
4107 |
-
|
4108 |
-
|
4109 |
-
|
4110 |
-
|
4111 |
-
|
4112 |
-
|
4113 |
-
|
4114 |
-
|
4115 |
-
|
4116 |
-
|
4117 |
-
|
4118 |
-
|
4119 |
-
|
4120 |
-
|
4121 |
-
|
4122 |
-
|
4123 |
-
|
4124 |
-
|
4125 |
-
|
4126 |
-
|
4127 |
-
|
4128 |
-
|
4129 |
-
|
4130 |
-
|
4131 |
-
|
4132 |
-
|
4133 |
-
|
4134 |
-
|
4135 |
-
|
4136 |
-
|
4137 |
-
|
4138 |
-
|
4139 |
-
|
4140 |
-
|
4141 |
-
|
4142 |
-
|
4143 |
-
|
4144 |
-
|
4145 |
-
|
4146 |
-
|
4147 |
-
|
4148 |
-
|
4149 |
-
|
4150 |
-
|
4151 |
-
|
4152 |
-
|
4153 |
-
|
4154 |
-
|
4155 |
-
|
4156 |
-
|
4157 |
-
|
4158 |
-
|
4159 |
-
|
4160 |
-
|
4161 |
-
|
4162 |
-
|
4163 |
-
|
4164 |
-
|
4165 |
-
|
4166 |
-
|
4167 |
-
|
4168 |
-
|
4169 |
-
|
4170 |
-
|
4171 |
-
|
4172 |
-
|
4173 |
-
|
4174 |
-
|
4175 |
-
|
4176 |
-
|
4177 |
-
|
4178 |
-
|
4179 |
-
|
4180 |
-
|
4181 |
-
|
4182 |
-
|
4183 |
-
|
4184 |
-
|
4185 |
-
|
4186 |
-
|
4187 |
-
|
4188 |
-
|
4189 |
-
|
4190 |
-
|
4191 |
-
|
4192 |
-
|
4193 |
-
|
4194 |
-
|
4195 |
-
|
4196 |
-
|
4197 |
-
|
4198 |
-
|
4199 |
-
|
4200 |
-
|
4201 |
-
|
4202 |
-
|
4203 |
-
|
4204 |
-
|
4205 |
-
|
4206 |
-
|
4207 |
-
|
4208 |
-
|
4209 |
-
|
4210 |
-
|
4211 |
-
|
4212 |
-
|
4213 |
-
|
4214 |
-
|
4215 |
-
|
4216 |
-
|
4217 |
-
|
4218 |
-
|
4219 |
-
|
4220 |
-
|
4221 |
-
|
4222 |
-
|
4223 |
-
|
4224 |
-
|
4225 |
-
|
4226 |
-
|
4227 |
-
|
4228 |
-
|
4229 |
-
|
4230 |
-
|
4231 |
-
|
4232 |
-
|
4233 |
-
|
4234 |
-
|
4235 |
-
|
4236 |
-
|
4237 |
-
|
4238 |
-
|
4239 |
-
|
4240 |
-
|
4241 |
-
|
4242 |
-
|
4243 |
-
|
4244 |
-
|
4245 |
-
|
4246 |
-
|
4247 |
-
|
4248 |
-
$
|
4249 |
-
|
4250 |
-
|
4251 |
-
|
4252 |
-
|
4253 |
-
|
4254 |
-
|
4255 |
-
|
4256 |
-
|
4257 |
-
|
4258 |
-
|
4259 |
-
|
4260 |
-
|
4261 |
-
|
4262 |
-
|
4263 |
-
|
4264 |
-
|
4265 |
-
|
4266 |
-
|
4267 |
-
|
4268 |
-
|
4269 |
-
|
4270 |
-
|
4271 |
-
|
4272 |
-
|
4273 |
-
|
4274 |
-
|
4275 |
-
|
4276 |
-
|
4277 |
-
|
4278 |
-
|
4279 |
-
|
4280 |
-
|
4281 |
-
|
4282 |
-
|
4283 |
-
|
4284 |
-
$
|
4285 |
-
|
4286 |
-
|
4287 |
-
|
4288 |
-
|
4289 |
-
|
4290 |
-
|
4291 |
-
|
4292 |
-
|
4293 |
-
|
4294 |
-
|
4295 |
-
|
4296 |
-
|
4297 |
-
|
4298 |
-
|
4299 |
-
|
4300 |
-
|
4301 |
-
|
4302 |
-
|
4303 |
-
|
4304 |
-
|
4305 |
-
|
4306 |
-
|
4307 |
-
|
4308 |
-
|
4309 |
-
|
4310 |
-
|
4311 |
-
|
4312 |
-
|
4313 |
-
|
4314 |
-
|
4315 |
-
|
4316 |
-
|
4317 |
-
|
4318 |
-
|
4319 |
-
|
4320 |
-
|
4321 |
-
|
4322 |
-
|
4323 |
-
|
4324 |
-
|
4325 |
-
|
4326 |
-
|
4327 |
-
|
4328 |
-
|
4329 |
-
|
4330 |
-
|
4331 |
-
|
4332 |
-
|
4333 |
-
|
4334 |
-
|
4335 |
-
|
4336 |
-
|
4337 |
-
|
4338 |
-
|
4339 |
-
|
4340 |
-
|
4341 |
-
|
4342 |
-
|
4343 |
-
|
4344 |
-
|
4345 |
-
|
4346 |
-
|
4347 |
-
|
4348 |
-
|
4349 |
-
|
4350 |
-
|
4351 |
-
|
4352 |
-
|
4353 |
-
|
4354 |
-
|
4355 |
-
|
4356 |
-
|
4357 |
-
|
4358 |
-
|
4359 |
-
|
4360 |
-
|
4361 |
-
|
4362 |
-
|
4363 |
-
|
4364 |
-
|
4365 |
-
|
4366 |
-
|
4367 |
-
|
4368 |
-
|
4369 |
-
|
4370 |
-
|
4371 |
-
|
4372 |
-
|
4373 |
-
|
4374 |
-
|
4375 |
-
|
4376 |
-
|
4377 |
-
|
4378 |
-
|
4379 |
-
|
4380 |
-
|
4381 |
-
|
4382 |
-
|
4383 |
-
|
4384 |
-
|
4385 |
-
|
4386 |
-
|
4387 |
-
|
4388 |
-
|
4389 |
-
|
4390 |
-
|
4391 |
-
|
4392 |
-
|
4393 |
-
|
4394 |
-
|
4395 |
-
|
4396 |
-
|
4397 |
-
|
4398 |
-
|
4399 |
-
|
4400 |
-
|
4401 |
-
|
4402 |
-
|
4403 |
-
|
4404 |
-
|
4405 |
-
|
4406 |
-
|
4407 |
-
|
4408 |
-
|
4409 |
-
|
4410 |
-
|
4411 |
-
|
4412 |
-
|
4413 |
-
|
4414 |
-
|
4415 |
-
|
4416 |
-
|
4417 |
-
|
4418 |
-
|
4419 |
-
|
4420 |
-
|
4421 |
-
|
4422 |
-
|
4423 |
-
|
4424 |
-
|
4425 |
-
|
4426 |
-
|
4427 |
-
|
4428 |
-
|
4429 |
-
|
4430 |
-
|
4431 |
-
|
4432 |
-
|
4433 |
-
|
4434 |
-
|
4435 |
-
|
4436 |
-
|
4437 |
-
|
4438 |
-
|
4439 |
-
|
4440 |
-
|
4441 |
-
|
4442 |
-
|
4443 |
-
|
4444 |
-
|
4445 |
-
|
4446 |
-
|
4447 |
-
|
4448 |
-
|
4449 |
-
|
4450 |
-
|
4451 |
-
|
4452 |
-
|
4453 |
-
|
4454 |
-
|
4455 |
-
|
4456 |
-
|
4457 |
-
|
4458 |
-
|
4459 |
-
|
4460 |
-
|
4461 |
-
|
4462 |
-
|
4463 |
-
|
4464 |
-
|
4465 |
-
|
4466 |
-
|
4467 |
-
|
4468 |
-
|
4469 |
-
|
4470 |
-
|
4471 |
-
|
4472 |
-
|
4473 |
-
|
4474 |
-
|
4475 |
-
|
4476 |
-
|
4477 |
-
|
4478 |
-
|
4479 |
-
|
4480 |
-
|
4481 |
-
|
4482 |
-
|
4483 |
-
|
4484 |
-
|
4485 |
-
|
4486 |
-
|
4487 |
-
|
4488 |
-
|
4489 |
-
|
4490 |
-
|
4491 |
-
|
4492 |
-
|
4493 |
-
|
4494 |
-
|
4495 |
-
|
4496 |
-
|
4497 |
-
|
4498 |
-
|
4499 |
-
|
4500 |
-
|
4501 |
-
|
4502 |
-
|
4503 |
-
|
4504 |
-
|
4505 |
-
|
4506 |
-
|
4507 |
-
|
4508 |
-
|
4509 |
-
|
4510 |
-
|
4511 |
-
|
4512 |
-
|
4513 |
-
|
4514 |
-
|
4515 |
-
|
4516 |
-
|
4517 |
-
|
4518 |
-
|
4519 |
-
|
4520 |
-
|
4521 |
-
|
4522 |
-
|
4523 |
-
|
4524 |
-
|
4525 |
-
|
4526 |
-
|
4527 |
-
|
4528 |
-
|
4529 |
-
|
4530 |
-
|
4531 |
-
|
4532 |
-
|
4533 |
-
|
4534 |
-
|
4535 |
-
|
4536 |
-
|
4537 |
-
|
4538 |
-
|
4539 |
-
|
4540 |
-
|
4541 |
-
|
4542 |
-
|
4543 |
-
|
4544 |
-
|
4545 |
-
|
4546 |
-
|
4547 |
-
|
4548 |
-
|
4549 |
-
|
4550 |
-
|
4551 |
-
|
4552 |
-
|
4553 |
-
|
4554 |
-
|
4555 |
-
|
4556 |
-
|
4557 |
-
|
4558 |
-
|
4559 |
-
|
4560 |
-
|
4561 |
-
|
4562 |
-
|
4563 |
-
|
4564 |
-
|
4565 |
-
|
4566 |
-
|
4567 |
-
|
4568 |
-
|
4569 |
-
|
4570 |
-
|
4571 |
-
|
4572 |
-
|
4573 |
-
|
4574 |
-
|
4575 |
-
|
4576 |
-
|
4577 |
-
|
4578 |
-
|
4579 |
-
|
4580 |
-
|
4581 |
-
|
4582 |
-
|
4583 |
-
|
4584 |
-
|
4585 |
-
|
4586 |
-
|
4587 |
-
|
4588 |
-
|
4589 |
-
|
4590 |
-
|
4591 |
-
|
4592 |
-
|
4593 |
-
|
4594 |
-
|
4595 |
-
|
4596 |
-
|
4597 |
-
|
4598 |
-
|
4599 |
-
|
4600 |
-
|
4601 |
-
|
4602 |
-
|
4603 |
-
|
4604 |
-
|
4605 |
-
|
4606 |
-
|
4607 |
-
|
4608 |
-
|
4609 |
-
|
4610 |
-
|
4611 |
-
|
4612 |
-
|
4613 |
-
|
4614 |
-
|
4615 |
-
|
4616 |
-
|
4617 |
-
|
4618 |
-
|
4619 |
-
|
4620 |
-
|
4621 |
-
|
4622 |
-
|
4623 |
-
|
4624 |
-
|
4625 |
-
|
4626 |
-
|
4627 |
-
|
4628 |
-
|
4629 |
-
|
4630 |
-
|
4631 |
-
|
4632 |
-
|
4633 |
-
$this->
|
4634 |
-
$this->
|
4635 |
-
|
4636 |
-
|
4637 |
-
|
4638 |
-
|
4639 |
-
|
4640 |
-
|
4641 |
-
|
4642 |
-
$
|
4643 |
-
|
4644 |
-
|
4645 |
-
);
|
4646 |
-
|
4647 |
-
|
4648 |
-
|
4649 |
-
|
4650 |
-
|
4651 |
-
$
|
4652 |
-
|
4653 |
-
|
4654 |
-
|
4655 |
-
|
4656 |
-
|
4657 |
-
)(
|
4658 |
-
|
4659 |
-
|
4660 |
-
|
4661 |
-
|
4662 |
-
|
4663 |
-
|
4664 |
-
|
4665 |
-
|
4666 |
-
|
4667 |
-
|
4668 |
-
|
4669 |
-
|
4670 |
-
|
4671 |
-
|
4672 |
-
|
4673 |
-
|
4674 |
-
|
4675 |
-
|
4676 |
-
|
4677 |
-
|
4678 |
-
|
4679 |
-
|
4680 |
-
|
4681 |
-
|
4682 |
-
|
4683 |
-
|
4684 |
-
|
4685 |
-
|
4686 |
-
0,
|
4687 |
-
|
4688 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4689 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('
|
4690 |
-
ON a.store_product_id
|
4691 |
-
|
4692 |
-
|
4693 |
-
|
4694 |
-
|
4695 |
-
|
4696 |
-
|
4697 |
-
|
4698 |
-
|
4699 |
-
|
4700 |
-
|
4701 |
-
|
4702 |
-
|
4703 |
-
|
4704 |
-
|
4705 |
-
|
4706 |
-
|
4707 |
-
|
4708 |
-
|
4709 |
-
|
4710 |
-
|
4711 |
-
|
4712 |
-
|
4713 |
-
|
4714 |
-
|
4715 |
-
|
4716 |
-
|
4717 |
-
|
4718 |
-
|
4719 |
-
|
4720 |
-
|
4721 |
-
|
4722 |
-
|
4723 |
-
|
4724 |
-
|
4725 |
-
|
4726 |
-
|
4727 |
-
|
4728 |
-
|
4729 |
-
|
4730 |
-
|
4731 |
-
|
4732 |
-
|
4733 |
-
|
4734 |
-
|
4735 |
-
|
4736 |
-
|
4737 |
-
|
4738 |
-
|
4739 |
-
|
4740 |
-
|
4741 |
-
|
4742 |
-
|
4743 |
-
|
4744 |
-
|
4745 |
-
$
|
4746 |
-
|
4747 |
-
|
4748 |
-
|
4749 |
-
|
4750 |
-
|
4751 |
-
|
4752 |
-
|
4753 |
-
|
4754 |
-
|
4755 |
-
|
4756 |
-
|
4757 |
-
|
4758 |
-
|
4759 |
-
|
4760 |
-
|
4761 |
-
|
4762 |
-
|
4763 |
-
|
4764 |
-
|
4765 |
-
|
4766 |
-
|
4767 |
-
|
4768 |
-
)(
|
4769 |
-
|
4770 |
-
|
4771 |
-
|
4772 |
-
|
4773 |
-
|
4774 |
-
|
4775 |
-
|
4776 |
-
|
4777 |
-
|
4778 |
-
|
4779 |
-
|
4780 |
-
|
4781 |
-
|
4782 |
-
|
4783 |
-
)
|
4784 |
-
|
4785 |
-
|
4786 |
-
|
4787 |
-
|
4788 |
-
|
4789 |
-
|
4790 |
-
|
4791 |
-
|
4792 |
-
|
4793 |
-
|
4794 |
-
entity_id,
|
4795 |
-
|
4796 |
-
|
4797 |
-
|
4798 |
-
|
4799 |
-
|
4800 |
-
|
4801 |
-
|
4802 |
-
|
4803 |
-
|
4804 |
-
|
4805 |
-
|
4806 |
-
|
4807 |
-
|
4808 |
-
|
4809 |
-
|
4810 |
-
|
4811 |
-
|
4812 |
-
|
4813 |
-
|
4814 |
-
|
4815 |
-
|
4816 |
-
|
4817 |
-
|
4818 |
-
|
4819 |
-
|
4820 |
-
|
4821 |
-
|
4822 |
-
|
4823 |
-
|
4824 |
-
|
4825 |
-
|
4826 |
-
|
4827 |
-
|
4828 |
-
|
4829 |
-
|
4830 |
-
|
4831 |
-
|
4832 |
-
|
4833 |
-
|
4834 |
-
|
4835 |
-
|
4836 |
-
|
4837 |
-
|
4838 |
-
|
4839 |
-
|
4840 |
-
|
4841 |
-
|
4842 |
-
|
4843 |
-
|
4844 |
-
|
4845 |
-
|
4846 |
-
|
4847 |
-
|
4848 |
-
|
4849 |
-
|
4850 |
-
|
4851 |
-
|
4852 |
-
|
4853 |
-
|
4854 |
-
|
4855 |
-
|
4856 |
-
|
4857 |
-
|
4858 |
-
|
4859 |
-
|
4860 |
-
|
4861 |
-
|
4862 |
-
|
4863 |
-
|
4864 |
-
|
4865 |
-
|
4866 |
-
|
4867 |
-
|
4868 |
-
)
|
4869 |
-
ON DUPLICATE KEY UPDATE
|
4870 |
-
value=
|
4871 |
-
|
4872 |
-
|
4873 |
-
//
|
4874 |
-
$result = $this->db_do("
|
4875 |
-
|
4876 |
-
|
4877 |
-
|
4878 |
-
|
4879 |
-
|
4880 |
-
|
4881 |
-
|
4882 |
-
|
4883 |
-
|
4884 |
-
|
4885 |
-
|
4886 |
-
|
4887 |
-
|
4888 |
-
|
4889 |
-
|
4890 |
-
|
4891 |
-
|
4892 |
-
|
4893 |
-
|
4894 |
-
|
4895 |
-
|
4896 |
-
|
4897 |
-
|
4898 |
-
|
4899 |
-
|
4900 |
-
|
4901 |
-
|
4902 |
-
|
4903 |
-
|
4904 |
-
|
4905 |
-
|
4906 |
-
|
4907 |
-
|
4908 |
-
|
4909 |
-
|
4910 |
-
|
4911 |
-
|
4912 |
-
|
4913 |
-
|
4914 |
-
|
4915 |
-
|
4916 |
-
|
4917 |
-
|
4918 |
-
|
4919 |
-
|
4920 |
-
|
4921 |
-
|
4922 |
-
|
4923 |
-
|
4924 |
-
|
4925 |
-
|
4926 |
-
|
4927 |
-
|
4928 |
-
|
4929 |
-
|
4930 |
-
|
4931 |
-
|
4932 |
-
|
4933 |
-
|
4934 |
-
|
4935 |
-
|
4936 |
-
|
4937 |
-
|
4938 |
-
|
4939 |
-
|
4940 |
-
|
4941 |
-
|
4942 |
-
|
4943 |
-
|
4944 |
-
|
4945 |
-
|
4946 |
-
|
4947 |
-
|
4948 |
-
|
4949 |
-
|
4950 |
-
|
4951 |
-
|
4952 |
-
|
4953 |
-
|
4954 |
-
$result = $this->db_do("
|
4955 |
-
|
4956 |
-
|
4957 |
-
|
4958 |
-
|
4959 |
-
|
4960 |
-
|
4961 |
-
|
4962 |
-
|
4963 |
-
|
4964 |
-
|
4965 |
-
|
4966 |
-
|
4967 |
-
|
4968 |
-
|
4969 |
-
|
4970 |
-
|
4971 |
-
|
4972 |
-
JOIN "
|
4973 |
-
ON
|
4974 |
-
|
4975 |
-
|
4976 |
-
|
4977 |
-
|
4978 |
-
|
4979 |
-
|
4980 |
-
|
4981 |
-
|
4982 |
-
|
4983 |
-
|
4984 |
-
|
4985 |
-
(
|
4986 |
-
|
4987 |
-
|
4988 |
-
|
4989 |
-
|
4990 |
-
|
4991 |
-
|
4992 |
-
|
4993 |
-
|
4994 |
-
|
4995 |
-
|
4996 |
-
|
4997 |
-
|
4998 |
-
|
4999 |
-
|
5000 |
-
|
5001 |
-
|
5002 |
-
|
5003 |
-
|
5004 |
-
|
5005 |
-
|
5006 |
-
ON
|
5007 |
-
|
5008 |
-
|
5009 |
-
|
5010 |
-
|
5011 |
-
|
5012 |
-
|
5013 |
-
|
5014 |
-
|
5015 |
-
|
5016 |
-
|
5017 |
-
|
5018 |
-
|
5019 |
-
|
5020 |
-
|
5021 |
-
|
5022 |
-
|
5023 |
-
|
5024 |
-
|
5025 |
-
|
5026 |
-
|
5027 |
-
|
5028 |
-
|
5029 |
-
|
5030 |
-
|
5031 |
-
|
5032 |
-
|
5033 |
-
|
5034 |
-
|
5035 |
-
|
5036 |
-
|
5037 |
-
|
5038 |
-
|
5039 |
-
|
5040 |
-
|
5041 |
-
|
5042 |
-
|
5043 |
-
|
5044 |
-
|
5045 |
-
|
5046 |
-
|
5047 |
-
|
5048 |
-
|
5049 |
-
|
5050 |
-
|
5051 |
-
|
5052 |
-
|
5053 |
-
|
5054 |
-
|
5055 |
-
|
5056 |
-
|
5057 |
-
|
5058 |
-
|
5059 |
-
|
5060 |
-
|
5061 |
-
|
5062 |
-
|
5063 |
-
|
5064 |
-
|
5065 |
-
|
5066 |
-
|
5067 |
-
|
5068 |
-
|
5069 |
-
|
5070 |
-
|
5071 |
-
|
5072 |
-
|
5073 |
-
|
5074 |
-
|
5075 |
-
|
5076 |
-
|
5077 |
-
|
5078 |
-
|
5079 |
-
|
5080 |
-
|
5081 |
-
|
5082 |
-
|
5083 |
-
|
5084 |
-
|
5085 |
-
$
|
5086 |
-
|
5087 |
-
|
5088 |
-
|
5089 |
-
|
5090 |
-
|
5091 |
-
|
5092 |
-
|
5093 |
-
|
5094 |
-
|
5095 |
-
|
5096 |
-
|
5097 |
-
|
5098 |
-
|
5099 |
-
|
5100 |
-
|
5101 |
-
|
5102 |
-
|
5103 |
-
|
5104 |
-
|
5105 |
-
|
5106 |
-
|
5107 |
-
|
5108 |
-
|
5109 |
-
|
5110 |
-
|
5111 |
-
|
5112 |
-
|
5113 |
-
|
5114 |
-
|
5115 |
-
|
5116 |
-
|
5117 |
-
|
5118 |
-
|
5119 |
-
|
5120 |
-
|
5121 |
-
|
5122 |
-
|
5123 |
-
|
5124 |
-
|
5125 |
-
$this->
|
5126 |
-
|
5127 |
-
|
5128 |
-
|
5129 |
-
|
5130 |
-
|
5131 |
-
|
5132 |
-
|
5133 |
-
|
5134 |
-
|
5135 |
-
|
5136 |
-
|
5137 |
-
|
5138 |
-
|
5139 |
-
|
5140 |
-
|
5141 |
-
|
5142 |
-
|
5143 |
-
|
5144 |
-
|
5145 |
-
|
5146 |
-
|
5147 |
-
|
5148 |
-
|
5149 |
-
|
5150 |
-
|
5151 |
-
|
5152 |
-
|
5153 |
-
|
5154 |
-
|
5155 |
-
|
5156 |
-
|
5157 |
-
|
5158 |
-
|
5159 |
-
|
5160 |
-
|
5161 |
-
|
5162 |
-
|
5163 |
-
|
5164 |
-
|
5165 |
-
|
5166 |
-
|
5167 |
-
|
5168 |
-
|
5169 |
-
|
5170 |
-
|
5171 |
-
|
5172 |
-
|
5173 |
-
|
5174 |
-
|
5175 |
-
|
5176 |
-
|
5177 |
-
|
5178 |
-
|
5179 |
-
|
5180 |
-
|
5181 |
-
|
5182 |
-
|
5183 |
-
|
5184 |
-
|
5185 |
-
|
5186 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5187 |
-
|
5188 |
-
)
|
5189 |
-
ON DUPLICATE KEY UPDATE
|
5190 |
-
|
5191 |
-
");
|
5192 |
-
|
5193 |
-
|
5194 |
-
|
5195 |
-
|
5196 |
-
|
5197 |
-
|
5198 |
-
|
5199 |
-
|
5200 |
-
|
5201 |
-
|
5202 |
-
|
5203 |
-
" . $this->
|
5204 |
-
|
5205 |
-
|
5206 |
-
|
5207 |
-
|
5208 |
-
|
5209 |
-
|
5210 |
-
|
5211 |
-
|
5212 |
-
|
5213 |
-
|
5214 |
-
|
5215 |
-
|
5216 |
-
|
5217 |
-
|
5218 |
-
|
5219 |
-
|
5220 |
-
|
5221 |
-
|
5222 |
-
|
5223 |
-
|
5224 |
-
|
5225 |
-
|
5226 |
-
|
5227 |
-
|
5228 |
-
|
5229 |
-
|
5230 |
-
|
5231 |
-
|
5232 |
-
|
5233 |
-
|
5234 |
-
|
5235 |
-
|
5236 |
-
|
5237 |
-
|
5238 |
-
|
5239 |
-
|
5240 |
-
|
5241 |
-
|
5242 |
-
|
5243 |
-
|
5244 |
-
|
5245 |
-
|
5246 |
-
|
5247 |
-
|
5248 |
-
|
5249 |
-
|
5250 |
-
|
5251 |
-
|
5252 |
-
|
5253 |
-
" . $this->
|
5254 |
-
|
5255 |
-
|
5256 |
-
|
5257 |
-
|
5258 |
-
|
5259 |
-
|
5260 |
-
|
5261 |
-
|
5262 |
-
|
5263 |
-
|
5264 |
-
|
5265 |
-
|
5266 |
-
|
5267 |
-
|
5268 |
-
|
5269 |
-
|
5270 |
-
|
5271 |
-
|
5272 |
-
|
5273 |
-
|
5274 |
-
|
5275 |
-
|
5276 |
-
|
5277 |
-
|
5278 |
-
|
5279 |
-
)
|
5280 |
-
|
5281 |
-
|
5282 |
-
|
5283 |
-
|
5284 |
-
|
5285 |
-
|
5286 |
-
|
5287 |
-
|
5288 |
-
|
5289 |
-
|
5290 |
-
|
5291 |
-
|
5292 |
-
|
5293 |
-
|
5294 |
-
|
5295 |
-
|
5296 |
-
|
5297 |
-
|
5298 |
-
|
5299 |
-
|
5300 |
-
|
5301 |
-
|
5302 |
-
|
5303 |
-
|
5304 |
-
|
5305 |
-
|
5306 |
-
|
5307 |
-
|
5308 |
-
|
5309 |
-
|
5310 |
-
|
5311 |
-
|
5312 |
-
|
5313 |
-
|
5314 |
-
|
5315 |
-
|
5316 |
-
value
|
5317 |
-
|
5318 |
-
|
5319 |
-
|
5320 |
-
|
5321 |
-
|
5322 |
-
|
5323 |
-
|
5324 |
-
|
5325 |
-
|
5326 |
-
|
5327 |
-
|
5328 |
-
|
5329 |
-
|
5330 |
-
|
5331 |
-
|
5332 |
-
|
5333 |
-
|
5334 |
-
|
5335 |
-
|
5336 |
-
|
5337 |
-
|
5338 |
-
|
5339 |
-
|
5340 |
-
|
5341 |
-
|
5342 |
-
|
5343 |
-
|
5344 |
-
|
5345 |
-
|
5346 |
-
|
5347 |
-
|
5348 |
-
|
5349 |
-
|
5350 |
-
|
5351 |
-
|
5352 |
-
|
5353 |
-
|
5354 |
-
|
5355 |
-
|
5356 |
-
|
5357 |
-
|
5358 |
-
|
5359 |
-
|
5360 |
-
|
5361 |
-
|
5362 |
-
|
5363 |
-
|
5364 |
-
|
5365 |
-
|
5366 |
-
|
5367 |
-
|
5368 |
-
|
5369 |
-
|
5370 |
-
|
5371 |
-
|
5372 |
-
|
5373 |
-
|
5374 |
-
|
5375 |
-
|
5376 |
-
|
5377 |
-
|
5378 |
-
|
5379 |
-
|
5380 |
-
|
5381 |
-
|
5382 |
-
|
5383 |
-
|
5384 |
-
|
5385 |
-
|
5386 |
-
|
5387 |
-
|
5388 |
-
|
5389 |
-
|
5390 |
-
|
5391 |
-
|
5392 |
-
|
5393 |
-
|
5394 |
-
|
5395 |
-
|
5396 |
-
|
5397 |
-
|
5398 |
-
|
5399 |
-
|
5400 |
-
|
5401 |
-
|
5402 |
-
|
5403 |
-
|
5404 |
-
|
5405 |
-
|
5406 |
-
|
5407 |
-
|
5408 |
-
|
5409 |
-
|
5410 |
-
|
5411 |
-
|
5412 |
-
|
5413 |
-
|
5414 |
-
|
5415 |
-
|
5416 |
-
|
5417 |
-
|
5418 |
-
|
5419 |
-
|
5420 |
-
|
5421 |
-
|
5422 |
-
|
5423 |
-
|
5424 |
-
|
5425 |
-
|
5426 |
-
|
5427 |
-
|
5428 |
-
|
5429 |
-
|
5430 |
-
|
5431 |
-
|
5432 |
-
|
5433 |
-
|
5434 |
-
|
5435 |
-
|
5436 |
-
$
|
5437 |
-
|
5438 |
-
|
5439 |
-
|
5440 |
-
$
|
5441 |
-
|
5442 |
-
|
5443 |
-
|
5444 |
-
|
5445 |
-
|
5446 |
-
|
5447 |
-
|
5448 |
-
|
5449 |
-
|
5450 |
-
|
5451 |
-
|
5452 |
-
|
5453 |
-
|
5454 |
-
|
5455 |
-
|
5456 |
-
|
5457 |
-
|
5458 |
-
|
5459 |
-
|
5460 |
-
|
5461 |
-
|
5462 |
-
|
5463 |
-
|
5464 |
-
|
5465 |
-
|
5466 |
-
|
5467 |
-
|
5468 |
-
|
5469 |
-
|
5470 |
-
|
5471 |
-
|
5472 |
-
|
5473 |
-
|
5474 |
-
|
5475 |
-
|
5476 |
-
|
5477 |
-
|
5478 |
-
|
5479 |
-
|
5480 |
-
|
5481 |
-
|
5482 |
-
|
5483 |
-
|
5484 |
-
|
5485 |
-
|
5486 |
-
|
5487 |
-
|
5488 |
-
|
5489 |
-
ON a.
|
5490 |
-
|
5491 |
-
|
5492 |
-
|
5493 |
-
|
5494 |
-
|
5495 |
-
|
5496 |
-
|
5497 |
-
|
5498 |
-
|
5499 |
-
|
5500 |
-
|
5501 |
-
|
5502 |
-
|
5503 |
-
|
5504 |
-
$
|
5505 |
-
|
5506 |
-
|
5507 |
-
|
5508 |
-
|
5509 |
-
|
5510 |
-
|
5511 |
-
|
5512 |
-
|
5513 |
-
|
5514 |
-
|
5515 |
-
|
5516 |
-
|
5517 |
-
|
5518 |
-
|
5519 |
-
|
5520 |
-
|
5521 |
-
|
5522 |
-
|
5523 |
-
|
5524 |
-
|
5525 |
-
|
5526 |
-
|
5527 |
-
|
5528 |
-
|
5529 |
-
|
5530 |
-
|
5531 |
-
|
5532 |
-
|
5533 |
-
|
5534 |
-
|
5535 |
-
|
5536 |
-
|
5537 |
-
|
5538 |
-
|
5539 |
-
|
5540 |
-
|
5541 |
-
|
5542 |
-
|
5543 |
-
|
5544 |
-
|
5545 |
-
|
5546 |
-
|
5547 |
-
|
5548 |
-
|
5549 |
-
|
5550 |
-
|
5551 |
-
|
5552 |
-
|
5553 |
-
|
5554 |
-
|
5555 |
-
|
5556 |
-
|
5557 |
-
|
5558 |
-
|
5559 |
-
|
5560 |
-
|
5561 |
-
|
5562 |
-
|
5563 |
-
|
5564 |
-
|
5565 |
-
|
5566 |
-
|
5567 |
-
|
5568 |
-
|
5569 |
-
|
5570 |
-
|
5571 |
-
|
5572 |
-
|
5573 |
-
|
5574 |
-
|
5575 |
-
|
5576 |
-
|
5577 |
-
|
5578 |
-
|
5579 |
-
|
5580 |
-
|
5581 |
-
|
5582 |
-
|
5583 |
-
$
|
5584 |
-
|
5585 |
-
|
5586 |
-
|
5587 |
-
//
|
5588 |
-
|
5589 |
-
|
5590 |
-
|
5591 |
-
|
5592 |
-
|
5593 |
-
|
5594 |
-
|
5595 |
-
|
5596 |
-
|
5597 |
-
|
5598 |
-
|
5599 |
-
|
5600 |
-
|
5601 |
-
|
5602 |
-
|
5603 |
-
|
5604 |
-
|
5605 |
-
|
5606 |
-
|
5607 |
-
|
5608 |
-
|
5609 |
-
|
5610 |
-
|
5611 |
-
|
5612 |
-
|
5613 |
-
|
5614 |
-
|
5615 |
-
|
5616 |
-
|
5617 |
-
|
5618 |
-
|
5619 |
-
|
5620 |
-
|
5621 |
-
|
5622 |
-
|
5623 |
-
|
5624 |
-
|
5625 |
-
|
5626 |
-
|
5627 |
-
|
5628 |
-
|
5629 |
-
|
5630 |
-
|
5631 |
-
|
5632 |
-
|
5633 |
-
|
5634 |
-
|
5635 |
-
|
5636 |
-
|
5637 |
-
|
5638 |
-
|
5639 |
-
|
5640 |
-
|
5641 |
-
|
5642 |
-
|
5643 |
-
|
5644 |
-
|
5645 |
-
|
5646 |
-
|
5647 |
-
|
5648 |
-
|
5649 |
-
|
5650 |
-
|
5651 |
-
|
5652 |
-
|
5653 |
-
|
5654 |
-
|
5655 |
-
|
5656 |
-
|
5657 |
-
|
5658 |
-
|
5659 |
-
|
5660 |
-
|
5661 |
-
|
5662 |
-
|
5663 |
-
|
5664 |
-
|
5665 |
-
|
5666 |
-
|
5667 |
-
|
5668 |
-
|
5669 |
-
|
5670 |
-
|
5671 |
-
|
5672 |
-
|
5673 |
-
|
5674 |
-
|
5675 |
-
|
5676 |
-
|
5677 |
-
|
5678 |
-
|
5679 |
-
|
5680 |
-
|
5681 |
-
|
5682 |
-
|
5683 |
-
|
5684 |
-
|
5685 |
-
|
5686 |
-
|
5687 |
-
|
5688 |
-
|
5689 |
-
|
5690 |
-
|
5691 |
-
|
5692 |
-
|
5693 |
-
|
5694 |
-
|
5695 |
-
|
5696 |
-
|
5697 |
-
|
5698 |
-
|
5699 |
-
|
5700 |
-
|
5701 |
-
|
5702 |
-
|
5703 |
-
|
5704 |
-
|
5705 |
-
|
5706 |
-
|
5707 |
-
|
5708 |
-
|
5709 |
-
|
5710 |
-
|
5711 |
-
|
5712 |
-
|
5713 |
-
|
5714 |
-
|
5715 |
-
|
5716 |
-
|
5717 |
-
|
5718 |
-
|
5719 |
-
|
5720 |
-
|
5721 |
-
|
5722 |
-
|
5723 |
-
|
5724 |
-
|
5725 |
-
|
5726 |
-
|
5727 |
-
|
5728 |
-
|
5729 |
-
|
5730 |
-
|
5731 |
-
|
5732 |
-
|
5733 |
-
|
5734 |
-
|
5735 |
-
|
5736 |
-
|
5737 |
-
|
5738 |
-
|
5739 |
-
|
5740 |
-
|
5741 |
-
|
5742 |
-
|
5743 |
-
|
5744 |
-
|
5745 |
-
|
5746 |
-
|
5747 |
-
|
5748 |
-
|
5749 |
-
|
5750 |
-
|
5751 |
-
|
5752 |
-
|
5753 |
-
|
5754 |
-
|
5755 |
-
|
5756 |
-
|
5757 |
-
|
5758 |
-
|
5759 |
-
|
5760 |
-
|
5761 |
-
|
5762 |
-
|
5763 |
-
|
5764 |
-
|
5765 |
-
|
5766 |
-
|
5767 |
-
|
5768 |
-
|
5769 |
-
|
5770 |
-
|
5771 |
-
|
5772 |
-
|
5773 |
-
|
5774 |
-
|
5775 |
-
|
5776 |
-
|
5777 |
-
|
5778 |
-
|
5779 |
-
|
5780 |
-
|
5781 |
-
|
5782 |
-
|
5783 |
-
|
5784 |
-
|
5785 |
-
|
5786 |
-
|
5787 |
-
|
5788 |
-
|
5789 |
-
|
5790 |
-
|
5791 |
-
|
5792 |
-
|
5793 |
-
|
5794 |
-
|
5795 |
-
|
5796 |
-
|
5797 |
-
|
5798 |
-
|
5799 |
-
|
5800 |
-
|
5801 |
-
|
5802 |
-
|
5803 |
-
|
5804 |
-
|
5805 |
-
|
5806 |
-
|
5807 |
-
|
5808 |
-
|
5809 |
-
|
5810 |
-
|
5811 |
-
|
5812 |
-
|
5813 |
-
|
5814 |
-
$
|
5815 |
-
|
5816 |
-
|
5817 |
-
|
5818 |
-
|
5819 |
-
|
5820 |
-
|
5821 |
-
|
5822 |
-
|
5823 |
-
|
5824 |
-
|
5825 |
-
|
5826 |
-
|
5827 |
-
|
5828 |
-
|
5829 |
-
|
5830 |
-
|
5831 |
-
|
5832 |
-
|
5833 |
-
|
5834 |
-
|
5835 |
-
|
5836 |
-
|
5837 |
-
|
5838 |
-
|
5839 |
-
|
5840 |
-
|
5841 |
-
|
5842 |
-
|
5843 |
-
|
5844 |
-
|
5845 |
-
|
5846 |
-
|
5847 |
-
|
5848 |
-
|
5849 |
-
|
5850 |
-
|
5851 |
-
|
5852 |
-
|
5853 |
-
|
5854 |
-
|
5855 |
-
|
5856 |
-
|
5857 |
-
|
5858 |
-
|
5859 |
-
|
5860 |
-
|
5861 |
-
|
5862 |
-
|
5863 |
-
|
5864 |
-
|
5865 |
-
|
5866 |
-
|
5867 |
-
|
5868 |
-
|
5869 |
-
|
5870 |
-
|
5871 |
-
|
5872 |
-
|
5873 |
-
|
5874 |
-
|
5875 |
-
|
5876 |
-
|
5877 |
-
|
5878 |
-
|
5879 |
-
|
5880 |
-
|
5881 |
-
|
5882 |
-
|
5883 |
-
|
5884 |
-
|
5885 |
-
|
5886 |
-
|
5887 |
-
|
5888 |
-
|
5889 |
-
|
5890 |
-
|
5891 |
-
|
5892 |
-
|
5893 |
-
|
5894 |
-
|
5895 |
-
|
5896 |
-
|
5897 |
-
|
5898 |
-
|
5899 |
-
|
5900 |
-
|
5901 |
-
|
5902 |
-
|
5903 |
-
|
5904 |
-
|
5905 |
-
|
5906 |
-
|
5907 |
-
|
5908 |
-
|
5909 |
-
|
5910 |
-
|
5911 |
-
|
5912 |
-
|
5913 |
-
|
5914 |
-
|
5915 |
-
|
5916 |
-
|
5917 |
-
|
5918 |
-
|
5919 |
-
|
5920 |
-
|
5921 |
-
|
5922 |
-
|
5923 |
-
|
5924 |
-
|
5925 |
-
|
5926 |
-
|
5927 |
-
|
5928 |
-
|
5929 |
-
|
5930 |
-
|
5931 |
-
|
5932 |
-
|
5933 |
-
|
5934 |
-
|
5935 |
-
|
5936 |
-
|
5937 |
-
|
5938 |
-
|
5939 |
-
|
5940 |
-
|
5941 |
-
|
5942 |
-
|
5943 |
-
|
5944 |
-
|
5945 |
-
|
5946 |
-
|
5947 |
-
|
5948 |
-
|
5949 |
-
|
5950 |
-
|
5951 |
-
|
5952 |
-
|
5953 |
-
|
5954 |
-
|
5955 |
-
|
5956 |
-
|
5957 |
-
|
5958 |
-
|
5959 |
-
|
5960 |
-
|
5961 |
-
|
5962 |
-
|
5963 |
-
|
5964 |
-
|
5965 |
-
|
5966 |
-
|
5967 |
-
|
5968 |
-
|
5969 |
-
|
5970 |
-
|
5971 |
-
|
5972 |
-
|
5973 |
-
|
5974 |
-
|
5975 |
-
|
5976 |
-
|
5977 |
-
|
5978 |
-
|
5979 |
-
|
5980 |
-
|
5981 |
-
|
5982 |
-
|
5983 |
-
|
5984 |
-
|
5985 |
-
|
5986 |
-
|
5987 |
-
|
5988 |
-
|
5989 |
-
|
5990 |
-
|
5991 |
-
|
5992 |
-
|
5993 |
-
|
5994 |
-
|
5995 |
-
|
5996 |
-
|
5997 |
-
|
5998 |
-
|
5999 |
-
|
6000 |
-
|
6001 |
-
|
6002 |
-
|
6003 |
-
|
6004 |
-
|
6005 |
-
|
6006 |
-
|
6007 |
-
|
6008 |
-
|
6009 |
-
|
6010 |
-
|
6011 |
-
|
6012 |
-
|
6013 |
-
|
6014 |
-
|
6015 |
-
|
6016 |
-
|
6017 |
-
|
6018 |
-
|
6019 |
-
|
6020 |
-
|
6021 |
-
|
6022 |
-
|
6023 |
-
|
6024 |
-
|
6025 |
-
|
6026 |
-
|
6027 |
-
|
6028 |
-
|
6029 |
-
|
6030 |
-
|
6031 |
-
|
6032 |
-
|
6033 |
-
|
6034 |
-
|
6035 |
-
|
6036 |
-
$this->db_do("
|
6037 |
-
|
6038 |
-
|
6039 |
-
|
6040 |
-
|
6041 |
-
|
6042 |
-
|
6043 |
-
|
6044 |
-
|
6045 |
-
|
6046 |
-
|
6047 |
-
|
6048 |
-
|
6049 |
-
|
6050 |
-
|
6051 |
-
|
6052 |
-
|
6053 |
-
|
6054 |
-
|
6055 |
-
|
6056 |
-
|
6057 |
-
|
6058 |
-
|
6059 |
-
|
6060 |
-
|
6061 |
-
|
6062 |
-
|
6063 |
-
|
6064 |
-
|
6065 |
-
|
6066 |
-
|
6067 |
-
|
6068 |
-
|
6069 |
-
|
6070 |
-
|
6071 |
-
|
6072 |
-
|
6073 |
-
|
6074 |
-
|
6075 |
-
|
6076 |
-
|
6077 |
-
|
6078 |
-
|
6079 |
-
|
6080 |
-
|
6081 |
-
|
6082 |
-
|
6083 |
-
|
6084 |
-
|
6085 |
-
|
6086 |
-
|
6087 |
-
|
6088 |
-
|
6089 |
-
|
6090 |
-
|
6091 |
-
|
6092 |
-
|
6093 |
-
|
6094 |
-
|
6095 |
-
|
6096 |
-
|
6097 |
-
|
6098 |
-
|
6099 |
-
|
6100 |
-
|
6101 |
-
|
6102 |
-
|
6103 |
-
|
6104 |
-
|
6105 |
-
|
6106 |
-
|
6107 |
-
|
6108 |
-
|
6109 |
-
|
6110 |
-
|
6111 |
-
|
6112 |
-
|
6113 |
-
|
6114 |
-
|
6115 |
-
|
6116 |
-
|
6117 |
-
|
6118 |
-
|
6119 |
-
|
6120 |
-
|
6121 |
-
|
6122 |
-
|
6123 |
-
|
6124 |
-
|
6125 |
-
|
6126 |
-
|
6127 |
-
|
6128 |
-
|
6129 |
-
|
6130 |
-
|
6131 |
-
|
6132 |
-
|
6133 |
-
|
6134 |
-
|
6135 |
-
|
6136 |
-
|
6137 |
-
|
6138 |
-
|
6139 |
-
|
6140 |
-
|
6141 |
-
|
6142 |
-
|
6143 |
-
|
6144 |
-
|
6145 |
-
|
6146 |
-
|
6147 |
-
|
6148 |
-
|
6149 |
-
|
6150 |
-
|
6151 |
-
|
6152 |
-
|
6153 |
-
|
6154 |
-
|
6155 |
-
|
6156 |
-
|
6157 |
-
|
6158 |
-
|
6159 |
-
|
6160 |
-
|
6161 |
-
|
6162 |
-
|
6163 |
-
|
6164 |
-
|
6165 |
-
|
6166 |
-
|
6167 |
-
|
6168 |
-
|
6169 |
-
|
6170 |
-
|
6171 |
-
|
6172 |
-
|
6173 |
-
|
6174 |
-
|
6175 |
-
|
6176 |
-
|
6177 |
-
|
6178 |
-
|
6179 |
-
|
6180 |
-
|
6181 |
-
$
|
6182 |
-
|
6183 |
-
|
6184 |
-
|
6185 |
-
|
6186 |
-
|
6187 |
-
|
6188 |
-
|
6189 |
-
|
6190 |
-
|
6191 |
-
|
6192 |
-
|
6193 |
-
|
6194 |
-
|
6195 |
-
|
6196 |
-
|
6197 |
-
|
6198 |
-
|
6199 |
-
|
6200 |
-
|
6201 |
-
|
6202 |
-
|
6203 |
-
|
6204 |
-
|
6205 |
-
|
6206 |
-
|
6207 |
-
|
6208 |
-
|
6209 |
-
|
6210 |
-
|
6211 |
-
|
6212 |
-
|
6213 |
-
|
6214 |
-
|
6215 |
-
|
6216 |
-
|
6217 |
-
|
6218 |
-
|
6219 |
-
|
6220 |
-
|
6221 |
-
|
6222 |
-
|
6223 |
-
|
6224 |
-
|
6225 |
-
|
6226 |
-
|
6227 |
-
|
6228 |
-
|
6229 |
-
|
6230 |
-
|
6231 |
-
|
6232 |
-
|
6233 |
-
|
6234 |
-
|
6235 |
-
|
6236 |
-
|
6237 |
-
|
6238 |
-
|
6239 |
-
|
6240 |
-
|
6241 |
-
|
6242 |
-
|
6243 |
-
|
6244 |
-
|
6245 |
-
|
6246 |
-
|
6247 |
-
|
6248 |
-
|
6249 |
-
|
6250 |
-
|
6251 |
-
|
6252 |
-
|
6253 |
-
|
6254 |
-
|
6255 |
-
|
6256 |
-
|
6257 |
-
|
6258 |
-
|
6259 |
-
|
6260 |
-
|
6261 |
-
|
6262 |
-
|
6263 |
-
|
6264 |
-
|
6265 |
-
|
6266 |
-
|
6267 |
-
|
6268 |
-
|
6269 |
-
|
6270 |
-
|
6271 |
-
|
6272 |
-
|
6273 |
-
|
6274 |
-
|
6275 |
-
|
6276 |
-
|
6277 |
-
|
6278 |
-
|
6279 |
-
|
6280 |
-
|
6281 |
-
|
6282 |
-
|
6283 |
-
|
6284 |
-
|
6285 |
-
|
6286 |
-
|
6287 |
-
|
6288 |
-
|
6289 |
-
|
6290 |
-
|
6291 |
-
|
6292 |
-
|
6293 |
-
|
6294 |
-
|
6295 |
-
|
6296 |
-
|
6297 |
-
|
6298 |
-
|
6299 |
-
|
6300 |
-
|
6301 |
-
|
6302 |
-
|
6303 |
-
|
6304 |
-
|
6305 |
-
|
6306 |
-
|
6307 |
-
|
6308 |
-
|
6309 |
-
|
6310 |
-
|
6311 |
-
|
6312 |
-
|
6313 |
-
|
6314 |
-
|
6315 |
-
|
6316 |
-
|
6317 |
-
|
6318 |
-
|
6319 |
-
|
6320 |
-
|
6321 |
-
|
6322 |
-
|
6323 |
-
|
6324 |
-
|
6325 |
-
|
6326 |
-
|
6327 |
-
|
6328 |
-
|
6329 |
-
|
6330 |
-
|
6331 |
-
|
6332 |
-
|
6333 |
-
|
6334 |
-
|
6335 |
-
|
6336 |
-
|
6337 |
-
|
6338 |
-
|
6339 |
-
|
6340 |
-
|
6341 |
-
|
6342 |
-
|
6343 |
-
|
6344 |
-
|
6345 |
-
|
6346 |
-
|
6347 |
-
|
6348 |
-
|
6349 |
-
|
6350 |
-
|
6351 |
-
|
6352 |
-
|
6353 |
-
|
6354 |
-
|
6355 |
-
|
6356 |
-
|
6357 |
-
|
6358 |
-
|
6359 |
-
|
6360 |
-
|
6361 |
-
|
6362 |
-
|
6363 |
-
|
6364 |
-
|
6365 |
-
|
6366 |
-
|
6367 |
-
|
6368 |
-
|
6369 |
-
|
6370 |
-
|
6371 |
-
|
6372 |
-
|
6373 |
-
|
6374 |
-
$
|
6375 |
-
|
6376 |
-
|
6377 |
-
|
6378 |
-
|
6379 |
-
|
6380 |
-
|
6381 |
-
|
6382 |
-
|
6383 |
-
|
6384 |
-
|
6385 |
-
|
6386 |
-
|
6387 |
-
|
6388 |
-
|
6389 |
-
|
6390 |
-
|
6391 |
-
|
6392 |
-
|
6393 |
-
|
6394 |
-
$
|
6395 |
-
|
6396 |
-
|
6397 |
-
|
6398 |
-
|
6399 |
-
|
6400 |
-
|
6401 |
-
|
6402 |
-
|
6403 |
-
|
6404 |
-
|
6405 |
-
|
6406 |
-
|
6407 |
-
|
6408 |
-
|
6409 |
-
|
6410 |
-
|
6411 |
-
|
6412 |
-
|
6413 |
-
|
6414 |
-
|
6415 |
-
|
6416 |
-
|
6417 |
-
|
6418 |
-
|
6419 |
-
|
6420 |
-
|
6421 |
-
|
6422 |
-
|
6423 |
-
|
6424 |
-
|
6425 |
-
|
6426 |
-
|
6427 |
-
|
6428 |
-
|
6429 |
-
|
6430 |
-
|
6431 |
-
|
6432 |
-
|
6433 |
-
|
6434 |
-
|
6435 |
-
|
6436 |
-
|
6437 |
-
|
6438 |
-
|
6439 |
-
|
6440 |
-
|
6441 |
-
|
6442 |
-
|
6443 |
-
|
6444 |
-
|
6445 |
-
|
6446 |
-
|
6447 |
-
|
6448 |
-
|
6449 |
-
|
6450 |
-
|
6451 |
-
|
6452 |
-
|
6453 |
-
|
6454 |
-
|
6455 |
-
|
6456 |
-
|
6457 |
-
|
6458 |
-
|
6459 |
-
|
6460 |
-
|
6461 |
-
|
6462 |
-
|
6463 |
-
|
6464 |
-
|
6465 |
-
|
6466 |
-
|
6467 |
-
|
6468 |
-
|
6469 |
-
|
6470 |
-
|
6471 |
-
|
6472 |
-
|
6473 |
-
|
6474 |
-
|
6475 |
-
|
6476 |
-
|
6477 |
-
|
6478 |
-
|
6479 |
-
|
6480 |
-
|
6481 |
-
|
6482 |
-
|
6483 |
-
|
6484 |
-
|
6485 |
-
|
6486 |
-
|
6487 |
-
|
6488 |
-
|
6489 |
-
|
6490 |
-
|
6491 |
-
|
6492 |
-
|
6493 |
-
|
6494 |
-
value
|
6495 |
-
|
6496 |
-
|
6497 |
-
|
6498 |
-
|
6499 |
-
|
6500 |
-
|
6501 |
-
|
6502 |
-
|
6503 |
-
|
6504 |
-
|
6505 |
-
$
|
6506 |
-
|
6507 |
-
|
6508 |
-
|
6509 |
-
|
6510 |
-
|
6511 |
-
|
6512 |
-
|
6513 |
-
|
6514 |
-
|
6515 |
-
|
6516 |
-
|
6517 |
-
|
6518 |
-
|
6519 |
-
|
6520 |
-
|
6521 |
-
|
6522 |
-
|
6523 |
-
|
6524 |
-
|
6525 |
-
|
6526 |
-
|
6527 |
-
|
6528 |
-
|
6529 |
-
|
6530 |
-
|
6531 |
-
|
6532 |
-
|
6533 |
-
|
6534 |
-
|
6535 |
-
|
6536 |
-
|
6537 |
-
|
6538 |
-
|
6539 |
-
|
6540 |
-
|
6541 |
-
|
6542 |
-
|
6543 |
-
|
6544 |
-
|
6545 |
-
|
6546 |
-
|
6547 |
-
|
6548 |
-
|
6549 |
-
|
6550 |
-
|
6551 |
-
|
6552 |
-
$result = $this->db_do("
|
6553 |
-
|
6554 |
-
|
6555 |
-
|
6556 |
-
|
6557 |
-
|
6558 |
-
|
6559 |
-
|
6560 |
-
|
6561 |
-
|
6562 |
-
|
6563 |
-
|
6564 |
-
|
6565 |
-
|
6566 |
-
|
6567 |
-
|
6568 |
-
|
6569 |
-
|
6570 |
-
|
6571 |
-
|
6572 |
-
|
6573 |
-
|
6574 |
-
|
6575 |
-
|
6576 |
-
|
6577 |
-
|
6578 |
-
|
6579 |
-
|
6580 |
-
$
|
6581 |
-
|
6582 |
-
|
6583 |
-
$
|
6584 |
-
$
|
6585 |
-
|
6586 |
-
|
6587 |
-
|
6588 |
-
|
6589 |
-
|
6590 |
-
|
6591 |
-
|
6592 |
-
|
6593 |
-
|
6594 |
-
|
6595 |
-
|
6596 |
-
|
6597 |
-
|
6598 |
-
|
6599 |
-
|
6600 |
-
|
6601 |
-
$
|
6602 |
-
|
6603 |
-
|
6604 |
-
|
6605 |
-
|
6606 |
-
|
6607 |
-
|
6608 |
-
|
6609 |
-
|
6610 |
-
|
6611 |
-
|
6612 |
-
|
6613 |
-
|
6614 |
-
|
6615 |
-
$
|
6616 |
-
|
6617 |
-
|
6618 |
-
|
6619 |
-
|
6620 |
-
WHERE
|
6621 |
-
|
6622 |
-
|
6623 |
-
|
6624 |
-
|
6625 |
-
|
6626 |
-
|
6627 |
-
|
6628 |
-
|
6629 |
-
|
6630 |
-
|
6631 |
-
|
6632 |
-
|
6633 |
-
|
6634 |
-
|
6635 |
-
|
6636 |
-
|
6637 |
-
|
6638 |
-
|
6639 |
-
|
6640 |
-
|
6641 |
-
|
6642 |
-
|
6643 |
-
|
6644 |
-
|
6645 |
-
|
6646 |
-
|
6647 |
-
|
6648 |
-
|
6649 |
-
|
6650 |
-
|
6651 |
-
|
6652 |
-
|
6653 |
-
|
6654 |
-
|
6655 |
-
|
6656 |
-
|
6657 |
-
|
6658 |
-
|
6659 |
-
|
6660 |
-
|
6661 |
-
|
6662 |
-
|
6663 |
-
|
6664 |
-
|
6665 |
-
|
6666 |
-
|
6667 |
-
|
6668 |
-
|
6669 |
-
|
6670 |
-
|
6671 |
-
|
6672 |
-
|
6673 |
-
|
6674 |
-
|
6675 |
-
|
6676 |
-
|
6677 |
-
|
6678 |
-
|
6679 |
-
|
6680 |
-
|
6681 |
-
|
6682 |
-
|
6683 |
-
|
6684 |
-
|
6685 |
-
|
6686 |
-
|
6687 |
-
|
6688 |
-
|
6689 |
-
|
6690 |
-
|
6691 |
-
|
6692 |
-
|
6693 |
-
|
6694 |
-
|
6695 |
-
|
6696 |
-
|
6697 |
-
|
6698 |
-
|
6699 |
-
|
6700 |
-
|
6701 |
-
|
6702 |
-
|
6703 |
-
|
6704 |
-
|
6705 |
-
|
6706 |
-
|
6707 |
-
|
6708 |
-
|
6709 |
-
|
6710 |
-
|
6711 |
-
|
6712 |
-
|
6713 |
-
|
6714 |
-
|
6715 |
-
|
6716 |
-
|
6717 |
-
|
6718 |
-
|
6719 |
-
|
6720 |
-
|
6721 |
-
|
6722 |
-
|
6723 |
-
|
6724 |
-
|
6725 |
-
|
6726 |
-
|
6727 |
-
|
6728 |
-
|
6729 |
-
|
6730 |
-
|
6731 |
-
|
6732 |
-
|
6733 |
-
|
6734 |
-
|
6735 |
-
|
6736 |
-
|
6737 |
-
|
6738 |
-
|
6739 |
-
|
6740 |
-
|
6741 |
-
|
6742 |
-
|
6743 |
-
|
6744 |
-
|
6745 |
-
|
6746 |
-
|
6747 |
-
|
6748 |
-
|
6749 |
-
|
6750 |
-
|
6751 |
-
|
6752 |
-
|
6753 |
-
|
6754 |
-
|
6755 |
-
|
6756 |
-
|
6757 |
-
|
6758 |
-
|
6759 |
-
|
6760 |
-
|
6761 |
-
|
6762 |
-
|
6763 |
-
|
6764 |
-
|
6765 |
-
|
6766 |
-
|
6767 |
-
|
6768 |
-
|
6769 |
-
|
6770 |
-
|
6771 |
-
|
6772 |
-
$result = $this->db_do("
|
6773 |
-
|
6774 |
-
|
6775 |
-
|
6776 |
-
|
6777 |
-
|
6778 |
-
|
6779 |
-
|
6780 |
-
|
6781 |
-
|
6782 |
-
|
6783 |
-
|
6784 |
-
|
6785 |
-
|
6786 |
-
|
6787 |
-
|
6788 |
-
|
6789 |
-
|
6790 |
-
|
6791 |
-
$
|
6792 |
-
|
6793 |
-
|
6794 |
-
|
6795 |
-
|
6796 |
-
|
6797 |
-
$
|
6798 |
-
$
|
6799 |
-
|
6800 |
-
$
|
6801 |
-
|
6802 |
-
|
6803 |
-
|
6804 |
-
|
6805 |
-
|
6806 |
-
|
6807 |
-
|
6808 |
-
|
6809 |
-
|
6810 |
-
|
6811 |
-
|
6812 |
-
|
6813 |
-
|
6814 |
-
|
6815 |
-
|
6816 |
-
|
6817 |
-
|
6818 |
-
|
6819 |
-
|
6820 |
-
|
6821 |
-
|
6822 |
-
|
6823 |
-
|
6824 |
-
|
6825 |
-
|
6826 |
-
|
6827 |
-
|
6828 |
-
|
6829 |
-
|
6830 |
-
|
6831 |
-
|
6832 |
-
|
6833 |
-
|
6834 |
-
|
6835 |
-
|
6836 |
-
|
6837 |
-
|
6838 |
-
|
6839 |
-
|
6840 |
-
|
6841 |
-
|
6842 |
-
|
6843 |
-
|
6844 |
-
|
6845 |
-
|
6846 |
-
|
6847 |
-
|
6848 |
-
|
6849 |
-
|
6850 |
-
|
6851 |
-
|
6852 |
-
|
6853 |
-
|
6854 |
-
echo("\n
|
6855 |
-
|
6856 |
-
|
6857 |
-
|
6858 |
-
|
6859 |
-
|
6860 |
-
|
6861 |
-
|
6862 |
-
|
6863 |
-
a.
|
6864 |
-
|
6865 |
-
|
6866 |
-
|
6867 |
-
|
6868 |
-
|
6869 |
-
|
6870 |
-
|
6871 |
-
|
6872 |
-
|
6873 |
-
|
6874 |
-
|
6875 |
-
|
6876 |
-
|
6877 |
-
|
6878 |
-
|
6879 |
-
|
6880 |
-
|
6881 |
-
|
6882 |
-
|
6883 |
-
|
6884 |
-
|
6885 |
-
|
6886 |
-
|
6887 |
-
|
6888 |
-
|
6889 |
-
|
6890 |
-
|
6891 |
-
|
6892 |
-
|
6893 |
-
|
6894 |
-
|
6895 |
-
|
6896 |
-
|
6897 |
-
|
6898 |
-
|
6899 |
-
|
6900 |
-
|
6901 |
-
|
6902 |
-
|
6903 |
-
|
6904 |
-
|
6905 |
-
|
6906 |
-
|
6907 |
-
|
6908 |
-
)
|
6909 |
-
ON DUPLICATE KEY UPDATE
|
6910 |
-
product_id = a.entity_id,
|
6911 |
-
website_id = w.website_id");
|
6912 |
-
|
6913 |
-
|
6914 |
-
//echo(" .... DONE\n");return;
|
6915 |
-
|
6916 |
-
|
6917 |
-
echo("\n replaceMagentoProductsMultistore 28\n");
|
6918 |
-
|
6919 |
-
// temporary disabled mart@bintime.com
|
6920 |
-
//$result = $this->db_do("
|
6921 |
-
// UPDATE catalog_category_entity_int a
|
6922 |
-
// SET a.value = 0
|
6923 |
-
// WHERE a.attribute_id = 32
|
6924 |
-
//");
|
6925 |
-
|
6926 |
-
|
6927 |
-
//Adding tax class "Taxable Goods"
|
6928 |
-
$result = $this->db_do("
|
6929 |
-
INSERT INTO $catalog_product_entity_int
|
6930 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6931 |
-
(SELECT
|
6932 |
-
$_getProductEntityTypeId,
|
6933 |
-
$attr_tax_class_id,
|
6934 |
-
w.website,
|
6935 |
-
a.entity_id,
|
6936 |
-
2
|
6937 |
-
FROM $catalog_product_entity a
|
6938 |
-
JOIN $products_website_temp w
|
6939 |
-
ON a.store_product_id = w.store_product_id
|
6940 |
-
)
|
6941 |
-
ON DUPLICATE KEY UPDATE
|
6942 |
-
value = 2");
|
6943 |
-
|
6944 |
-
echo("\n replaceMagentoProductsMultistore 29\n");
|
6945 |
-
|
6946 |
-
$result = $this->db_do("
|
6947 |
-
INSERT INTO $catalog_product_entity_int
|
6948 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6949 |
-
(SELECT
|
6950 |
-
$_getProductEntityTypeId,
|
6951 |
-
$attr_tax_class_id,
|
6952 |
-
0,
|
6953 |
-
a.entity_id,
|
6954 |
-
2
|
6955 |
-
FROM $catalog_product_entity a
|
6956 |
-
)
|
6957 |
-
ON DUPLICATE KEY UPDATE
|
6958 |
-
value = 2");
|
6959 |
-
|
6960 |
-
echo("\n replaceMagentoProductsMultistore 30\n");
|
6961 |
-
|
6962 |
-
// Load url Image
|
6963 |
-
$result = $this->db_do("
|
6964 |
-
INSERT INTO $catalog_product_entity_varchar
|
6965 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6966 |
-
(SELECT
|
6967 |
-
$_getProductEntityTypeId,
|
6968 |
-
$attr_image,
|
6969 |
-
w.store_id,
|
6970 |
-
a.entity_id,
|
6971 |
-
b.main_image_url
|
6972 |
-
FROM $catalog_product_entity a
|
6973 |
-
JOIN $core_store w
|
6974 |
-
JOIN $products_temp b
|
6975 |
-
ON a.store_product_id = b.store_product_id
|
6976 |
-
)
|
6977 |
-
ON DUPLICATE KEY UPDATE
|
6978 |
-
value = b.main_image_url");
|
6979 |
-
|
6980 |
-
echo("\n replaceMagentoProductsMultistore 31\n");
|
6981 |
-
|
6982 |
-
// image for specific web sites
|
6983 |
-
$result = $this->db_do("
|
6984 |
-
INSERT INTO $catalog_product_entity_varchar
|
6985 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6986 |
-
(SELECT
|
6987 |
-
$_getProductEntityTypeId,
|
6988 |
-
$attr_image,
|
6989 |
-
0,
|
6990 |
-
a.entity_id,
|
6991 |
-
b.main_image_url
|
6992 |
-
FROM $catalog_product_entity a
|
6993 |
-
JOIN $products_temp b
|
6994 |
-
ON a.store_product_id = b.store_product_id
|
6995 |
-
)
|
6996 |
-
ON DUPLICATE KEY UPDATE
|
6997 |
-
value = b.main_image_url");
|
6998 |
-
|
6999 |
-
echo("\n replaceMagentoProductsMultistore 32\n");
|
7000 |
-
|
7001 |
-
// small_image for specific web sites
|
7002 |
-
$result = $this->db_do("
|
7003 |
-
INSERT INTO $catalog_product_entity_varchar
|
7004 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7005 |
-
(SELECT
|
7006 |
-
$_getProductEntityTypeId,
|
7007 |
-
$attr_small_image,
|
7008 |
-
w.store_id,
|
7009 |
-
a.entity_id,
|
7010 |
-
b.medium_image_url
|
7011 |
-
FROM $catalog_product_entity a
|
7012 |
-
JOIN $core_store w
|
7013 |
-
JOIN $products_temp b
|
7014 |
-
ON a.store_product_id = b.store_product_id
|
7015 |
-
)
|
7016 |
-
ON DUPLICATE KEY UPDATE
|
7017 |
-
value = b.medium_image_url");
|
7018 |
-
|
7019 |
-
echo("\n replaceMagentoProductsMultistore 33\n");
|
7020 |
-
|
7021 |
-
// small_image for all web sites
|
7022 |
-
$result = $this->db_do("
|
7023 |
-
INSERT INTO $catalog_product_entity_varchar
|
7024 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7025 |
-
(SELECT
|
7026 |
-
$_getProductEntityTypeId,
|
7027 |
-
$attr_small_image,
|
7028 |
-
0,
|
7029 |
-
a.entity_id,
|
7030 |
-
b.medium_image_url
|
7031 |
-
FROM $catalog_product_entity a
|
7032 |
-
JOIN $core_store w
|
7033 |
-
JOIN $products_temp b
|
7034 |
-
ON a.store_product_id = b.store_product_id
|
7035 |
-
)
|
7036 |
-
ON DUPLICATE KEY UPDATE
|
7037 |
-
value = b.medium_image_url");
|
7038 |
-
|
7039 |
-
echo("\n replaceMagentoProductsMultistore 34\n");
|
7040 |
-
|
7041 |
-
// thumbnail for specific web site
|
7042 |
-
$result = $this->db_do("
|
7043 |
-
INSERT INTO $catalog_product_entity_varchar
|
7044 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7045 |
-
(SELECT
|
7046 |
-
$_getProductEntityTypeId,
|
7047 |
-
$attr_thumbnail,
|
7048 |
-
w.store_id,
|
7049 |
-
a.entity_id,
|
7050 |
-
b.thumb_image_url
|
7051 |
-
FROM $catalog_product_entity a
|
7052 |
-
JOIN $core_store w
|
7053 |
-
JOIN $products_temp b
|
7054 |
-
ON a.store_product_id = b.store_product_id
|
7055 |
-
)
|
7056 |
-
ON DUPLICATE KEY UPDATE
|
7057 |
-
value = b.thumb_image_url");
|
7058 |
-
|
7059 |
-
echo("\n replaceMagentoProductsMultistore 35\n");
|
7060 |
-
|
7061 |
-
// thumbnail for all web sites
|
7062 |
-
$result = $this->db_do("
|
7063 |
-
INSERT INTO $catalog_product_entity_varchar
|
7064 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7065 |
-
(SELECT
|
7066 |
-
$_getProductEntityTypeId,
|
7067 |
-
$attr_thumbnail,
|
7068 |
-
0,
|
7069 |
-
a.entity_id,
|
7070 |
-
b.thumb_image_url
|
7071 |
-
FROM $catalog_product_entity a
|
7072 |
-
JOIN $core_store w
|
7073 |
-
JOIN $products_temp b
|
7074 |
-
ON a.store_product_id = b.store_product_id
|
7075 |
-
)
|
7076 |
-
ON DUPLICATE KEY UPDATE
|
7077 |
-
value = b.thumb_image_url");
|
7078 |
-
|
7079 |
-
echo("\n replaceMagentoProductsMultistore 36\n");
|
7080 |
-
|
7081 |
-
|
7082 |
-
/*STP DELETE
|
7083 |
-
//Refresh fulltext search
|
7084 |
-
$result = $this->db_do("DROP TABLE IF EXISTS {$catalogsearch_fulltext}_tmp");
|
7085 |
-
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS {$catalogsearch_fulltext}_tmp LIKE $catalogsearch_fulltext");
|
7086 |
-
|
7087 |
-
|
7088 |
-
echo("\n replaceMagentoProductsMultistore 36.2\n");
|
7089 |
-
$q = "
|
7090 |
-
INSERT INTO {$catalogsearch_fulltext}_tmp
|
7091 |
-
(product_id, store_id, data_index)
|
7092 |
-
(SELECT
|
7093 |
-
a.entity_id,
|
7094 |
-
w.website,
|
7095 |
-
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
7096 |
-
FROM $catalog_product_entity a
|
7097 |
-
JOIN $products_website_temp w
|
7098 |
-
ON a.store_product_id = w.store_product_id
|
7099 |
-
LEFT JOIN $catalog_category_product b
|
7100 |
-
ON a.entity_id = b.product_id
|
7101 |
-
LEFT JOIN $catalog_category_entity_varchar c
|
7102 |
-
ON b.category_id = c.entity_id
|
7103 |
-
AND c.attribute_id = $cat_attr_name
|
7104 |
-
LEFT JOIN $catalog_product_entity_varchar e
|
7105 |
-
ON a.entity_id = e.entity_id
|
7106 |
-
AND e.attribute_id = $attr_name
|
7107 |
-
LEFT JOIN $catalog_product_website j
|
7108 |
-
ON a.entity_id = j.product_id
|
7109 |
-
LEFT JOIN $products_temp f
|
7110 |
-
ON a.store_product_id = f.store_product_id
|
7111 |
-
)
|
7112 |
-
ON DUPLICATE KEY UPDATE
|
7113 |
-
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)";
|
7114 |
-
echo("\n\n============================\n$q\n============================\n\n");
|
7115 |
-
|
7116 |
-
|
7117 |
-
$result = $this->db_do("
|
7118 |
-
INSERT INTO {$catalogsearch_fulltext}_tmp
|
7119 |
-
(product_id, store_id, data_index)
|
7120 |
-
(SELECT
|
7121 |
-
a.entity_id,
|
7122 |
-
w.website,
|
7123 |
-
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
7124 |
-
FROM $catalog_product_entity a
|
7125 |
-
JOIN $products_website_temp w
|
7126 |
-
ON a.store_product_id = w.store_product_id
|
7127 |
-
LEFT JOIN $catalog_category_product b
|
7128 |
-
ON a.entity_id = b.product_id
|
7129 |
-
LEFT JOIN $catalog_category_entity_varchar c
|
7130 |
-
ON b.category_id = c.entity_id
|
7131 |
-
AND c.attribute_id = $cat_attr_name
|
7132 |
-
LEFT JOIN $catalog_product_entity_varchar e
|
7133 |
-
ON a.entity_id = e.entity_id
|
7134 |
-
AND e.attribute_id = $attr_name
|
7135 |
-
LEFT JOIN $catalog_product_website j
|
7136 |
-
ON a.entity_id = j.product_id
|
7137 |
-
LEFT JOIN $products_temp f
|
7138 |
-
ON a.store_product_id = f.store_product_id
|
7139 |
-
)
|
7140 |
-
ON DUPLICATE KEY UPDATE
|
7141 |
-
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
7142 |
-
|
7143 |
-
echo("\n replaceMagentoProductsMultistore 37\n");
|
7144 |
-
|
7145 |
-
|
7146 |
-
$result = $this->db_do("
|
7147 |
-
INSERT INTO {$catalogsearch_fulltext}_tmp
|
7148 |
-
(product_id, store_id, data_index)
|
7149 |
-
(SELECT
|
7150 |
-
a.entity_id,
|
7151 |
-
w.website,
|
7152 |
-
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
7153 |
-
FROM $catalog_product_entity a
|
7154 |
-
JOIN $products_website_temp w
|
7155 |
-
ON a.store_product_id = w.store_product_id
|
7156 |
-
LEFT JOIN $catalog_category_product b
|
7157 |
-
ON a.entity_id = b.product_id
|
7158 |
-
LEFT JOIN $catalog_category_entity_varchar c
|
7159 |
-
ON b.category_id = c.entity_id
|
7160 |
-
AND c.attribute_id = $cat_attr_name
|
7161 |
-
LEFT JOIN $catalog_product_entity_varchar e
|
7162 |
-
ON a.entity_id = e.entity_id
|
7163 |
-
AND e.attribute_id = $attr_name
|
7164 |
-
LEFT JOIN $products_temp f
|
7165 |
-
ON a.store_product_id = f.store_product_id
|
7166 |
-
)
|
7167 |
-
ON DUPLICATE KEY UPDATE
|
7168 |
-
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
7169 |
-
|
7170 |
-
echo("\n replaceMagentoProductsMultistore 38\n");
|
7171 |
-
|
7172 |
-
$result = $this->db_do("
|
7173 |
-
DELETE cf
|
7174 |
-
FROM $catalogsearch_fulltext cf
|
7175 |
-
LEFT JOIN $catalog_product_entity cpe
|
7176 |
-
ON cf.product_id = cpe.entity_id
|
7177 |
-
WHERE cpe.entity_id IS NULL");
|
7178 |
-
|
7179 |
-
echo("\n replaceMagentoProductsMultistore 39\n");
|
7180 |
-
|
7181 |
-
$result = $this->db_do("
|
7182 |
-
INSERT INTO $catalogsearch_fulltext
|
7183 |
-
(product_id, store_id, data_index)
|
7184 |
-
(SELECT
|
7185 |
-
a.product_id,
|
7186 |
-
a.store_id,
|
7187 |
-
a.data_index
|
7188 |
-
FROM {$catalogsearch_fulltext}_tmp a
|
7189 |
-
)
|
7190 |
-
ON DUPLICATE KEY UPDATE
|
7191 |
-
data_index = a.data_index");
|
7192 |
-
|
7193 |
-
echo("\n replaceMagentoProductsMultistore 40\n");
|
7194 |
-
|
7195 |
-
$this->db_do("UPDATE $catalogsearch_query SET is_processed = 0");
|
7196 |
-
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
7197 |
-
//TODO add something else
|
7198 |
-
STP DELETE*/
|
7199 |
-
|
7200 |
-
$this->addRelatedProducts();
|
7201 |
-
echo("\n replaceMagentoProductsMultistore 41\n");
|
7202 |
-
}
|
7203 |
-
|
7204 |
-
#################################################################################################
|
7205 |
-
|
7206 |
-
public function replaceMagentoProductsMultistoreMERGE($coincidence)
|
7207 |
-
{
|
7208 |
-
|
7209 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 1\n");
|
7210 |
-
|
7211 |
-
|
7212 |
-
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
7213 |
-
|
7214 |
-
|
7215 |
-
$products_temp = Mage::getSingleton('core/resource')->getTableName('products_temp');
|
7216 |
-
$products_website_temp = Mage::getSingleton('core/resource')->getTableName('products_website_temp');
|
7217 |
-
$catalog_product_entity = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity');
|
7218 |
-
$catalog_product_entity_int = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int');
|
7219 |
-
$catalog_product_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar');
|
7220 |
-
$catalog_category_product = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
7221 |
-
$stINch_products_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping');
|
7222 |
-
$stINch_products = Mage::getSingleton('core/resource')->getTableName('stINch_products');
|
7223 |
-
$catalog_category_entity = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity');
|
7224 |
-
$stINch_categories_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping');
|
7225 |
-
$catalog_category_product_index = Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index');
|
7226 |
-
$core_store = Mage::getSingleton('core/resource')->getTableName('core_store');
|
7227 |
-
$catalog_product_enabled_index = Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index');
|
7228 |
-
$catalog_product_website = Mage::getSingleton('core/resource')->getTableName('catalog_product_website');
|
7229 |
-
//STP DELETE $catalogsearch_fulltext = Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext');
|
7230 |
-
// $catalogsearch_query = Mage::getSingleton('core/resource')->getTableName('catalogsearch_query');
|
7231 |
-
$catalog_category_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar');
|
7232 |
-
|
7233 |
-
$_getProductEntityTypeId = $this->_getProductEntityTypeId();
|
7234 |
-
$_defaultAttributeSetId = $this->_getProductDefaulAttributeSetId();
|
7235 |
-
|
7236 |
-
$attr_atatus = $this->_getProductAttributeId('status');
|
7237 |
-
$attr_name = $this->_getProductAttributeId('name');
|
7238 |
-
$attr_visibility = $this->_getProductAttributeId('visibility');
|
7239 |
-
$attr_tax_class_id = $this->_getProductAttributeId('tax_class_id');
|
7240 |
-
$attr_image = $this->_getProductAttributeId('image');
|
7241 |
-
$attr_small_image = $this->_getProductAttributeId('small_image');
|
7242 |
-
$attr_thumbnail = $this->_getProductAttributeId('thumbnail');
|
7243 |
-
|
7244 |
-
$cat_attr_name = $this->_getCategoryAttributeId('name');
|
7245 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 2\n");
|
7246 |
-
|
7247 |
-
|
7248 |
-
//clear products, inserting new products and updating old others.
|
7249 |
-
$query = "
|
7250 |
-
DELETE cpe
|
7251 |
-
FROM $catalog_product_entity cpe
|
7252 |
-
JOIN $stINch_products_mapping pm
|
7253 |
-
ON cpe.entity_id = pm.entity_id
|
7254 |
-
WHERE pm.shop_store_product_id IS NOT NULL
|
7255 |
-
AND pm.store_product_id IS NULL";
|
7256 |
-
$result = $this->db_do($query);
|
7257 |
-
|
7258 |
-
|
7259 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 3\n");
|
7260 |
-
|
7261 |
-
$result = $this->db_do("
|
7262 |
-
INSERT INTO $catalog_product_entity
|
7263 |
-
(entity_id, entity_type_id, attribute_set_id, type_id, sku, updated_at, has_options, store_product_id, sinch_product_id)
|
7264 |
-
(SELECT
|
7265 |
-
pm.entity_id,
|
7266 |
-
$_getProductEntityTypeId,
|
7267 |
-
$_defaultAttributeSetId,
|
7268 |
-
'simple',
|
7269 |
-
a.product_sku,
|
7270 |
-
NOW(),
|
7271 |
-
0,
|
7272 |
-
a.store_product_id,
|
7273 |
-
a.sinch_product_id
|
7274 |
-
FROM $products_temp a
|
7275 |
-
LEFT JOIN $stINch_products_mapping pm
|
7276 |
-
ON a.store_product_id = pm.store_product_id
|
7277 |
-
AND a.sinch_product_id = pm.sinch_product_id
|
7278 |
-
WHERE pm.entity_id IS NOT NULL
|
7279 |
-
)
|
7280 |
-
ON DUPLICATE KEY UPDATE
|
7281 |
-
sku = a.product_sku,
|
7282 |
-
store_product_id = a.store_product_id,
|
7283 |
-
sinch_product_id = a.sinch_product_id");
|
7284 |
-
// store_product_id = a.store_product_id,
|
7285 |
-
// sinch_product_id = a.sinch_product_id
|
7286 |
-
|
7287 |
-
$result = $this->db_do("
|
7288 |
-
INSERT INTO $catalog_product_entity
|
7289 |
-
(entity_id, entity_type_id, attribute_set_id, type_id, sku, updated_at, has_options, store_product_id, sinch_product_id)
|
7290 |
-
(SELECT
|
7291 |
-
pm.entity_id,
|
7292 |
-
$_getProductEntityTypeId,
|
7293 |
-
$_defaultAttributeSetId,
|
7294 |
-
'simple',
|
7295 |
-
a.product_sku,
|
7296 |
-
NOW(),
|
7297 |
-
0,
|
7298 |
-
a.store_product_id,
|
7299 |
-
a.sinch_product_id
|
7300 |
-
FROM $products_temp a
|
7301 |
-
LEFT JOIN $stINch_products_mapping pm
|
7302 |
-
ON a.store_product_id = pm.store_product_id
|
7303 |
-
AND a.sinch_product_id = pm.sinch_product_id
|
7304 |
-
WHERE pm.entity_id IS NULL
|
7305 |
-
)
|
7306 |
-
ON DUPLICATE KEY UPDATE
|
7307 |
-
sku = a.product_sku,
|
7308 |
-
store_product_id = a.store_product_id,
|
7309 |
-
sinch_product_id = a.sinch_product_id");
|
7310 |
-
// store_product_id = a.store_product_id,
|
7311 |
-
// sinch_product_id = a.sinch_product_id
|
7312 |
-
|
7313 |
-
|
7314 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 4\n");
|
7315 |
-
|
7316 |
-
|
7317 |
-
//Set enabled
|
7318 |
-
$result = $this->db_do("
|
7319 |
-
DELETE cpei
|
7320 |
-
FROM $catalog_product_entity_int cpei
|
7321 |
-
LEFT JOIN $catalog_product_entity cpe
|
7322 |
-
ON cpei.entity_id = cpe.entity_id
|
7323 |
-
WHERE cpe.entity_id IS NULL");
|
7324 |
-
|
7325 |
-
$result = $this->db_do("
|
7326 |
-
INSERT INTO $catalog_product_entity_int
|
7327 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7328 |
-
(SELECT
|
7329 |
-
$_getProductEntityTypeId,
|
7330 |
-
$attr_atatus,
|
7331 |
-
w.website,
|
7332 |
-
a.entity_id,
|
7333 |
-
1
|
7334 |
-
FROM $catalog_product_entity a
|
7335 |
-
JOIN $products_website_temp w
|
7336 |
-
ON a.store_product_id = w.store_product_id
|
7337 |
-
)
|
7338 |
-
ON DUPLICATE KEY UPDATE
|
7339 |
-
value = 1");
|
7340 |
-
|
7341 |
-
|
7342 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 5\n");
|
7343 |
-
|
7344 |
-
|
7345 |
-
// set status = 1 for all stores
|
7346 |
-
$result = $this->db_do("
|
7347 |
-
INSERT INTO $catalog_product_entity_int
|
7348 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7349 |
-
(SELECT
|
7350 |
-
$_getProductEntityTypeId,
|
7351 |
-
$attr_atatus,
|
7352 |
-
0,
|
7353 |
-
a.entity_id,
|
7354 |
-
1
|
7355 |
-
FROM $catalog_product_entity a
|
7356 |
-
)
|
7357 |
-
ON DUPLICATE KEY UPDATE
|
7358 |
-
value = 1");
|
7359 |
-
|
7360 |
-
|
7361 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 6\n");
|
7362 |
-
|
7363 |
-
|
7364 |
-
//Unifying products with categories.
|
7365 |
-
$result = $this->db_do("
|
7366 |
-
DELETE ccp
|
7367 |
-
FROM $catalog_category_product ccp
|
7368 |
-
LEFT JOIN $catalog_product_entity cpe
|
7369 |
-
ON ccp.product_id = cpe.entity_id
|
7370 |
-
WHERE cpe.entity_id IS NULL");
|
7371 |
-
|
7372 |
-
|
7373 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 7\n");
|
7374 |
-
|
7375 |
-
|
7376 |
-
$root_cats = Mage::getSingleton('core/resource')->getTableName('root_cats');
|
7377 |
-
|
7378 |
-
$result = $this->db_do("DROP TABLE IF EXISTS $root_cats");
|
7379 |
-
$result = $this->db_do("
|
7380 |
-
CREATE TABLE $root_cats
|
7381 |
-
SELECT
|
7382 |
-
entity_id,
|
7383 |
-
path,
|
7384 |
-
SUBSTRING(path, LOCATE('/', path)+1) AS short_path,
|
7385 |
-
LOCATE('/', SUBSTRING(path, LOCATE('/', path)+1)) AS end_pos,
|
7386 |
-
SUBSTRING(SUBSTRING(path, LOCATE('/', path)+1), 1, LOCATE('/', SUBSTRING(path, LOCATE('/', path)+1))-1) as root_cat
|
7387 |
-
FROM $catalog_category_entity
|
7388 |
-
");
|
7389 |
-
$result = $this->db_do("UPDATE $root_cats SET root_cat = entity_id WHERE CHAR_LENGTH(root_cat) = 0");
|
7390 |
-
|
7391 |
-
|
7392 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 8\n");
|
7393 |
-
|
7394 |
-
|
7395 |
-
// !!! $this->_root_cat
|
7396 |
-
$result = $this->db_do("
|
7397 |
-
UPDATE IGNORE $catalog_category_product ccp
|
7398 |
-
LEFT JOIN $catalog_category_entity cce
|
7399 |
-
ON ccp.category_id = cce.entity_id
|
7400 |
-
JOIN $root_cats rc
|
7401 |
-
ON cce.entity_id = rc.entity_id
|
7402 |
-
SET ccp.category_id = rc.root_cat
|
7403 |
-
WHERE cce.entity_id IS NULL");
|
7404 |
-
|
7405 |
-
|
7406 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 9\n");
|
7407 |
-
|
7408 |
-
|
7409 |
-
$result = $this->db_do("
|
7410 |
-
DELETE ccp
|
7411 |
-
FROM $catalog_category_product ccp
|
7412 |
-
LEFT JOIN $catalog_category_entity cce
|
7413 |
-
ON ccp.category_id = cce.entity_id
|
7414 |
-
WHERE cce.entity_id IS NULL");
|
7415 |
-
|
7416 |
-
|
7417 |
-
$stinch_products_delete = Mage::getSingleton('core/resource')->getTableName('stinch_products_delete');
|
7418 |
-
|
7419 |
-
$result = $this->db_do("DROP TABLE IF EXISTS $stinch_products_delete");
|
7420 |
-
$result = $this->db_do("
|
7421 |
-
CREATE TABLE $stinch_products_delete
|
7422 |
-
SELECT cpe.entity_id
|
7423 |
-
FROM $catalog_product_entity cpe
|
7424 |
-
WHERE cpe.entity_id NOT IN
|
7425 |
-
(
|
7426 |
-
SELECT cpe2.entity_id
|
7427 |
-
FROM $catalog_product_entity cpe2
|
7428 |
-
JOIN $stINch_products sp
|
7429 |
-
ON cpe2.sinch_product_id = sp.sinch_product_id
|
7430 |
-
)");
|
7431 |
-
|
7432 |
-
|
7433 |
-
$result = $this->db_do("DELETE cpe FROM $catalog_product_entity cpe JOIN $stinch_products_delete spd USING(entity_id)");
|
7434 |
-
|
7435 |
-
$result = $this->db_do("DROP TABLE IF EXISTS $stinch_products_delete");
|
7436 |
-
|
7437 |
-
|
7438 |
-
//echo("\n\nget out...\n\n");
|
7439 |
-
//return;
|
7440 |
-
|
7441 |
-
/**
|
7442 |
-
*
|
7443 |
-
* echo("\n replaceMagentoProductsMultistoreMERGE 10\n");
|
7444 |
-
*
|
7445 |
-
*
|
7446 |
-
* // TEMPORARY
|
7447 |
-
* $this->db_do(" DROP TABLE IF EXISTS {$catalog_category_product}_for_delete_temp");
|
7448 |
-
* $this->db_do("
|
7449 |
-
* CREATE TABLE `{$catalog_category_product}_for_delete_temp`
|
7450 |
-
* (
|
7451 |
-
* `category_id` int(10) unsigned NOT NULL default '0',
|
7452 |
-
* `product_id` int(10) unsigned NOT NULL default '0',
|
7453 |
-
* `store_product_id` int(10) NOT NULL default '0',
|
7454 |
-
* `store_category_id` int(10) NOT NULL default '0',
|
7455 |
-
* `new_category_id` int(10) NOT NULL default '0',
|
7456 |
-
*
|
7457 |
-
* UNIQUE KEY `UNQ_CATEGORY_PRODUCT` (`category_id`,`product_id`),
|
7458 |
-
* KEY `CATALOG_CATEGORY_PRODUCT_CATEGORY` (`category_id`),
|
7459 |
-
* KEY `CATALOG_CATEGORY_PRODUCT_PRODUCT` (`product_id`),
|
7460 |
-
* KEY `CATALOG_NEW_CATEGORY_PRODUCT_CATEGORY` (`new_category_id`)
|
7461 |
-
* )");
|
7462 |
-
*
|
7463 |
-
* echo("\n replaceMagentoProductsMultistoreMERGE 11\n");
|
7464 |
-
*
|
7465 |
-
* $result = $this->db_do("
|
7466 |
-
* INSERT INTO {$catalog_category_product}_for_delete_temp
|
7467 |
-
* (category_id, product_id, store_product_id)
|
7468 |
-
* (SELECT
|
7469 |
-
* ccp.category_id,
|
7470 |
-
* ccp.product_id,
|
7471 |
-
* cpe.store_product_id
|
7472 |
-
* FROM $catalog_category_product ccp
|
7473 |
-
* JOIN $catalog_product_entity cpe
|
7474 |
-
* ON ccp.product_id = cpe.entity_id
|
7475 |
-
* WHERE store_product_id IS NOT NULL)");
|
7476 |
-
*
|
7477 |
-
* echo("\n replaceMagentoProductsMultistoreMERGE 12\n");
|
7478 |
-
*
|
7479 |
-
* $result = $this->db_do("
|
7480 |
-
* UPDATE {$catalog_category_product}_for_delete_temp ccpfd
|
7481 |
-
* JOIN $products_temp p
|
7482 |
-
* ON ccpfd.store_product_id = p.store_product_id
|
7483 |
-
* SET ccpfd.store_category_id = p.store_category_id
|
7484 |
-
* WHERE ccpfd.store_product_id != 0");
|
7485 |
-
*
|
7486 |
-
* echo("\n replaceMagentoProductsMultistoreMERGE 13\n");
|
7487 |
-
*
|
7488 |
-
* $result = $this->db_do("
|
7489 |
-
* UPDATE {$catalog_category_product}_for_delete_temp ccpfd
|
7490 |
-
* JOIN $stINch_categories_mapping scm
|
7491 |
-
* ON ccpfd.store_category_id = scm.store_category_id
|
7492 |
-
* SET ccpfd.new_category_id = scm.shop_entity_id
|
7493 |
-
* WHERE ccpfd.store_category_id != 0");
|
7494 |
-
*
|
7495 |
-
* echo("\n replaceMagentoProductsMultistoreMERGE 14\n");
|
7496 |
-
*
|
7497 |
-
* $result = $this->db_do("DELETE FROM {$catalog_category_product}_for_delete_temp WHERE category_id = new_category_id");
|
7498 |
-
*
|
7499 |
-
*
|
7500 |
-
*
|
7501 |
-
* $result = $this->db_do("
|
7502 |
-
* DELETE ccp
|
7503 |
-
* FROM $catalog_category_product ccp
|
7504 |
-
* JOIN {$catalog_category_product}_for_delete_temp ccpfd
|
7505 |
-
* ON ccp.product_id = ccpfd.product_id
|
7506 |
-
* AND ccp.category_id = ccpfd.category_id");
|
7507 |
-
*
|
7508 |
-
* /**/
|
7509 |
-
|
7510 |
-
|
7511 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 15\n");
|
7512 |
-
|
7513 |
-
|
7514 |
-
$result = $this->db_do("
|
7515 |
-
INSERT INTO $catalog_category_product
|
7516 |
-
(category_id, product_id)
|
7517 |
-
(SELECT
|
7518 |
-
scm.shop_entity_id,
|
7519 |
-
cpe.entity_id
|
7520 |
-
FROM $catalog_product_entity cpe
|
7521 |
-
JOIN $products_temp p
|
7522 |
-
ON cpe.store_product_id = p.store_product_id
|
7523 |
-
JOIN $stINch_categories_mapping scm
|
7524 |
-
ON p.store_category_id = scm.store_category_id
|
7525 |
-
)
|
7526 |
-
ON DUPLICATE KEY UPDATE
|
7527 |
-
product_id = cpe.entity_id");
|
7528 |
-
|
7529 |
-
|
7530 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 15.1 (add multi categories)\n");
|
7531 |
-
|
7532 |
-
|
7533 |
-
$result = $this->db_do("
|
7534 |
-
INSERT INTO $catalog_category_product
|
7535 |
-
(category_id, product_id)
|
7536 |
-
(SELECT
|
7537 |
-
scm.shop_entity_id,
|
7538 |
-
cpe.entity_id
|
7539 |
-
FROM $catalog_product_entity cpe
|
7540 |
-
JOIN $products_temp p
|
7541 |
-
ON cpe.store_product_id = p.store_product_id
|
7542 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_product_categories') . " spc
|
7543 |
-
ON p.store_product_id=spc.store_product_id
|
7544 |
-
JOIN $stINch_categories_mapping scm
|
7545 |
-
ON spc.store_category_id = scm.store_category_id
|
7546 |
-
)
|
7547 |
-
ON DUPLICATE KEY UPDATE
|
7548 |
-
product_id = cpe.entity_id
|
7549 |
-
");
|
7550 |
-
|
7551 |
-
|
7552 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 16\n");
|
7553 |
-
|
7554 |
-
//Indexing products and categories in the shop
|
7555 |
-
$result = $this->db_do("
|
7556 |
-
DELETE ccpi
|
7557 |
-
FROM $catalog_category_product_index ccpi
|
7558 |
-
LEFT JOIN $catalog_product_entity cpe
|
7559 |
-
ON ccpi.product_id = cpe.entity_id
|
7560 |
-
WHERE cpe.entity_id IS NULL");
|
7561 |
-
|
7562 |
-
|
7563 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 16.2\n");
|
7564 |
-
|
7565 |
-
|
7566 |
-
$result = $this->db_do("
|
7567 |
-
INSERT INTO $catalog_category_product_index
|
7568 |
-
(category_id, product_id, position, is_parent, store_id, visibility)
|
7569 |
-
(SELECT
|
7570 |
-
a.category_id,
|
7571 |
-
a.product_id,
|
7572 |
-
a.position,
|
7573 |
-
1,
|
7574 |
-
b.store_id,
|
7575 |
-
4
|
7576 |
-
FROM $catalog_category_product a
|
7577 |
-
JOIN $core_store b
|
7578 |
-
)
|
7579 |
-
ON DUPLICATE KEY UPDATE
|
7580 |
-
visibility = 4");
|
7581 |
-
|
7582 |
-
|
7583 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 17\n");
|
7584 |
-
$root_cats = Mage::getSingleton('core/resource')->getTableName('root_cats');
|
7585 |
-
// !!! $this->_root_cat
|
7586 |
-
$result = $this->db_do("
|
7587 |
-
INSERT ignore INTO $catalog_category_product_index
|
7588 |
-
(category_id, product_id, position, is_parent, store_id, visibility)
|
7589 |
-
(SELECT
|
7590 |
-
rc.root_cat,
|
7591 |
-
a.product_id,
|
7592 |
-
a.position,
|
7593 |
-
1,
|
7594 |
-
b.store_id,
|
7595 |
-
4
|
7596 |
-
FROM $catalog_category_product a
|
7597 |
-
JOIN $root_cats rc
|
7598 |
-
ON a.category_id = rc.entity_id
|
7599 |
-
JOIN $core_store b
|
7600 |
-
)
|
7601 |
-
ON DUPLICATE KEY UPDATE
|
7602 |
-
visibility = 4");
|
7603 |
-
|
7604 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 18\n");
|
7605 |
-
|
7606 |
-
|
7607 |
-
//Set product name for specific web sites
|
7608 |
-
$result = $this->db_do("
|
7609 |
-
DELETE cpev
|
7610 |
-
FROM $catalog_product_entity_varchar cpev
|
7611 |
-
LEFT JOIN $catalog_product_entity cpe
|
7612 |
-
ON cpev.entity_id = cpe.entity_id
|
7613 |
-
WHERE cpe.entity_id IS NULL");
|
7614 |
-
|
7615 |
-
$result = $this->db_do("
|
7616 |
-
INSERT INTO $catalog_product_entity_varchar
|
7617 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7618 |
-
(SELECT
|
7619 |
-
$_getProductEntityTypeId,
|
7620 |
-
$attr_name,
|
7621 |
-
w.website,
|
7622 |
-
a.entity_id,
|
7623 |
-
b.product_name
|
7624 |
-
FROM $catalog_product_entity a
|
7625 |
-
JOIN $products_temp b
|
7626 |
-
ON a.store_product_id = b.store_product_id
|
7627 |
-
JOIN $products_website_temp w
|
7628 |
-
ON a.store_product_id = w.store_product_id
|
7629 |
-
)
|
7630 |
-
ON DUPLICATE KEY UPDATE
|
7631 |
-
value = b.product_name");
|
7632 |
-
|
7633 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 19\n");
|
7634 |
-
|
7635 |
-
|
7636 |
-
// product name for all web sites
|
7637 |
-
$result = $this->db_do("
|
7638 |
-
INSERT INTO $catalog_product_entity_varchar
|
7639 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7640 |
-
(SELECT
|
7641 |
-
$_getProductEntityTypeId,
|
7642 |
-
$attr_name,
|
7643 |
-
0,
|
7644 |
-
a.entity_id,
|
7645 |
-
b.product_name
|
7646 |
-
FROM $catalog_product_entity a
|
7647 |
-
JOIN $products_temp b
|
7648 |
-
ON a.store_product_id = b.store_product_id
|
7649 |
-
)
|
7650 |
-
ON DUPLICATE KEY UPDATE
|
7651 |
-
value = b.product_name");
|
7652 |
-
|
7653 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 20\n");
|
7654 |
-
|
7655 |
-
|
7656 |
-
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
7657 |
-
$this->addDescriptions();
|
7658 |
-
$this->cleanProductDistributors();
|
7659 |
-
if (!$this->_ignore_product_contracts) {
|
7660 |
-
$this->cleanProductContracts();
|
7661 |
-
}
|
7662 |
-
if ($this->product_file_format == "NEW") {
|
7663 |
-
$this->addReviews();
|
7664 |
-
$this->addWeight();
|
7665 |
-
$this->addSearchCache();
|
7666 |
-
$this->addPdfUrl();
|
7667 |
-
$this->addShortDescriptions();
|
7668 |
-
$this->addProductDistributors();
|
7669 |
-
if (!$this->_ignore_product_contracts) {
|
7670 |
-
$this->addProductContracts();
|
7671 |
-
}
|
7672 |
-
}
|
7673 |
-
$this->addEAN();
|
7674 |
-
$this->addSpecification();
|
7675 |
-
$this->addManufacturers();
|
7676 |
-
|
7677 |
-
|
7678 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 21\n");
|
7679 |
-
|
7680 |
-
//Enabling product index.
|
7681 |
-
$result = $this->db_do("
|
7682 |
-
DELETE cpei
|
7683 |
-
FROM $catalog_product_enabled_index cpei
|
7684 |
-
LEFT JOIN $catalog_product_entity cpe
|
7685 |
-
ON cpei.product_id = cpe.entity_id
|
7686 |
-
WHERE cpe.entity_id IS NULL");
|
7687 |
-
|
7688 |
-
|
7689 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 22\n");
|
7690 |
-
|
7691 |
-
$result = $this->db_do("
|
7692 |
-
INSERT INTO $catalog_product_enabled_index
|
7693 |
-
(product_id, store_id, visibility)
|
7694 |
-
(SELECT
|
7695 |
-
a.entity_id,
|
7696 |
-
w.website,
|
7697 |
-
4
|
7698 |
-
FROM $catalog_product_entity a
|
7699 |
-
JOIN $products_website_temp w
|
7700 |
-
ON a.store_product_id = w.store_product_id
|
7701 |
-
)
|
7702 |
-
ON DUPLICATE KEY UPDATE
|
7703 |
-
visibility = 4");
|
7704 |
-
|
7705 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 23\n");
|
7706 |
-
|
7707 |
-
$result = $this->db_do("
|
7708 |
-
INSERT INTO $catalog_product_enabled_index
|
7709 |
-
(product_id, store_id, visibility)
|
7710 |
-
(SELECT
|
7711 |
-
a.entity_id,
|
7712 |
-
0,
|
7713 |
-
4
|
7714 |
-
FROM $catalog_product_entity a
|
7715 |
-
JOIN $products_website_temp w
|
7716 |
-
ON a.store_product_id = w.store_product_id
|
7717 |
-
)
|
7718 |
-
ON DUPLICATE KEY UPDATE
|
7719 |
-
visibility = 4");
|
7720 |
-
|
7721 |
-
|
7722 |
-
/////////////////////////////////////echo(" .... DONE\n");return;
|
7723 |
-
|
7724 |
-
|
7725 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 24\n");
|
7726 |
-
|
7727 |
-
$result = $this->db_do("
|
7728 |
-
INSERT INTO $catalog_product_entity_int
|
7729 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7730 |
-
(SELECT
|
7731 |
-
$_getProductEntityTypeId,
|
7732 |
-
$attr_visibility,
|
7733 |
-
w.website,
|
7734 |
-
a.entity_id,
|
7735 |
-
4
|
7736 |
-
FROM $catalog_product_entity a
|
7737 |
-
JOIN $products_website_temp w
|
7738 |
-
ON a.store_product_id = w.store_product_id
|
7739 |
-
)
|
7740 |
-
ON DUPLICATE KEY UPDATE
|
7741 |
-
value = 4");
|
7742 |
-
|
7743 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 25\n");
|
7744 |
-
|
7745 |
-
$result = $this->db_do("
|
7746 |
-
INSERT INTO $catalog_product_entity_int
|
7747 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7748 |
-
(SELECT
|
7749 |
-
$_getProductEntityTypeId,
|
7750 |
-
$attr_visibility,
|
7751 |
-
0,
|
7752 |
-
a.entity_id,
|
7753 |
-
4
|
7754 |
-
FROM $catalog_product_entity a
|
7755 |
-
)
|
7756 |
-
ON DUPLICATE KEY UPDATE
|
7757 |
-
value = 4");
|
7758 |
-
|
7759 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 26\n");
|
7760 |
-
|
7761 |
-
|
7762 |
-
$result = $this->db_do("
|
7763 |
-
DELETE cpw
|
7764 |
-
FROM $catalog_product_website cpw
|
7765 |
-
LEFT JOIN $catalog_product_entity cpe
|
7766 |
-
ON cpw.product_id = cpe.entity_id
|
7767 |
-
WHERE cpe.entity_id IS NULL");
|
7768 |
-
|
7769 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 27\n");
|
7770 |
-
|
7771 |
-
|
7772 |
-
$result = $this->db_do("
|
7773 |
-
INSERT INTO $catalog_product_website
|
7774 |
-
(product_id, website_id)
|
7775 |
-
(SELECT
|
7776 |
-
a.entity_id,
|
7777 |
-
w.website_id
|
7778 |
-
FROM $catalog_product_entity a
|
7779 |
-
JOIN $products_website_temp w
|
7780 |
-
ON a.store_product_id = w.store_product_id
|
7781 |
-
)
|
7782 |
-
ON DUPLICATE KEY UPDATE
|
7783 |
-
product_id = a.entity_id,
|
7784 |
-
website_id = w.website_id");
|
7785 |
-
|
7786 |
-
|
7787 |
-
//echo(" .... DONE\n");return;
|
7788 |
-
|
7789 |
-
|
7790 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 28\n");
|
7791 |
-
|
7792 |
-
// temporary disabled mart@bintime.com
|
7793 |
-
//$result = $this->db_do("
|
7794 |
-
// UPDATE catalog_category_entity_int a
|
7795 |
-
// SET a.value = 0
|
7796 |
-
// WHERE a.attribute_id = 32
|
7797 |
-
//");
|
7798 |
-
|
7799 |
-
|
7800 |
-
//Adding tax class "Taxable Goods"
|
7801 |
-
$result = $this->db_do("
|
7802 |
-
INSERT INTO $catalog_product_entity_int
|
7803 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7804 |
-
(SELECT
|
7805 |
-
$_getProductEntityTypeId,
|
7806 |
-
$attr_tax_class_id,
|
7807 |
-
w.website,
|
7808 |
-
a.entity_id,
|
7809 |
-
2
|
7810 |
-
FROM $catalog_product_entity a
|
7811 |
-
JOIN $products_website_temp w
|
7812 |
-
ON a.store_product_id = w.store_product_id
|
7813 |
-
)
|
7814 |
-
ON DUPLICATE KEY UPDATE
|
7815 |
-
value = 2");
|
7816 |
-
|
7817 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 29\n");
|
7818 |
-
|
7819 |
-
$result = $this->db_do("
|
7820 |
-
INSERT INTO $catalog_product_entity_int
|
7821 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7822 |
-
(SELECT
|
7823 |
-
$_getProductEntityTypeId,
|
7824 |
-
$attr_tax_class_id,
|
7825 |
-
0,
|
7826 |
-
a.entity_id,
|
7827 |
-
2
|
7828 |
-
FROM $catalog_product_entity a
|
7829 |
-
)
|
7830 |
-
ON DUPLICATE KEY UPDATE
|
7831 |
-
value = 2");
|
7832 |
-
|
7833 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 30\n");
|
7834 |
-
|
7835 |
-
// Load url Image
|
7836 |
-
$result = $this->db_do("
|
7837 |
-
INSERT INTO $catalog_product_entity_varchar
|
7838 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7839 |
-
(SELECT
|
7840 |
-
$_getProductEntityTypeId,
|
7841 |
-
$attr_image,
|
7842 |
-
w.store_id,
|
7843 |
-
a.entity_id,
|
7844 |
-
b.main_image_url
|
7845 |
-
FROM $catalog_product_entity a
|
7846 |
-
JOIN $core_store w
|
7847 |
-
JOIN $products_temp b
|
7848 |
-
ON a.store_product_id = b.store_product_id
|
7849 |
-
)
|
7850 |
-
ON DUPLICATE KEY UPDATE
|
7851 |
-
value = b.main_image_url");
|
7852 |
-
|
7853 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 31\n");
|
7854 |
-
|
7855 |
-
// image for specific web sites
|
7856 |
-
$result = $this->db_do("
|
7857 |
-
INSERT INTO $catalog_product_entity_varchar
|
7858 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7859 |
-
(SELECT
|
7860 |
-
$_getProductEntityTypeId,
|
7861 |
-
$attr_image,
|
7862 |
-
0,
|
7863 |
-
a.entity_id,
|
7864 |
-
b.main_image_url
|
7865 |
-
FROM $catalog_product_entity a
|
7866 |
-
JOIN $products_temp b
|
7867 |
-
ON a.store_product_id = b.store_product_id
|
7868 |
-
)
|
7869 |
-
ON DUPLICATE KEY UPDATE
|
7870 |
-
value = b.main_image_url");
|
7871 |
-
|
7872 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 32\n");
|
7873 |
-
|
7874 |
-
// small_image for specific web sites
|
7875 |
-
$result = $this->db_do("
|
7876 |
-
INSERT INTO $catalog_product_entity_varchar
|
7877 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7878 |
-
(SELECT
|
7879 |
-
$_getProductEntityTypeId,
|
7880 |
-
$attr_small_image,
|
7881 |
-
w.store_id,
|
7882 |
-
a.entity_id,
|
7883 |
-
b.medium_image_url
|
7884 |
-
FROM $catalog_product_entity a
|
7885 |
-
JOIN $core_store w
|
7886 |
-
JOIN $products_temp b
|
7887 |
-
ON a.store_product_id = b.store_product_id
|
7888 |
-
)
|
7889 |
-
ON DUPLICATE KEY UPDATE
|
7890 |
-
value = b.medium_image_url");
|
7891 |
-
|
7892 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 33\n");
|
7893 |
-
|
7894 |
-
// small_image for all web sites
|
7895 |
-
$result = $this->db_do("
|
7896 |
-
INSERT INTO $catalog_product_entity_varchar
|
7897 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7898 |
-
(SELECT
|
7899 |
-
$_getProductEntityTypeId,
|
7900 |
-
$attr_small_image,
|
7901 |
-
0,
|
7902 |
-
a.entity_id,
|
7903 |
-
b.medium_image_url
|
7904 |
-
FROM $catalog_product_entity a
|
7905 |
-
JOIN $core_store w
|
7906 |
-
JOIN $products_temp b
|
7907 |
-
ON a.store_product_id = b.store_product_id
|
7908 |
-
)
|
7909 |
-
ON DUPLICATE KEY UPDATE
|
7910 |
-
value = b.medium_image_url");
|
7911 |
-
|
7912 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 34\n");
|
7913 |
-
|
7914 |
-
// thumbnail for specific web site
|
7915 |
-
$result = $this->db_do("
|
7916 |
-
INSERT INTO $catalog_product_entity_varchar
|
7917 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7918 |
-
(SELECT
|
7919 |
-
$_getProductEntityTypeId,
|
7920 |
-
$attr_thumbnail,
|
7921 |
-
w.store_id,
|
7922 |
-
a.entity_id,
|
7923 |
-
b.thumb_image_url
|
7924 |
-
FROM $catalog_product_entity a
|
7925 |
-
JOIN $core_store w
|
7926 |
-
JOIN $products_temp b
|
7927 |
-
ON a.store_product_id = b.store_product_id
|
7928 |
-
)
|
7929 |
-
ON DUPLICATE KEY UPDATE
|
7930 |
-
value = b.thumb_image_url");
|
7931 |
-
|
7932 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 35\n");
|
7933 |
-
|
7934 |
-
// thumbnail for all web sites
|
7935 |
-
$result = $this->db_do("
|
7936 |
-
INSERT INTO $catalog_product_entity_varchar
|
7937 |
-
(entity_type_id, attribute_id, store_id, entity_id, value)
|
7938 |
-
(SELECT
|
7939 |
-
$_getProductEntityTypeId,
|
7940 |
-
$attr_thumbnail,
|
7941 |
-
0,
|
7942 |
-
a.entity_id,
|
7943 |
-
b.thumb_image_url
|
7944 |
-
FROM $catalog_product_entity a
|
7945 |
-
JOIN $core_store w
|
7946 |
-
JOIN $products_temp b
|
7947 |
-
ON a.store_product_id = b.store_product_id
|
7948 |
-
)
|
7949 |
-
ON DUPLICATE KEY UPDATE
|
7950 |
-
value = b.thumb_image_url");
|
7951 |
-
|
7952 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 36\n");
|
7953 |
-
|
7954 |
-
|
7955 |
-
/* STP DELETE
|
7956 |
-
//Refresh fulltext search
|
7957 |
-
$result = $this->db_do("DROP TABLE IF EXISTS {$catalogsearch_fulltext}_tmp");
|
7958 |
-
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS {$catalogsearch_fulltext}_tmp LIKE $catalogsearch_fulltext");
|
7959 |
-
|
7960 |
-
|
7961 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 36.2\n");
|
7962 |
-
$q = "
|
7963 |
-
INSERT INTO {$catalogsearch_fulltext}_tmp
|
7964 |
-
(product_id, store_id, data_index)
|
7965 |
-
(SELECT
|
7966 |
-
a.entity_id,
|
7967 |
-
w.website,
|
7968 |
-
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
7969 |
-
FROM $catalog_product_entity a
|
7970 |
-
JOIN $products_website_temp w
|
7971 |
-
ON a.store_product_id = w.store_product_id
|
7972 |
-
LEFT JOIN $catalog_category_product b
|
7973 |
-
ON a.entity_id = b.product_id
|
7974 |
-
LEFT JOIN $catalog_category_entity_varchar c
|
7975 |
-
ON b.category_id = c.entity_id
|
7976 |
-
AND c.attribute_id = $cat_attr_name
|
7977 |
-
LEFT JOIN $catalog_product_entity_varchar e
|
7978 |
-
ON a.entity_id = e.entity_id
|
7979 |
-
AND e.attribute_id = $attr_name
|
7980 |
-
LEFT JOIN $catalog_product_website j
|
7981 |
-
ON a.entity_id = j.product_id
|
7982 |
-
LEFT JOIN $products_temp f
|
7983 |
-
ON a.store_product_id = f.store_product_id
|
7984 |
-
)
|
7985 |
-
ON DUPLICATE KEY UPDATE
|
7986 |
-
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)";
|
7987 |
-
echo("\n\n============================\n$q\n============================\n\n");
|
7988 |
-
|
7989 |
-
|
7990 |
-
$result = $this->db_do("
|
7991 |
-
INSERT INTO {$catalogsearch_fulltext}_tmp
|
7992 |
-
(product_id, store_id, data_index)
|
7993 |
-
(SELECT
|
7994 |
-
a.entity_id,
|
7995 |
-
w.website,
|
7996 |
-
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
7997 |
-
FROM $catalog_product_entity a
|
7998 |
-
JOIN $products_website_temp w
|
7999 |
-
ON a.store_product_id = w.store_product_id
|
8000 |
-
LEFT JOIN $catalog_category_product b
|
8001 |
-
ON a.entity_id = b.product_id
|
8002 |
-
LEFT JOIN $catalog_category_entity_varchar c
|
8003 |
-
ON b.category_id = c.entity_id
|
8004 |
-
AND c.attribute_id = $cat_attr_name
|
8005 |
-
LEFT JOIN $catalog_product_entity_varchar e
|
8006 |
-
ON a.entity_id = e.entity_id
|
8007 |
-
AND e.attribute_id = $attr_name
|
8008 |
-
LEFT JOIN $catalog_product_website j
|
8009 |
-
ON a.entity_id = j.product_id
|
8010 |
-
LEFT JOIN $products_temp f
|
8011 |
-
ON a.store_product_id = f.store_product_id
|
8012 |
-
)
|
8013 |
-
ON DUPLICATE KEY UPDATE
|
8014 |
-
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
8015 |
-
|
8016 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 37\n");
|
8017 |
-
|
8018 |
-
|
8019 |
-
$result = $this->db_do("
|
8020 |
-
INSERT INTO {$catalogsearch_fulltext}_tmp
|
8021 |
-
(product_id, store_id, data_index)
|
8022 |
-
(SELECT
|
8023 |
-
a.entity_id,
|
8024 |
-
w.website,
|
8025 |
-
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
8026 |
-
FROM $catalog_product_entity a
|
8027 |
-
JOIN $products_website_temp w
|
8028 |
-
ON a.store_product_id = w.store_product_id
|
8029 |
-
LEFT JOIN $catalog_category_product b
|
8030 |
-
ON a.entity_id = b.product_id
|
8031 |
-
LEFT JOIN $catalog_category_entity_varchar c
|
8032 |
-
ON b.category_id = c.entity_id
|
8033 |
-
AND c.attribute_id = $cat_attr_name
|
8034 |
-
LEFT JOIN $catalog_product_entity_varchar e
|
8035 |
-
ON a.entity_id = e.entity_id
|
8036 |
-
AND e.attribute_id = $attr_name
|
8037 |
-
LEFT JOIN $products_temp f
|
8038 |
-
ON a.store_product_id = f.store_product_id
|
8039 |
-
)
|
8040 |
-
ON DUPLICATE KEY UPDATE
|
8041 |
-
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
8042 |
-
|
8043 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 38\n");
|
8044 |
-
|
8045 |
-
$result = $this->db_do("
|
8046 |
-
DELETE cf
|
8047 |
-
FROM $catalogsearch_fulltext cf
|
8048 |
-
LEFT JOIN $catalog_product_entity cpe
|
8049 |
-
ON cf.product_id = cpe.entity_id
|
8050 |
-
WHERE cpe.entity_id IS NULL");
|
8051 |
-
|
8052 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 39\n");
|
8053 |
-
|
8054 |
-
$result = $this->db_do("
|
8055 |
-
INSERT INTO $catalogsearch_fulltext
|
8056 |
-
(product_id, store_id, data_index)
|
8057 |
-
(SELECT
|
8058 |
-
a.product_id,
|
8059 |
-
a.store_id,
|
8060 |
-
a.data_index
|
8061 |
-
FROM {$catalogsearch_fulltext}_tmp a
|
8062 |
-
)
|
8063 |
-
ON DUPLICATE KEY UPDATE
|
8064 |
-
data_index = a.data_index");
|
8065 |
-
|
8066 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 40\n");
|
8067 |
-
|
8068 |
-
$this->db_do("UPDATE $catalogsearch_query SET is_processed = 0");
|
8069 |
-
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
8070 |
-
//TODO add something else
|
8071 |
-
STP DELETE*/
|
8072 |
-
|
8073 |
-
$this->addRelatedProducts();
|
8074 |
-
echo("\n replaceMagentoProductsMultistoreMERGE 41\n");
|
8075 |
-
}
|
8076 |
-
|
8077 |
-
#################################################################################################
|
8078 |
-
|
8079 |
-
function ParseProductsPicturesGallery()
|
8080 |
-
{
|
8081 |
-
|
8082 |
-
$parse_file = $this->varDir . FILE_PRODUCTS_PICTURES_GALLERY;
|
8083 |
-
if (filesize($parse_file)) {
|
8084 |
-
$this->_LOG("Start parse " . FILE_PRODUCTS_PICTURES_GALLERY);
|
8085 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp'));
|
8086 |
-
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp') . " (
|
8087 |
-
sinch_product_id int(11),
|
8088 |
-
image_url varchar(255),
|
8089 |
-
thumb_image_url varchar(255),
|
8090 |
-
store_product_id int(11),
|
8091 |
-
key(sinch_product_id),
|
8092 |
-
key(store_product_id)
|
8093 |
-
)");
|
8094 |
-
|
8095 |
-
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
8096 |
-
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp') . "
|
8097 |
-
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
8098 |
-
OPTIONALLY ENCLOSED BY '\"'
|
8099 |
-
LINES TERMINATED BY \"\r\n\"
|
8100 |
-
IGNORE 1 LINES ");
|
8101 |
-
|
8102 |
-
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp') . " ppgt
|
8103 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products') . " sp
|
8104 |
-
ON ppgt.sinch_product_id=sp.sinch_product_id
|
8105 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
8106 |
-
ON sp.store_product_id=cpe.store_product_id
|
8107 |
-
SET ppgt.store_product_id=sp.store_product_id");
|
8108 |
-
|
8109 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery'));
|
8110 |
-
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp') . "
|
8111 |
-
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery'));
|
8112 |
-
|
8113 |
-
$this->_LOG("Finish parse" . FILE_PRODUCTS_PICTURES_GALLERY);
|
8114 |
-
} else {
|
8115 |
-
$this->_LOG("Wrong file" . $parse_file);
|
8116 |
-
}
|
8117 |
-
$this->_LOG(" ");
|
8118 |
-
|
8119 |
-
}
|
8120 |
-
#################################################################################################
|
8121 |
-
|
8122 |
-
function ParseRestrictedValues()
|
8123 |
-
{
|
8124 |
-
|
8125 |
-
$parse_file = $this->varDir . FILE_RESTRICTED_VALUES;
|
8126 |
-
if (filesize($parse_file) || $this->_ignore_restricted_values) {
|
8127 |
-
$this->_LOG("Start parse " . FILE_RESTRICTED_VALUES);
|
8128 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('restricted_values_temp'));
|
8129 |
-
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('restricted_values_temp') . " (
|
8130 |
-
restricted_value_id int(11),
|
8131 |
-
category_feature_id int(11),
|
8132 |
-
text text,
|
8133 |
-
display_order_number int(11),
|
8134 |
-
KEY(restricted_value_id),
|
8135 |
-
KEY(category_feature_id)
|
8136 |
-
)");
|
8137 |
-
if (!$this->_ignore_restricted_values) {
|
8138 |
-
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
8139 |
-
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('restricted_values_temp') . "
|
8140 |
-
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
8141 |
-
OPTIONALLY ENCLOSED BY '\"'
|
8142 |
-
LINES TERMINATED BY \"\r\n\"
|
8143 |
-
IGNORE 1 LINES ");
|
8144 |
-
}
|
8145 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values'));
|
8146 |
-
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('restricted_values_temp') . "
|
8147 |
-
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values'));
|
8148 |
-
|
8149 |
-
$this->_LOG("Finish parse " . FILE_RESTRICTED_VALUES);
|
8150 |
-
} else {
|
8151 |
-
$this->_LOG("Wrong file " . $parse_file);
|
8152 |
-
}
|
8153 |
-
$this->_LOG(" ");
|
8154 |
-
}
|
8155 |
-
|
8156 |
-
#################################################################################################
|
8157 |
-
|
8158 |
-
function ParseStockAndPrices()
|
8159 |
-
{
|
8160 |
-
|
8161 |
-
$parse_file = $this->varDir . FILE_STOCK_AND_PRICES;
|
8162 |
-
|
8163 |
-
if (filesize($parse_file)) {
|
8164 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp_before'));
|
8165 |
-
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp_before') . " (
|
8166 |
-
store_product_id int(11),
|
8167 |
-
stock int(11),
|
8168 |
-
price varchar(255),
|
8169 |
-
cost varchar(255),
|
8170 |
-
distributor_id int(11),
|
8171 |
-
KEY(store_product_id),
|
8172 |
-
KEY(distributor_id)
|
8173 |
-
)");
|
8174 |
-
|
8175 |
-
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
8176 |
-
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp_before') . "
|
8177 |
-
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
8178 |
-
OPTIONALLY ENCLOSED BY '\"'
|
8179 |
-
LINES TERMINATED BY \"\r\n\"
|
8180 |
-
IGNORE 1 LINES ");
|
8181 |
-
|
8182 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp'));
|
8183 |
-
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " (
|
8184 |
-
store_product_id int(11),
|
8185 |
-
stock int(11),
|
8186 |
-
price decimal(15,4),
|
8187 |
-
cost decimal(15,4),
|
8188 |
-
distributor_id int(11),
|
8189 |
-
KEY(store_product_id),
|
8190 |
-
KEY(distributor_id)
|
8191 |
-
)");
|
8192 |
-
|
8193 |
-
$this->db_do("
|
8194 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " (
|
8195 |
-
store_product_id,
|
8196 |
-
stock,
|
8197 |
-
price,
|
8198 |
-
cost,
|
8199 |
-
distributor_id
|
8200 |
-
)(
|
8201 |
-
SELECT
|
8202 |
-
store_product_id,
|
8203 |
-
stock,
|
8204 |
-
REPLACE(price, ',', '.'),
|
8205 |
-
REPLACE(cost, ',', '.' ),
|
8206 |
-
distributor_id
|
8207 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp_before') . "
|
8208 |
-
)
|
8209 |
-
");
|
8210 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp_before'));
|
8211 |
-
|
8212 |
-
$this->replaceMagentoProductsStockPrice();
|
8213 |
-
|
8214 |
-
$res = $this->db_do("SELECT count(*) as cnt
|
8215 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
8216 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " b
|
8217 |
-
ON a.store_product_id=b.store_product_id");
|
8218 |
-
$row = mysqli_fetch_assoc($res);
|
8219 |
-
$this->db_do("UPDATE " . $this->import_status_statistic_table . "
|
8220 |
-
SET number_of_products=" . $row['cnt'] . "
|
8221 |
-
WHERE id=" . $this->current_import_status_statistic_id);
|
8222 |
-
|
8223 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_stock_and_prices'));
|
8224 |
-
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . "
|
8225 |
-
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_stock_and_prices'));
|
8226 |
-
|
8227 |
-
$this->_LOG("Finish parse" . FILE_RELATED_PRODUCTS);
|
8228 |
-
} else {
|
8229 |
-
$this->_LOG("Wrong file" . $parse_file);
|
8230 |
-
}
|
8231 |
-
$this->_LOG(" ");
|
8232 |
-
}
|
8233 |
-
|
8234 |
-
#################################################################################################
|
8235 |
-
|
8236 |
-
function replaceMagentoProductsStockPrice()
|
8237 |
-
{
|
8238 |
-
//Add stock
|
8239 |
-
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
8240 |
-
$result = $this->db_do("DELETE csi
|
8241 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item') . " csi
|
8242 |
-
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
8243 |
-
ON csi.product_id=cpe.entity_id
|
8244 |
-
WHERE cpe.entity_id is null");
|
8245 |
-
//set all sinch products stock=0 before upgrade (nedds for dayly stock&price import)
|
8246 |
-
|
8247 |
-
$result = $this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
8248 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item') . " csi
|
8249 |
-
ON cpe.entity_id=csi.product_id
|
8250 |
-
SET
|
8251 |
-
csi.qty=0,
|
8252 |
-
csi.is_in_stock=0
|
8253 |
-
WHERE cpe.store_product_id IS NOT NULL");
|
8254 |
-
|
8255 |
-
$result = $this->db_do("
|
8256 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item') . " (
|
8257 |
-
product_id,
|
8258 |
-
stock_id,
|
8259 |
-
qty,
|
8260 |
-
is_in_stock,
|
8261 |
-
manage_stock
|
8262 |
-
)(
|
8263 |
-
SELECT
|
8264 |
-
a.entity_id,
|
8265 |
-
1,
|
8266 |
-
b.stock,
|
8267 |
-
IF(b.stock > 0, 1, 0),
|
8268 |
-
1
|
8269 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
8270 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " b
|
8271 |
-
ON a.store_product_id=b.store_product_id
|
8272 |
-
)
|
8273 |
-
ON DUPLICATE KEY UPDATE
|
8274 |
-
qty=b.stock,
|
8275 |
-
is_in_stock = IF(b.stock > 0, 1, 0),
|
8276 |
-
manage_stock = 1
|
8277 |
-
");
|
8278 |
-
|
8279 |
-
|
8280 |
-
$result = $this->db_do("DELETE FROM " . Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_status'));
|
8281 |
-
|
8282 |
-
$result = $this->db_do("
|
8283 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_status') . " (
|
8284 |
-
product_id,
|
8285 |
-
website_id,
|
8286 |
-
stock_id,
|
8287 |
-
qty,
|
8288 |
-
stock_status
|
8289 |
-
)(
|
8290 |
-
SELECT
|
8291 |
-
a.product_id,
|
8292 |
-
w.website_id,
|
8293 |
-
1,
|
8294 |
-
a.qty,
|
8295 |
-
IF(qty > 0, 1, 0)
|
8296 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item') . " a
|
8297 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " b
|
8298 |
-
ON a.product_id=b.entity_id
|
8299 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
8300 |
-
ON b.store_product_id=w.store_product_id
|
8301 |
-
)
|
8302 |
-
ON DUPLICATE KEY UPDATE
|
8303 |
-
qty=a.qty,
|
8304 |
-
stock_status = IF(a.qty > 0, 1, 0)
|
8305 |
-
");
|
8306 |
-
|
8307 |
-
//Add prices
|
8308 |
-
//$result = $this->db_do("truncate catalog_product_entity_decimal");
|
8309 |
-
$result = $this->db_do("DELETE cped
|
8310 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal') . " cped
|
8311 |
-
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
8312 |
-
ON cped.entity_id=cpe.entity_id
|
8313 |
-
WHERE cpe.entity_id IS NULL");
|
8314 |
-
|
8315 |
-
$result = $this->db_do("
|
8316 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal') . " (
|
8317 |
-
entity_type_id,
|
8318 |
-
attribute_id,
|
8319 |
-
store_id,
|
8320 |
-
entity_id,
|
8321 |
-
value
|
8322 |
-
)(
|
8323 |
-
SELECT
|
8324 |
-
" . $this->_getProductEntityTypeId() . ",
|
8325 |
-
" . $this->_getProductAttributeId('price') . ",
|
8326 |
-
w.website,
|
8327 |
-
a.entity_id,
|
8328 |
-
b.price
|
8329 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
8330 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " b
|
8331 |
-
ON a.store_product_id=b.store_product_id
|
8332 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
8333 |
-
ON a.store_product_id=w.store_product_id
|
8334 |
-
)
|
8335 |
-
ON DUPLICATE KEY UPDATE
|
8336 |
-
value = b.price
|
8337 |
-
");
|
8338 |
-
|
8339 |
-
$result = $this->db_do("
|
8340 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal') . " (
|
8341 |
-
entity_type_id,
|
8342 |
-
attribute_id,
|
8343 |
-
store_id,
|
8344 |
-
entity_id,
|
8345 |
-
value
|
8346 |
-
)(
|
8347 |
-
SELECT
|
8348 |
-
" . $this->_getProductEntityTypeId() . ",
|
8349 |
-
" . $this->_getProductAttributeId('price') . ",
|
8350 |
-
0,
|
8351 |
-
a.entity_id,
|
8352 |
-
b.price
|
8353 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
8354 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " b
|
8355 |
-
ON a.store_product_id=b.store_product_id
|
8356 |
-
)
|
8357 |
-
ON DUPLICATE KEY UPDATE
|
8358 |
-
value = b.price
|
8359 |
-
");
|
8360 |
-
//Add cost
|
8361 |
-
// $result = $this->db_do("truncate catalog_product_entity_decimal");
|
8362 |
-
$result = $this->db_do("
|
8363 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal') . " (
|
8364 |
-
entity_type_id,
|
8365 |
-
attribute_id,
|
8366 |
-
store_id,
|
8367 |
-
entity_id,
|
8368 |
-
value
|
8369 |
-
)(
|
8370 |
-
SELECT
|
8371 |
-
" . $this->_getProductEntityTypeId() . ",
|
8372 |
-
" . $this->_getProductAttributeId('cost') . ",
|
8373 |
-
w.website,
|
8374 |
-
a.entity_id,
|
8375 |
-
b.cost
|
8376 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
8377 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " b
|
8378 |
-
ON a.store_product_id=b.store_product_id
|
8379 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
8380 |
-
ON a.store_product_id=w.store_product_id
|
8381 |
-
)
|
8382 |
-
ON DUPLICATE KEY UPDATE
|
8383 |
-
value = b.cost
|
8384 |
-
");
|
8385 |
-
|
8386 |
-
$result = $this->db_do("
|
8387 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal') . " (
|
8388 |
-
entity_type_id,
|
8389 |
-
attribute_id,
|
8390 |
-
store_id,
|
8391 |
-
entity_id,
|
8392 |
-
value
|
8393 |
-
)(
|
8394 |
-
SELECT
|
8395 |
-
" . $this->_getProductEntityTypeId() . ",
|
8396 |
-
" . $this->_getProductAttributeId('cost') . ",
|
8397 |
-
0,
|
8398 |
-
a.entity_id,
|
8399 |
-
b.cost
|
8400 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
8401 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " b
|
8402 |
-
ON a.store_product_id=b.store_product_id
|
8403 |
-
)
|
8404 |
-
ON DUPLICATE KEY UPDATE
|
8405 |
-
value = b.cost
|
8406 |
-
");
|
8407 |
-
|
8408 |
-
//make products enable in FO
|
8409 |
-
// $result = $this->db_do(" truncate catalog_product_index_price");
|
8410 |
-
$result = $this->db_do("DELETE cpip
|
8411 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price') . " cpip
|
8412 |
-
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
8413 |
-
ON cpip.entity_id=cpe.entity_id
|
8414 |
-
WHERE cpe.entity_id IS NULL");
|
8415 |
-
|
8416 |
-
$q = "SELECT customer_group_id FROM " . Mage::getSingleton('core/resource')->getTableName('customer_group');
|
8417 |
-
$quer = $this->db_do($q);
|
8418 |
-
|
8419 |
-
while ($row = mysqli_fetch_assoc($quer)) {
|
8420 |
-
$result = $this->db_do("
|
8421 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price') . " (
|
8422 |
-
entity_id,
|
8423 |
-
customer_group_id,
|
8424 |
-
website_id,
|
8425 |
-
tax_class_id,
|
8426 |
-
price,
|
8427 |
-
final_price,
|
8428 |
-
min_price,
|
8429 |
-
max_price
|
8430 |
-
)(SELECT
|
8431 |
-
a.entity_id,
|
8432 |
-
" . $row['customer_group_id'] . ",
|
8433 |
-
w.website_id,
|
8434 |
-
2,
|
8435 |
-
b.price ,
|
8436 |
-
b.price ,
|
8437 |
-
b.price ,
|
8438 |
-
b.price
|
8439 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
8440 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp') . " b
|
8441 |
-
ON a.store_product_id=b.store_product_id
|
8442 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
8443 |
-
ON a.store_product_id=w.store_product_id
|
8444 |
-
)
|
8445 |
-
ON DUPLICATE KEY UPDATE
|
8446 |
-
tax_class_id = 2,
|
8447 |
-
price = b.price,
|
8448 |
-
final_price = b.price,
|
8449 |
-
min_price = b.price,
|
8450 |
-
max_price = b.price
|
8451 |
-
");
|
8452 |
-
}
|
8453 |
-
}
|
8454 |
-
|
8455 |
-
#################################################################################################
|
8456 |
-
|
8457 |
-
private function _cleanCateoryProductFlatTable()
|
8458 |
-
{
|
8459 |
-
$dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
|
8460 |
-
$q = 'SHOW TABLES LIKE "' . Mage::getSingleton('core/resource')->getTableName('catalog_product_flat_') . '%"';
|
8461 |
-
$quer = $this->db_do($q);
|
8462 |
-
$result = false;
|
8463 |
-
While ($row = mysqli_fetch_array($quer)) {
|
8464 |
-
if (is_array($row)) {
|
8465 |
-
$catalog_product_flat = array_pop($row);
|
8466 |
-
$q = 'DELETE pf1 FROM ' . $catalog_product_flat . ' pf1
|
8467 |
-
LEFT JOIN ' . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . ' p
|
8468 |
-
ON pf1.entity_id = p.entity_id
|
8469 |
-
WHERE p.entity_id IS NULL;';
|
8470 |
-
$this->db_do($q);
|
8471 |
-
$this->_LOG('cleaned wrong rows from ' . $catalog_product_flat);
|
8472 |
-
}
|
8473 |
-
}
|
8474 |
-
return $result;
|
8475 |
-
|
8476 |
-
}
|
8477 |
-
|
8478 |
-
#################################################################################################
|
8479 |
-
|
8480 |
-
public function runIndexer()
|
8481 |
-
{
|
8482 |
-
$this->db_do("DELETE FROM " . Mage::getSingleton('core/resource')->getTableName('core_url_rewrite'));
|
8483 |
-
$this->db_do("SET FOREIGN_KEY_CHECKS=0");
|
8484 |
-
$this->db_do("TRUNCATE TABLE " . Mage::getSingleton('core/resource')->getTableName('core_url_rewrite'));
|
8485 |
-
$this->db_do("SET FOREIGN_KEY_CHECKS=1");
|
8486 |
-
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . "
|
8487 |
-
SET value = ''
|
8488 |
-
WHERE entity_type_id=" . $this->_getProductEntityTypeId() . " AND attribute_id=" . $this->_getProductAttributeId('url_key'));
|
8489 |
-
exec(PHP_RUN_STRING . ' ' . $this->shellDir . 'indexer.php reindexall');
|
8490 |
-
}
|
8491 |
-
|
8492 |
-
#################################################################################################
|
8493 |
-
|
8494 |
-
function cron_start_full_import()
|
8495 |
-
{
|
8496 |
-
$this->import_run_type = 'CRON';
|
8497 |
-
$this->run_sinch_import();
|
8498 |
-
}
|
8499 |
-
|
8500 |
-
#################################################################################################
|
8501 |
-
|
8502 |
-
function cron_start_stock_price_import()
|
8503 |
-
{
|
8504 |
-
$this->import_run_type = 'CRON';
|
8505 |
-
$this->run_stock_price_sinch_import();
|
8506 |
-
}
|
8507 |
-
|
8508 |
-
##################################################################################################
|
8509 |
-
|
8510 |
-
function run_stock_price_sinch_import()
|
8511 |
-
{
|
8512 |
-
$safe_mode_set = ini_get('safe_mode');
|
8513 |
-
|
8514 |
-
$this->InitImportStatuses('PRICE STOCK');
|
8515 |
-
if ($safe_mode_set) {
|
8516 |
-
$this->_LOG('safe_mode is enable. import stoped.');
|
8517 |
-
$this->set_import_error_reporting_message('Safe_mode is enabled. Please check the documentation on how to fix this. Import stopped.');
|
8518 |
-
exit;
|
8519 |
-
}
|
8520 |
-
$store_proc = $this->check_store_procedure_exist();
|
8521 |
-
|
8522 |
-
if (!$store_proc) {
|
8523 |
-
$this->_LOG('store prcedure "' . Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s') . '" is absent in this database. import stoped.');
|
8524 |
-
$this->set_import_error_reporting_message('Stored procedure "' . Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s') . '" is absent in this database. Import stopped.');
|
8525 |
-
exit;
|
8526 |
-
}
|
8527 |
-
|
8528 |
-
$file_privileg = $this->check_db_privileges();
|
8529 |
-
|
8530 |
-
if (!$file_privileg) {
|
8531 |
-
$this->_LOG("Loaddata option not set - please check the documentation on how to fix this. You dan't have privileges for LOAD DATA.");
|
8532 |
-
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
8533 |
-
exit;
|
8534 |
-
}
|
8535 |
-
$local_infile = $this->check_local_infile();
|
8536 |
-
if (!$local_infile) {
|
8537 |
-
$this->_LOG("Loaddata option not set - please check the documentation on how to fix this. Add this string to 'set-variable=local-infile=0' in '/etc/my.cnf'");
|
8538 |
-
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
8539 |
-
exit;
|
8540 |
-
}
|
8541 |
-
|
8542 |
-
if ($this->is_imort_not_run() && $this->is_full_import_have_been_run()) {
|
8543 |
-
try {
|
8544 |
-
//$this->InitImportStatuses();
|
8545 |
-
$q = "SELECT GET_LOCK('sinchimport', 30)";
|
8546 |
-
$quer = $this->db_do($q);
|
8547 |
-
$import = $this;
|
8548 |
-
$import->addImportStatus('Stock Price Start Import');
|
8549 |
-
echo "Upload Files <br>";
|
8550 |
-
$this->files = array(
|
8551 |
-
FILE_STOCK_AND_PRICES,
|
8552 |
-
FILE_PRICE_RULES
|
8553 |
-
);
|
8554 |
-
|
8555 |
-
$import->UploadFiles();
|
8556 |
-
$import->addImportStatus('Stock Price Upload Files');
|
8557 |
-
|
8558 |
-
echo "Parse Stock And Prices <br>";
|
8559 |
-
//exit;
|
8560 |
-
$import->ParseStockAndPrices();
|
8561 |
-
$import->addImportStatus('Stock Price Parse Products');
|
8562 |
-
|
8563 |
-
echo "Apply Customer Group Price <br>";
|
8564 |
-
//$import->ParsePriceRules();
|
8565 |
-
//$import->AddPriceRules();
|
8566 |
-
//$import->ApplyCustomerGroupPrice();
|
8567 |
-
|
8568 |
-
$ftpCred = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
8569 |
-
Mage::dispatchEvent('sinch_pricerules_import_ftp', array(
|
8570 |
-
'ftp_host' => $ftpCred["ftp_server"],
|
8571 |
-
'ftp_username' => $ftpCred["login"],
|
8572 |
-
'ftp_password' => $ftpCred["password"]
|
8573 |
-
));
|
8574 |
-
|
8575 |
-
|
8576 |
-
Mage::log("Finish Stock & Price Sinch import", null, $this->_logFile);
|
8577 |
-
echo "Finish Stock & Price Sinch import<br>";
|
8578 |
-
|
8579 |
-
Mage::log("Start indexing Stock & Price", null, $this->_logFile);
|
8580 |
-
echo "Start indexing Stock & Price<br>";
|
8581 |
-
$import->_cleanCateoryProductFlatTable();
|
8582 |
-
$import->runStockPriceIndexer();
|
8583 |
-
Mage::log("Finish indexing Stock & Price", null, $this->_logFile);
|
8584 |
-
$import->addImportStatus('Stock Price Indexing data');
|
8585 |
-
$import->addImportStatus('Stock Price Finish import', 1);
|
8586 |
-
echo "Finish indexing Stock & Price<br>";
|
8587 |
-
|
8588 |
-
$q = "SELECT RELEASE_LOCK('sinchimport')";
|
8589 |
-
$quer = $this->db_do($q);
|
8590 |
-
} catch (Exception $e) {
|
8591 |
-
$this->set_import_error_reporting_message($e);
|
8592 |
-
}
|
8593 |
-
} else {
|
8594 |
-
if (!$this->is_imort_not_run()) {
|
8595 |
-
Mage::log("Sinchimport already run", null, $this->_logFile);
|
8596 |
-
echo "Sinchimport already run<br>";
|
8597 |
-
} else {
|
8598 |
-
Mage::log("Full import have never finished with success", null, $this->_logFile);
|
8599 |
-
echo "Full import have never finished with success<br>";
|
8600 |
-
}
|
8601 |
-
}
|
8602 |
-
|
8603 |
-
}
|
8604 |
-
|
8605 |
-
##################################################################################################
|
8606 |
-
|
8607 |
-
function is_full_import_have_been_run()
|
8608 |
-
{
|
8609 |
-
$q = "SELECT COUNT(*) AS cnt
|
8610 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic') . "
|
8611 |
-
WHERE import_type='FULL' AND global_status_import='Successful'";
|
8612 |
-
$quer = $this->db_do($q);
|
8613 |
-
$row = mysqli_fetch_array($quer);
|
8614 |
-
if ($row['cnt'] > 0) {
|
8615 |
-
return true;
|
8616 |
-
} else {
|
8617 |
-
return false;
|
8618 |
-
}
|
8619 |
-
}
|
8620 |
-
|
8621 |
-
##################################################################################################
|
8622 |
-
|
8623 |
-
public function runStockPriceIndexer()
|
8624 |
-
{
|
8625 |
-
exec(PHP_RUN_STRING . ' ' . $this->shellDir . 'indexer.php --reindex catalog_product_price,cataloginventory_stock');
|
8626 |
-
}
|
8627 |
-
|
8628 |
-
##################################################################################################
|
8629 |
-
|
8630 |
-
function ParsePriceRules()
|
8631 |
-
{
|
8632 |
-
$parse_file = $this->varDir . FILE_PRICE_RULES;
|
8633 |
-
if (filesize($parse_file) || $this->_ignore_price_rules) {
|
8634 |
-
$this->_LOG("Start parse " . FILE_PRICE_RULES);
|
8635 |
-
|
8636 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp'));
|
8637 |
-
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . "(
|
8638 |
-
`id` int(11) NOT NULL,
|
8639 |
-
`price_from` decimal(10,2) DEFAULT NULL,
|
8640 |
-
`price_to` decimal(10,2) DEFAULT NULL,
|
8641 |
-
`category_id` int(10) unsigned DEFAULT NULL,
|
8642 |
-
`vendor_id` int(11) DEFAULT NULL,
|
8643 |
-
`vendor_product_id` varchar(255) DEFAULT NULL,
|
8644 |
-
`customergroup_id` varchar(32) DEFAULT NULL,
|
8645 |
-
`marge` decimal(10,2) DEFAULT NULL,
|
8646 |
-
`fixed` decimal(10,2) DEFAULT NULL,
|
8647 |
-
`final_price` decimal(10,2) DEFAULT NULL,
|
8648 |
-
PRIMARY KEY (`id`),
|
8649 |
-
UNIQUE KEY `price_from` (`price_from`,`price_to`,`vendor_id`,`category_id`,`vendor_product_id`,`customergroup_id`),
|
8650 |
-
KEY `vendor_product_id` (`vendor_product_id`),
|
8651 |
-
KEY `category_id` (`category_id`)
|
8652 |
-
)
|
8653 |
-
");
|
8654 |
-
if (!$this->_ignore_price_rules) {
|
8655 |
-
|
8656 |
-
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
8657 |
-
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . "
|
8658 |
-
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
8659 |
-
OPTIONALLY ENCLOSED BY '\"'
|
8660 |
-
LINES TERMINATED BY \"\r\n\"
|
8661 |
-
IGNORE 1 LINES
|
8662 |
-
(id, @vprice_from, @vprice_to, @vcategory_id, @vvendor_id, @vvendor_product_id, @vcustomergroup_id, @vmarge, @vfixed, @vfinal_price)
|
8663 |
-
SET price_from = nullif(@vprice_from,''),
|
8664 |
-
price_to = nullif(@vprice_to,''),
|
8665 |
-
category_id = nullif(@vcategory_id,''),
|
8666 |
-
vendor_id = nullif(@vvendor_id,''),
|
8667 |
-
vendor_product_id = nullif(@vvendor_product_id,''),
|
8668 |
-
customergroup_id = nullif(@vcustomergroup_id,''),
|
8669 |
-
marge = nullif(@vmarge,''),
|
8670 |
-
fixed = nullif(@vfixed,''),
|
8671 |
-
final_price = nullif(@vfinal_price,'')
|
8672 |
-
");
|
8673 |
-
}
|
8674 |
-
|
8675 |
-
$this->db_do("ALTER TABLE " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . "
|
8676 |
-
ADD COLUMN `shop_category_id` int(10) unsigned DEFAULT NULL,
|
8677 |
-
ADD COLUMN `shop_vendor_id` int(11) DEFAULT NULL,
|
8678 |
-
ADD COLUMN `shop_vendor_product_id` varchar(255) DEFAULT NULL,
|
8679 |
-
ADD COLUMN `shop_customergroup_id` varchar(32) DEFAULT NULL
|
8680 |
-
");
|
8681 |
-
|
8682 |
-
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . " prt
|
8683 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . " cce
|
8684 |
-
ON prt.category_id = cce.store_category_id
|
8685 |
-
SET prt.shop_category_id = cce.entity_id");
|
8686 |
-
|
8687 |
-
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . " prt
|
8688 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers') . " sicm
|
8689 |
-
ON prt.vendor_id = sicm.sinch_manufacturer_id
|
8690 |
-
SET prt.shop_vendor_id = sicm.shop_option_id");
|
8691 |
-
|
8692 |
-
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . " prt
|
8693 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping') . " sicpm
|
8694 |
-
ON prt.vendor_product_id = sicpm.product_sku
|
8695 |
-
SET prt.shop_vendor_product_id = sicpm.sku");
|
8696 |
-
|
8697 |
-
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . " prt
|
8698 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('customer_group') . " cg
|
8699 |
-
ON prt.customergroup_id = cg.customer_group_id
|
8700 |
-
SET prt.shop_customergroup_id = cg.customer_group_id");
|
8701 |
-
|
8702 |
-
$this->db_do("DELETE FROM " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . "
|
8703 |
-
WHERE
|
8704 |
-
(category_id IS NOT NULL AND shop_category_id IS NULL) OR
|
8705 |
-
(vendor_id IS NOT NULL AND shop_vendor_id IS NULL) OR
|
8706 |
-
(vendor_product_id IS NOT NULL AND shop_vendor_product_id IS NULL) OR
|
8707 |
-
(customergroup_id IS NOT NULL AND shop_customergroup_id IS NULL)
|
8708 |
-
");
|
8709 |
-
|
8710 |
-
|
8711 |
-
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_price_rules'));
|
8712 |
-
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('price_rules_temp') . "
|
8713 |
-
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_price_rules'));
|
8714 |
-
|
8715 |
-
$this->_LOG("Finish parse " . FILE_PRICE_RULES);
|
8716 |
-
} else {
|
8717 |
-
$this->_LOG("Wrong file " . $parse_file);
|
8718 |
-
}
|
8719 |
-
$this->_LOG(" ");
|
8720 |
-
}
|
8721 |
-
|
8722 |
-
#################################################################################################
|
8723 |
-
|
8724 |
-
function AddPriceRules()
|
8725 |
-
{
|
8726 |
-
if (!$this->check_table_exist('import_pricerules_standards')) {
|
8727 |
-
return;
|
8728 |
-
}
|
8729 |
-
|
8730 |
-
$result = $this->db_do("
|
8731 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('import_pricerules') . " (
|
8732 |
-
id,
|
8733 |
-
price_from,
|
8734 |
-
price_to,
|
8735 |
-
vendor_id,
|
8736 |
-
category_id,
|
8737 |
-
vendor_product_id,
|
8738 |
-
customergroup_id,
|
8739 |
-
marge,
|
8740 |
-
fixed,
|
8741 |
-
final_price
|
8742 |
-
)(SELECT
|
8743 |
-
id,
|
8744 |
-
price_from,
|
8745 |
-
price_to,
|
8746 |
-
shop_vendor_id,
|
8747 |
-
shop_category_id,
|
8748 |
-
shop_vendor_product_id,
|
8749 |
-
shop_customergroup_id,
|
8750 |
-
marge,
|
8751 |
-
fixed,
|
8752 |
-
final_price
|
8753 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_price_rules') . " a
|
8754 |
-
)
|
8755 |
-
ON DUPLICATE KEY UPDATE
|
8756 |
-
id = a.id,
|
8757 |
-
price_from = a.price_from,
|
8758 |
-
price_to = a.price_to,
|
8759 |
-
vendor_id = a.shop_vendor_id,
|
8760 |
-
category_id = a.shop_category_id,
|
8761 |
-
vendor_product_id = a.shop_vendor_product_id,
|
8762 |
-
customergroup_id = a.shop_customergroup_id,
|
8763 |
-
marge = a.marge,
|
8764 |
-
fixed = a.fixed,
|
8765 |
-
final_price = a.final_price
|
8766 |
-
");
|
8767 |
-
|
8768 |
-
}
|
8769 |
-
|
8770 |
-
#################################################################################################
|
8771 |
-
|
8772 |
-
private function check_table_exist($table)
|
8773 |
-
{
|
8774 |
-
|
8775 |
-
$q = "SHOW TABLES LIKE \"%" . Mage::getSingleton('core/resource')->getTableName($table) . "%\"";
|
8776 |
-
// echo $q;
|
8777 |
-
$quer = $this->db_do($q);
|
8778 |
-
$i = 0;
|
8779 |
-
while ($row = mysqli_fetch_array($quer)) {
|
8780 |
-
$i++;
|
8781 |
-
}
|
8782 |
-
return ($i);
|
8783 |
-
}
|
8784 |
-
|
8785 |
-
#################################################################################################
|
8786 |
-
|
8787 |
-
function ApplyCustomerGroupPrice()
|
8788 |
-
{
|
8789 |
-
if (!$this->check_table_exist('import_pricerules_standards')) {
|
8790 |
-
return;
|
8791 |
-
}
|
8792 |
-
$this->_getProductsForCustomerGroupPrice();
|
8793 |
-
$pricerulesArray = $this->_getPricerulesList();
|
8794 |
-
if (is_array($pricerulesArray)) {
|
8795 |
-
$this->db_do("TRUNCATE TABLE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_group_price'));
|
8796 |
-
$this->db_do("TRUNCATE TABLE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_index_group_price'));
|
8797 |
-
|
8798 |
-
}
|
8799 |
-
// $i=1;
|
8800 |
-
foreach ($pricerulesArray as $pricerule) {
|
8801 |
-
$this->_LOG("Calculation group price for rule " . $pricerule['id'] . "
|
8802 |
-
(\nname = " . $pricerule['name'] . "
|
8803 |
-
\nfinal_price = " . $pricerule['final_price'] . "
|
8804 |
-
\nprice_from = " . $pricerule['price_from'] . "
|
8805 |
-
\nprice_to = " . $pricerule['price_to'] . "
|
8806 |
-
\nvendor_id = " . $pricerule['vendor_id'] . "
|
8807 |
-
\ncategory_id = " . $pricerule['category_id'] . "
|
8808 |
-
\nproduct_entity_id = " . $pricerule['product_entity_id'] . "
|
8809 |
-
\nvendor_product_id = " . $pricerule['vendor_product_id'] . "
|
8810 |
-
\ncustomergroup_id = " . $pricerule['customergroup_id'] . "
|
8811 |
-
\ndistributor_id = " . $pricerule['distributor_id'] . "
|
8812 |
-
\nrating = " . $pricerule['rating'] . "
|
8813 |
-
\nmarge = " . $pricerule['marge'] . "
|
8814 |
-
\nfixed = " . $pricerule['fixed'] . "
|
8815 |
-
\nallow_subcat = " . $pricerule['allow_subcat'] . "
|
8816 |
-
\nstore_id = " . $pricerule['store_id'] . "
|
8817 |
-
)");
|
8818 |
-
|
8819 |
-
$vendor_product_id_str = "'" . str_replace(';', "','", $pricerule['vendor_product_id']) . "'";
|
8820 |
-
$where = "";
|
8821 |
-
if (empty($pricerule['marge'])) $marge = "NULL";
|
8822 |
-
else $marge = $pricerule['marge'];
|
8823 |
-
|
8824 |
-
if (empty($pricerule['fixed'])) $fixed = "NULL";
|
8825 |
-
else $fixed = $pricerule['fixed'];
|
8826 |
-
|
8827 |
-
if (empty($pricerule['final_price'])) $final_price = "NULL";
|
8828 |
-
else $final_price = $pricerule['final_price'];
|
8829 |
-
|
8830 |
-
if (!empty($pricerule['price_from'])) $where .= " AND a.price > " . $pricerule['price_from'];
|
8831 |
-
|
8832 |
-
if (!empty($pricerule['price_to'])) $where .= " AND a.price < " . $pricerule['price_to'];
|
8833 |
-
|
8834 |
-
if (!empty($pricerule['vendor_id'])) $where .= " AND a.manufacturer_id = " . $pricerule['vendor_id'];
|
8835 |
-
|
8836 |
-
//if(!empty($pricerule['vendor_product_id']))
|
8837 |
-
// $where.= " AND vendor_product_id = ".$pricerule['vendor_product_id'];
|
8838 |
-
if (!empty($pricerule['product_entity_id'])) $where .= " AND a.product_id = '" . $pricerule['product_entity_id'] . "'";
|
8839 |
-
|
8840 |
-
// if (!empty($pricerule['vendor_product_id'])) $where.= " AND a.sku = '".$pricerule['vendor_product_id']."'";
|
8841 |
-
if (!empty($pricerule['vendor_product_id'])) $where .= " AND a.sku IN (" . $vendor_product_id_str . ")";
|
8842 |
-
|
8843 |
-
if (!empty($pricerule['allow_subcat'])) {
|
8844 |
-
if (!empty($pricerule['category_id'])) {
|
8845 |
-
$children_cat = $this->get_all_children_cat($pricerule['category_id']);
|
8846 |
-
$where .= " AND a.category_id IN (" . $children_cat . ")";
|
8847 |
-
}
|
8848 |
-
} else {
|
8849 |
-
if (!empty($pricerule['category_id'])) $where .= " AND a.category_id = " . $pricerule['category_id'];
|
8850 |
-
}
|
8851 |
-
|
8852 |
-
|
8853 |
-
// if (!empty($pricerule['store_id'])) $where.= " AND store_id = ".$pricerule['store_id'];
|
8854 |
-
|
8855 |
-
// if (!empty($pricerule['distributor_id'])) $where.= " AND distributor_id = ".$pricerule['distributor_id'];
|
8856 |
-
|
8857 |
-
// $this->createCalcPriceFunc();
|
8858 |
-
//echo "\n\nAAAAAAAAAAAAAAAAAAAAa".$pricerule['customergroup_id']."----------";
|
8859 |
-
$customer_group_id_array = array();
|
8860 |
-
if (strstr($pricerule['customergroup_id'], ",")) {
|
8861 |
-
//echo "55555555555555555";
|
8862 |
-
$customer_group_id_array = explode(",", $pricerule['customergroup_id']);
|
8863 |
-
} else {
|
8864 |
-
$customer_group_id_array[0] = $pricerule['customergroup_id'];
|
8865 |
-
}
|
8866 |
-
// var_dump($pricerule);
|
8867 |
-
// echo "CCCCCCC\n";
|
8868 |
-
// var_dump($customer_group_id_array);
|
8869 |
-
foreach ($customer_group_id_array as $customer_group_id) {
|
8870 |
-
if (isset($customer_group_id) && $customer_group_id >= 0) {
|
8871 |
-
$query = "
|
8872 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_group_price') . " (entity_id,
|
8873 |
-
all_groups,
|
8874 |
-
customer_group_id,
|
8875 |
-
value,
|
8876 |
-
website_id
|
8877 |
-
)
|
8878 |
-
(SELECT
|
8879 |
-
a.product_id,
|
8880 |
-
0,
|
8881 |
-
" . $customer_group_id . ",
|
8882 |
-
" . Mage::getSingleton('core/resource')->getTableName('func_calc_price') . "(
|
8883 |
-
a.price,
|
8884 |
-
" . $marge . " ,
|
8885 |
-
" . $fixed . ",
|
8886 |
-
" . $final_price . "),
|
8887 |
-
0
|
8888 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp') . " a
|
8889 |
-
WHERE true " . $where . "
|
8890 |
-
)
|
8891 |
-
ON DUPLICATE KEY UPDATE
|
8892 |
-
value =
|
8893 |
-
" . Mage::getSingleton('core/resource')->getTableName('func_calc_price') . "(
|
8894 |
-
a.price,
|
8895 |
-
" . $marge . " ,
|
8896 |
-
" . $fixed . ",
|
8897 |
-
" . $final_price . ")
|
8898 |
-
";
|
8899 |
-
// echo "\n\n".$query;
|
8900 |
-
$this->db_do($query);
|
8901 |
-
if (!empty($pricerule['store_id']) && $pricerule['store_id'] > 0) {
|
8902 |
-
$query = "
|
8903 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_index_group_price') . " (entity_id,
|
8904 |
-
customer_group_id,
|
8905 |
-
price,
|
8906 |
-
website_id
|
8907 |
-
)
|
8908 |
-
(SELECT
|
8909 |
-
a.product_id,
|
8910 |
-
" . $customer_group_id . ",
|
8911 |
-
" . Mage::getSingleton('core/resource')->getTableName('func_calc_price') . "(
|
8912 |
-
a.price,
|
8913 |
-
" . $marge . " ,
|
8914 |
-
" . $fixed . ",
|
8915 |
-
" . $final_price . "),
|
8916 |
-
" . $pricerule['store_id'] . "
|
8917 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp') . " a
|
8918 |
-
WHERE true " . $where . "
|
8919 |
-
)
|
8920 |
-
ON DUPLICATE KEY UPDATE
|
8921 |
-
price =
|
8922 |
-
" . Mage::getSingleton('core/resource')->getTableName('func_calc_price') . "(
|
8923 |
-
a.price,
|
8924 |
-
" . $marge . " ,
|
8925 |
-
" . $fixed . ",
|
8926 |
-
" . $final_price . ")
|
8927 |
-
";
|
8928 |
-
// echo "\n\n".$query;
|
8929 |
-
$this->db_do($query);
|
8930 |
-
|
8931 |
-
}
|
8932 |
-
}
|
8933 |
-
}
|
8934 |
-
}
|
8935 |
-
|
8936 |
-
}
|
8937 |
-
|
8938 |
-
#################################################################################################
|
8939 |
-
|
8940 |
-
function _getProductsForCustomerGroupPrice()
|
8941 |
-
{
|
8942 |
-
// TEMPORARY
|
8943 |
-
$this->db_do(" DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp'));
|
8944 |
-
$this->db_do("
|
8945 |
-
CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp') . "
|
8946 |
-
(
|
8947 |
-
`category_id` int(10) unsigned NOT NULL default '0',
|
8948 |
-
`product_id` int(10) unsigned NOT NULL default '0',
|
8949 |
-
`store_product_id` int(10) NOT NULL default '0',
|
8950 |
-
`sku` varchar(64) DEFAULT NULL COMMENT 'SKU',
|
8951 |
-
`manufacturer_id` int(10) NOT NULL default '0',
|
8952 |
-
`price` decimal(15,4) DEFAULT NULL,
|
8953 |
-
UNIQUE KEY `UNQ_CATEGORY_PRODUCT` (`product_id`,`category_id`),
|
8954 |
-
KEY `CATALOG_CATEGORY_PRODUCT_CATEGORY` (`category_id`),
|
8955 |
-
KEY `CATALOG_CATEGORY_PRODUCT_PRODUCT` (`product_id`)
|
8956 |
-
)");
|
8957 |
-
|
8958 |
-
$result = $this->db_do("
|
8959 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp') . "
|
8960 |
-
(category_id, product_id, store_product_id, sku)
|
8961 |
-
(SELECT
|
8962 |
-
ccp.category_id,
|
8963 |
-
ccp.product_id,
|
8964 |
-
cpe.store_product_id,
|
8965 |
-
cpe.sku
|
8966 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " ccp
|
8967 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
8968 |
-
ON ccp.product_id = cpe.entity_id
|
8969 |
-
WHERE cpe.store_product_id IS NOT NULL)");
|
8970 |
-
|
8971 |
-
$result = $this->db_do("
|
8972 |
-
UPDATE " . Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp') . " pfcgpt
|
8973 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " cpei
|
8974 |
-
ON pfcgpt.product_id = cpei.entity_id
|
8975 |
-
AND cpei.entity_type_id = " . $this->_getProductEntityTypeId() . "
|
8976 |
-
AND cpei.attribute_id = " . $this->_getProductAttributeId('manufacturer') . "
|
8977 |
-
SET pfcgpt.manufacturer_id = cpei.value
|
8978 |
-
");
|
8979 |
-
|
8980 |
-
$result = $this->db_do("
|
8981 |
-
UPDATE " . Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp') . " pfcgpt
|
8982 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal') . " cped
|
8983 |
-
ON pfcgpt.product_id = cped.entity_id
|
8984 |
-
AND cped.entity_type_id = " . $this->_getProductEntityTypeId() . "
|
8985 |
-
AND cped.attribute_id = " . $this->_getProductAttributeId('price') . "
|
8986 |
-
SET pfcgpt.price = cped.value
|
8987 |
-
");
|
8988 |
-
|
8989 |
-
|
8990 |
-
}
|
8991 |
-
#################################################################################################
|
8992 |
-
|
8993 |
-
protected function _getPricerulesList()
|
8994 |
-
{
|
8995 |
-
$rulesArray = array();
|
8996 |
-
$result = $this->db_do("
|
8997 |
-
SELECT *
|
8998 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('import_pricerules') . "
|
8999 |
-
ORDER BY rating DESC
|
9000 |
-
");
|
9001 |
-
while ($row = mysqli_fetch_assoc($result)) {
|
9002 |
-
$rulesArray[$row['id']] = $row;
|
9003 |
-
}
|
9004 |
-
return $rulesArray;
|
9005 |
-
}
|
9006 |
-
|
9007 |
-
#################################################################################################
|
9008 |
-
|
9009 |
-
private function get_all_children_cat($entity_id)
|
9010 |
-
{
|
9011 |
-
$children_cat = "'" . $entity_id . "'" . $this->get_all_children_cat_recursive($entity_id);
|
9012 |
-
return ($children_cat);
|
9013 |
-
}
|
9014 |
-
|
9015 |
-
#################################################################################################
|
9016 |
-
|
9017 |
-
private function get_all_children_cat_recursive($entity_id)
|
9018 |
-
{
|
9019 |
-
$q = "SELECT entity_id
|
9020 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . "
|
9021 |
-
WHERE parent_id=" . $entity_id;
|
9022 |
-
$quer = $this->db_do($q);
|
9023 |
-
$children_cat = '';
|
9024 |
-
while ($row = mysqli_fetch_array($quer)) {
|
9025 |
-
$children_cat .= ", '" . $row['entity_id'] . "'";
|
9026 |
-
$children_cat .= $this->get_all_children_cat_recursive($row['entity_id']);
|
9027 |
-
}
|
9028 |
-
return ($children_cat);
|
9029 |
-
}
|
9030 |
-
|
9031 |
-
#################################################################################################
|
9032 |
-
|
9033 |
-
function getProductDescription($entity_id)
|
9034 |
-
{
|
9035 |
-
|
9036 |
-
$this->loadProductParams($entity_id);
|
9037 |
-
$this->loadProductStarfeatures($entity_id);
|
9038 |
-
$this->loadGalleryPhotos($entity_id);
|
9039 |
-
Varien_Profiler::start('Bintime FILE RELATED');
|
9040 |
-
$this->loadRelatedProducts($entity_id);
|
9041 |
-
Varien_Profiler::stop('Bintime FILE RELATED');
|
9042 |
-
|
9043 |
-
return true;
|
9044 |
-
}
|
9045 |
-
|
9046 |
-
#################################################################################################
|
9047 |
-
|
9048 |
-
private function loadProductParams($entity_id)
|
9049 |
-
{
|
9050 |
-
$store_product_id = $this->getStoreProductIdByEntity($entity_id);
|
9051 |
-
if (!$store_product_id) {
|
9052 |
-
// echo "AAAAAAA"; exit;
|
9053 |
-
return;
|
9054 |
-
}
|
9055 |
-
$q = "SELECT
|
9056 |
-
sinch_product_id,
|
9057 |
-
product_sku,
|
9058 |
-
product_name,
|
9059 |
-
sinch_manufacturer_id,
|
9060 |
-
store_category_id,
|
9061 |
-
main_image_url,
|
9062 |
-
thumb_image_url,
|
9063 |
-
medium_image_url,
|
9064 |
-
specifications,
|
9065 |
-
description,
|
9066 |
-
specifications
|
9067 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_products') . "
|
9068 |
-
WHERE store_product_id =" . $store_product_id;
|
9069 |
-
$quer = $this->db_do($q);
|
9070 |
-
$product = mysqli_fetch_array($quer);
|
9071 |
-
|
9072 |
-
$this->productDescription = (string)substr($product['description'], 50, 0);
|
9073 |
-
$this->fullProductDescription = (string)$product['description'];
|
9074 |
-
$this->lowPicUrl = (string)$product["medium_image_url"];//thumb_image_url"];
|
9075 |
-
$this->highPicUrl = (string)$product["main_image_url"];
|
9076 |
-
$this->productName = (string)$product["product_name"];
|
9077 |
-
$this->productId = (string)$product['product_sku'];
|
9078 |
-
$this->specifications = (string)$product['specifications'];
|
9079 |
-
$this->sinchProductId = (string)$product['sinch_product_id'];
|
9080 |
-
if ($product['sinch_manufacturer_id']) {
|
9081 |
-
$q = "SELECT manufacturer_name
|
9082 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers') . "
|
9083 |
-
WHERE sinch_manufacturer_id=" . $product['sinch_manufacturer_id'];
|
9084 |
-
$quer = $this->db_do($q);
|
9085 |
-
$manufacturer = mysqli_fetch_array($quer);
|
9086 |
-
$this->vendor = (string)$manufacturer['manufacturer_name'];
|
9087 |
-
}
|
9088 |
-
$q = "SELECT DISTINCT ean_code
|
9089 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_ean_codes') . " sec
|
9090 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products') . " sp
|
9091 |
-
ON sec.product_id=sp.sinch_product_id
|
9092 |
-
WHERE sp.store_product_id=" . $store_product_id;
|
9093 |
-
$quer = $this->db_do($q);
|
9094 |
-
while ($row = mysqli_fetch_array($quer)) {
|
9095 |
-
$EANarr[] = $row['ean_code'];
|
9096 |
-
}
|
9097 |
-
// $prodEAN = $productTag->EANCode;
|
9098 |
-
$EANstr = '';
|
9099 |
-
/* $EANarr=null;
|
9100 |
-
foreach($prodEAN as $ellEAN){
|
9101 |
-
$EANarr[]=$ellEAN['EAN'];
|
9102 |
-
}
|
9103 |
-
*/
|
9104 |
-
$EANstr = implode(", ", $EANarr);
|
9105 |
-
$this->EAN = (string)$EANstr;//$productTag->EANCode['EAN'];
|
9106 |
-
}
|
9107 |
-
|
9108 |
-
#################################################################################################
|
9109 |
-
|
9110 |
-
private function getStoreProductIdByEntity($entity_id)
|
9111 |
-
{
|
9112 |
-
$q = $this->db_do("SELECT store_product_id
|
9113 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping') . "
|
9114 |
-
WHERE entity_id=" . $entity_id);
|
9115 |
-
$res = mysqli_fetch_array($q);
|
9116 |
-
// echo $entity_id."AAAA".$res['store_product_id']; exit;
|
9117 |
-
return ($res['store_product_id']);
|
9118 |
-
}
|
9119 |
-
|
9120 |
-
#################################################################################################
|
9121 |
-
|
9122 |
-
private function loadProductStarfeatures($entity_id)
|
9123 |
-
{
|
9124 |
-
$descriptionArray = array();
|
9125 |
-
$product_info_features = $this->db_do("
|
9126 |
-
SELECT c.feature_name AS name, b.text AS value
|
9127 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_product_features') . " a
|
9128 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values') . " b
|
9129 |
-
ON a.restricted_value_id = b.restricted_value_id
|
9130 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_features') . " c
|
9131 |
-
ON b.category_feature_id = c.category_feature_id
|
9132 |
-
WHERE a.sinch_product_id = '" . $this->sinchProductId . "'");
|
9133 |
-
while ($features = mysqli_fetch_array($product_info_features)) {
|
9134 |
-
$descriptionArray[$features['name']] = $features['value'];
|
9135 |
-
}
|
9136 |
-
|
9137 |
-
|
9138 |
-
$this->productDescriptionList = $descriptionArray;
|
9139 |
-
}
|
9140 |
-
|
9141 |
-
#################################################################################################
|
9142 |
-
|
9143 |
-
/**
|
9144 |
-
* load Gallery array from XML
|
9145 |
-
*/
|
9146 |
-
public function loadGalleryPhotos($entity_id)
|
9147 |
-
{
|
9148 |
-
/*$galleryPhotos = $this->simpleDoc->Product->ProductGallery->ProductPicture;
|
9149 |
-
if (!count($galleryPhotos)){
|
9150 |
-
return false;
|
9151 |
-
}
|
9152 |
-
*/
|
9153 |
-
$store_product_id = $this->getStoreProductIdByEntity($entity_id);
|
9154 |
-
if (!$store_product_id) {
|
9155 |
-
return;
|
9156 |
-
}
|
9157 |
-
$q = $this->db_do("SELECT COUNT(*) AS cnt
|
9158 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery') . "
|
9159 |
-
WHERE store_product_id=" . $store_product_id);
|
9160 |
-
|
9161 |
-
$res = mysqli_fetch_array($q);
|
9162 |
-
if (!$res || !$res['cnt']) {
|
9163 |
-
return false;
|
9164 |
-
}
|
9165 |
-
$q = "SELECT
|
9166 |
-
image_url as Pic,
|
9167 |
-
thumb_image_url as ThumbPic
|
9168 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery') . "
|
9169 |
-
WHERE store_product_id=" . $store_product_id;
|
9170 |
-
|
9171 |
-
$res = $this->db_do($q);
|
9172 |
-
|
9173 |
-
while ($photo = mysqli_fetch_array($res)) {
|
9174 |
-
$picHeight = (int)500;//$photo["PicHeight"];
|
9175 |
-
$picWidth = (int)500;//$photo["PicWidth"];
|
9176 |
-
$thumbUrl = (string)$photo["ThumbPic"];
|
9177 |
-
$picUrl = (string)$photo["Pic"];
|
9178 |
-
|
9179 |
-
array_push($this->galleryPhotos, array(
|
9180 |
-
'height' => $picHeight,
|
9181 |
-
'width' => $picWidth,
|
9182 |
-
'thumb' => $thumbUrl,
|
9183 |
-
'pic' => $picUrl
|
9184 |
-
));
|
9185 |
-
}
|
9186 |
-
}
|
9187 |
-
|
9188 |
-
#################################################################################################
|
9189 |
-
|
9190 |
-
private function loadRelatedProducts($entity_id)
|
9191 |
-
{
|
9192 |
-
$this->sinchProductId;
|
9193 |
-
if (!$this->sinchProductId) {
|
9194 |
-
return;
|
9195 |
-
}
|
9196 |
-
$q = "SELECT
|
9197 |
-
st_prod.sinch_product_id,
|
9198 |
-
st_prod.product_sku,
|
9199 |
-
st_prod.product_name,
|
9200 |
-
st_prod.sinch_manufacturer_id,
|
9201 |
-
st_prod.store_category_id,
|
9202 |
-
st_prod.main_image_url,
|
9203 |
-
st_prod.thumb_image_url,
|
9204 |
-
st_prod.medium_image_url,
|
9205 |
-
st_prod.specifications,
|
9206 |
-
st_prod.description,
|
9207 |
-
st_prod.specifications,
|
9208 |
-
st_manuf.manufacturer_name,
|
9209 |
-
st_manuf.manufacturers_image
|
9210 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_related_products') . " st_rel_prod
|
9211 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products') . " st_prod
|
9212 |
-
ON st_rel_prod.related_sinch_product_id=st_prod.sinch_product_id
|
9213 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers') . " st_manuf
|
9214 |
-
ON st_prod.sinch_manufacturer_id=st_manuf.sinch_manufacturer_id
|
9215 |
-
WHERE st_rel_prod.sinch_product_id=" . $this->sinchProductId;
|
9216 |
-
|
9217 |
-
// echo $q;
|
9218 |
-
$quer = $this->db_do($q);
|
9219 |
-
while ($row = mysqli_fetch_array($quer)) {
|
9220 |
-
|
9221 |
-
$productArray = array();
|
9222 |
-
$productArray['name'] = (string)$row['product_name'];
|
9223 |
-
$productArray['thumb'] = (string)$row['thumb_image_url'];
|
9224 |
-
$mpn = (string)$row['product_sku'];
|
9225 |
-
$productSupplierId = (int)$row['sinch_manufacturer_id'];
|
9226 |
-
$productArray['supplier_thumb'] = (string)($row['manufacturers_image']);
|
9227 |
-
$productArray['supplier_name'] = (string)$row['manufacturer_name'];
|
9228 |
-
|
9229 |
-
$this->relatedProducts[$mpn] = $productArray;
|
9230 |
-
}
|
9231 |
-
}
|
9232 |
-
|
9233 |
-
#################################################################################################
|
9234 |
-
|
9235 |
-
public function getProductName()
|
9236 |
-
{
|
9237 |
-
return $this->productName;
|
9238 |
-
}
|
9239 |
-
|
9240 |
-
#################################################################################################
|
9241 |
-
|
9242 |
-
public function getProductDescriptionList()
|
9243 |
-
{
|
9244 |
-
return $this->productDescriptionList;
|
9245 |
-
}
|
9246 |
-
|
9247 |
-
#################################################################################################
|
9248 |
-
|
9249 |
-
public function getProductSpecifications()
|
9250 |
-
{
|
9251 |
-
return $this->specifications;
|
9252 |
-
}
|
9253 |
-
|
9254 |
-
#################################################################################################
|
9255 |
-
|
9256 |
-
public function getShortProductDescription()
|
9257 |
-
{
|
9258 |
-
return $this->productDescription;
|
9259 |
-
}
|
9260 |
-
|
9261 |
-
#################################################################################################
|
9262 |
-
|
9263 |
-
public function getFullProductDescription()
|
9264 |
-
{
|
9265 |
-
return $this->fullProductDescription;
|
9266 |
-
}
|
9267 |
-
|
9268 |
-
#################################################################################################
|
9269 |
-
|
9270 |
-
public function getLowPicUrl()
|
9271 |
-
{
|
9272 |
-
return $this->highPicUrl;
|
9273 |
-
}
|
9274 |
-
|
9275 |
-
#################################################################################
|
9276 |
-
|
9277 |
-
public function getRelatedProducts()
|
9278 |
-
{
|
9279 |
-
return $this->relatedProducts;
|
9280 |
-
}
|
9281 |
-
|
9282 |
-
#################################################################################################
|
9283 |
-
|
9284 |
-
public function getVendor()
|
9285 |
-
{
|
9286 |
-
return $this->vendor;
|
9287 |
-
}
|
9288 |
-
|
9289 |
-
##################################################################################################
|
9290 |
-
|
9291 |
-
public function getMPN()
|
9292 |
-
{
|
9293 |
-
return $this->productId;
|
9294 |
-
}
|
9295 |
-
|
9296 |
-
##################################################################################################
|
9297 |
-
|
9298 |
-
public function getEAN()
|
9299 |
-
{
|
9300 |
-
return $this->EAN;
|
9301 |
-
}
|
9302 |
-
|
9303 |
-
##################################################################################################
|
9304 |
-
|
9305 |
-
public function getGalleryPhotos()
|
9306 |
-
{
|
9307 |
-
return $this->galleryPhotos;
|
9308 |
-
}
|
9309 |
-
|
9310 |
-
##################################################################################################
|
9311 |
-
|
9312 |
-
public function reloadProductImage($entity_id)
|
9313 |
-
{
|
9314 |
-
$result = $this->db_do("
|
9315 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
9316 |
-
entity_type_id,
|
9317 |
-
attribute_id,
|
9318 |
-
store_id,
|
9319 |
-
entity_id,
|
9320 |
-
value
|
9321 |
-
)(
|
9322 |
-
SELECT
|
9323 |
-
" . $this->_getProductEntityTypeId() . ",
|
9324 |
-
" . $this->_getProductAttributeId('image') . ",
|
9325 |
-
w.store_id,
|
9326 |
-
a.entity_id,
|
9327 |
-
b.main_image_url
|
9328 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
9329 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " w
|
9330 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products') . " b
|
9331 |
-
ON a.store_product_id = b.store_product_id
|
9332 |
-
WHERE a.entity_id=$entity_id
|
9333 |
-
)
|
9334 |
-
ON DUPLICATE KEY UPDATE
|
9335 |
-
value = b.main_image_url
|
9336 |
-
");
|
9337 |
-
|
9338 |
-
|
9339 |
-
// image for specific web sites
|
9340 |
-
$result = $this->db_do("
|
9341 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
9342 |
-
entity_type_id,
|
9343 |
-
attribute_id,
|
9344 |
-
store_id,
|
9345 |
-
entity_id,
|
9346 |
-
value
|
9347 |
-
)(
|
9348 |
-
SELECT
|
9349 |
-
" . $this->_getProductEntityTypeId() . ",
|
9350 |
-
" . $this->_getProductAttributeId('image') . ",
|
9351 |
-
0,
|
9352 |
-
a.entity_id,
|
9353 |
-
b.main_image_url
|
9354 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
9355 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products') . " b
|
9356 |
-
ON a.store_product_id = b.store_product_id
|
9357 |
-
WHERE a.entity_id=$entity_id
|
9358 |
-
)
|
9359 |
-
ON DUPLICATE KEY UPDATE
|
9360 |
-
value = b.main_image_url
|
9361 |
-
");
|
9362 |
-
|
9363 |
-
|
9364 |
-
// small_image for specific web sites
|
9365 |
-
$result = $this->db_do("
|
9366 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
9367 |
-
entity_type_id,
|
9368 |
-
attribute_id,
|
9369 |
-
store_id,
|
9370 |
-
entity_id,
|
9371 |
-
value
|
9372 |
-
)(
|
9373 |
-
SELECT
|
9374 |
-
" . $this->_getProductEntityTypeId() . ",
|
9375 |
-
" . $this->_getProductAttributeId('small_image') . ",
|
9376 |
-
w.store_id,
|
9377 |
-
a.entity_id,
|
9378 |
-
b.main_image_url
|
9379 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
9380 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " w
|
9381 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products') . " b
|
9382 |
-
ON a.store_product_id = b.store_product_id
|
9383 |
-
WHERE a.entity_id=$entity_id
|
9384 |
-
)
|
9385 |
-
ON DUPLICATE KEY UPDATE
|
9386 |
-
value = b.main_image_url
|
9387 |
-
");
|
9388 |
-
|
9389 |
-
|
9390 |
-
// small_image for all web sites
|
9391 |
-
$result = $this->db_do("
|
9392 |
-
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
9393 |
-
entity_type_id,
|
9394 |
-
attribute_id,
|
9395 |
-
store_id,
|
9396 |
-
entity_id,
|
9397 |
-
value
|
9398 |
-
)(
|
9399 |
-
SELECT
|
9400 |
-
" . $this->_getProductEntityTypeId() . ",
|
9401 |
-
" . $this->_getProductAttributeId('small_image') . ",
|
9402 |
-
0,
|
9403 |
-
a.entity_id,
|
9404 |
-
b.main_image_url
|
9405 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
9406 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " w
|
9407 |
-
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products') . " b
|
9408 |
-
ON a.store_product_id = b.store_product_id
|
9409 |
-
WHERE a.entity_id=$entity_id
|
9410 |
-
)
|
9411 |
-
ON DUPLICATE KEY UPDATE
|
9412 |
-
value = b.main_image_url
|
9413 |
-
");
|
9414 |
-
}
|
9415 |
-
|
9416 |
-
##################################################################################################
|
9417 |
-
|
9418 |
-
function valid_utf($string, $new_line = true)
|
9419 |
-
{
|
9420 |
-
/* if($new_line == true){
|
9421 |
-
$string = preg_replace('/\\\n/',"\n",$string);
|
9422 |
-
}
|
9423 |
-
*/
|
9424 |
-
$string = preg_replace('/™/', '™', $string);
|
9425 |
-
$string = preg_replace("/®/", '®', $string);
|
9426 |
-
$string = preg_replace("/≈/", '≈', $string);
|
9427 |
-
$string = preg_replace("/" . chr(226) . chr(128) . chr(157) . "/", '"', $string);
|
9428 |
-
$string = preg_replace("/" . chr(226) . chr(128) . chr(153) . "/", '′', $string);
|
9429 |
-
$string = preg_replace("/°/", '°', $string);
|
9430 |
-
$string = preg_replace("/±/", '±', $string);
|
9431 |
-
$string = preg_replace("/µ/", 'µ', $string);
|
9432 |
-
$string = preg_replace("/²/", '²', $string);
|
9433 |
-
$string = preg_replace("/³/", '³', $string);
|
9434 |
-
$string = preg_replace('/\xe2\x80\x93/', '-', $string);
|
9435 |
-
$string = preg_replace('/\xe2\x80\x99/', '\'', $string);
|
9436 |
-
$string = preg_replace('/\xe2\x80\x9c/', ' ', $string);
|
9437 |
-
$string = preg_replace('/\xe2\x80\x9d/', ' ', $string);
|
9438 |
-
|
9439 |
-
return utf8_decode($string);
|
9440 |
-
|
9441 |
-
// return $string;
|
9442 |
-
}
|
9443 |
-
|
9444 |
-
##################################################################################################
|
9445 |
-
|
9446 |
-
function set_imports_failed()
|
9447 |
-
{
|
9448 |
-
$this->db_do("UPDATE " . $this->import_status_statistic_table . "
|
9449 |
-
SET global_status_import='Failed'
|
9450 |
-
WHERE global_status_import='Run'");
|
9451 |
-
}
|
9452 |
-
##################################################################################################
|
9453 |
-
|
9454 |
-
|
9455 |
-
##################################################################################################
|
9456 |
-
|
9457 |
-
function getImportStatusHistory()
|
9458 |
-
{
|
9459 |
-
$res = "SELECT COUNT(*) FROM " . $this->import_status_statistic_table;
|
9460 |
-
$cnt_arr = mysqli_fetch_array($this->db_do($res));
|
9461 |
-
$cnt = $cnt_arr[0];
|
9462 |
-
$StatusHistory_arr = array();
|
9463 |
-
if ($cnt > 0) {
|
9464 |
-
$a = (($cnt > 7) ? ($cnt - 7) : 0);
|
9465 |
-
$b = $cnt;
|
9466 |
-
$q = "SELECT
|
9467 |
-
id,
|
9468 |
-
start_import,
|
9469 |
-
finish_import,
|
9470 |
-
import_type,
|
9471 |
-
number_of_products,
|
9472 |
-
global_status_import,
|
9473 |
-
detail_status_import
|
9474 |
-
FROM " . $this->import_status_statistic_table . "
|
9475 |
-
ORDER BY start_import limit " . $a . ", " . $b;
|
9476 |
-
$result = $this->db_do($q);
|
9477 |
-
while ($row = mysqli_fetch_array($result)) {
|
9478 |
-
$StatusHistory_arr[] = $row;
|
9479 |
-
}
|
9480 |
-
}
|
9481 |
-
return $StatusHistory_arr;
|
9482 |
-
} // public function getImportEnvironment()
|
9483 |
-
##################################################################################################
|
9484 |
-
|
9485 |
-
|
9486 |
-
##################################################################################################
|
9487 |
-
|
9488 |
-
function getDateOfLatestSuccessImport()
|
9489 |
-
{
|
9490 |
-
$q = "SELECT start_import, finish_import
|
9491 |
-
FROM " . $this->import_status_statistic_table . "
|
9492 |
-
WHERE global_status_import='Successful'
|
9493 |
-
ORDER BY id DESC LIMIT 1";
|
9494 |
-
$imp_date = mysqli_fetch_array($this->db_do($q));
|
9495 |
-
return $imp_date['start_import'];
|
9496 |
-
} // public function getImportEnvironment()
|
9497 |
-
##################################################################################################
|
9498 |
-
|
9499 |
-
|
9500 |
-
##################################################################################################
|
9501 |
-
|
9502 |
-
function getDataOfLatestImport()
|
9503 |
-
{
|
9504 |
-
$q = "SELECT
|
9505 |
-
start_import,
|
9506 |
-
finish_import,
|
9507 |
-
import_type,
|
9508 |
-
number_of_products,
|
9509 |
-
global_status_import,
|
9510 |
-
detail_status_import,
|
9511 |
-
number_of_products,
|
9512 |
-
error_report_message
|
9513 |
-
FROM " . $this->import_status_statistic_table . "
|
9514 |
-
ORDER BY id DESC LIMIT 1";
|
9515 |
-
$imp_status = mysqli_fetch_array($this->db_do($q));
|
9516 |
-
return $imp_status;
|
9517 |
-
} // public function getImportEnvironment()
|
9518 |
-
##################################################################################################
|
9519 |
-
|
9520 |
-
|
9521 |
-
##################################################################################################
|
9522 |
-
|
9523 |
-
function getImportStatuses()
|
9524 |
-
{
|
9525 |
-
$q = "SELECT id, message, finished
|
9526 |
-
FROM " . $this->import_status_table . "
|
9527 |
-
ORDER BY id LIMIT 1";
|
9528 |
-
$quer = $this->db_do($q);
|
9529 |
-
if ($row = mysqli_fetch_array($quer)) {
|
9530 |
-
$messages = array('message' => $row['message'], 'id' => $row['id'], 'finished' => $row['finished']);
|
9531 |
-
$id = $row['id'];
|
9532 |
-
}
|
9533 |
-
if ($id) {
|
9534 |
-
$q = "DELETE FROM " . $this->import_status_table . " WHERE id=" . $id;
|
9535 |
-
$this->db_do($q);
|
9536 |
-
}
|
9537 |
-
return $messages;
|
9538 |
-
} // public function getImportEnvironment()
|
9539 |
-
##################################################################################################
|
9540 |
-
|
9541 |
-
|
9542 |
-
##################################################################################################
|
9543 |
-
|
9544 |
-
public function checkMemory()
|
9545 |
-
{
|
9546 |
-
$check_code = 'memory';
|
9547 |
-
|
9548 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9549 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9550 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9551 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9552 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9553 |
-
|
9554 |
-
|
9555 |
-
$Caption = $row['caption'];
|
9556 |
-
$CheckValue = $row['check_value'];
|
9557 |
-
$CheckMeasure = $row['check_measure'];
|
9558 |
-
$ErrorMessage = $row['error_msg'];
|
9559 |
-
$FixMessage = $row['fix_msg'];
|
9560 |
-
|
9561 |
-
$retvalue = array();
|
9562 |
-
$retvalue["'$check_code'"] = array();
|
9563 |
-
|
9564 |
-
$memInfoContent = file_get_contents("/proc/meminfo");
|
9565 |
-
if ($memInfoContent === false) {
|
9566 |
-
return array(
|
9567 |
-
'error',
|
9568 |
-
$Caption,
|
9569 |
-
$CheckValue,
|
9570 |
-
0,
|
9571 |
-
$CheckMeasure,
|
9572 |
-
'Cannot read /proc/meminfo for RAM information',
|
9573 |
-
'Make sure open_basedir permits access to /proc/meminfo (or is off) and that this is a *nix system'
|
9574 |
-
);
|
9575 |
-
}
|
9576 |
-
$data = explode("\n", $memInfoContent);
|
9577 |
-
|
9578 |
-
foreach ($data as $line) {
|
9579 |
-
$lineParts = explode(":", $line);
|
9580 |
-
if (count($lineParts) < 2) continue;
|
9581 |
-
list($key, $val) = $lineParts;
|
9582 |
-
|
9583 |
-
if ($key == 'MemTotal') {
|
9584 |
-
$val = trim($val);
|
9585 |
-
$value = (int)substr($val, 0, strpos($val, ' kB'));
|
9586 |
-
$measure = substr($val, strpos($val, ' kB'));
|
9587 |
-
|
9588 |
-
$retvalue['memory']['value'] = (integer)(((float)$value) / 1024); // (float)$value
|
9589 |
-
$retvalue['memory']['measure'] = 'MB'; // $measure;
|
9590 |
-
}
|
9591 |
-
}
|
9592 |
-
|
9593 |
-
$errmsg = '';
|
9594 |
-
$fixmsg = '';
|
9595 |
-
if ($retvalue['memory']['value'] <= $CheckValue) {
|
9596 |
-
$errmsg = sprintf($ErrorMessage, $retvalue['memory']['value']); //." ".$retvalue['memory']['value']." ".$retvalue['memory']['measure'];
|
9597 |
-
$fixmsg = sprintf($FixMessage, " " . $CheckValue . " " . $CheckMeasure);
|
9598 |
-
$retvalue['memory']['status'] = 'error';
|
9599 |
-
} else {
|
9600 |
-
$retvalue['memory']['status'] = 'OK';
|
9601 |
-
}
|
9602 |
-
|
9603 |
-
return array(
|
9604 |
-
$retvalue['memory']['status'],
|
9605 |
-
$Caption,
|
9606 |
-
$CheckValue,
|
9607 |
-
$retvalue['memory']['value'],
|
9608 |
-
$CheckMeasure,
|
9609 |
-
$errmsg,
|
9610 |
-
$fixmsg
|
9611 |
-
);
|
9612 |
-
} // public function getImportEnvironment()
|
9613 |
-
##################################################################################################
|
9614 |
-
|
9615 |
-
|
9616 |
-
##################################################################################################
|
9617 |
-
|
9618 |
-
public function checkLoaddata()
|
9619 |
-
{
|
9620 |
-
$check_code = 'loaddata';
|
9621 |
-
|
9622 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9623 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9624 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9625 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9626 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9627 |
-
|
9628 |
-
$Caption = $row['caption'];
|
9629 |
-
$CheckValue = $row['check_value'];
|
9630 |
-
$CheckMeasure = $row['check_measure'];
|
9631 |
-
$ErrorMessage = $row['error_msg'];
|
9632 |
-
$FixMessage = $row['fix_msg'];
|
9633 |
-
|
9634 |
-
$retvalue = array();
|
9635 |
-
$retvalue["'$check_code'"] = array();
|
9636 |
-
|
9637 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9638 |
-
$result = $conn->query("SHOW VARIABLES LIKE 'local_infile'");
|
9639 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9640 |
-
$value = $row['Value'];
|
9641 |
-
|
9642 |
-
|
9643 |
-
$errmsg = '';
|
9644 |
-
$fixmsg = '';
|
9645 |
-
if ($value != $CheckValue) {
|
9646 |
-
$errmsg .= $ErrorMessage . " " . $value . " " . $CheckMeasure;
|
9647 |
-
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
9648 |
-
$status = 'error';
|
9649 |
-
} else {
|
9650 |
-
$errmsg .= 'none';
|
9651 |
-
$fixmsg .= 'none';
|
9652 |
-
$status = 'OK';
|
9653 |
-
}
|
9654 |
-
|
9655 |
-
$ret = array();
|
9656 |
-
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
9657 |
-
|
9658 |
-
return $ret;
|
9659 |
-
} // public function getImportEnvironment()
|
9660 |
-
##################################################################################################
|
9661 |
-
|
9662 |
-
|
9663 |
-
##################################################################################################
|
9664 |
-
|
9665 |
-
public function checkPhpsafemode()
|
9666 |
-
{
|
9667 |
-
$check_code = 'phpsafemode';
|
9668 |
-
|
9669 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9670 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9671 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9672 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9673 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9674 |
-
|
9675 |
-
$Caption = $row['caption'];
|
9676 |
-
$CheckValue = $row['check_value'];
|
9677 |
-
$CheckMeasure = $row['check_measure'];
|
9678 |
-
$ErrorMessage = $row['error_msg'];
|
9679 |
-
$FixMessage = $row['fix_msg'];
|
9680 |
-
|
9681 |
-
$retvalue = array();
|
9682 |
-
$retvalue["'$check_code'"] = array();
|
9683 |
-
|
9684 |
-
$a = ini_get('safe_mode');
|
9685 |
-
if ($a) {
|
9686 |
-
$value = 'ON';
|
9687 |
-
} else {
|
9688 |
-
$value = 'OFF';
|
9689 |
-
}
|
9690 |
-
|
9691 |
-
$errmsg = '';
|
9692 |
-
$fixmsg = '';
|
9693 |
-
if ($value != $CheckValue) {
|
9694 |
-
$errmsg .= sprintf($ErrorMessage, " " . $value . " " . $CheckMeasure);
|
9695 |
-
$fixmsg .= sprintf($FixMessage, " " . $CheckValue . " " . $CheckMeasure);
|
9696 |
-
$status = 'error';
|
9697 |
-
} else {
|
9698 |
-
$errmsg .= 'none';
|
9699 |
-
$fixmsg .= 'none';
|
9700 |
-
$status = 'OK';
|
9701 |
-
}
|
9702 |
-
|
9703 |
-
$ret = array();
|
9704 |
-
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
9705 |
-
|
9706 |
-
return $ret;
|
9707 |
-
} // public function getImportEnvironment()
|
9708 |
-
##################################################################################################
|
9709 |
-
|
9710 |
-
|
9711 |
-
##################################################################################################
|
9712 |
-
|
9713 |
-
public function checkWaittimeout()
|
9714 |
-
{
|
9715 |
-
$check_code = 'waittimeout';
|
9716 |
-
|
9717 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9718 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9719 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9720 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9721 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9722 |
-
|
9723 |
-
$Caption = $row['caption'];
|
9724 |
-
$CheckValue = $row['check_value'];
|
9725 |
-
$CheckMeasure = $row['check_measure'];
|
9726 |
-
$ErrorMessage = $row['error_msg'];
|
9727 |
-
$FixMessage = $row['fix_msg'];
|
9728 |
-
|
9729 |
-
$retvalue = array();
|
9730 |
-
$retvalue["'$check_code'"] = array();
|
9731 |
-
|
9732 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9733 |
-
$result = $conn->query("SHOW VARIABLES LIKE 'wait_timeout'");
|
9734 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9735 |
-
$value = $row['Value'];
|
9736 |
-
|
9737 |
-
$errmsg = '';
|
9738 |
-
$fixmsg = '';
|
9739 |
-
if ($value <= $CheckValue) {
|
9740 |
-
$errmsg .= $ErrorMessage . " " . $value . " " . $CheckMeasure;
|
9741 |
-
$fixmsg .= sprintf($FixMessage, " " . $CheckValue);
|
9742 |
-
$status = 'error';
|
9743 |
-
} else {
|
9744 |
-
$errmsg .= 'none';
|
9745 |
-
$fixmsg .= 'none';
|
9746 |
-
$status = 'OK';
|
9747 |
-
}
|
9748 |
-
|
9749 |
-
$ret = array();
|
9750 |
-
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
9751 |
-
|
9752 |
-
return $ret;
|
9753 |
-
} // public function checkChmodwgetcronphpfile()
|
9754 |
-
##################################################################################################
|
9755 |
-
|
9756 |
-
|
9757 |
-
##################################################################################################
|
9758 |
-
|
9759 |
-
public function checkInnodbbufferpoolsize()
|
9760 |
-
{
|
9761 |
-
$check_code = 'innodbbufpool';
|
9762 |
-
|
9763 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9764 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9765 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9766 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9767 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9768 |
-
|
9769 |
-
$Caption = $row['caption'];
|
9770 |
-
$CheckValue = $row['check_value'];
|
9771 |
-
$CheckMeasure = $row['check_measure'];
|
9772 |
-
$ErrorMessage = $row['error_msg'];
|
9773 |
-
$FixMessage = $row['fix_msg'];
|
9774 |
-
|
9775 |
-
$retvalue = array();
|
9776 |
-
$retvalue["'$check_code'"] = array();
|
9777 |
-
|
9778 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9779 |
-
$result = $conn->query("SHOW VARIABLES LIKE 'innodb_buffer_pool_size'");
|
9780 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9781 |
-
$value = (int)($row['Value'] / (1024 * 1024));
|
9782 |
-
|
9783 |
-
$errmsg = '';
|
9784 |
-
$fixmsg = '';
|
9785 |
-
if ($value < $CheckValue) {
|
9786 |
-
$errmsg .= sprintf($ErrorMessage, " " . $value . " " . $CheckMeasure);
|
9787 |
-
$fixmsg .= sprintf($FixMessage, " " . $CheckValue . " " . $CheckMeasure);
|
9788 |
-
$status = 'error';
|
9789 |
-
} else {
|
9790 |
-
$errmsg .= 'none';
|
9791 |
-
$fixmsg .= 'none';
|
9792 |
-
$status = 'OK';
|
9793 |
-
}
|
9794 |
-
|
9795 |
-
$ret = array();
|
9796 |
-
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
9797 |
-
|
9798 |
-
return $ret;
|
9799 |
-
} // public function checkChmodwgetcronphpfile()
|
9800 |
-
##################################################################################################
|
9801 |
-
|
9802 |
-
|
9803 |
-
##################################################################################################
|
9804 |
-
|
9805 |
-
public function checkPhprunstring()
|
9806 |
-
{
|
9807 |
-
$check_code = 'php5run';
|
9808 |
-
|
9809 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9810 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9811 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9812 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9813 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9814 |
-
|
9815 |
-
$Caption = $row['caption'];
|
9816 |
-
$CheckValue = $row['check_value'];
|
9817 |
-
$CheckMeasure = $row['check_measure'];
|
9818 |
-
$ErrorMessage = $row['error_msg'];
|
9819 |
-
$FixMessage = $row['fix_msg'];
|
9820 |
-
|
9821 |
-
$retvalue = array();
|
9822 |
-
$retvalue["'$check_code'"] = array();
|
9823 |
-
|
9824 |
-
$value = trim(PHP_RUN_STRING);
|
9825 |
-
$errmsg = '';
|
9826 |
-
$fixmsg = '';
|
9827 |
-
$status = 'OK';
|
9828 |
-
|
9829 |
-
if (!defined('PHP_RUN_STRING')) {
|
9830 |
-
$errmsg .= "You haven't installed PHP CLI";
|
9831 |
-
$fixmsg .= "Install PHP CLI."; // ." ".$CheckValue." ".$CheckMeasure
|
9832 |
-
$status = 'error';
|
9833 |
-
}
|
9834 |
-
|
9835 |
-
return array(
|
9836 |
-
$status,
|
9837 |
-
$Caption,
|
9838 |
-
$CheckValue,
|
9839 |
-
$value,
|
9840 |
-
$CheckMeasure,
|
9841 |
-
$errmsg,
|
9842 |
-
$fixmsg
|
9843 |
-
);
|
9844 |
-
} // public function getImportEnvironment()
|
9845 |
-
##################################################################################################
|
9846 |
-
|
9847 |
-
|
9848 |
-
##################################################################################################
|
9849 |
-
|
9850 |
-
public function checkChmodwgetdatafile()
|
9851 |
-
{
|
9852 |
-
$check_code = 'chmodwget';
|
9853 |
-
|
9854 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9855 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9856 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9857 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9858 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9859 |
-
|
9860 |
-
$Caption = $row['caption'];
|
9861 |
-
$CheckValue = $row['check_value'];
|
9862 |
-
$CheckMeasure = $row['check_measure'];
|
9863 |
-
$ErrorMessage = $row['error_msg'];
|
9864 |
-
$FixMessage = $row['fix_msg'];
|
9865 |
-
|
9866 |
-
$retvalue = array();
|
9867 |
-
$retvalue["'$check_code'"] = array();
|
9868 |
-
|
9869 |
-
$datafile_csv = '/usr/bin/wget';
|
9870 |
-
|
9871 |
-
$value = substr(sprintf('%o', fileperms($datafile_csv)), -4);
|
9872 |
-
|
9873 |
-
$CheckValue_own = $CheckValue{1};
|
9874 |
-
$CheckValue_group = $CheckValue{2};
|
9875 |
-
$CheckValue_other = $CheckValue{3};
|
9876 |
-
|
9877 |
-
$value_own = $value{1};
|
9878 |
-
$value_group = $value{2};
|
9879 |
-
$value_other = $value{3};
|
9880 |
-
|
9881 |
-
$errmsg = '';
|
9882 |
-
$fixmsg = '';
|
9883 |
-
//if ($value <= $CheckValue) {
|
9884 |
-
if (($value_own < $CheckValue_own) || ($value_group < $CheckValue_group) || ($value_other < $CheckValue_other)) {
|
9885 |
-
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
9886 |
-
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
9887 |
-
$status = 'error';
|
9888 |
-
} else {
|
9889 |
-
$errmsg .= 'none';
|
9890 |
-
$fixmsg .= 'none';
|
9891 |
-
$status = 'OK';
|
9892 |
-
}
|
9893 |
-
|
9894 |
-
$ret = array();
|
9895 |
-
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
9896 |
-
|
9897 |
-
return $ret;
|
9898 |
-
} // public function getImportEnvironment()
|
9899 |
-
##################################################################################################
|
9900 |
-
|
9901 |
-
|
9902 |
-
##################################################################################################
|
9903 |
-
|
9904 |
-
public function checkChmodwgetcronphpfile()
|
9905 |
-
{
|
9906 |
-
$check_code = 'chmodcronphp';
|
9907 |
-
|
9908 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9909 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9910 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9911 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9912 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9913 |
-
|
9914 |
-
$Caption = $row['caption'];
|
9915 |
-
$CheckValue = $row['check_value'];
|
9916 |
-
$CheckMeasure = $row['check_measure'];
|
9917 |
-
$ErrorMessage = $row['error_msg'];
|
9918 |
-
$FixMessage = $row['fix_msg'];
|
9919 |
-
|
9920 |
-
$retvalue = array();
|
9921 |
-
$retvalue["'$check_code'"] = array();
|
9922 |
-
|
9923 |
-
$cronfile_php = Mage::getBaseDir() . '/cron.php';
|
9924 |
-
|
9925 |
-
$value = substr(sprintf('%o', fileperms($cronfile_php)), -4);
|
9926 |
-
|
9927 |
-
$CheckValue_own = $CheckValue{1};
|
9928 |
-
$CheckValue_group = $CheckValue{2};
|
9929 |
-
$CheckValue_other = $CheckValue{3};
|
9930 |
-
|
9931 |
-
$value_own = $value{1};
|
9932 |
-
$value_group = $value{2};
|
9933 |
-
$value_other = $value{3};
|
9934 |
-
|
9935 |
-
$errmsg = '';
|
9936 |
-
$fixmsg = '';
|
9937 |
-
//if ($value <= $CheckValue) {
|
9938 |
-
if (($value_own < $CheckValue_own) || ($value_group < $CheckValue_group) || ($value_other < $CheckValue_other)) {
|
9939 |
-
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
9940 |
-
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
9941 |
-
$status = 'error';
|
9942 |
-
} else {
|
9943 |
-
$errmsg .= 'none';
|
9944 |
-
$fixmsg .= 'none';
|
9945 |
-
$status = 'OK';
|
9946 |
-
}
|
9947 |
-
|
9948 |
-
$ret = array();
|
9949 |
-
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
9950 |
-
|
9951 |
-
return $ret;
|
9952 |
-
}
|
9953 |
-
##################################################################################################
|
9954 |
-
|
9955 |
-
|
9956 |
-
##################################################################################################
|
9957 |
-
|
9958 |
-
public function checkChmodwgetcronshfile()
|
9959 |
-
{
|
9960 |
-
$check_code = 'chmodcronsh';
|
9961 |
-
|
9962 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9963 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9964 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9965 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9966 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9967 |
-
|
9968 |
-
$Caption = $row['caption'];
|
9969 |
-
$CheckValue = $row['check_value'];
|
9970 |
-
$CheckMeasure = $row['check_measure'];
|
9971 |
-
$ErrorMessage = $row['error_msg'];
|
9972 |
-
$FixMessage = $row['fix_msg'];
|
9973 |
-
|
9974 |
-
$retvalue = array();
|
9975 |
-
$retvalue["'$check_code'"] = array();
|
9976 |
-
|
9977 |
-
$cronfile_sh = Mage::getBaseDir() . '/cron.sh';
|
9978 |
-
|
9979 |
-
$value = substr(sprintf('%o', fileperms($cronfile_sh)), -4);
|
9980 |
-
|
9981 |
-
$CheckValue_own = $CheckValue{1};
|
9982 |
-
$CheckValue_group = $CheckValue{2};
|
9983 |
-
$CheckValue_other = $CheckValue{3};
|
9984 |
-
|
9985 |
-
$value_own = $value{1};
|
9986 |
-
$value_group = $value{2};
|
9987 |
-
$value_other = $value{3};
|
9988 |
-
|
9989 |
-
$errmsg = '';
|
9990 |
-
$fixmsg = '';
|
9991 |
-
//if ($value <= $CheckValue) {
|
9992 |
-
if (($value_own < $CheckValue_own) || ($value_group < $CheckValue_group) || ($value_other < $CheckValue_other)) {
|
9993 |
-
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
9994 |
-
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
9995 |
-
$status = 'error';
|
9996 |
-
} else {
|
9997 |
-
$errmsg .= 'none';
|
9998 |
-
$fixmsg .= 'none';
|
9999 |
-
$status = 'OK';
|
10000 |
-
}
|
10001 |
-
|
10002 |
-
$ret = array();
|
10003 |
-
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
10004 |
-
|
10005 |
-
return $ret;
|
10006 |
-
}
|
10007 |
-
|
10008 |
-
#################################################################################################
|
10009 |
-
|
10010 |
-
public function checkProcedure()
|
10011 |
-
{
|
10012 |
-
$check_code = 'routine';
|
10013 |
-
|
10014 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
10015 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
10016 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
10017 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
10018 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
10019 |
-
|
10020 |
-
$Caption = $row['caption'];
|
10021 |
-
$CheckValue = $row['check_value'];
|
10022 |
-
$CheckMeasure = $row['check_measure'];
|
10023 |
-
$ErrorMessage = $row['error_msg'];
|
10024 |
-
$FixMessage = $row['fix_msg'];
|
10025 |
-
|
10026 |
-
$retvalue = array();
|
10027 |
-
$retvalue["'$check_code'"] = array();
|
10028 |
-
|
10029 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
10030 |
-
$storedFunctionName = Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s');
|
10031 |
-
$result = $conn->query("SHOW PROCEDURE STATUS LIKE '$storedFunctionName'");
|
10032 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
10033 |
-
$value = $row['Name'];
|
10034 |
-
|
10035 |
-
$errmsg = '';
|
10036 |
-
$fixmsg = '';
|
10037 |
-
if ($value != $CheckValue) {
|
10038 |
-
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
10039 |
-
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
10040 |
-
$status = 'error';
|
10041 |
-
} else {
|
10042 |
-
$errmsg .= 'none';
|
10043 |
-
$fixmsg .= 'none';
|
10044 |
-
$status = 'OK';
|
10045 |
-
}
|
10046 |
-
|
10047 |
-
$ret = array();
|
10048 |
-
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
10049 |
-
|
10050 |
-
return $ret;
|
10051 |
-
}
|
10052 |
-
|
10053 |
-
#################################################################################################
|
10054 |
-
|
10055 |
-
public function checkConflictsWithInstalledModules()
|
10056 |
-
{
|
10057 |
-
$check_code = 'conflictwithinstalledmodules';
|
10058 |
-
|
10059 |
-
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
10060 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
10061 |
-
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
10062 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
10063 |
-
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
10064 |
-
|
10065 |
-
$Caption = $row['caption'];
|
10066 |
-
$CheckValue = $row['check_value'];
|
10067 |
-
$CheckMeasure = $row['check_measure'];
|
10068 |
-
$ErrorMessage = $row['error_msg'];
|
10069 |
-
$FixMessage = $row['fix_msg'];
|
10070 |
-
|
10071 |
-
$retvalue = array();
|
10072 |
-
$retvalue["'$check_code'"] = array();
|
10073 |
-
|
10074 |
-
/* $conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
10075 |
-
$storedFunctionName = Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s');
|
10076 |
-
$result = $conn->query("SHOW PROCEDURE STATUS LIKE '$storedFunctionName'");
|
10077 |
-
$row = $result->fetch(PDO::FETCH_ASSOC);
|
10078 |
-
$value = $row['Name'];
|
10079 |
-
*/
|
10080 |
-
$config_file = (Mage::app()->getConfig()->getNode()->asXML());
|
10081 |
-
|
10082 |
-
$errmsg = $ErrorMessage;
|
10083 |
-
$fixmsg = $FixMessage;
|
10084 |
-
/*
|
10085 |
-
if ($value != $CheckValue) {
|
10086 |
-
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
10087 |
-
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
10088 |
-
$status = 'error';
|
10089 |
-
*/
|
10090 |
-
$status = 'OK';
|
10091 |
-
|
10092 |
-
if (!strstr($config_file, '<image>Bintime_Sinchimport_Helper_Image</image>')) {
|
10093 |
-
$errmsg .= " Can't find <image>Bintime_Sinchimport_Helper_Image</image> in <helpers><catalog></catalog></helpers>"; // ." ".$value." ".$CheckMeasure
|
10094 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10095 |
-
$status = 'error';
|
10096 |
-
}
|
10097 |
-
|
10098 |
-
if (!strstr($config_file, '<product_image>Bintime_Sinchimport_Model_Image</product_image>')) {
|
10099 |
-
$errmsg .= " Can't find <product_image>Bintime_Sinchimport_Model_Image</product_image> in <models><catalog></catalog></models>"; // ." ".$value." ".$CheckMeasure
|
10100 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10101 |
-
$status = 'error';
|
10102 |
-
}
|
10103 |
-
|
10104 |
-
if (!strstr($config_file, '<category>Bintime_Sinchimport_Model_Category</category>')) {
|
10105 |
-
$errmsg .= " Can't find <category>Bintime_Sinchimport_Model_Category</category> in <models><catalog></catalog></models>"; // ." ".$value." ".$CheckMeasure
|
10106 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10107 |
-
$status = 'error';
|
10108 |
-
}
|
10109 |
-
|
10110 |
-
if (!strstr($config_file, '<product_compare_list>Bintime_Sinchimport_Block_List</product_compare_list>')) {
|
10111 |
-
$errmsg .= " Can't find <product_compare_list>Bintime_Sinchimport_Block_List</product_compare_list> in <blocks><catalog></catalog></blocks>"; // ." ".$value." ".$CheckMeasure
|
10112 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10113 |
-
$status = 'error';
|
10114 |
-
}
|
10115 |
-
|
10116 |
-
if (!strstr($config_file, '<product_view_media>Bintime_Sinchimport_Block_Product_View_Media</product_view_media>')) {
|
10117 |
-
$errmsg .= " Can't find <product_view_media>Bintime_Sinchimport_Block_Product_View_Media</product_view_media> in <blocks><catalog></catalog></blocks>"; // ." ".$value." ".$CheckMeasure
|
10118 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10119 |
-
$status = 'error';
|
10120 |
-
}
|
10121 |
-
|
10122 |
-
if (!strstr($config_file, '<product>Bintime_Sinchimport_Model_Product</product>')) {
|
10123 |
-
$errmsg .= " Can't find <product>Bintime_Sinchimport_Model_Product</product> in <models><catalog></catalog></models>"; // ." ".$value." ".$CheckMeasure
|
10124 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10125 |
-
$status = 'error';
|
10126 |
-
}
|
10127 |
-
|
10128 |
-
if (!strstr($config_file, '<layer_filter_price>Bintime_Sinchimport_Model_Layer_Filter_Price</layer_filter_price>')) {
|
10129 |
-
$errmsg .= " Can't find <layer_filter_price>Bintime_Sinchimport_Model_Layer_Filter_Price</layer_filter_price> in <models><catalog></catalog><models>"; // ." ".$value." ".$CheckMeasure
|
10130 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10131 |
-
$status = 'error';
|
10132 |
-
}
|
10133 |
-
|
10134 |
-
if (!strstr($config_file, '<layer_view>Bintime_Sinchimport_Block_Layer_View</layer_view>')) {
|
10135 |
-
$errmsg .= " Can't find <layer_view>Bintime_Sinchimport_Block_Layer_View</layer_view> in <blocks><catalog></catalog></blocks>"; // ." ".$value." ".$CheckMeasure
|
10136 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10137 |
-
$status = 'error';
|
10138 |
-
}
|
10139 |
-
|
10140 |
-
if (!strstr($config_file, '<layer>Bintime_Sinchimport_Model_Layer</layer>')) {
|
10141 |
-
$errmsg .= " Can't find <layer>Bintime_Sinchimport_Model_Layer</layer> in <models><catalog></catalog><models>"; // ." ".$value." ".$CheckMeasure
|
10142 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10143 |
-
$status = 'error';
|
10144 |
-
}
|
10145 |
-
|
10146 |
-
if (!strstr($config_file, '<layer_filter_price>Bintime_Sinchimport_Model_Resource_Layer_Filter_Price</layer_filter_price>')) {
|
10147 |
-
$errmsg .= " Can't find <layer_filter_price>Bintime_Sinchimport_Model_Resource_Layer_Filter_Price</layer_filter_price> in <models><catalog_resource_eav_mysql4></catalog_resource_eav_mysql4></models>"; // ." ".$value." ".$CheckMeasure
|
10148 |
-
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
10149 |
-
$status = 'error';
|
10150 |
-
}
|
10151 |
-
|
10152 |
-
|
10153 |
-
if ($status == 'OK') {
|
10154 |
-
$errmsg = 'none';
|
10155 |
-
$fixmsg = 'none';
|
10156 |
-
}
|
10157 |
-
return array(
|
10158 |
-
$status,
|
10159 |
-
$Caption,
|
10160 |
-
$CheckValue,
|
10161 |
-
'',
|
10162 |
-
$CheckMeasure,
|
10163 |
-
$errmsg,
|
10164 |
-
$fixmsg
|
10165 |
-
);
|
10166 |
-
}
|
10167 |
-
|
10168 |
-
#################################################################################################
|
10169 |
-
|
10170 |
-
public function getSinchDistribotorsTableHtml($entity_id = null)
|
10171 |
-
{
|
10172 |
-
/*/ Load the collection
|
10173 |
-
$collection = getResourceModel('sales/order_grid_collection');
|
10174 |
-
|
10175 |
-
// Add custom data
|
10176 |
-
$collection->addToAll('example', 'This is a test');
|
10177 |
-
|
10178 |
-
// Set the collection
|
10179 |
-
$this->setCollection($collection);
|
10180 |
-
// return parent::_prepareCollection();
|
10181 |
-
*/
|
10182 |
-
if (!$entity_id) {
|
10183 |
-
$entity_id = Mage::registry('current_product')->getId();
|
10184 |
-
}
|
10185 |
-
if (!$entity_id) {
|
10186 |
-
return '';
|
10187 |
-
}
|
10188 |
-
|
10189 |
-
$distributors_stock_price = $this->getDistributorStockPriceByProductid($entity_id);
|
10190 |
-
$distributors_table = '
|
10191 |
-
<table>
|
10192 |
-
<thead>
|
10193 |
-
<tr class="headings">
|
10194 |
-
<th>Supplier</th>
|
10195 |
-
<th>Stock</th>
|
10196 |
-
<th>Price</th>
|
10197 |
-
</tr>
|
10198 |
-
</thead>
|
10199 |
-
<tbody>';
|
10200 |
-
$i = 1;
|
10201 |
-
foreach ($distributors_stock_price as $offer) {
|
10202 |
-
if ($i > 0) {
|
10203 |
-
$class = "even pointer";
|
10204 |
-
$i = 0;
|
10205 |
-
} else {
|
10206 |
-
$class = "pointer";
|
10207 |
-
$i = 1;
|
10208 |
-
}
|
10209 |
-
$distributors_table .= '
|
10210 |
-
<tr class="' . $class . '">
|
10211 |
-
<td nowrap style="font-weight: normal">' . $offer['distributor_name'] . '</td>
|
10212 |
-
<td style="font-weight: normal">' . $offer['stock'] . '</td>
|
10213 |
-
<td style="font-weight: normal">' . Mage::helper('core')->currency($offer['cost']) . '</td>
|
10214 |
-
</tr>';
|
10215 |
-
}
|
10216 |
-
$distributors_table .= '
|
10217 |
-
</tbody>
|
10218 |
-
</table>
|
10219 |
-
';
|
10220 |
-
return $distributors_table;
|
10221 |
-
}
|
10222 |
-
|
10223 |
-
#################################################################################################
|
10224 |
-
|
10225 |
-
private function getDistributorStockPriceByProductid($entity_id)
|
10226 |
-
{
|
10227 |
-
$store_product_id = $this->getStoreProductIdByEntity($entity_id);
|
10228 |
-
if (!$store_product_id) {
|
10229 |
-
// echo "AAAAAAA"; exit;
|
10230 |
-
return;
|
10231 |
-
}
|
10232 |
-
$q = "SELECT
|
10233 |
-
d.distributor_name,
|
10234 |
-
d.website,
|
10235 |
-
dsp.stock,
|
10236 |
-
dsp.cost,
|
10237 |
-
dsp.distributor_sku,
|
10238 |
-
dsp.distributor_category,
|
10239 |
-
dsp.eta
|
10240 |
-
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price') . " dsp
|
10241 |
-
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors') . " d
|
10242 |
-
ON dsp.distributor_id = d.distributor_id
|
10243 |
-
WHERE store_product_id =" . $store_product_id;
|
10244 |
-
$quer = $this->db_do($q);
|
10245 |
-
$offers = null;
|
10246 |
-
while ($row = mysqli_fetch_array($quer)) {
|
10247 |
-
$offers[] = $row;
|
10248 |
-
}
|
10249 |
-
return $offers;
|
10250 |
-
|
10251 |
-
}
|
10252 |
-
|
10253 |
-
protected function _checkCategoryBackupExist($catalog_category_entity_backup) {
|
10254 |
-
$query = $this->db_do("
|
10255 |
-
SELECT *
|
10256 |
-
FROM $catalog_category_entity_backup
|
10257 |
-
");
|
10258 |
-
while ($row = mysqli_fetch_array($query))
|
10259 |
-
{
|
10260 |
-
return true;
|
10261 |
-
}
|
10262 |
-
|
10263 |
-
return false;
|
10264 |
-
}
|
10265 |
-
|
10266 |
-
} // class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract
|
1 |
+
<?php
|
2 |
+
ini_set('memory_limit', '256M');
|
3 |
+
$dir = Mage::getBaseDir('code') . "/local/Bintime/Sinchimport/Model";
|
4 |
+
require_once($dir . '/config.php');
|
5 |
+
|
6 |
+
class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract
|
7 |
+
{
|
8 |
+
var
|
9 |
+
$connection,
|
10 |
+
$varDir,
|
11 |
+
$shellDir,
|
12 |
+
$files,
|
13 |
+
$attributes,
|
14 |
+
$db,
|
15 |
+
$lang_id,
|
16 |
+
$debug_mode = 1;
|
17 |
+
public $php_run_string;
|
18 |
+
public $php_run_strings;
|
19 |
+
public $price_breaks_filter;
|
20 |
+
private $field_terminated_char;
|
21 |
+
|
22 |
+
private $productDescriptionList = array();
|
23 |
+
private $specifications;
|
24 |
+
private $productDescription;
|
25 |
+
private $fullProductDescription;
|
26 |
+
private $lowPicUrl;
|
27 |
+
private $highPicUrl;
|
28 |
+
private $galleryPhotos = array();
|
29 |
+
private $productName;
|
30 |
+
private $relatedProducts = array();
|
31 |
+
private $sinchProductId;
|
32 |
+
|
33 |
+
private $_productEntityTypeId = 0;
|
34 |
+
private $defaultAttributeSetId = 0;
|
35 |
+
private $current_import_status_statistic_id;
|
36 |
+
|
37 |
+
private $import_status_table;
|
38 |
+
private $import_status_statistic_table;
|
39 |
+
private $import_log_table;
|
40 |
+
|
41 |
+
private $_attributeId;
|
42 |
+
private $_categoryEntityTypeId;
|
43 |
+
private $_categoryDefault_attribute_set_id;
|
44 |
+
private $_root_cat;
|
45 |
+
private $_categoryMetaTitleAttrId;
|
46 |
+
private $_categoryMetadescriptionAttrId;
|
47 |
+
private $_categoryDescriptionAttrId;
|
48 |
+
|
49 |
+
private $_ignore_category_features = false;
|
50 |
+
private $_ignore_product_features = false;
|
51 |
+
private $_ignore_product_related = false;
|
52 |
+
private $_ignore_product_categories = false;
|
53 |
+
private $_ignore_product_contracts = false;
|
54 |
+
private $_ignore_price_rules = false;
|
55 |
+
private $_ignore_restricted_values = false;
|
56 |
+
|
57 |
+
private $product_file_format = "NEW";
|
58 |
+
private $import_run_type = 'MANUAL';
|
59 |
+
private $im_type;
|
60 |
+
|
61 |
+
function __construct()
|
62 |
+
{
|
63 |
+
$this->import_status_table = Mage::getSingleton('core/resource')->getTableName('stINch_import_status');
|
64 |
+
$this->import_status_statistic_table = Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic');
|
65 |
+
$this->import_log_table = "stINch_import_log";
|
66 |
+
|
67 |
+
$this->php_run_string = PHP_RUN_STRING;
|
68 |
+
$this->php_run_strings = PHP_RUN_STRINGS;
|
69 |
+
|
70 |
+
$this->price_breaks_filter = PRICE_BREAKS;
|
71 |
+
$this->field_terminated_char = DEFAULT_FILE_TERMINATED_CHAR;
|
72 |
+
|
73 |
+
$this->varDir = Mage::getBaseDir('var') . DS . 'bintime' . DS . 'sinchimport' . DS;
|
74 |
+
//$this->varDir = str_replace(DS, '/', $this->varDir);
|
75 |
+
if (!is_dir($this->varDir)) {
|
76 |
+
mkdir($this->varDir, 0777, true);
|
77 |
+
}
|
78 |
+
|
79 |
+
$this->shellDir = Mage::getBaseDir('base') . DS . 'shell' . DS;
|
80 |
+
|
81 |
+
$this->connection = $this->db_connect();
|
82 |
+
|
83 |
+
$this->_logFile = "Sinch.log";
|
84 |
+
$this->_errorLogFile = "SinchError.log";
|
85 |
+
|
86 |
+
$this->files = array(
|
87 |
+
FILE_CATEGORIES,
|
88 |
+
FILE_CATEGORY_TYPES,
|
89 |
+
FILE_CATEGORIES_FEATURES,
|
90 |
+
FILE_DISTRIBUTORS,
|
91 |
+
FILE_DISTRIBUTORS_STOCK_AND_PRICES,
|
92 |
+
FILE_EANCODES,
|
93 |
+
FILE_MANUFACTURERS,
|
94 |
+
FILE_PRODUCT_FEATURES,
|
95 |
+
FILE_PRODUCT_CATEGORIES,
|
96 |
+
FILE_PRODUCTS,
|
97 |
+
FILE_RELATED_PRODUCTS,
|
98 |
+
FILE_RESTRICTED_VALUES,
|
99 |
+
FILE_STOCK_AND_PRICES,
|
100 |
+
FILE_PRODUCTS_PICTURES_GALLERY,
|
101 |
+
FILE_PRICE_RULES,
|
102 |
+
FILE_PRODUCT_CONTRACTS
|
103 |
+
);
|
104 |
+
$this->attributes['manufacturer'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('manufacturer')->getFirstItem()->getId();
|
105 |
+
$this->attributes['name'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('name')->getFirstItem()->getId();
|
106 |
+
$this->attributes['is_active'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('is_active')->getFirstItem()->getId();
|
107 |
+
$this->attributes['include_in_menu'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('include_in_menu')->getFirstItem()->getId();
|
108 |
+
$this->attributes['url_key'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('url_key')->getFirstItem()->getId();
|
109 |
+
$this->attributes['display_mode'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('display_mode')->getFirstItem()->getId();
|
110 |
+
$this->attributes['status'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('status')->getFirstItem()->getId();
|
111 |
+
$this->attributes['visibility'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('visibility')->getFirstItem()->getId();
|
112 |
+
$this->attributes['price'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('price')->getFirstItem()->getId();
|
113 |
+
$this->attributes['cost'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('cost')->getFirstItem()->getId();
|
114 |
+
$this->attributes['weight'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('weight')->getFirstItem()->getId();
|
115 |
+
$this->attributes['tax_class_id'] = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('tax_class_id')->getFirstItem()->getId();
|
116 |
+
}
|
117 |
+
|
118 |
+
private function db_connect()
|
119 |
+
{
|
120 |
+
$dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
|
121 |
+
$dbConn = mysqli_init();
|
122 |
+
mysqli_options($dbConn, MYSQLI_OPT_LOCAL_INFILE, true);
|
123 |
+
if (mysqli_real_connect($dbConn, $dbConf->host, $dbConf->username, $dbConf->password)) {
|
124 |
+
$this->db = $dbConn;
|
125 |
+
if (!mysqli_select_db($this->db, $dbConf->dbname)) {
|
126 |
+
die("Can't select the database: " . mysqli_error($this->db));
|
127 |
+
}
|
128 |
+
} else {
|
129 |
+
die("Could not connect: " . mysqli_error($this->db));
|
130 |
+
}
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
function _LOG($log, $isError = false)
|
135 |
+
{
|
136 |
+
if ($log) {
|
137 |
+
if ($isError) {
|
138 |
+
Mage::log($log, null, $this->_errorLogFile);
|
139 |
+
} else {
|
140 |
+
Mage::log($log, null, $this->_logFile);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
function cron_start_import()
|
146 |
+
{
|
147 |
+
$this->_LOG("Start import from cron");
|
148 |
+
$start_hr = Mage::getStoreConfig('sinchimport_root/sinch_cron/sinch_cron_time');
|
149 |
+
$now_hr = date('H');
|
150 |
+
$this->_LOG("Now $now_hr hr, scheduler time is $start_hr hr");
|
151 |
+
|
152 |
+
if ($start_hr == $now_hr) {
|
153 |
+
$this->run_sinch_import();
|
154 |
+
} else {
|
155 |
+
$this->_LOG(" it's NOT time for SINCH ");
|
156 |
+
}
|
157 |
+
|
158 |
+
$this->_LOG("Finish import from cron");
|
159 |
+
}
|
160 |
+
|
161 |
+
function run_sinch_import()
|
162 |
+
{
|
163 |
+
$this->_categoryMetaTitleAttrId = $this->_getCategoryAttributeId('meta_title');
|
164 |
+
$this->_categoryMetadescriptionAttrId = $this->_getCategoryAttributeId('meta_description');
|
165 |
+
$this->_categoryDescriptionAttrId = $this->_getCategoryAttributeId('description');
|
166 |
+
|
167 |
+
$safe_mode_set = ini_get('safe_mode');
|
168 |
+
|
169 |
+
$this->InitImportStatuses('FULL');
|
170 |
+
if ($safe_mode_set) {
|
171 |
+
$this->_LOG('safe_mode is enable. import stoped.');
|
172 |
+
$this->set_import_error_reporting_message('Safe_mode is enabled. Please check the documentation on how to fix this. Import stopped.');
|
173 |
+
exit;
|
174 |
+
}
|
175 |
+
$store_proc = $this->check_store_procedure_exist();
|
176 |
+
|
177 |
+
if (!$store_proc) {
|
178 |
+
$this->_LOG('store prcedure "' . Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s') . '" is absent in this database. import stoped.');
|
179 |
+
$this->set_import_error_reporting_message('Stored procedure "' . Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s') . '" is absent in this database. Import stopped.');
|
180 |
+
exit;
|
181 |
+
}
|
182 |
+
|
183 |
+
$file_privileg = $this->check_db_privileges();
|
184 |
+
|
185 |
+
if (!$file_privileg) {
|
186 |
+
$this->_LOG("Loaddata option not set - please check the documentation on how to fix this. You dan't have privileges for LOAD DATA.");
|
187 |
+
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
188 |
+
exit;
|
189 |
+
}
|
190 |
+
$local_infile = $this->check_local_infile();
|
191 |
+
if (!$local_infile) {
|
192 |
+
$this->_LOG("Loaddata option not set - please check the documentation on how to fix this. Add this string to 'set-variable=local-infile=0' in '/etc/my.cnf'");
|
193 |
+
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
194 |
+
exit;
|
195 |
+
}
|
196 |
+
|
197 |
+
if ($this->is_imort_not_run()) {
|
198 |
+
try {
|
199 |
+
$q = "SELECT GET_LOCK('sinchimport', 30)";
|
200 |
+
$this->db_do($q);
|
201 |
+
|
202 |
+
$import = $this;
|
203 |
+
$import->addImportStatus('Start Import');
|
204 |
+
echo "Upload Files\n";
|
205 |
+
$import->UploadFiles();
|
206 |
+
$import->addImportStatus('Upload Files');
|
207 |
+
|
208 |
+
echo "Parse Category Types\n";
|
209 |
+
$import->ParseCategoryTypes();
|
210 |
+
|
211 |
+
echo "Parse Categories\n";
|
212 |
+
$coincidence = $import->ParseCategories();
|
213 |
+
$import->addImportStatus('Parse Categories');
|
214 |
+
|
215 |
+
echo "Parse Category Features\n";
|
216 |
+
$import->ParseCategoryFeatures();
|
217 |
+
$import->addImportStatus('Parse Category Features');
|
218 |
+
|
219 |
+
echo "Parse Distributors\n";
|
220 |
+
$import->ParseDistributors();
|
221 |
+
if ($this->product_file_format == "NEW") {
|
222 |
+
$this->ParseDistributorsStockAndPrice();
|
223 |
+
$this->ParseProductContracts();
|
224 |
+
}
|
225 |
+
$import->addImportStatus('Parse Distributors');
|
226 |
+
|
227 |
+
echo "Parse EAN Codes\n";
|
228 |
+
$import->ParseEANCodes();
|
229 |
+
$import->addImportStatus('Parse EAN Codes');
|
230 |
+
|
231 |
+
|
232 |
+
echo "Parse Manufacturers\n";
|
233 |
+
$import->ParseManufacturers();
|
234 |
+
$import->addImportStatus('Parse Manufacturers');
|
235 |
+
|
236 |
+
echo "Parse Related Products\n";
|
237 |
+
$import->ParseRelatedProducts();
|
238 |
+
$import->addImportStatus('Parse Related Products');
|
239 |
+
|
240 |
+
echo "Parse Product Features\n";
|
241 |
+
$import->ParseProductFeatures();
|
242 |
+
$import->addImportStatus('Parse Product Features');
|
243 |
+
|
244 |
+
echo "Parse Product Categories\n";
|
245 |
+
$import->ParseProductCategories();
|
246 |
+
|
247 |
+
echo "Parse Products\n";
|
248 |
+
$import->ParseProducts($coincidence);
|
249 |
+
$import->addImportStatus('Parse Products');
|
250 |
+
|
251 |
+
echo "Parse Pictures Gallery";
|
252 |
+
$import->ParseProductsPicturesGallery();
|
253 |
+
$import->addImportStatus('Parse Pictures Gallery');
|
254 |
+
|
255 |
+
echo "Parse Restricted Values\n";
|
256 |
+
$import->ParseRestrictedValues();
|
257 |
+
$import->addImportStatus('Parse Restricted Values');
|
258 |
+
|
259 |
+
echo "Parse Stock And Prices\n";
|
260 |
+
$import->ParseStockAndPrices();
|
261 |
+
$import->addImportStatus('Parse Stock And Prices');
|
262 |
+
|
263 |
+
echo "Apply Customer Group Price\n";
|
264 |
+
//$import->ParsePriceRules();
|
265 |
+
//$import->AddPriceRules();
|
266 |
+
//$import->ApplyCustomerGroupPrice();
|
267 |
+
|
268 |
+
if (file_exists($this->varDir . FILE_PRICE_RULES)) {
|
269 |
+
$ftpCred = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
270 |
+
Mage::dispatchEvent('sinch_pricerules_import_ftp', array(
|
271 |
+
'ftp_host' => $ftpCred["ftp_server"],
|
272 |
+
'ftp_username' => $ftpCred["login"],
|
273 |
+
'ftp_password' => $ftpCred["password"]
|
274 |
+
));
|
275 |
+
}
|
276 |
+
|
277 |
+
Mage::log("Finish Sinch import", null, $this->_logFile);
|
278 |
+
echo "Finish Sinch import\n";
|
279 |
+
|
280 |
+
Mage::log("Start cleanin Sinch cache\n", null, $this->_logFile);
|
281 |
+
echo "Start cleanin Sinch cache\n";
|
282 |
+
Mage::app()->getCacheInstance()->cleanType('block_html');
|
283 |
+
|
284 |
+
Mage::log("Start indexing Sinch features for filters", null, $this->_logFile);
|
285 |
+
echo "Start indexing Sinch features for filters\n";
|
286 |
+
|
287 |
+
// Drop feature result tables
|
288 |
+
$this->_dropFeatureResultTables();
|
289 |
+
|
290 |
+
Mage::log("Finish indexing Sinch features for filters", null, $this->_logFile);
|
291 |
+
$import->addImportStatus('Generate category filters');
|
292 |
+
echo "Finish indexing Sinch features for filters\n";
|
293 |
+
|
294 |
+
|
295 |
+
Mage::log("Start indexing data", null, $this->_logFile);
|
296 |
+
echo "Start indexing data";
|
297 |
+
$import->_cleanCateoryProductFlatTable();
|
298 |
+
$import->runIndexer();
|
299 |
+
|
300 |
+
// Reindex manufacturers
|
301 |
+
$import->reindexManufacturers();
|
302 |
+
|
303 |
+
Mage::log("Finish indexing data", null, $this->_logFile);
|
304 |
+
$import->addImportStatus('Indexing data', 1);
|
305 |
+
echo "Finish indexing data";
|
306 |
+
|
307 |
+
$q = "SELECT RELEASE_LOCK('sinchimport')";
|
308 |
+
$this->db_do($q);
|
309 |
+
} catch (Exception $e) {
|
310 |
+
$this->set_import_error_reporting_message($e);
|
311 |
+
}
|
312 |
+
} else {
|
313 |
+
Mage::log("Sinchimport already run", null, $this->_logFile);
|
314 |
+
echo "Sinchimport already run\n";
|
315 |
+
}
|
316 |
+
|
317 |
+
}
|
318 |
+
|
319 |
+
private function _getCategoryAttributeId($attributeCode)
|
320 |
+
{
|
321 |
+
return $this->_getAttributeId($attributeCode, 'catalog_category');
|
322 |
+
}
|
323 |
+
|
324 |
+
private function _getAttributeId($attributeCode, $typeCode)
|
325 |
+
{
|
326 |
+
if ($typeCode == 'catalog_product') {
|
327 |
+
$typeId = $this->_getProductEntityTypeId();
|
328 |
+
} else {
|
329 |
+
$typeId = $this->_getEntityTypeId($typeCode);
|
330 |
+
}
|
331 |
+
if (!isset($this->_attributeId[$typeCode]) OR !is_array($this->_attributeId[$typeCode])) {
|
332 |
+
$sql = "
|
333 |
+
SELECT attribute_id, attribute_code
|
334 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('eav_attribute') . "
|
335 |
+
WHERE entity_type_id = '" . $typeId . "'
|
336 |
+
";
|
337 |
+
$result = $this->db_do($sql);
|
338 |
+
while ($row = mysqli_fetch_assoc($result)) {
|
339 |
+
$this->_attributeId[$typeCode][$row['attribute_code']] = $row['attribute_id'];
|
340 |
+
}
|
341 |
+
}
|
342 |
+
return $this->_attributeId[$typeCode][$attributeCode];
|
343 |
+
}
|
344 |
+
|
345 |
+
private function _getProductEntityTypeId()
|
346 |
+
{
|
347 |
+
if (!$this->_productEntityTypeId) {
|
348 |
+
$this->_productEntityTypeId = $this->_getEntityTypeId('catalog_product');
|
349 |
+
}
|
350 |
+
return $this->_productEntityTypeId;
|
351 |
+
}
|
352 |
+
|
353 |
+
private function _getEntityTypeId($code)
|
354 |
+
{
|
355 |
+
$sql = "
|
356 |
+
SELECT entity_type_id
|
357 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('eav_entity_type') . "
|
358 |
+
WHERE entity_type_code = '" . $code . "'
|
359 |
+
LIMIT 1
|
360 |
+
";
|
361 |
+
$result = $this->db_do($sql);
|
362 |
+
if ($row = mysqli_fetch_assoc($result)) {
|
363 |
+
return $row['entity_type_id'];
|
364 |
+
}
|
365 |
+
return false;
|
366 |
+
}
|
367 |
+
|
368 |
+
private function db_do($query, $stopLog = false)
|
369 |
+
{
|
370 |
+
if ($this->debug_mode && !$stopLog) {
|
371 |
+
Mage::log("Query: " . $query, null, $this->_logFile);
|
372 |
+
}
|
373 |
+
$result = mysqli_query($this->db, $query);
|
374 |
+
if (!$result) {
|
375 |
+
$this->_LOG("Invalid query: $query\n -->Exception: " . mysqli_error($this->db), true);
|
376 |
+
throw new Exception("Invalid query: $query\n" . mysqli_error($this->db));
|
377 |
+
} else {
|
378 |
+
return $result;
|
379 |
+
}
|
380 |
+
return $result;
|
381 |
+
}
|
382 |
+
|
383 |
+
function InitImportStatuses($type)
|
384 |
+
{
|
385 |
+
$this->db_do("DROP TABLE IF EXISTS " . $this->import_status_table);
|
386 |
+
$this->db_do("CREATE TABLE " . $this->import_status_table . "(
|
387 |
+
id int(11) NOT NULL auto_increment PRIMARY KEY,
|
388 |
+
message varchar(50),
|
389 |
+
finished int(1) default 0
|
390 |
+
)"
|
391 |
+
);
|
392 |
+
$this->db_do("INSERT INTO " . $this->import_status_statistic_table . " (
|
393 |
+
start_import,
|
394 |
+
finish_import,
|
395 |
+
import_type,
|
396 |
+
global_status_import,
|
397 |
+
import_run_type,
|
398 |
+
error_report_message)
|
399 |
+
VALUES(
|
400 |
+
now(),
|
401 |
+
now(),
|
402 |
+
'$type',
|
403 |
+
'Run',
|
404 |
+
'" . $this->import_run_type . "',
|
405 |
+
''
|
406 |
+
)
|
407 |
+
");
|
408 |
+
$q = "SELECT MAX(id) AS id FROM " . $this->import_status_statistic_table;
|
409 |
+
|
410 |
+
$quer = $this->db_do($q);
|
411 |
+
$row = mysqli_fetch_array($quer);
|
412 |
+
$this->current_import_status_statistic_id = $row['id'];
|
413 |
+
$this->db_do("UPDATE " . $this->import_status_statistic_table . "
|
414 |
+
SET global_status_import='Failed'
|
415 |
+
WHERE global_status_import='Run' AND id!=" . $this->current_import_status_statistic_id);
|
416 |
+
|
417 |
+
}
|
418 |
+
|
419 |
+
function set_import_error_reporting_message($message)
|
420 |
+
{
|
421 |
+
$this->db_do("UPDATE " . $this->import_status_statistic_table . "
|
422 |
+
SET error_report_message='" . mysqli_real_escape_string($this->db, $message) . "'
|
423 |
+
WHERE id=" . $this->current_import_status_statistic_id);
|
424 |
+
}
|
425 |
+
|
426 |
+
function check_store_procedure_exist()
|
427 |
+
{
|
428 |
+
$dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
|
429 |
+
$q = 'SHOW PROCEDURE STATUS LIKE "' . Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s') . '"';
|
430 |
+
$quer = $this->db_do($q);
|
431 |
+
$result = false;
|
432 |
+
While ($row = mysqli_fetch_array($quer)) {
|
433 |
+
if (($row['Name'] == Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s')) && ($row['Db'] == $dbConf->dbname)) {
|
434 |
+
$result = true;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
return $result;
|
438 |
+
}
|
439 |
+
|
440 |
+
function check_db_privileges()
|
441 |
+
{
|
442 |
+
$q = 'SHOW PRIVILEGES';
|
443 |
+
$quer = $this->db_do($q);
|
444 |
+
while ($row = mysqli_fetch_array($quer)) {
|
445 |
+
if ($row['Privilege'] == 'File' && $row['Context'] == 'File access on server') {
|
446 |
+
return true;
|
447 |
+
}
|
448 |
+
}
|
449 |
+
return false;
|
450 |
+
}
|
451 |
+
|
452 |
+
function check_local_infile()
|
453 |
+
{
|
454 |
+
$q = 'SHOW VARIABLES LIKE "local_infile"';
|
455 |
+
$quer = $this->db_do($q);
|
456 |
+
$row = mysqli_fetch_array($quer);
|
457 |
+
if ($row['Variable_name'] == 'local_infile' && $row['Value'] == "ON") {
|
458 |
+
return true;
|
459 |
+
} else {
|
460 |
+
return false;
|
461 |
+
}
|
462 |
+
}
|
463 |
+
|
464 |
+
function is_imort_not_run()
|
465 |
+
{
|
466 |
+
$q = "SELECT IS_FREE_LOCK('sinchimport') as getlock";
|
467 |
+
$quer = $this->db_do($q);
|
468 |
+
$row = mysqli_fetch_array($quer);
|
469 |
+
return $row['getlock'];
|
470 |
+
}
|
471 |
+
|
472 |
+
function addImportStatus($message, $finished = 0)
|
473 |
+
{
|
474 |
+
$q = "INSERT INTO " . $this->import_status_table . "
|
475 |
+
(message, finished)
|
476 |
+
VALUES('" . $message . "', $finished)";
|
477 |
+
$this->db_do($q);
|
478 |
+
$this->db_do("UPDATE " . $this->import_status_statistic_table . "
|
479 |
+
SET detail_status_import='" . $message . "'
|
480 |
+
WHERE id=" . $this->current_import_status_statistic_id);
|
481 |
+
if ($finished == 1) {
|
482 |
+
$this->db_do("UPDATE " . $this->import_status_statistic_table . "
|
483 |
+
SET
|
484 |
+
global_status_import='Successful',
|
485 |
+
finish_import=now()
|
486 |
+
WHERE
|
487 |
+
error_report_message='' and
|
488 |
+
id=" . $this->current_import_status_statistic_id);
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
function UploadFiles()
|
493 |
+
{
|
494 |
+
$this->_LOG("Start upload files");
|
495 |
+
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
496 |
+
$login = $dataConf['login'];
|
497 |
+
$passw = $dataConf['password'];
|
498 |
+
$server = $dataConf['ftp_server'];
|
499 |
+
|
500 |
+
if (!$login || !$passw) {
|
501 |
+
$this->_LOG('ftp login or password dosent defined');
|
502 |
+
$this->set_import_error_reporting_message('FTP login or password has not been defined. Import stopped.');
|
503 |
+
exit;
|
504 |
+
|
505 |
+
}
|
506 |
+
$file_url_and_dir = $this->repl_ph(FILE_URL_AND_DIR, array(
|
507 |
+
'server' => $server,
|
508 |
+
'login' => $login,
|
509 |
+
'password' => $passw
|
510 |
+
)
|
511 |
+
);
|
512 |
+
foreach ($this->files as $file) {
|
513 |
+
$this->_LOG("Copy " . $file_url_and_dir . $file . " to " . $this->varDir . $file);
|
514 |
+
if (strstr($file_url_and_dir, 'ftp://')) {
|
515 |
+
preg_match("/ftp:\/\/(.*?):(.*?)@(.*?)(\/.*)/i", $file_url_and_dir, $match);
|
516 |
+
if ($conn = ftp_connect($match[3])) {
|
517 |
+
if (!ftp_login($conn, $login, $passw)) {
|
518 |
+
$this->set_import_error_reporting_message('Incorrect username or password for the Stock In The Channel server. Import stopped.');
|
519 |
+
exit;
|
520 |
+
}
|
521 |
+
} else {
|
522 |
+
$this->set_import_error_reporting_message('FTP connection failed. Unable to connect to the Stock In The Channel server');
|
523 |
+
exit;
|
524 |
+
}
|
525 |
+
if (!$this->wget($file_url_and_dir . $file, $this->varDir . $file, 'system')) {
|
526 |
+
$this->_LOG("wget Can't copy " . $file . ", will use old one");
|
527 |
+
echo "copy Can't copy " . $file_url_and_dir . $file . " to " . $this->varDir . $file . ", will use old one\n";
|
528 |
+
}
|
529 |
+
} else {
|
530 |
+
if (!copy($file_url_and_dir . $file, $this->varDir . $file)) {
|
531 |
+
$this->_LOG("copy Can't copy " . $file . ", will use old one");
|
532 |
+
echo "copy Can't copy " . $file_url_and_dir . $file . " to " . $this->varDir . $file . " will use old one\n";
|
533 |
+
}
|
534 |
+
}
|
535 |
+
exec("chmod a+rw " . $this->varDir . $file);
|
536 |
+
if (!filesize($this->varDir . $file)) {
|
537 |
+
if ($file != FILE_CATEGORIES_FEATURES && $file != FILE_PRODUCT_FEATURES && $file != FILE_RELATED_PRODUCTS && $file != FILE_RESTRICTED_VALUES && $file != FILE_PRODUCT_CATEGORIES && $file != FILE_CATEGORY_TYPES && $file != FILE_DISTRIBUTORS_STOCK_AND_PRICES && $file != FILE_PRODUCT_CONTRACTS && $file != FILE_PRICE_RULES) {
|
538 |
+
$this->_LOG("Can't copy " . $file_url_and_dir . $file . ". file $this->varDir.$file is emty");
|
539 |
+
$this->set_import_error_reporting_message("Can't copy " . $file_url_and_dir . $file . ". file " . $this->varDir . $file . " is emty");
|
540 |
+
$this->addImportStatus('Sinch import stoped. Impot file(s) empty', 1);
|
541 |
+
|
542 |
+
exit;
|
543 |
+
} else {
|
544 |
+
if ($file == FILE_CATEGORIES_FEATURES) {
|
545 |
+
$this->_LOG("Can't copy " . FILE_CATEGORIES_FEATURES . " file ignored");
|
546 |
+
$this->_ignore_category_features = true;
|
547 |
+
} elseif ($file == FILE_PRODUCT_FEATURES) {
|
548 |
+
$this->_LOG("Can't copy " . FILE_PRODUCT_FEATURES . " file ignored");
|
549 |
+
$this->_ignore_product_features = true;
|
550 |
+
} elseif ($file == FILE_RELATED_PRODUCTS) {
|
551 |
+
$this->_LOG("Can't copy " . FILE_RELATED_PRODUCTS . " file ignored");
|
552 |
+
$this->_ignore_product_related = true;
|
553 |
+
} elseif ($file == FILE_RESTRICTED_VALUES) {
|
554 |
+
$this->_LOG("Can't copy " . FILE_RESTRICTED_VALUES . " file ignored");
|
555 |
+
$this->_ignore_restricted_values = true;
|
556 |
+
} elseif ($file == FILE_PRODUCT_CATEGORIES) {
|
557 |
+
$this->_LOG("Can't copy " . FILE_PRODUCT_CATEGORIES . " file ignored");
|
558 |
+
$this->_ignore_product_categories = true;
|
559 |
+
$this->product_file_format = "OLD";
|
560 |
+
} elseif ($file == FILE_CATEGORY_TYPES) {
|
561 |
+
$this->_LOG("Can't copy " . FILE_CATEGORY_TYPES . " file ignored");
|
562 |
+
$this->_ignore_category_types = true;
|
563 |
+
} elseif ($file == FILE_DISTRIBUTORS_STOCK_AND_PRICES) {
|
564 |
+
$this->_LOG("Can't copy " . FILE_DISTRIBUTORS_STOCK_AND_PRICES . " file ignored");
|
565 |
+
$this->_ignore_category_types = true;
|
566 |
+
} elseif ($file == FILE_PRODUCT_CONTRACTS) {
|
567 |
+
$this->_LOG("Can't copy " . FILE_PRODUCT_CONTRACTS . " file ignored");
|
568 |
+
$this->_ignore_product_contracts = true;
|
569 |
+
} elseif ($file == FILE_PRICE_RULES) {
|
570 |
+
$this->_LOG("Can't copy " . FILE_PRICE_RULES . " file ignored");
|
571 |
+
$this->_ignore_price_rules = true;
|
572 |
+
}
|
573 |
+
|
574 |
+
}
|
575 |
+
}
|
576 |
+
}
|
577 |
+
if (file_exists($file_url_and_dir . FILE_PRODUCT_CATEGORIES)) {
|
578 |
+
$this->product_file_format = "NEW";
|
579 |
+
$this->_LOG("File " . $file_url_and_dir . FILE_PRODUCT_CATEGORIES . " exist. Will used parser for NEW format product.csv");
|
580 |
+
} else {
|
581 |
+
$this->product_file_format = "OLD";
|
582 |
+
$this->_LOG("File " . $file_url_and_dir . FILE_PRODUCT_CATEGORIES . " dosen't exist. Will used parser for OLD format product.csv");
|
583 |
+
}
|
584 |
+
$this->_LOG("Finish upload files");
|
585 |
+
}
|
586 |
+
|
587 |
+
private function repl_ph($content, $hash)
|
588 |
+
{
|
589 |
+
if ($hash) {
|
590 |
+
foreach ($hash as $key => $val) {
|
591 |
+
if ($key == "category_name") {
|
592 |
+
if (strlen($val) > 25) {
|
593 |
+
$val = substr($val, 0, 24) . "...";
|
594 |
+
}
|
595 |
+
}
|
596 |
+
$content = preg_replace("/%%%$key%%%/", $val, $content);
|
597 |
+
}
|
598 |
+
}
|
599 |
+
return $content;
|
600 |
+
}
|
601 |
+
|
602 |
+
function wget()
|
603 |
+
{
|
604 |
+
|
605 |
+
$got = func_num_args();
|
606 |
+
$url = $file = $flag = false;
|
607 |
+
|
608 |
+
if ($got < 1) {
|
609 |
+
return false;
|
610 |
+
} elseif ($got == 1) {
|
611 |
+
$url = func_get_arg(0);
|
612 |
+
} elseif ($got == 2) {
|
613 |
+
$url = func_get_arg(0);
|
614 |
+
$file = func_get_arg(1);
|
615 |
+
} elseif ($got == 3) {
|
616 |
+
$url = func_get_arg(0);
|
617 |
+
$file = func_get_arg(1);
|
618 |
+
$flag = func_get_arg(2);
|
619 |
+
}
|
620 |
+
|
621 |
+
if ($flag == 'copy') {
|
622 |
+
if (copy($url, $file)) {
|
623 |
+
return true;
|
624 |
+
} else {
|
625 |
+
return false;
|
626 |
+
}
|
627 |
+
} elseif ($flag == 'system') {
|
628 |
+
exec("wget -O$file $url");
|
629 |
+
return true;
|
630 |
+
} else {
|
631 |
+
$c = curl_init($url);
|
632 |
+
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
633 |
+
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
|
634 |
+
curl_setopt($c, CURLOPT_HEADER, array("Accept-Encoding: gzip"));
|
635 |
+
if (!$file) {
|
636 |
+
$page = curl_exec($c);
|
637 |
+
curl_close($c);
|
638 |
+
return $page;
|
639 |
+
} else {
|
640 |
+
$FH = fopen($file, "wb");
|
641 |
+
fwrite($FH, curl_exec($c));
|
642 |
+
fclose($FH);
|
643 |
+
curl_close($c);
|
644 |
+
return true;
|
645 |
+
}
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
+
function ParseCategoryTypes()
|
650 |
+
{
|
651 |
+
$parse_file = $this->varDir . FILE_CATEGORY_TYPES;
|
652 |
+
if (filesize($parse_file)) {
|
653 |
+
$this->_LOG("Start parse " . FILE_CATEGORY_TYPES);
|
654 |
+
|
655 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('category_types_temp'));
|
656 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('category_types_temp') . "(
|
657 |
+
id int(11),
|
658 |
+
name varchar(255),
|
659 |
+
key(id)
|
660 |
+
)");
|
661 |
+
|
662 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
663 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('category_types_temp') . "
|
664 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
665 |
+
OPTIONALLY ENCLOSED BY '\"'
|
666 |
+
LINES TERMINATED BY \"\r\n\"
|
667 |
+
IGNORE 1 LINES ");
|
668 |
+
|
669 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_category_types'));
|
670 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('category_types_temp') . "
|
671 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_category_types'));
|
672 |
+
|
673 |
+
$this->_LOG("Finish parse " . FILE_CATEGORY_TYPES);
|
674 |
+
} else {
|
675 |
+
$this->_LOG("Wrong file " . $parse_file);
|
676 |
+
}
|
677 |
+
$this->_LOG(' ');
|
678 |
+
|
679 |
+
}
|
680 |
+
|
681 |
+
function ParseCategories()
|
682 |
+
{
|
683 |
+
|
684 |
+
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
685 |
+
$im_type = $dataConf['replace_category'];
|
686 |
+
$parse_file = $this->varDir . FILE_CATEGORIES;
|
687 |
+
//$parse_file = $this->varDir . FILE_CATEGORIES_TEST;
|
688 |
+
$field_terminated_char = $this->field_terminated_char;
|
689 |
+
|
690 |
+
$this->im_type = $im_type;
|
691 |
+
|
692 |
+
if (filesize($parse_file)) {
|
693 |
+
$this->_LOG("Start parse " . FILE_CATEGORIES);
|
694 |
+
|
695 |
+
$this->_getCategoryEntityTypeIdAndDefault_attribute_set_id();
|
696 |
+
|
697 |
+
$categories_temp = Mage::getSingleton('core/resource')->getTableName('categories_temp');
|
698 |
+
$catalog_category_entity = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity');
|
699 |
+
$catalog_category_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar');
|
700 |
+
$catalog_category_entity_int = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int');
|
701 |
+
$stINch_categories_mapping_temp = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp');
|
702 |
+
$stINch_categories_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping');
|
703 |
+
$stINch_categories = Mage::getSingleton('core/resource')->getTableName('stINch_categories');
|
704 |
+
$category_types = Mage::getSingleton('core/resource')->getTableName('stINch_category_types');
|
705 |
+
|
706 |
+
$_categoryEntityTypeId = $this->_categoryEntityTypeId;
|
707 |
+
$_categoryDefault_attribute_set_id = $this->_categoryDefault_attribute_set_id;
|
708 |
+
|
709 |
+
$name_attrid = $this->_getCategoryAttributeId('name');
|
710 |
+
$is_anchor_attrid = $this->_getCategoryAttributeId('is_anchor');
|
711 |
+
$image_attrid = $this->_getCategoryAttributeId('image');
|
712 |
+
|
713 |
+
$attr_url_key = $this->attributes['url_key'];
|
714 |
+
$attr_display_mode = $this->attributes['display_mode'];
|
715 |
+
$attr_is_active = $this->attributes['is_active'];
|
716 |
+
$attr_include_in_menu = $this->attributes['include_in_menu'];
|
717 |
+
|
718 |
+
$this->loadCategoriesTemp($categories_temp, $parse_file, $field_terminated_char);
|
719 |
+
$coincidence = $this->calculateCategoryCoincidence($categories_temp, $catalog_category_entity, $catalog_category_entity_varchar, $im_type, $category_types);
|
720 |
+
|
721 |
+
if (!$this->check_loaded_data($parse_file, $categories_temp)) {
|
722 |
+
$inf = mysqli_info();
|
723 |
+
$this->set_import_error_reporting_message('The Stock In The Channel data files do not appear to be in the correct format. Check file' . $parse_file . "(LOAD DATA ... " . $inf . ")");
|
724 |
+
exit;
|
725 |
+
}
|
726 |
+
|
727 |
+
echo("\n\ncoincidence = [" . count($coincidence) . "]\n\n");
|
728 |
+
|
729 |
+
if (count($coincidence) == 1) // one store logic
|
730 |
+
{
|
731 |
+
echo("\n\n\n====================================\nSINGLE STORE\n====================================\n\n\n");
|
732 |
+
if ($im_type == "REWRITE") {
|
733 |
+
$root_cat = 2;
|
734 |
+
|
735 |
+
$root_cat = $this->truncateAllCateriesAndRecreateDefaults($root_cat, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
736 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id,
|
737 |
+
$name_attrid, $attr_url_key, $attr_display_mode, $attr_is_active, $attr_include_in_menu);
|
738 |
+
} else {
|
739 |
+
$root_cat = $this->_getShopRootCategoryId();
|
740 |
+
}
|
741 |
+
|
742 |
+
$this->_root_cat = $root_cat;
|
743 |
+
|
744 |
+
$this->setCategorySettings($categories_temp, $root_cat);
|
745 |
+
$this->mapSinchCategories($stINch_categories_mapping, $catalog_category_entity, $categories_temp, $im_type, $root_cat);
|
746 |
+
$this->addCategoryData($categories_temp, $stINch_categories_mapping, $stINch_categories, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
747 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $name_attrid, $attr_is_active, $attr_include_in_menu, $is_anchor_attrid, $image_attrid, $im_type, $root_cat);
|
748 |
+
} else if (count($coincidence) > 1) // multistore logic
|
749 |
+
{
|
750 |
+
echo("\n\n\n====================================\nMULTIPESTORE\n====================================\n\n\n");
|
751 |
+
switch ($im_type) {
|
752 |
+
case "REWRITE":
|
753 |
+
$this->rewriteMultistoreCategories($coincidence, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
754 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $im_type,
|
755 |
+
$name_attrid, $attr_display_mode, $attr_url_key, $attr_include_in_menu, $attr_is_active, $image_attrid, $is_anchor_attrid,
|
756 |
+
$stINch_categories_mapping_temp, $stINch_categories_mapping, $stINch_categories, $categories_temp);
|
757 |
+
break;
|
758 |
+
case "MERGE" :
|
759 |
+
$this->mergeMultistoreCategories($coincidence, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
760 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $im_type,
|
761 |
+
$name_attrid, $attr_display_mode, $attr_url_key, $attr_include_in_menu, $attr_is_active, $image_attrid, $is_anchor_attrid,
|
762 |
+
$stINch_categories_mapping_temp, $stINch_categories_mapping, $stINch_categories, $categories_temp);
|
763 |
+
break;
|
764 |
+
default :
|
765 |
+
//do nothing
|
766 |
+
};
|
767 |
+
} else {
|
768 |
+
echo("error");
|
769 |
+
}
|
770 |
+
|
771 |
+
$this->_LOG("Finish parse " . FILE_CATEGORIES);
|
772 |
+
} else {
|
773 |
+
$this->_LOG("Wrong file " . $parse_file);
|
774 |
+
}
|
775 |
+
$this->_LOG(' ');
|
776 |
+
$this->_set_default_root_category();
|
777 |
+
return $coincidence;
|
778 |
+
}
|
779 |
+
|
780 |
+
private function _getCategoryEntityTypeIdAndDefault_attribute_set_id()
|
781 |
+
{
|
782 |
+
if (!$this->_categoryEntityTypeId || !$this->_categoryDefault_attribute_set_id) {
|
783 |
+
$sql = "
|
784 |
+
SELECT entity_type_id, default_attribute_set_id
|
785 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('eav_entity_type') . "
|
786 |
+
WHERE entity_type_code = 'catalog_category'
|
787 |
+
LIMIT 1
|
788 |
+
";
|
789 |
+
$result = $this->db_do($sql);
|
790 |
+
if ($row = mysqli_fetch_assoc($result)) {
|
791 |
+
$this->_categoryEntityTypeId = $row['entity_type_id'];
|
792 |
+
$this->_categoryDefault_attribute_set_id = $row['default_attribute_set_id'];
|
793 |
+
}
|
794 |
+
}
|
795 |
+
}
|
796 |
+
|
797 |
+
private function loadCategoriesTemp($categories_temp, $parse_file, $field_terminated_char)
|
798 |
+
{
|
799 |
+
$this->db_do("DROP TABLE IF EXISTS $categories_temp");
|
800 |
+
|
801 |
+
$this->db_do("
|
802 |
+
CREATE TABLE $categories_temp
|
803 |
+
(
|
804 |
+
store_category_id INT(11),
|
805 |
+
parent_store_category_id INT(11),
|
806 |
+
category_name VARCHAR(50),
|
807 |
+
order_number INT(11),
|
808 |
+
is_hidden VARCHAR(10),
|
809 |
+
products_within_sub_categories INT(11),
|
810 |
+
products_within_this_category INT(11),
|
811 |
+
categories_image VARCHAR(255),
|
812 |
+
level INT(10) NOT NULL DEFAULT 0,
|
813 |
+
children_count INT(11) NOT NULL DEFAULT 0,
|
814 |
+
UNSPSC INT(10) DEFAULT NULL,
|
815 |
+
RootName INT(10) DEFAULT NULL,
|
816 |
+
MainImageURL VARCHAR(255),
|
817 |
+
MetaTitle TEXT,
|
818 |
+
MetaDescription TEXT,
|
819 |
+
Description TEXT,
|
820 |
+
KEY(store_category_id),
|
821 |
+
KEY(parent_store_category_id)
|
822 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
823 |
+
|
824 |
+
$this->db_do("
|
825 |
+
LOAD DATA LOCAL INFILE '$parse_file' INTO TABLE $categories_temp
|
826 |
+
FIELDS TERMINATED BY '$field_terminated_char' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\r\n\" IGNORE 1 LINES");
|
827 |
+
|
828 |
+
$this->db_do("ALTER TABLE $categories_temp ADD COLUMN include_in_menu TINYINT(1) NOT NULL DEFAULT 1");
|
829 |
+
$this->db_do("UPDATE $categories_temp SET include_in_menu = 0 WHERE UCASE(is_hidden)='TRUE'");
|
830 |
+
|
831 |
+
$this->db_do("ALTER TABLE $categories_temp ADD COLUMN is_anchor TINYINT(1) NOT NULL DEFAULT 1");
|
832 |
+
$this->db_do("UPDATE $categories_temp SET level = (level+2) WHERE level >= 0");
|
833 |
+
}
|
834 |
+
|
835 |
+
private function calculateCategoryCoincidence($categories_temp, $catalog_category_entity, $catalog_category_entity_varchar, $im_type, $category_types)
|
836 |
+
{
|
837 |
+
$root_categories = $this->db_do("
|
838 |
+
SELECT
|
839 |
+
cce.entity_id,
|
840 |
+
ccev.value AS category_name
|
841 |
+
FROM $catalog_category_entity cce
|
842 |
+
JOIN $catalog_category_entity_varchar ccev
|
843 |
+
ON cce.entity_id = ccev.entity_id
|
844 |
+
AND ccev.store_id = 0
|
845 |
+
AND cce.entity_type_id = ccev.entity_type_id
|
846 |
+
AND ccev.attribute_id = 41
|
847 |
+
WHERE parent_id = 1"); // 41 - category name
|
848 |
+
$OLD = array();
|
849 |
+
while ($root_cat = mysqli_fetch_array($root_categories)) $OLD[] = $root_cat['category_name'];
|
850 |
+
|
851 |
+
$new_categories = $this->db_do("SELECT DISTINCT RootName FROM $categories_temp");
|
852 |
+
|
853 |
+
while ($new_root_cat = mysqli_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['RootName']] = TRUE;
|
854 |
+
|
855 |
+
echo("\ncalculateCategoryCoincidence ...im_type = [$im_type]\n\n");
|
856 |
+
var_dump($exists_coincidence);
|
857 |
+
|
858 |
+
return $exists_coincidence;
|
859 |
+
}
|
860 |
+
|
861 |
+
function check_loaded_data($file, $table)
|
862 |
+
{
|
863 |
+
$cnt_strings_in_file = $this->file_strings_count($file);
|
864 |
+
$cnt_rows_int_table = $this->table_rows_count($table);
|
865 |
+
$persent_cnt_strings_in_file = $cnt_strings_in_file / 10;
|
866 |
+
if ($cnt_rows_int_table > $persent_cnt_strings_in_file) {
|
867 |
+
return true;
|
868 |
+
} else {
|
869 |
+
return false;
|
870 |
+
}
|
871 |
+
}
|
872 |
+
|
873 |
+
function file_strings_count($parse_file)
|
874 |
+
{
|
875 |
+
$files_str = count(file($parse_file));
|
876 |
+
return $files_str;
|
877 |
+
}
|
878 |
+
|
879 |
+
function table_rows_count($table)
|
880 |
+
{
|
881 |
+
$rows_count_res = $this->db_do("select count(*) as cnt from " . $table);
|
882 |
+
$rows_count = mysqli_fetch_array($rows_count_res);
|
883 |
+
return ($rows_count['cnt']);
|
884 |
+
}
|
885 |
+
|
886 |
+
private function truncateAllCateriesAndRecreateDefaults($root_cat, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
887 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id,
|
888 |
+
$name_attrid, $attr_url_key, $attr_display_mode, $attr_is_active, $attr_include_in_menu)
|
889 |
+
{
|
890 |
+
$this->db_do('SET foreign_key_checks=0');
|
891 |
+
|
892 |
+
$this->db_do("TRUNCATE $catalog_category_entity");
|
893 |
+
$this->db_do("
|
894 |
+
INSERT $catalog_category_entity
|
895 |
+
(
|
896 |
+
entity_id,
|
897 |
+
entity_type_id,
|
898 |
+
attribute_set_id,
|
899 |
+
parent_id,
|
900 |
+
created_at,
|
901 |
+
updated_at,
|
902 |
+
path,
|
903 |
+
position,
|
904 |
+
level,
|
905 |
+
children_count,
|
906 |
+
store_category_id,
|
907 |
+
parent_store_category_id
|
908 |
+
)
|
909 |
+
VALUES
|
910 |
+
(1, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 0, '0000-00-00 00:00:00', now(), '1', 0, 0, 1, null, null),
|
911 |
+
(2, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/2', 1, 1, 1, null, null)");
|
912 |
+
|
913 |
+
$this->db_do("TRUNCATE $catalog_category_entity_varchar");
|
914 |
+
$this->db_do("
|
915 |
+
INSERT $catalog_category_entity_varchar
|
916 |
+
(
|
917 |
+
value_id,
|
918 |
+
entity_type_id,
|
919 |
+
attribute_id,
|
920 |
+
store_id,
|
921 |
+
entity_id,
|
922 |
+
value
|
923 |
+
)
|
924 |
+
VALUES
|
925 |
+
(1, $_categoryEntityTypeId, $name_attrid, 0, 1, 'Root Catalog'),
|
926 |
+
(2, $_categoryEntityTypeId, $name_attrid, 1, 1, 'Root Catalog'),
|
927 |
+
(3, $_categoryEntityTypeId, $attr_url_key, 0, 1, 'root-catalog'),
|
928 |
+
(4, $_categoryEntityTypeId, $name_attrid, 0, 2, 'Default Category'),
|
929 |
+
(5, $_categoryEntityTypeId, $name_attrid, 1, 2, 'Default Category'),
|
930 |
+
(6, $_categoryEntityTypeId, $attr_display_mode, 1, 2, 'PRODUCTS'),
|
931 |
+
(7, $_categoryEntityTypeId, $attr_url_key, 0, 2, 'default-category')");
|
932 |
+
|
933 |
+
$this->db_do("TRUNCATE $catalog_category_entity_int");
|
934 |
+
$this->db_do("
|
935 |
+
INSERT $catalog_category_entity_int
|
936 |
+
(
|
937 |
+
value_id,
|
938 |
+
entity_type_id,
|
939 |
+
attribute_id,
|
940 |
+
store_id,
|
941 |
+
entity_id,
|
942 |
+
value
|
943 |
+
)
|
944 |
+
VALUES
|
945 |
+
(1, $_categoryEntityTypeId, $attr_is_active, 0, 2, 1),
|
946 |
+
(2, $_categoryEntityTypeId, $attr_is_active, 1, 2, 1),
|
947 |
+
(3, $_categoryEntityTypeId, $attr_include_in_menu, 0, 1, 1),
|
948 |
+
(4, $_categoryEntityTypeId, $attr_include_in_menu, 0, 2, 1)");
|
949 |
+
|
950 |
+
return $root_cat;
|
951 |
+
}
|
952 |
+
|
953 |
+
private function _getShopRootCategoryId($cat_id = 0)
|
954 |
+
{
|
955 |
+
if ($root_cat = Mage::app()->getStore()->getRootCategoryId()) {
|
956 |
+
return $root_cat;
|
957 |
+
} else {
|
958 |
+
$q = "SELECT
|
959 |
+
entity_id
|
960 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar') . "
|
961 |
+
WHERE
|
962 |
+
value='default-category'";
|
963 |
+
$res = $this->db_do($q);
|
964 |
+
$row = mysqli_fetch_array($res);
|
965 |
+
if ($row['entity_id'] > 0) {
|
966 |
+
return $row['entity_id'];
|
967 |
+
} else {
|
968 |
+
$q = "SELECT entity_id
|
969 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . "
|
970 |
+
WHERE parent_id=" . $cat_id;
|
971 |
+
$quer = $this->db_do($q);
|
972 |
+
$count = 0;
|
973 |
+
while ($row = mysqli_fetch_array($quer)) {
|
974 |
+
$count++;
|
975 |
+
$entity_id = $row['entity_id'];
|
976 |
+
}
|
977 |
+
if ($count > 1 || $count == 0) {
|
978 |
+
return ($cat_id);
|
979 |
+
} else {
|
980 |
+
return $this->_getShopRootCategoryId($entity_id);
|
981 |
+
}
|
982 |
+
}
|
983 |
+
}
|
984 |
+
}
|
985 |
+
|
986 |
+
private function setCategorySettings($categories_temp, $root_cat)
|
987 |
+
{
|
988 |
+
$this->db_do("
|
989 |
+
UPDATE $categories_temp
|
990 |
+
SET parent_store_category_id = $root_cat
|
991 |
+
WHERE parent_store_category_id = 0");
|
992 |
+
|
993 |
+
$store_cat_ids = $this->db_do("SELECT store_category_id FROM $categories_temp");
|
994 |
+
while ($row = mysqli_fetch_array($store_cat_ids)) {
|
995 |
+
$store_category_id = $row['store_category_id'];
|
996 |
+
|
997 |
+
$children_count = $this->count_children($store_category_id);
|
998 |
+
$level = $this->get_category_level($store_category_id);
|
999 |
+
|
1000 |
+
$this->db_do("
|
1001 |
+
UPDATE $categories_temp
|
1002 |
+
SET children_count = $children_count,
|
1003 |
+
level = $level
|
1004 |
+
WHERE store_category_id = $store_category_id");
|
1005 |
+
}
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
function count_children($id)
|
1009 |
+
{
|
1010 |
+
|
1011 |
+
$q = "SELECT store_category_id
|
1012 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('categories_temp') . "
|
1013 |
+
WHERE parent_store_category_id=" . $id;
|
1014 |
+
$quer = $this->db_do($q);
|
1015 |
+
$count = 0;
|
1016 |
+
while ($row = mysqli_fetch_array($quer)) {
|
1017 |
+
$count += $this->count_children($row['store_category_id']);
|
1018 |
+
$count++;
|
1019 |
+
}
|
1020 |
+
return ($count);
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
function get_category_level($id)
|
1024 |
+
{
|
1025 |
+
$q = "SELECT parent_store_category_id
|
1026 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('categories_temp') . "
|
1027 |
+
WHERE store_category_id=" . $id;
|
1028 |
+
$quer = $this->db_do($q);
|
1029 |
+
$level = 1;
|
1030 |
+
$row = mysqli_fetch_array($quer);
|
1031 |
+
while ($row['parent_store_category_id'] != 0) {
|
1032 |
+
$q = "SELECT parent_store_category_id
|
1033 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('categories_temp') . "
|
1034 |
+
WHERE store_category_id=" . $row['parent_store_category_id'];
|
1035 |
+
$quer = $this->db_do($q);
|
1036 |
+
$row = mysqli_fetch_array($quer);
|
1037 |
+
$level++;
|
1038 |
+
if ($level > 20) {
|
1039 |
+
break;
|
1040 |
+
}
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
return ($level);
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
public function mapSinchCategories($stINch_categories_mapping, $catalog_category_entity, $categories_temp, $im_type, $root_cat, $mapping_again = false)
|
1047 |
+
{
|
1048 |
+
$stINch_categories_mapping_temp = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp');
|
1049 |
+
|
1050 |
+
$this->db_do("DROP TABLE IF EXISTS $stINch_categories_mapping_temp");
|
1051 |
+
|
1052 |
+
$this->db_do("
|
1053 |
+
CREATE TABLE $stINch_categories_mapping_temp
|
1054 |
+
(
|
1055 |
+
shop_entity_id INT(11) UNSIGNED NOT NULL,
|
1056 |
+
shop_entity_type_id INT(11),
|
1057 |
+
shop_attribute_set_id INT(11),
|
1058 |
+
shop_parent_id INT(11),
|
1059 |
+
shop_store_category_id INT(11),
|
1060 |
+
shop_parent_store_category_id INT(11),
|
1061 |
+
store_category_id INT(11),
|
1062 |
+
parent_store_category_id INT(11),
|
1063 |
+
category_name VARCHAR(255),
|
1064 |
+
order_number INT(11),
|
1065 |
+
products_within_this_category INT(11),
|
1066 |
+
|
1067 |
+
KEY shop_entity_id (shop_entity_id),
|
1068 |
+
KEY shop_parent_id (shop_parent_id),
|
1069 |
+
KEY store_category_id (store_category_id),
|
1070 |
+
KEY parent_store_category_id (parent_store_category_id),
|
1071 |
+
UNIQUE KEY(shop_entity_id)
|
1072 |
+
)");
|
1073 |
+
|
1074 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS $stINch_categories_mapping LIKE $stINch_categories_mapping_temp");
|
1075 |
+
|
1076 |
+
// added for mapping new sinch categories in merge && !UPDATE_CATEGORY_DATA mode
|
1077 |
+
if ((UPDATE_CATEGORY_DATA && $im_type == "MERGE") || ($im_type == "REWRITE")) {
|
1078 |
+
// backup Category ID in REWRITE mode
|
1079 |
+
if ($mapping_again) {
|
1080 |
+
$this->db_do("
|
1081 |
+
INSERT IGNORE INTO $stINch_categories_mapping_temp
|
1082 |
+
(
|
1083 |
+
shop_entity_id,
|
1084 |
+
shop_entity_type_id,
|
1085 |
+
shop_attribute_set_id,
|
1086 |
+
shop_parent_id,
|
1087 |
+
shop_store_category_id,
|
1088 |
+
shop_parent_store_category_id
|
1089 |
+
)
|
1090 |
+
(SELECT
|
1091 |
+
entity_id,
|
1092 |
+
entity_type_id,
|
1093 |
+
attribute_set_id,
|
1094 |
+
parent_id,
|
1095 |
+
store_category_id,
|
1096 |
+
parent_store_category_id
|
1097 |
+
FROM $catalog_category_entity)");
|
1098 |
+
|
1099 |
+
$this->db_do("
|
1100 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1101 |
+
JOIN $categories_temp c
|
1102 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
1103 |
+
SET
|
1104 |
+
cmt.store_category_id = c.store_category_id,
|
1105 |
+
cmt.parent_store_category_id = c.parent_store_category_id,
|
1106 |
+
cmt.category_name = c.category_name,
|
1107 |
+
cmt.order_number = c.order_number,
|
1108 |
+
cmt.products_within_this_category = c.products_within_this_category");
|
1109 |
+
|
1110 |
+
$this->db_do("
|
1111 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1112 |
+
JOIN $catalog_category_entity cce
|
1113 |
+
ON cmt.parent_store_category_id = cce.store_category_id
|
1114 |
+
SET cmt.shop_parent_id = cce.entity_id");
|
1115 |
+
|
1116 |
+
$this->db_do("
|
1117 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1118 |
+
JOIN $categories_temp c
|
1119 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
1120 |
+
SET shop_parent_id = " . $this->_root_cat . "
|
1121 |
+
WHERE shop_parent_id = 0");
|
1122 |
+
|
1123 |
+
$this->db_do("
|
1124 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1125 |
+
JOIN $catalog_category_entity cce
|
1126 |
+
ON cmt.shop_entity_id = cce.entity_id
|
1127 |
+
SET cce.parent_id = cmt.shop_parent_id");
|
1128 |
+
} else {
|
1129 |
+
$catalog_category_entity_backup = Mage::getSingleton('core/resource')->getTableName('sinch_category_backup');
|
1130 |
+
if (!$this->_checkDataExist($catalog_category_entity_backup)) {
|
1131 |
+
$catalog_category_entity_backup = $catalog_category_entity;
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
$this->db_do("
|
1135 |
+
INSERT IGNORE INTO $stINch_categories_mapping_temp
|
1136 |
+
(
|
1137 |
+
shop_entity_id,
|
1138 |
+
shop_entity_type_id,
|
1139 |
+
shop_attribute_set_id,
|
1140 |
+
shop_parent_id,
|
1141 |
+
shop_store_category_id,
|
1142 |
+
shop_parent_store_category_id
|
1143 |
+
)
|
1144 |
+
(SELECT
|
1145 |
+
entity_id,
|
1146 |
+
entity_type_id,
|
1147 |
+
attribute_set_id,
|
1148 |
+
parent_id,
|
1149 |
+
store_category_id,
|
1150 |
+
parent_store_category_id
|
1151 |
+
FROM $catalog_category_entity_backup)");
|
1152 |
+
|
1153 |
+
$this->db_do("
|
1154 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1155 |
+
JOIN $categories_temp c
|
1156 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
1157 |
+
SET
|
1158 |
+
cmt.store_category_id = c.store_category_id,
|
1159 |
+
cmt.parent_store_category_id = c.parent_store_category_id,
|
1160 |
+
cmt.category_name = c.category_name,
|
1161 |
+
cmt.order_number = c.order_number,
|
1162 |
+
cmt.products_within_this_category = c.products_within_this_category");
|
1163 |
+
|
1164 |
+
$this->db_do("
|
1165 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1166 |
+
JOIN $catalog_category_entity_backup cce
|
1167 |
+
ON cmt.parent_store_category_id = cce.store_category_id
|
1168 |
+
SET cmt.shop_parent_id = cce.entity_id");
|
1169 |
+
|
1170 |
+
$this->db_do("
|
1171 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1172 |
+
JOIN $categories_temp c
|
1173 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
1174 |
+
SET shop_parent_id = " . $this->_root_cat . "
|
1175 |
+
WHERE shop_parent_id = 0");
|
1176 |
+
|
1177 |
+
$this->db_do("
|
1178 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1179 |
+
JOIN $catalog_category_entity cce
|
1180 |
+
ON cmt.shop_entity_id = cce.entity_id
|
1181 |
+
SET cce.parent_id = cmt.shop_parent_id");
|
1182 |
+
}
|
1183 |
+
// (end) backup Category ID in REWRITE mode
|
1184 |
+
} else {
|
1185 |
+
$this->db_do("
|
1186 |
+
INSERT IGNORE INTO $stINch_categories_mapping_temp
|
1187 |
+
(
|
1188 |
+
shop_entity_id,
|
1189 |
+
shop_entity_type_id,
|
1190 |
+
shop_attribute_set_id,
|
1191 |
+
shop_parent_id,
|
1192 |
+
shop_store_category_id,
|
1193 |
+
shop_parent_store_category_id
|
1194 |
+
)
|
1195 |
+
(SELECT
|
1196 |
+
entity_id,
|
1197 |
+
entity_type_id,
|
1198 |
+
attribute_set_id,
|
1199 |
+
parent_id,
|
1200 |
+
store_category_id,
|
1201 |
+
parent_store_category_id
|
1202 |
+
FROM $catalog_category_entity)");
|
1203 |
+
|
1204 |
+
$this->db_do("
|
1205 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1206 |
+
JOIN $categories_temp c
|
1207 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
1208 |
+
SET
|
1209 |
+
cmt.store_category_id = c.store_category_id,
|
1210 |
+
cmt.parent_store_category_id = c.parent_store_category_id,
|
1211 |
+
cmt.category_name = c.category_name,
|
1212 |
+
cmt.order_number = c.order_number,
|
1213 |
+
cmt.products_within_this_category = c.products_within_this_category");
|
1214 |
+
|
1215 |
+
$this->db_do("
|
1216 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1217 |
+
JOIN $catalog_category_entity cce
|
1218 |
+
ON cmt.parent_store_category_id = cce.store_category_id
|
1219 |
+
SET cmt.shop_parent_id = cce.entity_id");
|
1220 |
+
|
1221 |
+
$this->db_do("
|
1222 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1223 |
+
JOIN $categories_temp c
|
1224 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
1225 |
+
SET shop_parent_id = " . $this->_root_cat . "
|
1226 |
+
WHERE shop_parent_id = 0");
|
1227 |
+
|
1228 |
+
$this->db_do("
|
1229 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1230 |
+
JOIN $catalog_category_entity cce
|
1231 |
+
ON cmt.shop_entity_id = cce.entity_id
|
1232 |
+
SET cce.parent_id = cmt.shop_parent_id
|
1233 |
+
WHERE cce.parent_id = 0 AND cce.store_category_id IS NOT NULL");
|
1234 |
+
}
|
1235 |
+
$this->_LOG("Execute function mapSinchCategories");
|
1236 |
+
$this->db_do("DROP TABLE IF EXISTS $stINch_categories_mapping");
|
1237 |
+
$this->db_do("RENAME TABLE $stINch_categories_mapping_temp TO $stINch_categories_mapping");
|
1238 |
+
}
|
1239 |
+
|
1240 |
+
private function addCategoryData($categories_temp, $stINch_categories_mapping, $stINch_categories, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
1241 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $name_attrid, $attr_is_active, $attr_include_in_menu, $is_anchor_attrid, $image_attrid, $im_type, $root_cat)
|
1242 |
+
{
|
1243 |
+
if (UPDATE_CATEGORY_DATA) {
|
1244 |
+
echo "Update category_entity \n";
|
1245 |
+
|
1246 |
+
$q = "
|
1247 |
+
INSERT INTO $catalog_category_entity
|
1248 |
+
(
|
1249 |
+
entity_type_id,
|
1250 |
+
attribute_set_id,
|
1251 |
+
created_at,
|
1252 |
+
updated_at,
|
1253 |
+
level,
|
1254 |
+
children_count,
|
1255 |
+
entity_id,
|
1256 |
+
position,
|
1257 |
+
parent_id,
|
1258 |
+
store_category_id,
|
1259 |
+
parent_store_category_id
|
1260 |
+
)
|
1261 |
+
(SELECT
|
1262 |
+
$_categoryEntityTypeId,
|
1263 |
+
$_categoryDefault_attribute_set_id,
|
1264 |
+
now(),
|
1265 |
+
now(),
|
1266 |
+
c.level,
|
1267 |
+
c.children_count,
|
1268 |
+
scm.shop_entity_id,
|
1269 |
+
c.order_number,
|
1270 |
+
scm.shop_parent_id,
|
1271 |
+
c.store_category_id,
|
1272 |
+
c.parent_store_category_id
|
1273 |
+
FROM $categories_temp c
|
1274 |
+
LEFT JOIN $stINch_categories_mapping scm
|
1275 |
+
ON c.store_category_id = scm.store_category_id
|
1276 |
+
)
|
1277 |
+
ON DUPLICATE KEY UPDATE
|
1278 |
+
updated_at = now(),
|
1279 |
+
store_category_id = c.store_category_id,
|
1280 |
+
level = c.level,
|
1281 |
+
children_count = c.children_count,
|
1282 |
+
position = c.order_number,
|
1283 |
+
parent_store_category_id = c.parent_store_category_id";
|
1284 |
+
} else {
|
1285 |
+
echo "Insert ignore category_entity \n";
|
1286 |
+
|
1287 |
+
$q = "
|
1288 |
+
INSERT IGNORE INTO $catalog_category_entity
|
1289 |
+
(
|
1290 |
+
entity_type_id,
|
1291 |
+
attribute_set_id,
|
1292 |
+
created_at,
|
1293 |
+
updated_at,
|
1294 |
+
level,
|
1295 |
+
children_count,
|
1296 |
+
entity_id,
|
1297 |
+
position,
|
1298 |
+
parent_id,
|
1299 |
+
store_category_id,
|
1300 |
+
parent_store_category_id
|
1301 |
+
)
|
1302 |
+
(SELECT
|
1303 |
+
$_categoryEntityTypeId,
|
1304 |
+
$_categoryDefault_attribute_set_id,
|
1305 |
+
now(),
|
1306 |
+
now(),
|
1307 |
+
c.level,
|
1308 |
+
c.children_count,
|
1309 |
+
scm.shop_entity_id,
|
1310 |
+
c.order_number,
|
1311 |
+
scm.shop_parent_id,
|
1312 |
+
c.store_category_id,
|
1313 |
+
c.parent_store_category_id
|
1314 |
+
FROM $categories_temp c
|
1315 |
+
LEFT JOIN $stINch_categories_mapping scm
|
1316 |
+
ON c.store_category_id = scm.store_category_id
|
1317 |
+
)";
|
1318 |
+
}
|
1319 |
+
$this->db_do($q);
|
1320 |
+
|
1321 |
+
$this->mapSinchCategories($stINch_categories_mapping, $catalog_category_entity, $categories_temp, $im_type, $root_cat, true);
|
1322 |
+
|
1323 |
+
|
1324 |
+
$categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
|
1325 |
+
while ($row = mysqli_fetch_array($categories)) {
|
1326 |
+
$parent_id = $row['parent_id'];
|
1327 |
+
$entity_id = $row['entity_id'];
|
1328 |
+
|
1329 |
+
$path = $this->culc_path($parent_id, $entity_id);
|
1330 |
+
|
1331 |
+
$this->db_do("
|
1332 |
+
UPDATE $catalog_category_entity
|
1333 |
+
SET path = '$path'
|
1334 |
+
WHERE entity_id = $entity_id");
|
1335 |
+
}
|
1336 |
+
|
1337 |
+
if (UPDATE_CATEGORY_DATA) {
|
1338 |
+
echo "Update category_data \n";
|
1339 |
+
|
1340 |
+
$q = "
|
1341 |
+
INSERT INTO $catalog_category_entity_varchar
|
1342 |
+
(
|
1343 |
+
entity_type_id,
|
1344 |
+
attribute_id,
|
1345 |
+
store_id,
|
1346 |
+
entity_id,
|
1347 |
+
value
|
1348 |
+
)
|
1349 |
+
(SELECT
|
1350 |
+
$_categoryEntityTypeId,
|
1351 |
+
$name_attrid,
|
1352 |
+
0,
|
1353 |
+
scm.shop_entity_id,
|
1354 |
+
c.category_name
|
1355 |
+
FROM $categories_temp c
|
1356 |
+
JOIN $stINch_categories_mapping scm
|
1357 |
+
ON c.store_category_id = scm.store_category_id
|
1358 |
+
)
|
1359 |
+
ON DUPLICATE KEY UPDATE
|
1360 |
+
value = c.category_name";
|
1361 |
+
$this->db_do($q);
|
1362 |
+
|
1363 |
+
$q = "
|
1364 |
+
INSERT INTO $catalog_category_entity_varchar
|
1365 |
+
(
|
1366 |
+
entity_type_id,
|
1367 |
+
attribute_id,
|
1368 |
+
store_id,
|
1369 |
+
entity_id,
|
1370 |
+
value
|
1371 |
+
)
|
1372 |
+
(SELECT
|
1373 |
+
$_categoryEntityTypeId,
|
1374 |
+
$name_attrid,
|
1375 |
+
1,
|
1376 |
+
scm.shop_entity_id,
|
1377 |
+
c.category_name
|
1378 |
+
FROM $categories_temp c
|
1379 |
+
JOIN $stINch_categories_mapping scm
|
1380 |
+
ON c.store_category_id = scm.store_category_id
|
1381 |
+
)
|
1382 |
+
ON DUPLICATE KEY UPDATE
|
1383 |
+
value = c.category_name";
|
1384 |
+
$this->db_do($q);
|
1385 |
+
|
1386 |
+
$q = "
|
1387 |
+
INSERT INTO $catalog_category_entity
|
1388 |
+
(
|
1389 |
+
entity_type_id,
|
1390 |
+
attribute_id,
|
1391 |
+
store_id,
|
1392 |
+
entity_id,
|
1393 |
+
value
|
1394 |
+
)
|
1395 |
+
(SELECT
|
1396 |
+
$_categoryEntityTypeId,
|
1397 |
+
$attr_is_active,
|
1398 |
+
0,
|
1399 |
+
scm.shop_entity_id,
|
1400 |
+
1
|
1401 |
+
FROM $categories_temp c
|
1402 |
+
JOIN $stINch_categories_mapping scm
|
1403 |
+
ON c.store_category_id = scm.store_category_id
|
1404 |
+
)
|
1405 |
+
ON DUPLICATE KEY UPDATE
|
1406 |
+
value = 1";
|
1407 |
+
$this->db_do($q);
|
1408 |
+
|
1409 |
+
$q = "
|
1410 |
+
INSERT INTO $catalog_category_entity_int
|
1411 |
+
(
|
1412 |
+
entity_type_id,
|
1413 |
+
attribute_id,
|
1414 |
+
store_id,
|
1415 |
+
entity_id,
|
1416 |
+
value
|
1417 |
+
)
|
1418 |
+
(SELECT
|
1419 |
+
$_categoryEntityTypeId,
|
1420 |
+
$attr_is_active,
|
1421 |
+
1,
|
1422 |
+
scm.shop_entity_id,
|
1423 |
+
1
|
1424 |
+
FROM $categories_temp c
|
1425 |
+
JOIN $stINch_categories_mapping scm
|
1426 |
+
ON c.store_category_id = scm.store_category_id
|
1427 |
+
)
|
1428 |
+
ON DUPLICATE KEY UPDATE
|
1429 |
+
value = 1";
|
1430 |
+
$this->db_do($q);
|
1431 |
+
|
1432 |
+
$q = "
|
1433 |
+
INSERT INTO $catalog_category_entity_int
|
1434 |
+
(
|
1435 |
+
entity_type_id,
|
1436 |
+
attribute_id,
|
1437 |
+
store_id,
|
1438 |
+
entity_id,
|
1439 |
+
value
|
1440 |
+
)
|
1441 |
+
(SELECT
|
1442 |
+
$_categoryEntityTypeId,
|
1443 |
+
$attr_include_in_menu,
|
1444 |
+
0,
|
1445 |
+
scm.shop_entity_id,
|
1446 |
+
c.include_in_menu
|
1447 |
+
FROM $categories_temp c
|
1448 |
+
JOIN $stINch_categories_mapping scm
|
1449 |
+
ON c.store_category_id = scm.store_category_id
|
1450 |
+
)
|
1451 |
+
ON DUPLICATE KEY UPDATE
|
1452 |
+
value = c.include_in_menu";
|
1453 |
+
$this->db_do($q);
|
1454 |
+
|
1455 |
+
$q = "
|
1456 |
+
INSERT INTO $catalog_category_entity_int
|
1457 |
+
(
|
1458 |
+
entity_type_id,
|
1459 |
+
attribute_id,
|
1460 |
+
store_id,
|
1461 |
+
entity_id,
|
1462 |
+
value
|
1463 |
+
)
|
1464 |
+
(SELECT
|
1465 |
+
$_categoryEntityTypeId,
|
1466 |
+
$is_anchor_attrid,
|
1467 |
+
1,
|
1468 |
+
scm.shop_entity_id,
|
1469 |
+
c.is_anchor
|
1470 |
+
FROM $categories_temp c
|
1471 |
+
JOIN $stINch_categories_mapping scm
|
1472 |
+
ON c.store_category_id = scm.store_category_id
|
1473 |
+
)
|
1474 |
+
ON DUPLICATE KEY UPDATE
|
1475 |
+
value = c.is_anchor";
|
1476 |
+
$this->db_do($q);
|
1477 |
+
|
1478 |
+
$q = "
|
1479 |
+
INSERT INTO $catalog_category_entity_int
|
1480 |
+
(
|
1481 |
+
entity_type_id,
|
1482 |
+
attribute_id,
|
1483 |
+
store_id,
|
1484 |
+
entity_id,
|
1485 |
+
value
|
1486 |
+
)
|
1487 |
+
(SELECT
|
1488 |
+
$_categoryEntityTypeId,
|
1489 |
+
$is_anchor_attrid,
|
1490 |
+
0,
|
1491 |
+
scm.shop_entity_id,
|
1492 |
+
c.is_anchor
|
1493 |
+
FROM $categories_temp c
|
1494 |
+
JOIN $stINch_categories_mapping scm
|
1495 |
+
ON c.store_category_id = scm.store_category_id
|
1496 |
+
)
|
1497 |
+
ON DUPLICATE KEY UPDATE
|
1498 |
+
value = c.is_anchor";
|
1499 |
+
$this->db_do($q);
|
1500 |
+
|
1501 |
+
$q = "
|
1502 |
+
INSERT INTO $catalog_category_entity_varchar
|
1503 |
+
(
|
1504 |
+
entity_type_id,
|
1505 |
+
attribute_id,
|
1506 |
+
store_id,
|
1507 |
+
entity_id,
|
1508 |
+
value
|
1509 |
+
)
|
1510 |
+
(SELECT
|
1511 |
+
$_categoryEntityTypeId,
|
1512 |
+
$image_attrid,
|
1513 |
+
0,
|
1514 |
+
scm.shop_entity_id,
|
1515 |
+
c.categories_image
|
1516 |
+
FROM $categories_temp c
|
1517 |
+
JOIN $stINch_categories_mapping scm
|
1518 |
+
ON c.store_category_id = scm.store_category_id
|
1519 |
+
)
|
1520 |
+
ON DUPLICATE KEY UPDATE
|
1521 |
+
value = c.categories_image";
|
1522 |
+
$this->db_do($q);
|
1523 |
+
|
1524 |
+
$q = "
|
1525 |
+
INSERT INTO $catalog_category_entity_varchar
|
1526 |
+
(
|
1527 |
+
entity_type_id,
|
1528 |
+
attribute_id,
|
1529 |
+
store_id,
|
1530 |
+
entity_id,
|
1531 |
+
value
|
1532 |
+
)
|
1533 |
+
(SELECT
|
1534 |
+
$this->_categoryEntityTypeId,
|
1535 |
+
$this->_categoryMetaTitleAttrId,
|
1536 |
+
0,
|
1537 |
+
scm.shop_entity_id,
|
1538 |
+
c.MetaTitle
|
1539 |
+
FROM $categories_temp c
|
1540 |
+
JOIN $stINch_categories_mapping scm
|
1541 |
+
ON c.store_category_id = scm.store_category_id
|
1542 |
+
)
|
1543 |
+
ON DUPLICATE KEY UPDATE
|
1544 |
+
value = c.MetaTitle";
|
1545 |
+
$this->db_do($q);
|
1546 |
+
|
1547 |
+
$q = "
|
1548 |
+
INSERT INTO $catalog_category_entity_varchar
|
1549 |
+
(
|
1550 |
+
entity_type_id,
|
1551 |
+
attribute_id,
|
1552 |
+
store_id,
|
1553 |
+
entity_id,
|
1554 |
+
value
|
1555 |
+
)
|
1556 |
+
(SELECT
|
1557 |
+
$this->_categoryEntityTypeId,
|
1558 |
+
$this->_categoryMetadescriptionAttrId,
|
1559 |
+
0,
|
1560 |
+
scm.shop_entity_id,
|
1561 |
+
c.MetaDescription
|
1562 |
+
FROM $categories_temp c
|
1563 |
+
JOIN $stINch_categories_mapping scm
|
1564 |
+
ON c.store_category_id = scm.store_category_id
|
1565 |
+
)
|
1566 |
+
ON DUPLICATE KEY UPDATE
|
1567 |
+
value = c.MetaDescription";
|
1568 |
+
$this->db_do($q);
|
1569 |
+
|
1570 |
+
$q = "
|
1571 |
+
INSERT INTO $catalog_category_entity_varchar
|
1572 |
+
(
|
1573 |
+
entity_type_id,
|
1574 |
+
attribute_id,
|
1575 |
+
store_id,
|
1576 |
+
entity_id,
|
1577 |
+
value
|
1578 |
+
)
|
1579 |
+
(SELECT
|
1580 |
+
$this->_categoryEntityTypeId,
|
1581 |
+
$this->_categoryDescriptionAttrId,
|
1582 |
+
0,
|
1583 |
+
scm.shop_entity_id,
|
1584 |
+
c.Description
|
1585 |
+
FROM $categories_temp c
|
1586 |
+
JOIN $stINch_categories_mapping scm
|
1587 |
+
ON c.store_category_id = scm.store_category_id
|
1588 |
+
)
|
1589 |
+
ON DUPLICATE KEY UPDATE
|
1590 |
+
value = c.Description";
|
1591 |
+
$this->db_do($q);
|
1592 |
+
} else {
|
1593 |
+
echo "Insert ignore category_data \n";
|
1594 |
+
|
1595 |
+
$q = "
|
1596 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
1597 |
+
(
|
1598 |
+
entity_type_id,
|
1599 |
+
attribute_id,
|
1600 |
+
store_id,
|
1601 |
+
entity_id,
|
1602 |
+
value
|
1603 |
+
)
|
1604 |
+
(SELECT
|
1605 |
+
$_categoryEntityTypeId,
|
1606 |
+
$name_attrid,
|
1607 |
+
0,
|
1608 |
+
scm.shop_entity_id,
|
1609 |
+
c.category_name
|
1610 |
+
FROM $categories_temp c
|
1611 |
+
JOIN $stINch_categories_mapping scm
|
1612 |
+
ON c.store_category_id = scm.store_category_id
|
1613 |
+
)";
|
1614 |
+
$this->db_do($q);
|
1615 |
+
|
1616 |
+
$q = "
|
1617 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
1618 |
+
(
|
1619 |
+
entity_type_id,
|
1620 |
+
attribute_id,
|
1621 |
+
store_id,
|
1622 |
+
entity_id,
|
1623 |
+
value
|
1624 |
+
)
|
1625 |
+
(SELECT
|
1626 |
+
$_categoryEntityTypeId,
|
1627 |
+
$attr_is_active,
|
1628 |
+
0,
|
1629 |
+
scm.shop_entity_id,
|
1630 |
+
1
|
1631 |
+
FROM $categories_temp c
|
1632 |
+
JOIN $stINch_categories_mapping scm
|
1633 |
+
ON c.store_category_id = scm.store_category_id
|
1634 |
+
)";
|
1635 |
+
$this->db_do($q);
|
1636 |
+
|
1637 |
+
$q = "
|
1638 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
1639 |
+
(
|
1640 |
+
entity_type_id,
|
1641 |
+
attribute_id,
|
1642 |
+
store_id,
|
1643 |
+
entity_id,
|
1644 |
+
value
|
1645 |
+
)
|
1646 |
+
(SELECT
|
1647 |
+
$_categoryEntityTypeId,
|
1648 |
+
$attr_include_in_menu,
|
1649 |
+
0,
|
1650 |
+
scm.shop_entity_id,
|
1651 |
+
c.include_in_menu
|
1652 |
+
FROM $categories_temp c
|
1653 |
+
JOIN $stINch_categories_mapping scm
|
1654 |
+
ON c.store_category_id = scm.store_category_id
|
1655 |
+
)";
|
1656 |
+
$this->db_do($q);
|
1657 |
+
|
1658 |
+
$q = "
|
1659 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
1660 |
+
(
|
1661 |
+
entity_type_id,
|
1662 |
+
attribute_id,
|
1663 |
+
store_id,
|
1664 |
+
entity_id,
|
1665 |
+
value
|
1666 |
+
)
|
1667 |
+
(SELECT
|
1668 |
+
$_categoryEntityTypeId,
|
1669 |
+
$is_anchor_attrid,
|
1670 |
+
0,
|
1671 |
+
scm.shop_entity_id,
|
1672 |
+
c.is_anchor
|
1673 |
+
FROM $categories_temp c
|
1674 |
+
JOIN $stINch_categories_mapping scm
|
1675 |
+
ON c.store_category_id = scm.store_category_id
|
1676 |
+
)";
|
1677 |
+
$this->db_do($q);
|
1678 |
+
|
1679 |
+
$q = "
|
1680 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
1681 |
+
(
|
1682 |
+
entity_type_id,
|
1683 |
+
attribute_id,
|
1684 |
+
store_id,
|
1685 |
+
entity_id,
|
1686 |
+
value
|
1687 |
+
)
|
1688 |
+
(SELECT
|
1689 |
+
$_categoryEntityTypeId,
|
1690 |
+
$image_attrid,
|
1691 |
+
0,
|
1692 |
+
scm.shop_entity_id,
|
1693 |
+
c.categories_image
|
1694 |
+
FROM $categories_temp c
|
1695 |
+
JOIN $stINch_categories_mapping scm
|
1696 |
+
ON c.store_category_id = scm.store_category_id
|
1697 |
+
)";
|
1698 |
+
$this->db_do($q);
|
1699 |
+
//STP
|
1700 |
+
$q = "
|
1701 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
1702 |
+
(
|
1703 |
+
entity_type_id,
|
1704 |
+
attribute_id,
|
1705 |
+
store_id,
|
1706 |
+
entity_id,
|
1707 |
+
value
|
1708 |
+
)
|
1709 |
+
(SELECT
|
1710 |
+
$this->_categoryEntityTypeId,
|
1711 |
+
$this->_categoryMetaTitleAttrId,
|
1712 |
+
0,
|
1713 |
+
scm.shop_entity_id,
|
1714 |
+
c.MetaTitle
|
1715 |
+
FROM $categories_temp c
|
1716 |
+
JOIN $stINch_categories_mapping scm
|
1717 |
+
ON c.store_category_id = scm.store_category_id
|
1718 |
+
)
|
1719 |
+
";
|
1720 |
+
$this->db_do($q);
|
1721 |
+
|
1722 |
+
$q = "
|
1723 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
1724 |
+
(
|
1725 |
+
entity_type_id,
|
1726 |
+
attribute_id,
|
1727 |
+
store_id,
|
1728 |
+
entity_id,
|
1729 |
+
value
|
1730 |
+
)
|
1731 |
+
(SELECT
|
1732 |
+
$this->_categoryEntityTypeId,
|
1733 |
+
$this->_categoryMetadescriptionAttrId,
|
1734 |
+
0,
|
1735 |
+
scm.shop_entity_id,
|
1736 |
+
c.MetaDescription
|
1737 |
+
FROM $categories_temp c
|
1738 |
+
JOIN $stINch_categories_mapping scm
|
1739 |
+
ON c.store_category_id = scm.store_category_id
|
1740 |
+
)
|
1741 |
+
";
|
1742 |
+
$this->db_do($q);
|
1743 |
+
|
1744 |
+
$q = "
|
1745 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
1746 |
+
(
|
1747 |
+
entity_type_id,
|
1748 |
+
attribute_id,
|
1749 |
+
store_id,
|
1750 |
+
entity_id,
|
1751 |
+
value
|
1752 |
+
)
|
1753 |
+
(SELECT
|
1754 |
+
$this->_categoryEntityTypeId,
|
1755 |
+
$this->_categoryDescriptionAttrId,
|
1756 |
+
0,
|
1757 |
+
scm.shop_entity_id,
|
1758 |
+
c.Description
|
1759 |
+
FROM $categories_temp c
|
1760 |
+
JOIN $stINch_categories_mapping scm
|
1761 |
+
ON c.store_category_id = scm.store_category_id
|
1762 |
+
)
|
1763 |
+
";
|
1764 |
+
$this->db_do($q);
|
1765 |
+
}
|
1766 |
+
|
1767 |
+
$this->delete_old_sinch_categories_from_shop();
|
1768 |
+
|
1769 |
+
$this->db_do("DROP TABLE IF EXISTS $stINch_categories");
|
1770 |
+
$this->db_do("RENAME TABLE $categories_temp TO $stINch_categories");
|
1771 |
+
}
|
1772 |
+
|
1773 |
+
function culc_path($parent_id, $ent_id)
|
1774 |
+
{
|
1775 |
+
$path = '';
|
1776 |
+
$cat_id = $parent_id;
|
1777 |
+
$q = "SELECT
|
1778 |
+
parent_id
|
1779 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . "
|
1780 |
+
WHERE entity_id=" . $cat_id;
|
1781 |
+
$quer = $this->db_do($q);
|
1782 |
+
$row = mysqli_fetch_array($quer);
|
1783 |
+
while ($row['parent_id']) {
|
1784 |
+
$path = $row['parent_id'] . '/' . $path;
|
1785 |
+
$q = "SELECT
|
1786 |
+
parent_id
|
1787 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . "
|
1788 |
+
WHERE entity_id=" . $row['parent_id'];
|
1789 |
+
$quer = $this->db_do($q);
|
1790 |
+
$row = mysqli_fetch_array($quer);
|
1791 |
+
|
1792 |
+
}
|
1793 |
+
if ($cat_id) {
|
1794 |
+
$path .= $cat_id . "/";
|
1795 |
+
}
|
1796 |
+
|
1797 |
+
if ($path) {
|
1798 |
+
return ($path . $ent_id);
|
1799 |
+
} else {
|
1800 |
+
return ($ent_id);
|
1801 |
+
}
|
1802 |
+
}
|
1803 |
+
|
1804 |
+
private function delete_old_sinch_categories_from_shop()
|
1805 |
+
{
|
1806 |
+
$q = "DELETE cat FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar') . " cat
|
1807 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping') . " scm
|
1808 |
+
ON cat.entity_id=scm.shop_entity_id
|
1809 |
+
WHERE
|
1810 |
+
(scm.shop_store_category_id is not null) AND
|
1811 |
+
(scm.store_category_id is null)";
|
1812 |
+
$this->db_do($q);
|
1813 |
+
|
1814 |
+
$q = "DELETE cat FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int') . " cat
|
1815 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping') . " scm
|
1816 |
+
ON cat.entity_id=scm.shop_entity_id
|
1817 |
+
WHERE
|
1818 |
+
(scm.shop_store_category_id is not null) AND
|
1819 |
+
(scm.store_category_id is null)";
|
1820 |
+
$this->db_do($q);
|
1821 |
+
|
1822 |
+
$q = "DELETE cat FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . " cat
|
1823 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping') . " scm
|
1824 |
+
ON cat.entity_id=scm.shop_entity_id
|
1825 |
+
WHERE
|
1826 |
+
(scm.shop_store_category_id is not null) AND
|
1827 |
+
(scm.store_category_id is null)";
|
1828 |
+
$this->db_do($q);
|
1829 |
+
}
|
1830 |
+
|
1831 |
+
|
1832 |
+
private function rewriteMultistoreCategories($coincidence, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
1833 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $im_type,
|
1834 |
+
$name_attrid, $attr_display_mode, $attr_url_key, $attr_include_in_menu, $attr_is_active, $image_attrid, $is_anchor_attrid,
|
1835 |
+
$stINch_categories_mapping_temp, $stINch_categories_mapping, $stINch_categories, $categories_temp)
|
1836 |
+
{
|
1837 |
+
echo("rewriteMultistoreCategories RUN\n");
|
1838 |
+
|
1839 |
+
echo(" truncateAllCateriesAndCreateRoot start...");
|
1840 |
+
$this->truncateAllCateriesAndCreateRoot($catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
1841 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $name_attrid, $attr_display_mode, $attr_url_key, $attr_include_in_menu, $attr_is_active);
|
1842 |
+
echo(" done.\n");
|
1843 |
+
|
1844 |
+
echo(" createDefaultCategories start...");
|
1845 |
+
$this->createDefaultCategories($coincidence, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
1846 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $name_attrid, $attr_display_mode, $attr_url_key, $attr_is_active, $attr_include_in_menu);
|
1847 |
+
echo(" done.\n");
|
1848 |
+
|
1849 |
+
echo(" mapSinchCategoriesMultistore start...");
|
1850 |
+
$this->mapSinchCategoriesMultistore($stINch_categories_mapping_temp, $stINch_categories_mapping, $catalog_category_entity, $catalog_category_entity_varchar, $categories_temp, $im_type, $_categoryEntityTypeId, $name_attrid);
|
1851 |
+
echo(" done.\n");
|
1852 |
+
|
1853 |
+
echo(" addCategoryDataMultistore start...");
|
1854 |
+
$this->addCategoryDataMultistore($categories_temp, $stINch_categories_mapping_temp, $stINch_categories_mapping, $stINch_categories, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
1855 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $im_type,
|
1856 |
+
$name_attrid, $attr_is_active, $attr_include_in_menu, $is_anchor_attrid, $image_attrid);
|
1857 |
+
echo(" done.\n");
|
1858 |
+
|
1859 |
+
echo("rewriteMultistoreCategories DONE\n");
|
1860 |
+
}
|
1861 |
+
|
1862 |
+
|
1863 |
+
private function truncateAllCateriesAndCreateRoot($catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
1864 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $name_attrid, $attr_display_mode, $attr_url_key, $attr_include_in_menu, $attr_is_active)
|
1865 |
+
{
|
1866 |
+
$this->db_do('SET foreign_key_checks=0');
|
1867 |
+
|
1868 |
+
|
1869 |
+
$this->db_do("TRUNCATE $catalog_category_entity");
|
1870 |
+
$this->db_do("TRUNCATE $catalog_category_entity_varchar");
|
1871 |
+
$this->db_do("TRUNCATE $catalog_category_entity_int");
|
1872 |
+
|
1873 |
+
|
1874 |
+
$this->db_do("INSERT $catalog_category_entity
|
1875 |
+
(entity_id, entity_type_id, attribute_set_id, parent_id, created_at, updated_at,
|
1876 |
+
path, position, level, children_count, store_category_id, parent_store_category_id)
|
1877 |
+
VALUES
|
1878 |
+
(1, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 0, '0000-00-00 00:00:00', NOW(), '1', 0, 0, 1, NULL, NULL)");
|
1879 |
+
|
1880 |
+
|
1881 |
+
$this->db_do("INSERT $catalog_category_entity_varchar
|
1882 |
+
(value_id, entity_type_id, attribute_id, store_id, entity_id, value)
|
1883 |
+
VALUES
|
1884 |
+
(1, $_categoryEntityTypeId, $name_attrid, 0, 1, 'Root Catalog'),
|
1885 |
+
(2, $_categoryEntityTypeId, $name_attrid, 1, 1, 'Root Catalog'),
|
1886 |
+
(3, $_categoryEntityTypeId, $attr_url_key, 0, 1, 'root-catalog')");
|
1887 |
+
|
1888 |
+
|
1889 |
+
$this->db_do("INSERT $catalog_category_entity_int
|
1890 |
+
(value_id, entity_type_id, attribute_id, store_id, entity_id, value)
|
1891 |
+
VALUES
|
1892 |
+
(1, $_categoryEntityTypeId, $attr_include_in_menu, 0, 1, 1)");
|
1893 |
+
}
|
1894 |
+
|
1895 |
+
private function createDefaultCategories($coincidence, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
1896 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $name_attrid, $attr_display_mode, $attr_url_key, $attr_is_active, $attr_include_in_menu)
|
1897 |
+
{
|
1898 |
+
$i = 3;
|
1899 |
+
|
1900 |
+
foreach ($coincidence as $key => $item) {
|
1901 |
+
$this->db_do("INSERT $catalog_category_entity
|
1902 |
+
(entity_id, entity_type_id, attribute_set_id, parent_id, created_at, updated_at,
|
1903 |
+
path, position, level, children_count, store_category_id, parent_store_category_id)
|
1904 |
+
VALUES
|
1905 |
+
($i, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/$i', 1, 1, 1, NULL, NULL)");
|
1906 |
+
|
1907 |
+
|
1908 |
+
$this->db_do("INSERT $catalog_category_entity_varchar
|
1909 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
1910 |
+
VALUES
|
1911 |
+
($_categoryEntityTypeId, $name_attrid, 0, $i, '$key'),
|
1912 |
+
($_categoryEntityTypeId, $name_attrid, 1, $i, '$key'),
|
1913 |
+
($_categoryEntityTypeId, $attr_display_mode, 1, $i, '$key'),
|
1914 |
+
($_categoryEntityTypeId, $attr_url_key, 0, $i, '$key')");
|
1915 |
+
|
1916 |
+
|
1917 |
+
$this->db_do("INSERT $catalog_category_entity_int
|
1918 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
1919 |
+
VALUES
|
1920 |
+
($_categoryEntityTypeId, $attr_is_active, 0, $i, 1),
|
1921 |
+
($_categoryEntityTypeId, $attr_is_active, 1, $i, 1),
|
1922 |
+
($_categoryEntityTypeId, $attr_include_in_menu, 0, $i, 1),
|
1923 |
+
($_categoryEntityTypeId, $attr_include_in_menu, 1, $i, 1)");
|
1924 |
+
$i++;
|
1925 |
+
}
|
1926 |
+
}
|
1927 |
+
|
1928 |
+
private function mapSinchCategoriesMultistore($stINch_categories_mapping_temp, $stINch_categories_mapping, $catalog_category_entity, $catalog_category_entity_varchar, $categories_temp, $im_type, $_categoryEntityTypeId, $name_attrid, $mapping_again = false)
|
1929 |
+
{
|
1930 |
+
echo("\n\n\n\n==========================================================================\nmapSinchCategoriesMultistore start... \n");
|
1931 |
+
|
1932 |
+
$this->createMappingSinchTables($stINch_categories_mapping_temp, $stINch_categories_mapping);
|
1933 |
+
|
1934 |
+
// backup Category ID in REWRITE mode
|
1935 |
+
if ($im_type == "REWRITE" || (UPDATE_CATEGORY_DATA && $im_type == "MERGE")) {
|
1936 |
+
if ($mapping_again) {
|
1937 |
+
$query = "
|
1938 |
+
INSERT IGNORE INTO $stINch_categories_mapping_temp
|
1939 |
+
(
|
1940 |
+
shop_entity_id,
|
1941 |
+
shop_entity_type_id,
|
1942 |
+
shop_attribute_set_id,
|
1943 |
+
shop_parent_id,
|
1944 |
+
shop_store_category_id,
|
1945 |
+
shop_parent_store_category_id
|
1946 |
+
)
|
1947 |
+
(SELECT
|
1948 |
+
entity_id,
|
1949 |
+
entity_type_id,
|
1950 |
+
attribute_set_id,
|
1951 |
+
parent_id,
|
1952 |
+
store_category_id,
|
1953 |
+
parent_store_category_id
|
1954 |
+
FROM $catalog_category_entity)";
|
1955 |
+
echo("\n\n$query\n\n");
|
1956 |
+
$this->db_do($query);
|
1957 |
+
|
1958 |
+
|
1959 |
+
$query = "
|
1960 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1961 |
+
JOIN $categories_temp c
|
1962 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
1963 |
+
SET
|
1964 |
+
cmt.store_category_id = c.store_category_id,
|
1965 |
+
cmt.parent_store_category_id = c.parent_store_category_id,
|
1966 |
+
cmt.category_name = c.category_name,
|
1967 |
+
cmt.order_number = c.order_number,
|
1968 |
+
cmt.products_within_this_category = c.products_within_this_category";
|
1969 |
+
echo("\n\n$query\n\n");
|
1970 |
+
$this->db_do($query);
|
1971 |
+
|
1972 |
+
|
1973 |
+
$query = "
|
1974 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
1975 |
+
JOIN $catalog_category_entity cce
|
1976 |
+
ON cmt.parent_store_category_id = cce.store_category_id
|
1977 |
+
SET cmt.shop_parent_id = cce.entity_id";
|
1978 |
+
echo("\n\n$query\n\n");
|
1979 |
+
$this->db_do($query);
|
1980 |
+
|
1981 |
+
|
1982 |
+
$query = "
|
1983 |
+
SELECT DISTINCT
|
1984 |
+
c.RootName, cce.entity_id
|
1985 |
+
FROM $categories_temp c
|
1986 |
+
JOIN $catalog_category_entity_varchar ccev
|
1987 |
+
ON c.RootName = ccev.value
|
1988 |
+
AND ccev.entity_type_id = $_categoryEntityTypeId
|
1989 |
+
AND ccev.attribute_id = $name_attrid
|
1990 |
+
AND ccev.store_id = 0
|
1991 |
+
JOIN $catalog_category_entity cce
|
1992 |
+
ON ccev.entity_id = cce.entity_id";
|
1993 |
+
echo("\n\n$query\n\n");
|
1994 |
+
$root_categories = $this->db_do($query);
|
1995 |
+
|
1996 |
+
while ($root_cat = mysqli_fetch_array($root_categories)) {
|
1997 |
+
$root_id = $root_cat['entity_id'];
|
1998 |
+
$root_name = $root_cat['RootName'];
|
1999 |
+
|
2000 |
+
$query = "
|
2001 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2002 |
+
JOIN $categories_temp c
|
2003 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
2004 |
+
SET
|
2005 |
+
cmt.shop_parent_id = $root_id,
|
2006 |
+
cmt.shop_parent_store_category_id = $root_id,
|
2007 |
+
cmt.parent_store_category_id = $root_id,
|
2008 |
+
c.parent_store_category_id = $root_id
|
2009 |
+
WHERE RootName = '$root_name'
|
2010 |
+
AND cmt.shop_parent_id = 0";
|
2011 |
+
echo("\n\n$query\n\n");
|
2012 |
+
$this->db_do($query);
|
2013 |
+
}
|
2014 |
+
} else {
|
2015 |
+
$catalog_category_entity_backup = Mage::getSingleton('core/resource')->getTableName('sinch_category_backup');
|
2016 |
+
if (!$this->_checkDataExist($catalog_category_entity_backup)) {
|
2017 |
+
$catalog_category_entity_backup = $catalog_category_entity;
|
2018 |
+
}
|
2019 |
+
$query = "
|
2020 |
+
INSERT IGNORE INTO $stINch_categories_mapping_temp
|
2021 |
+
(
|
2022 |
+
shop_entity_id,
|
2023 |
+
shop_entity_type_id,
|
2024 |
+
shop_attribute_set_id,
|
2025 |
+
shop_parent_id,
|
2026 |
+
shop_store_category_id,
|
2027 |
+
shop_parent_store_category_id
|
2028 |
+
)
|
2029 |
+
(SELECT
|
2030 |
+
entity_id,
|
2031 |
+
entity_type_id,
|
2032 |
+
attribute_set_id,
|
2033 |
+
parent_id,
|
2034 |
+
store_category_id,
|
2035 |
+
parent_store_category_id
|
2036 |
+
FROM $catalog_category_entity_backup)";
|
2037 |
+
echo("\n\n$query\n\n");
|
2038 |
+
$this->db_do($query);
|
2039 |
+
|
2040 |
+
|
2041 |
+
$query = "
|
2042 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2043 |
+
JOIN $categories_temp c
|
2044 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
2045 |
+
SET
|
2046 |
+
cmt.store_category_id = c.store_category_id,
|
2047 |
+
cmt.parent_store_category_id = c.parent_store_category_id,
|
2048 |
+
cmt.category_name = c.category_name,
|
2049 |
+
cmt.order_number = c.order_number,
|
2050 |
+
cmt.products_within_this_category = c.products_within_this_category";
|
2051 |
+
echo("\n\n$query\n\n");
|
2052 |
+
$this->db_do($query);
|
2053 |
+
|
2054 |
+
|
2055 |
+
$query = "
|
2056 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2057 |
+
JOIN $catalog_category_entity_backup cce
|
2058 |
+
ON cmt.parent_store_category_id = cce.store_category_id
|
2059 |
+
SET cmt.shop_parent_id = cce.entity_id";
|
2060 |
+
echo("\n\n$query\n\n");
|
2061 |
+
$this->db_do($query);
|
2062 |
+
|
2063 |
+
|
2064 |
+
$query = "
|
2065 |
+
SELECT DISTINCT
|
2066 |
+
c.RootName, cce.entity_id
|
2067 |
+
FROM $categories_temp c
|
2068 |
+
JOIN $catalog_category_entity_varchar ccev
|
2069 |
+
ON c.RootName = ccev.value
|
2070 |
+
AND ccev.entity_type_id = $_categoryEntityTypeId
|
2071 |
+
AND ccev.attribute_id = $name_attrid
|
2072 |
+
AND ccev.store_id = 0
|
2073 |
+
JOIN $catalog_category_entity_backup cce
|
2074 |
+
ON ccev.entity_id = cce.entity_id";
|
2075 |
+
echo("\n\n$query\n\n");
|
2076 |
+
$root_categories = $this->db_do($query);
|
2077 |
+
|
2078 |
+
while ($root_cat = mysqli_fetch_array($root_categories)) {
|
2079 |
+
$root_id = $root_cat['entity_id'];
|
2080 |
+
$root_name = $root_cat['RootName'];
|
2081 |
+
|
2082 |
+
$query = "
|
2083 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2084 |
+
JOIN $categories_temp c
|
2085 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
2086 |
+
SET
|
2087 |
+
cmt.shop_parent_id = $root_id,
|
2088 |
+
cmt.shop_parent_store_category_id = $root_id,
|
2089 |
+
cmt.parent_store_category_id = $root_id,
|
2090 |
+
c.parent_store_category_id = $root_id
|
2091 |
+
WHERE RootName = '$root_name'
|
2092 |
+
AND cmt.shop_parent_id = 0";
|
2093 |
+
echo("\n\n$query\n\n");
|
2094 |
+
$this->db_do($query);
|
2095 |
+
}
|
2096 |
+
}
|
2097 |
+
// (end) backup Category ID in REWRITE mode
|
2098 |
+
} else {
|
2099 |
+
$query = "
|
2100 |
+
INSERT IGNORE INTO $stINch_categories_mapping_temp
|
2101 |
+
(shop_entity_id, shop_entity_type_id, shop_attribute_set_id, shop_parent_id, shop_store_category_id, shop_parent_store_category_id)
|
2102 |
+
(SELECT entity_id, entity_type_id, attribute_set_id, parent_id, store_category_id, parent_store_category_id
|
2103 |
+
FROM $catalog_category_entity)";
|
2104 |
+
$this->db_do($query);
|
2105 |
+
|
2106 |
+
$query = "
|
2107 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2108 |
+
JOIN $categories_temp c
|
2109 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
2110 |
+
SET
|
2111 |
+
cmt.store_category_id = c.store_category_id,
|
2112 |
+
cmt.parent_store_category_id = c.parent_store_category_id,
|
2113 |
+
cmt.category_name = c.category_name,
|
2114 |
+
cmt.order_number = c.order_number,
|
2115 |
+
cmt.products_within_this_category = c.products_within_this_category";
|
2116 |
+
echo("\n\n$query\n\n");
|
2117 |
+
$this->db_do($query);
|
2118 |
+
|
2119 |
+
|
2120 |
+
$query = "
|
2121 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2122 |
+
JOIN $catalog_category_entity cce
|
2123 |
+
ON cmt.parent_store_category_id = cce.store_category_id
|
2124 |
+
SET cmt.shop_parent_id = cce.entity_id";
|
2125 |
+
echo("\n\n$query\n\n");
|
2126 |
+
$this->db_do($query);
|
2127 |
+
|
2128 |
+
|
2129 |
+
$query = "
|
2130 |
+
SELECT DISTINCT
|
2131 |
+
c.RootName, cce.entity_id
|
2132 |
+
FROM $categories_temp c
|
2133 |
+
JOIN $catalog_category_entity_varchar ccev
|
2134 |
+
ON c.RootName = ccev.value
|
2135 |
+
AND ccev.entity_type_id = $_categoryEntityTypeId
|
2136 |
+
AND ccev.attribute_id = $name_attrid
|
2137 |
+
AND ccev.store_id = 0
|
2138 |
+
JOIN $catalog_category_entity cce
|
2139 |
+
ON ccev.entity_id = cce.entity_id";
|
2140 |
+
echo("\n\n$query\n\n");
|
2141 |
+
$root_categories = $this->db_do($query);
|
2142 |
+
|
2143 |
+
while ($root_cat = mysqli_fetch_array($root_categories)) {
|
2144 |
+
$root_id = $root_cat['entity_id'];
|
2145 |
+
$root_name = $root_cat['RootName'];
|
2146 |
+
|
2147 |
+
$query = "
|
2148 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2149 |
+
JOIN $categories_temp c
|
2150 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
2151 |
+
SET
|
2152 |
+
cmt.shop_parent_id = $root_id,
|
2153 |
+
cmt.shop_parent_store_category_id = $root_id,
|
2154 |
+
cmt.parent_store_category_id = $root_id,
|
2155 |
+
c.parent_store_category_id = $root_id
|
2156 |
+
WHERE RootName = '$root_name'
|
2157 |
+
AND cmt.shop_parent_id = 0";
|
2158 |
+
echo("\n\n$query\n\n");
|
2159 |
+
$this->db_do($query);
|
2160 |
+
}
|
2161 |
+
}
|
2162 |
+
|
2163 |
+
// added for mapping new sinch categories in merge && !UPDATE_CATEGORY_DATA mode
|
2164 |
+
if ((UPDATE_CATEGORY_DATA && $im_type == "MERGE") || ($im_type == "REWRITE")) $where = '';
|
2165 |
+
else $where = 'WHERE cce.parent_id = 0 AND cce.store_category_id IS NOT NULL';
|
2166 |
+
|
2167 |
+
$query = "
|
2168 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2169 |
+
JOIN $catalog_category_entity cce
|
2170 |
+
ON cmt.shop_entity_id = cce.entity_id
|
2171 |
+
SET cce.parent_id = cmt.shop_parent_id
|
2172 |
+
$where";
|
2173 |
+
echo("\n\n$query\n\n");
|
2174 |
+
$this->db_do($query);
|
2175 |
+
$this->_LOG("Execute function mapSinchCategoriesMultistore");
|
2176 |
+
$query = "DROP TABLE IF EXISTS $stINch_categories_mapping";
|
2177 |
+
echo("\n\n$query\n\n");
|
2178 |
+
$this->db_do($query);
|
2179 |
+
|
2180 |
+
$query = "RENAME TABLE $stINch_categories_mapping_temp TO $stINch_categories_mapping";
|
2181 |
+
echo("\n\n$query\n\n");
|
2182 |
+
$this->db_do($query);
|
2183 |
+
|
2184 |
+
echo("\nmapSinchCategoriesMultistore done... \n==========================================================================\n\n\n\n");
|
2185 |
+
}
|
2186 |
+
|
2187 |
+
private function createMappingSinchTables($stINch_categories_mapping_temp, $stINch_categories_mapping)
|
2188 |
+
{
|
2189 |
+
$this->db_do("DROP TABLE IF EXISTS $stINch_categories_mapping_temp");
|
2190 |
+
$this->db_do("
|
2191 |
+
CREATE TABLE $stINch_categories_mapping_temp
|
2192 |
+
(
|
2193 |
+
shop_entity_id INT(11) UNSIGNED NOT NULL,
|
2194 |
+
shop_entity_type_id INT(11),
|
2195 |
+
shop_attribute_set_id INT(11),
|
2196 |
+
shop_parent_id INT(11),
|
2197 |
+
shop_store_category_id INT(11),
|
2198 |
+
shop_parent_store_category_id INT(11),
|
2199 |
+
store_category_id INT(11),
|
2200 |
+
parent_store_category_id INT(11),
|
2201 |
+
category_name VARCHAR(255),
|
2202 |
+
order_number INT(11),
|
2203 |
+
products_within_this_category INT(11),
|
2204 |
+
|
2205 |
+
KEY shop_entity_id (shop_entity_id),
|
2206 |
+
KEY shop_parent_id (shop_parent_id),
|
2207 |
+
KEY store_category_id (store_category_id),
|
2208 |
+
KEY parent_store_category_id (parent_store_category_id),
|
2209 |
+
UNIQUE KEY(shop_entity_id)
|
2210 |
+
)");
|
2211 |
+
|
2212 |
+
|
2213 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS $stINch_categories_mapping LIKE $stINch_categories_mapping_temp");
|
2214 |
+
}
|
2215 |
+
|
2216 |
+
private function addCategoryDataMultistore($categories_temp, $stINch_categories_mapping_temp, $stINch_categories_mapping, $stINch_categories, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
2217 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $im_type,
|
2218 |
+
$name_attrid, $attr_is_active, $attr_include_in_menu, $is_anchor_attrid, $image_attrid)
|
2219 |
+
{
|
2220 |
+
echo("\n\n\n\n*************************************************************\nmapSinchCategoriesMultistore start... \n");
|
2221 |
+
if (UPDATE_CATEGORY_DATA) {
|
2222 |
+
$ignore = '';
|
2223 |
+
$on_diplicate_key_update = "
|
2224 |
+
ON DUPLICATE KEY UPDATE
|
2225 |
+
updated_at = now(),
|
2226 |
+
store_category_id = c.store_category_id,
|
2227 |
+
level = c.level,
|
2228 |
+
children_count = c.children_count,
|
2229 |
+
position = c.order_number,
|
2230 |
+
parent_store_category_id = c.parent_store_category_id";
|
2231 |
+
} else {
|
2232 |
+
$ignore = 'IGNORE';
|
2233 |
+
$on_diplicate_key_update = '';
|
2234 |
+
}
|
2235 |
+
|
2236 |
+
$query = "
|
2237 |
+
INSERT $ignore INTO $catalog_category_entity
|
2238 |
+
(
|
2239 |
+
entity_type_id,
|
2240 |
+
attribute_set_id,
|
2241 |
+
created_at,
|
2242 |
+
updated_at,
|
2243 |
+
level,
|
2244 |
+
children_count,
|
2245 |
+
entity_id,
|
2246 |
+
position,
|
2247 |
+
parent_id,
|
2248 |
+
store_category_id,
|
2249 |
+
parent_store_category_id
|
2250 |
+
)
|
2251 |
+
(SELECT
|
2252 |
+
$_categoryEntityTypeId,
|
2253 |
+
$_categoryDefault_attribute_set_id,
|
2254 |
+
NOW(),
|
2255 |
+
NOW(),
|
2256 |
+
c.level,
|
2257 |
+
c.children_count,
|
2258 |
+
scm.shop_entity_id,
|
2259 |
+
c.order_number,
|
2260 |
+
scm.shop_parent_id,
|
2261 |
+
c.store_category_id,
|
2262 |
+
c.parent_store_category_id
|
2263 |
+
FROM $categories_temp c
|
2264 |
+
LEFT JOIN $stINch_categories_mapping scm
|
2265 |
+
ON c.store_category_id = scm.store_category_id
|
2266 |
+
) $on_diplicate_key_update";
|
2267 |
+
echo("\n\n$query\n\n");
|
2268 |
+
$this->db_do($query);
|
2269 |
+
|
2270 |
+
$this->mapSinchCategoriesMultistore($stINch_categories_mapping_temp, $stINch_categories_mapping, $catalog_category_entity, $catalog_category_entity_varchar, $categories_temp, $im_type, $_categoryEntityTypeId, $name_attrid, true);
|
2271 |
+
|
2272 |
+
$categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
|
2273 |
+
while ($row = mysqli_fetch_array($categories)) {
|
2274 |
+
$parent_id = $row['parent_id'];
|
2275 |
+
$entity_id = $row['entity_id'];
|
2276 |
+
|
2277 |
+
$path = $this->culcPathMultistore($parent_id, $entity_id, $catalog_category_entity);
|
2278 |
+
|
2279 |
+
$this->db_do("
|
2280 |
+
UPDATE $catalog_category_entity
|
2281 |
+
SET path = '$path'
|
2282 |
+
WHERE entity_id = $entity_id");
|
2283 |
+
}
|
2284 |
+
|
2285 |
+
if (UPDATE_CATEGORY_DATA) {
|
2286 |
+
echo "Update category_data \n";
|
2287 |
+
|
2288 |
+
$q = "
|
2289 |
+
INSERT INTO $catalog_category_entity_varchar
|
2290 |
+
(
|
2291 |
+
entity_type_id,
|
2292 |
+
attribute_id,
|
2293 |
+
store_id,
|
2294 |
+
entity_id,
|
2295 |
+
value
|
2296 |
+
)
|
2297 |
+
(SELECT
|
2298 |
+
$_categoryEntityTypeId,
|
2299 |
+
$name_attrid,
|
2300 |
+
0,
|
2301 |
+
scm.shop_entity_id,
|
2302 |
+
c.category_name
|
2303 |
+
FROM $categories_temp c
|
2304 |
+
JOIN $stINch_categories_mapping scm
|
2305 |
+
ON c.store_category_id = scm.store_category_id
|
2306 |
+
)
|
2307 |
+
ON DUPLICATE KEY UPDATE
|
2308 |
+
value = c.category_name";
|
2309 |
+
$this->db_do($q);
|
2310 |
+
|
2311 |
+
$q = "
|
2312 |
+
INSERT INTO $catalog_category_entity_varchar
|
2313 |
+
(
|
2314 |
+
entity_type_id,
|
2315 |
+
attribute_id,
|
2316 |
+
store_id,
|
2317 |
+
entity_id,
|
2318 |
+
value
|
2319 |
+
)
|
2320 |
+
(SELECT
|
2321 |
+
$_categoryEntityTypeId,
|
2322 |
+
$name_attrid,
|
2323 |
+
1,
|
2324 |
+
scm.shop_entity_id,
|
2325 |
+
c.category_name
|
2326 |
+
FROM $categories_temp c
|
2327 |
+
JOIN $stINch_categories_mapping scm
|
2328 |
+
ON c.store_category_id = scm.store_category_id
|
2329 |
+
)
|
2330 |
+
ON DUPLICATE KEY UPDATE
|
2331 |
+
value = c.category_name";
|
2332 |
+
$this->db_do($q);
|
2333 |
+
|
2334 |
+
$q = "
|
2335 |
+
INSERT INTO $catalog_category_entity
|
2336 |
+
(
|
2337 |
+
entity_type_id,
|
2338 |
+
attribute_id,
|
2339 |
+
store_id,
|
2340 |
+
entity_id,
|
2341 |
+
value
|
2342 |
+
)
|
2343 |
+
(SELECT
|
2344 |
+
$_categoryEntityTypeId,
|
2345 |
+
$attr_is_active,
|
2346 |
+
0,
|
2347 |
+
scm.shop_entity_id,
|
2348 |
+
1
|
2349 |
+
FROM $categories_temp c
|
2350 |
+
JOIN $stINch_categories_mapping scm
|
2351 |
+
ON c.store_category_id = scm.store_category_id
|
2352 |
+
)
|
2353 |
+
ON DUPLICATE KEY UPDATE
|
2354 |
+
value = 1";
|
2355 |
+
$this->db_do($q);
|
2356 |
+
|
2357 |
+
$q = "
|
2358 |
+
INSERT INTO $catalog_category_entity_int
|
2359 |
+
(
|
2360 |
+
entity_type_id,
|
2361 |
+
attribute_id,
|
2362 |
+
store_id,
|
2363 |
+
entity_id,
|
2364 |
+
value
|
2365 |
+
)
|
2366 |
+
(SELECT
|
2367 |
+
$_categoryEntityTypeId,
|
2368 |
+
$attr_is_active,
|
2369 |
+
1,
|
2370 |
+
scm.shop_entity_id,
|
2371 |
+
1
|
2372 |
+
FROM $categories_temp c
|
2373 |
+
JOIN $stINch_categories_mapping scm
|
2374 |
+
ON c.store_category_id = scm.store_category_id
|
2375 |
+
)
|
2376 |
+
ON DUPLICATE KEY UPDATE
|
2377 |
+
value = 1";
|
2378 |
+
$this->db_do($q);
|
2379 |
+
|
2380 |
+
$q = "
|
2381 |
+
INSERT INTO $catalog_category_entity_int
|
2382 |
+
(
|
2383 |
+
entity_type_id,
|
2384 |
+
attribute_id,
|
2385 |
+
store_id,
|
2386 |
+
entity_id,
|
2387 |
+
value
|
2388 |
+
)
|
2389 |
+
(SELECT
|
2390 |
+
$_categoryEntityTypeId,
|
2391 |
+
$attr_include_in_menu,
|
2392 |
+
0,
|
2393 |
+
scm.shop_entity_id,
|
2394 |
+
c.include_in_menu
|
2395 |
+
FROM $categories_temp c
|
2396 |
+
JOIN $stINch_categories_mapping scm
|
2397 |
+
ON c.store_category_id = scm.store_category_id
|
2398 |
+
)
|
2399 |
+
ON DUPLICATE KEY UPDATE
|
2400 |
+
value = c.include_in_menu";
|
2401 |
+
$this->db_do($q);
|
2402 |
+
|
2403 |
+
|
2404 |
+
$q = "
|
2405 |
+
INSERT INTO $catalog_category_entity_int
|
2406 |
+
(
|
2407 |
+
entity_type_id,
|
2408 |
+
attribute_id,
|
2409 |
+
store_id,
|
2410 |
+
entity_id,
|
2411 |
+
value
|
2412 |
+
)
|
2413 |
+
(SELECT
|
2414 |
+
$_categoryEntityTypeId,
|
2415 |
+
$is_anchor_attrid,
|
2416 |
+
1,
|
2417 |
+
scm.shop_entity_id,
|
2418 |
+
c.is_anchor
|
2419 |
+
FROM $categories_temp c
|
2420 |
+
JOIN $stINch_categories_mapping scm
|
2421 |
+
ON c.store_category_id = scm.store_category_id
|
2422 |
+
)
|
2423 |
+
ON DUPLICATE KEY UPDATE
|
2424 |
+
value = c.is_anchor";
|
2425 |
+
$this->db_do($q);
|
2426 |
+
|
2427 |
+
|
2428 |
+
$q = "
|
2429 |
+
INSERT INTO $catalog_category_entity_int
|
2430 |
+
(
|
2431 |
+
entity_type_id,
|
2432 |
+
attribute_id,
|
2433 |
+
store_id,
|
2434 |
+
entity_id,
|
2435 |
+
value
|
2436 |
+
)
|
2437 |
+
(SELECT
|
2438 |
+
$_categoryEntityTypeId,
|
2439 |
+
$is_anchor_attrid,
|
2440 |
+
0,
|
2441 |
+
scm.shop_entity_id,
|
2442 |
+
c.is_anchor
|
2443 |
+
FROM $categories_temp c
|
2444 |
+
JOIN $stINch_categories_mapping scm
|
2445 |
+
ON c.store_category_id = scm.store_category_id
|
2446 |
+
)
|
2447 |
+
ON DUPLICATE KEY UPDATE
|
2448 |
+
value = c.is_anchor";
|
2449 |
+
$this->db_do($q);
|
2450 |
+
|
2451 |
+
$q = "
|
2452 |
+
INSERT INTO $catalog_category_entity_varchar
|
2453 |
+
(
|
2454 |
+
entity_type_id,
|
2455 |
+
attribute_id,
|
2456 |
+
store_id,
|
2457 |
+
entity_id,
|
2458 |
+
value
|
2459 |
+
)
|
2460 |
+
(SELECT
|
2461 |
+
$_categoryEntityTypeId,
|
2462 |
+
$image_attrid,
|
2463 |
+
0,
|
2464 |
+
scm.shop_entity_id,
|
2465 |
+
c.categories_image
|
2466 |
+
FROM $categories_temp c
|
2467 |
+
JOIN $stINch_categories_mapping scm
|
2468 |
+
ON c.store_category_id = scm.store_category_id
|
2469 |
+
)
|
2470 |
+
ON DUPLICATE KEY UPDATE
|
2471 |
+
value = c.categories_image";
|
2472 |
+
$this->db_do($q);
|
2473 |
+
|
2474 |
+
$q = "
|
2475 |
+
INSERT INTO $catalog_category_entity_varchar
|
2476 |
+
(
|
2477 |
+
entity_type_id,
|
2478 |
+
attribute_id,
|
2479 |
+
store_id,
|
2480 |
+
entity_id,
|
2481 |
+
value
|
2482 |
+
)
|
2483 |
+
(SELECT
|
2484 |
+
$this->_categoryEntityTypeId,
|
2485 |
+
$this->_categoryMetaTitleAttrId,
|
2486 |
+
0,
|
2487 |
+
scm.shop_entity_id,
|
2488 |
+
c.MetaTitle
|
2489 |
+
FROM $categories_temp c
|
2490 |
+
JOIN $stINch_categories_mapping scm
|
2491 |
+
ON c.store_category_id = scm.store_category_id
|
2492 |
+
)
|
2493 |
+
ON DUPLICATE KEY UPDATE
|
2494 |
+
value = c.MetaTitle";
|
2495 |
+
$this->db_do($q);
|
2496 |
+
|
2497 |
+
$q = "
|
2498 |
+
INSERT INTO $catalog_category_entity_varchar
|
2499 |
+
(
|
2500 |
+
entity_type_id,
|
2501 |
+
attribute_id,
|
2502 |
+
store_id,
|
2503 |
+
entity_id,
|
2504 |
+
value
|
2505 |
+
)
|
2506 |
+
(SELECT
|
2507 |
+
$this->_categoryEntityTypeId,
|
2508 |
+
$this->_categoryMetadescriptionAttrId,
|
2509 |
+
0,
|
2510 |
+
scm.shop_entity_id,
|
2511 |
+
c.MetaDescription
|
2512 |
+
FROM $categories_temp c
|
2513 |
+
JOIN $stINch_categories_mapping scm
|
2514 |
+
ON c.store_category_id = scm.store_category_id
|
2515 |
+
)
|
2516 |
+
ON DUPLICATE KEY UPDATE
|
2517 |
+
value = c.MetaDescription";
|
2518 |
+
$this->db_do($q);
|
2519 |
+
|
2520 |
+
$q = "
|
2521 |
+
INSERT INTO $catalog_category_entity_varchar
|
2522 |
+
(
|
2523 |
+
entity_type_id,
|
2524 |
+
attribute_id,
|
2525 |
+
store_id,
|
2526 |
+
entity_id,
|
2527 |
+
value
|
2528 |
+
)
|
2529 |
+
(SELECT
|
2530 |
+
$this->_categoryEntityTypeId,
|
2531 |
+
$this->_categoryDescriptionAttrId,
|
2532 |
+
0,
|
2533 |
+
scm.shop_entity_id,
|
2534 |
+
c.Description
|
2535 |
+
FROM $categories_temp c
|
2536 |
+
JOIN $stINch_categories_mapping scm
|
2537 |
+
ON c.store_category_id = scm.store_category_id
|
2538 |
+
)
|
2539 |
+
ON DUPLICATE KEY UPDATE
|
2540 |
+
value = c.Description";
|
2541 |
+
$this->db_do($q);
|
2542 |
+
|
2543 |
+
} else {
|
2544 |
+
echo "Insert ignore category_data \n";
|
2545 |
+
|
2546 |
+
$q = "
|
2547 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
2548 |
+
(
|
2549 |
+
entity_type_id,
|
2550 |
+
attribute_id,
|
2551 |
+
store_id,
|
2552 |
+
entity_id,
|
2553 |
+
value
|
2554 |
+
)
|
2555 |
+
(SELECT
|
2556 |
+
$_categoryEntityTypeId,
|
2557 |
+
$name_attrid,
|
2558 |
+
0,
|
2559 |
+
scm.shop_entity_id,
|
2560 |
+
c.category_name
|
2561 |
+
FROM $categories_temp c
|
2562 |
+
JOIN $stINch_categories_mapping scm
|
2563 |
+
ON c.store_category_id = scm.store_category_id
|
2564 |
+
)";
|
2565 |
+
$this->db_do($q);
|
2566 |
+
|
2567 |
+
|
2568 |
+
$q = "
|
2569 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
2570 |
+
(
|
2571 |
+
entity_type_id,
|
2572 |
+
attribute_id,
|
2573 |
+
store_id,
|
2574 |
+
entity_id,
|
2575 |
+
value
|
2576 |
+
)
|
2577 |
+
(SELECT
|
2578 |
+
$_categoryEntityTypeId,
|
2579 |
+
$attr_is_active,
|
2580 |
+
0,
|
2581 |
+
scm.shop_entity_id,
|
2582 |
+
1
|
2583 |
+
FROM $categories_temp c
|
2584 |
+
JOIN $stINch_categories_mapping scm
|
2585 |
+
ON c.store_category_id = scm.store_category_id
|
2586 |
+
)";
|
2587 |
+
$this->db_do($q);
|
2588 |
+
|
2589 |
+
|
2590 |
+
$q = "
|
2591 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
2592 |
+
(
|
2593 |
+
entity_type_id,
|
2594 |
+
attribute_id,
|
2595 |
+
store_id,
|
2596 |
+
entity_id,
|
2597 |
+
value
|
2598 |
+
)
|
2599 |
+
(SELECT
|
2600 |
+
$_categoryEntityTypeId,
|
2601 |
+
$attr_include_in_menu,
|
2602 |
+
0,
|
2603 |
+
scm.shop_entity_id,
|
2604 |
+
c.include_in_menu
|
2605 |
+
FROM $categories_temp c
|
2606 |
+
JOIN $stINch_categories_mapping scm
|
2607 |
+
ON c.store_category_id = scm.store_category_id
|
2608 |
+
)";
|
2609 |
+
$this->db_do($q);
|
2610 |
+
|
2611 |
+
|
2612 |
+
$q = "
|
2613 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
2614 |
+
(
|
2615 |
+
entity_type_id,
|
2616 |
+
attribute_id,
|
2617 |
+
store_id,
|
2618 |
+
entity_id,
|
2619 |
+
value
|
2620 |
+
)
|
2621 |
+
(SELECT
|
2622 |
+
$_categoryEntityTypeId,
|
2623 |
+
$is_anchor_attrid,
|
2624 |
+
0,
|
2625 |
+
scm.shop_entity_id,
|
2626 |
+
c.is_anchor
|
2627 |
+
FROM $categories_temp c
|
2628 |
+
JOIN $stINch_categories_mapping scm
|
2629 |
+
ON c.store_category_id = scm.store_category_id
|
2630 |
+
)";
|
2631 |
+
$this->db_do($q);
|
2632 |
+
|
2633 |
+
$q = "
|
2634 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
2635 |
+
(
|
2636 |
+
entity_type_id,
|
2637 |
+
attribute_id,
|
2638 |
+
store_id,
|
2639 |
+
entity_id,
|
2640 |
+
value
|
2641 |
+
)
|
2642 |
+
(SELECT
|
2643 |
+
$_categoryEntityTypeId,
|
2644 |
+
$image_attrid,
|
2645 |
+
0,
|
2646 |
+
scm.shop_entity_id,
|
2647 |
+
c.categories_image
|
2648 |
+
FROM $categories_temp c
|
2649 |
+
JOIN $stINch_categories_mapping scm
|
2650 |
+
ON c.store_category_id = scm.store_category_id
|
2651 |
+
)";
|
2652 |
+
$this->db_do($q);
|
2653 |
+
|
2654 |
+
$q = "
|
2655 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
2656 |
+
(
|
2657 |
+
entity_type_id,
|
2658 |
+
attribute_id,
|
2659 |
+
store_id,
|
2660 |
+
entity_id,
|
2661 |
+
value
|
2662 |
+
)
|
2663 |
+
(SELECT
|
2664 |
+
$this->_categoryEntityTypeId,
|
2665 |
+
$this->_categoryMetaTitleAttrId,
|
2666 |
+
0,
|
2667 |
+
scm.shop_entity_id,
|
2668 |
+
c.MetaTitle
|
2669 |
+
FROM $categories_temp c
|
2670 |
+
JOIN $stINch_categories_mapping scm
|
2671 |
+
ON c.store_category_id = scm.store_category_id
|
2672 |
+
)
|
2673 |
+
";
|
2674 |
+
$this->db_do($q);
|
2675 |
+
|
2676 |
+
$q = "
|
2677 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
2678 |
+
(
|
2679 |
+
entity_type_id,
|
2680 |
+
attribute_id,
|
2681 |
+
store_id,
|
2682 |
+
entity_id,
|
2683 |
+
value
|
2684 |
+
)
|
2685 |
+
(SELECT
|
2686 |
+
$this->_categoryEntityTypeId,
|
2687 |
+
$this->_categoryMetadescriptionAttrId,
|
2688 |
+
0,
|
2689 |
+
scm.shop_entity_id,
|
2690 |
+
c.MetaDescription
|
2691 |
+
FROM $categories_temp c
|
2692 |
+
JOIN $stINch_categories_mapping scm
|
2693 |
+
ON c.store_category_id = scm.store_category_id
|
2694 |
+
)
|
2695 |
+
";
|
2696 |
+
$this->db_do($q);
|
2697 |
+
|
2698 |
+
$q = "
|
2699 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
2700 |
+
(
|
2701 |
+
entity_type_id,
|
2702 |
+
attribute_id,
|
2703 |
+
store_id,
|
2704 |
+
entity_id,
|
2705 |
+
value
|
2706 |
+
)
|
2707 |
+
(SELECT
|
2708 |
+
$this->_categoryEntityTypeId,
|
2709 |
+
$this->_categoryDescriptionAttrId,
|
2710 |
+
0,
|
2711 |
+
scm.shop_entity_id,
|
2712 |
+
c.Description
|
2713 |
+
FROM $categories_temp c
|
2714 |
+
JOIN $stINch_categories_mapping scm
|
2715 |
+
ON c.store_category_id = scm.store_category_id
|
2716 |
+
)
|
2717 |
+
";
|
2718 |
+
$this->db_do($q);
|
2719 |
+
|
2720 |
+
}
|
2721 |
+
|
2722 |
+
$this->delete_old_sinch_categories_from_shop();
|
2723 |
+
$this->db_do("DROP TABLE IF EXISTS $stINch_categories\n\n");
|
2724 |
+
$this->db_do("RENAME TABLE $categories_temp TO $stINch_categories");
|
2725 |
+
}
|
2726 |
+
|
2727 |
+
function culcPathMultistore($parent_id, $ent_id, $catalog_category_entity)
|
2728 |
+
{
|
2729 |
+
$path = '';
|
2730 |
+
$cat_id = $parent_id;
|
2731 |
+
|
2732 |
+
$q = "
|
2733 |
+
SELECT
|
2734 |
+
parent_id
|
2735 |
+
FROM $catalog_category_entity
|
2736 |
+
WHERE entity_id = $cat_id";
|
2737 |
+
$quer = $this->db_do($q);
|
2738 |
+
$row = mysqli_fetch_array($quer);
|
2739 |
+
while ($row['parent_id']) {
|
2740 |
+
$path = $row['parent_id'] . '/' . $path;
|
2741 |
+
$parent_id = $row['parent_id'];
|
2742 |
+
|
2743 |
+
$q = "
|
2744 |
+
SELECT
|
2745 |
+
parent_id
|
2746 |
+
FROM $catalog_category_entity
|
2747 |
+
WHERE entity_id = $parent_id";
|
2748 |
+
$quer = $this->db_do($q);
|
2749 |
+
$row = mysqli_fetch_array($quer);
|
2750 |
+
}
|
2751 |
+
|
2752 |
+
if ($cat_id) $path .= $cat_id . "/";
|
2753 |
+
|
2754 |
+
if ($path) $path .= $ent_id;
|
2755 |
+
else $path = $ent_id;
|
2756 |
+
|
2757 |
+
return $path;
|
2758 |
+
}
|
2759 |
+
|
2760 |
+
private function mergeMultistoreCategories($coincidence, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
2761 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $im_type,
|
2762 |
+
$name_attrid, $attr_display_mode, $attr_url_key, $attr_include_in_menu, $attr_is_active, $image_attrid, $is_anchor_attrid,
|
2763 |
+
$stINch_categories_mapping_temp, $stINch_categories_mapping, $stINch_categories, $categories_temp)
|
2764 |
+
{
|
2765 |
+
echo("mergeMultistoreCategories RUN\n");
|
2766 |
+
|
2767 |
+
$this->createNewDefaultCategories($coincidence, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
2768 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $name_attrid, $attr_display_mode, $attr_url_key, $attr_is_active, $attr_include_in_menu);
|
2769 |
+
|
2770 |
+
$this->mapSinchCategoriesMultistoreMerge($stINch_categories_mapping_temp, $stINch_categories_mapping, $catalog_category_entity, $catalog_category_entity_varchar, $categories_temp, $im_type, $_categoryEntityTypeId, $name_attrid);
|
2771 |
+
|
2772 |
+
$this->addCategoryDataMultistoreMerge($categories_temp, $stINch_categories_mapping_temp, $stINch_categories_mapping, $stINch_categories, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
2773 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $im_type,
|
2774 |
+
$name_attrid, $attr_is_active, $attr_include_in_menu, $is_anchor_attrid, $image_attrid);
|
2775 |
+
|
2776 |
+
echo("\n\n\nmergeMultistoreCategories DONE\n");
|
2777 |
+
}
|
2778 |
+
|
2779 |
+
private function createNewDefaultCategories($coincidence, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
2780 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $name_attrid, $attr_display_mode, $attr_url_key, $attr_is_active, $attr_include_in_menu)
|
2781 |
+
{
|
2782 |
+
echo("\n\n ==========================================================================\n createNewDefaultCategories start... \n");
|
2783 |
+
|
2784 |
+
$old_cats = array();
|
2785 |
+
$query = $this->db_do("
|
2786 |
+
SELECT
|
2787 |
+
cce.entity_id,
|
2788 |
+
ccev.value AS category_name
|
2789 |
+
FROM $catalog_category_entity cce
|
2790 |
+
JOIN $catalog_category_entity_varchar ccev
|
2791 |
+
ON cce.entity_id = ccev.entity_id
|
2792 |
+
AND ccev.store_id = 0
|
2793 |
+
AND cce.entity_type_id = ccev.entity_type_id
|
2794 |
+
AND ccev.attribute_id = 41
|
2795 |
+
WHERE parent_id = 1"); // 41 - category name
|
2796 |
+
while ($row = mysqli_fetch_array($query)) $old_cats[] = $row['category_name'];
|
2797 |
+
|
2798 |
+
$query = $this->db_do("SELECT MAX(entity_id) AS max_entity_id FROM $catalog_category_entity");
|
2799 |
+
$max_entity_id = mysqli_fetch_array($query);
|
2800 |
+
|
2801 |
+
$i = $max_entity_id[max_entity_id] + 1;
|
2802 |
+
|
2803 |
+
foreach ($coincidence as $key => $item) {
|
2804 |
+
echo("\n coincidence: key = [$key]\n");
|
2805 |
+
|
2806 |
+
if (in_array($key, $old_cats)) {
|
2807 |
+
echo(" CONTINUE: key = [$key] item = [$item]\n");
|
2808 |
+
continue;
|
2809 |
+
} else {
|
2810 |
+
echo(" CREATE NEW CATEGORY: key = [$key] item = [$item]\n");
|
2811 |
+
}
|
2812 |
+
|
2813 |
+
$this->db_do("INSERT $catalog_category_entity
|
2814 |
+
(entity_id, entity_type_id, attribute_set_id, parent_id, created_at, updated_at,
|
2815 |
+
path, position, level, children_count, store_category_id, parent_store_category_id)
|
2816 |
+
VALUES
|
2817 |
+
($i, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/$i', 1, 1, 1, NULL, NULL)");
|
2818 |
+
|
2819 |
+
$this->db_do("INSERT $catalog_category_entity_varchar
|
2820 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
2821 |
+
VALUES
|
2822 |
+
($_categoryEntityTypeId, $name_attrid, 0, $i, '$key'),
|
2823 |
+
($_categoryEntityTypeId, $name_attrid, 1, $i, '$key'),
|
2824 |
+
($_categoryEntityTypeId, $attr_display_mode, 1, $i, '$key'),
|
2825 |
+
($_categoryEntityTypeId, $attr_url_key, 0, $i, '$key')");
|
2826 |
+
|
2827 |
+
|
2828 |
+
$this->db_do("INSERT $catalog_category_entity_int
|
2829 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
2830 |
+
VALUES
|
2831 |
+
($_categoryEntityTypeId, $attr_is_active, 0, $i, 1),
|
2832 |
+
($_categoryEntityTypeId, $attr_is_active, 1, $i, 1),
|
2833 |
+
($_categoryEntityTypeId, $attr_include_in_menu, 0, $i, 1),
|
2834 |
+
($_categoryEntityTypeId, $attr_include_in_menu, 1, $i, 1)");
|
2835 |
+
$i++;
|
2836 |
+
}
|
2837 |
+
|
2838 |
+
echo("\n createNewDefaultCategories done... \n ==========================================================================\n");
|
2839 |
+
}
|
2840 |
+
|
2841 |
+
private function mapSinchCategoriesMultistoreMerge($stINch_categories_mapping_temp, $stINch_categories_mapping, $catalog_category_entity, $catalog_category_entity_varchar, $categories_temp, $im_type, $_categoryEntityTypeId, $name_attrid)
|
2842 |
+
{
|
2843 |
+
echo("\n\n\ ==========================================================================\n mapSinchCategoriesMultistore start... \n");
|
2844 |
+
|
2845 |
+
$this->createMappingSinchTables($stINch_categories_mapping_temp, $stINch_categories_mapping);
|
2846 |
+
|
2847 |
+
$query = "
|
2848 |
+
INSERT IGNORE INTO $stINch_categories_mapping_temp
|
2849 |
+
(shop_entity_id, shop_entity_type_id, shop_attribute_set_id, shop_parent_id, shop_store_category_id, shop_parent_store_category_id)
|
2850 |
+
(SELECT entity_id, entity_type_id, attribute_set_id, parent_id, store_category_id, parent_store_category_id
|
2851 |
+
FROM $catalog_category_entity)";
|
2852 |
+
echo("\n $query\n");
|
2853 |
+
$this->db_do($query);
|
2854 |
+
|
2855 |
+
$query = "
|
2856 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2857 |
+
JOIN $categories_temp c
|
2858 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
2859 |
+
SET
|
2860 |
+
cmt.store_category_id = c.store_category_id,
|
2861 |
+
cmt.parent_store_category_id = c.parent_store_category_id,
|
2862 |
+
cmt.category_name = c.category_name,
|
2863 |
+
cmt.order_number = c.order_number,
|
2864 |
+
cmt.products_within_this_category = c.products_within_this_category";
|
2865 |
+
echo("\n $query\n");
|
2866 |
+
$this->db_do($query);
|
2867 |
+
|
2868 |
+
$query = "
|
2869 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2870 |
+
JOIN $catalog_category_entity cce
|
2871 |
+
ON cmt.parent_store_category_id = cce.store_category_id
|
2872 |
+
SET cmt.shop_parent_id = cce.entity_id";
|
2873 |
+
echo("\n $query\n");
|
2874 |
+
$this->db_do($query);
|
2875 |
+
|
2876 |
+
$query = "
|
2877 |
+
SELECT DISTINCT
|
2878 |
+
c.RootName, cce.entity_id
|
2879 |
+
FROM $categories_temp c
|
2880 |
+
JOIN $catalog_category_entity_varchar ccev
|
2881 |
+
ON c.RootName = ccev.value
|
2882 |
+
AND ccev.entity_type_id = $_categoryEntityTypeId
|
2883 |
+
AND ccev.attribute_id = $name_attrid
|
2884 |
+
AND ccev.store_id = 0
|
2885 |
+
JOIN $catalog_category_entity cce
|
2886 |
+
ON ccev.entity_id = cce.entity_id";
|
2887 |
+
echo("\n $query\n");
|
2888 |
+
$root_categories = $this->db_do($query);
|
2889 |
+
|
2890 |
+
while ($root_cat = mysqli_fetch_array($root_categories)) {
|
2891 |
+
$root_id = $root_cat['entity_id'];
|
2892 |
+
$root_name = $root_cat['RootName'];
|
2893 |
+
|
2894 |
+
$query = "
|
2895 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2896 |
+
JOIN $categories_temp c
|
2897 |
+
ON cmt.shop_store_category_id = c.store_category_id
|
2898 |
+
SET
|
2899 |
+
cmt.shop_parent_id = $root_id,
|
2900 |
+
cmt.shop_parent_store_category_id = $root_id,
|
2901 |
+
cmt.parent_store_category_id = $root_id,
|
2902 |
+
c.parent_store_category_id = $root_id
|
2903 |
+
WHERE RootName = '$root_name'
|
2904 |
+
AND cmt.shop_parent_id = 0";
|
2905 |
+
echo("\n $query\n");
|
2906 |
+
$this->db_do($query);
|
2907 |
+
}
|
2908 |
+
|
2909 |
+
// added for mapping new sinch categories in merge && !UPDATE_CATEGORY_DATA mode
|
2910 |
+
if ((UPDATE_CATEGORY_DATA && $im_type == "MERGE") || ($im_type == "REWRITE")) $where = '';
|
2911 |
+
else $where = 'WHERE cce.parent_id = 0 AND cce.store_category_id IS NOT NULL';
|
2912 |
+
|
2913 |
+
$query = "
|
2914 |
+
UPDATE $stINch_categories_mapping_temp cmt
|
2915 |
+
JOIN $catalog_category_entity cce
|
2916 |
+
ON cmt.shop_entity_id = cce.entity_id
|
2917 |
+
SET cce.parent_id = cmt.shop_parent_id
|
2918 |
+
$where";
|
2919 |
+
echo("\n $query\n");
|
2920 |
+
$this->db_do($query);
|
2921 |
+
|
2922 |
+
$query = "DROP TABLE IF EXISTS $stINch_categories_mapping";
|
2923 |
+
echo("\n $query\n");
|
2924 |
+
$this->db_do($query);
|
2925 |
+
|
2926 |
+
$query = "RENAME TABLE $stINch_categories_mapping_temp TO $stINch_categories_mapping";
|
2927 |
+
echo("\n $query\n");
|
2928 |
+
$this->db_do($query);
|
2929 |
+
|
2930 |
+
echo("\n mapSinchCategoriesMultistore done... \n ==========================================================================\n\n\n\n");
|
2931 |
+
}
|
2932 |
+
|
2933 |
+
|
2934 |
+
private function addCategoryDataMultistoreMerge($categories_temp, $stINch_categories_mapping_temp, $stINch_categories_mapping, $stINch_categories, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int,
|
2935 |
+
$_categoryEntityTypeId, $_categoryDefault_attribute_set_id, $im_type,
|
2936 |
+
$name_attrid, $attr_is_active, $attr_include_in_menu, $is_anchor_attrid, $image_attrid)
|
2937 |
+
{
|
2938 |
+
echo("\n\n\n\n *************************************************************\n addCategoryDataMultistoreMerge start... \n");
|
2939 |
+
|
2940 |
+
if (UPDATE_CATEGORY_DATA) {
|
2941 |
+
$ignore = '';
|
2942 |
+
$on_diplicate_key_update = "
|
2943 |
+
ON DUPLICATE KEY UPDATE
|
2944 |
+
updated_at = now(),
|
2945 |
+
store_category_id = c.store_category_id,
|
2946 |
+
level = c.level,
|
2947 |
+
children_count = c.children_count,
|
2948 |
+
position = c.order_number,
|
2949 |
+
parent_store_category_id = c.parent_store_category_id";
|
2950 |
+
} else {
|
2951 |
+
$ignore = 'IGNORE';
|
2952 |
+
$on_diplicate_key_update = '';
|
2953 |
+
}
|
2954 |
+
|
2955 |
+
$query = "
|
2956 |
+
INSERT $ignore INTO $catalog_category_entity
|
2957 |
+
(
|
2958 |
+
entity_type_id,
|
2959 |
+
attribute_set_id,
|
2960 |
+
created_at,
|
2961 |
+
updated_at,
|
2962 |
+
level,
|
2963 |
+
children_count,
|
2964 |
+
entity_id,
|
2965 |
+
position,
|
2966 |
+
parent_id,
|
2967 |
+
store_category_id,
|
2968 |
+
parent_store_category_id
|
2969 |
+
)
|
2970 |
+
(SELECT
|
2971 |
+
$_categoryEntityTypeId,
|
2972 |
+
$_categoryDefault_attribute_set_id,
|
2973 |
+
NOW(),
|
2974 |
+
NOW(),
|
2975 |
+
c.level,
|
2976 |
+
c.children_count,
|
2977 |
+
scm.shop_entity_id,
|
2978 |
+
c.order_number,
|
2979 |
+
scm.shop_parent_id,
|
2980 |
+
c.store_category_id,
|
2981 |
+
c.parent_store_category_id
|
2982 |
+
FROM $categories_temp c
|
2983 |
+
LEFT JOIN $stINch_categories_mapping scm
|
2984 |
+
ON c.store_category_id = scm.store_category_id
|
2985 |
+
) $on_diplicate_key_update";
|
2986 |
+
echo("\n\n $query\n\n");
|
2987 |
+
$this->db_do($query);
|
2988 |
+
|
2989 |
+
$this->mapSinchCategoriesMultistoreMerge($stINch_categories_mapping_temp, $stINch_categories_mapping, $catalog_category_entity, $catalog_category_entity_varchar, $categories_temp, $im_type, $_categoryEntityTypeId, $name_attrid);
|
2990 |
+
|
2991 |
+
$categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
|
2992 |
+
while ($row = mysqli_fetch_array($categories)) {
|
2993 |
+
$parent_id = $row['parent_id'];
|
2994 |
+
$entity_id = $row['entity_id'];
|
2995 |
+
|
2996 |
+
$path = $this->culcPathMultistore($parent_id, $entity_id, $catalog_category_entity);
|
2997 |
+
|
2998 |
+
$this->db_do("
|
2999 |
+
UPDATE $catalog_category_entity
|
3000 |
+
SET path = '$path'
|
3001 |
+
WHERE entity_id = $entity_id");
|
3002 |
+
}
|
3003 |
+
|
3004 |
+
if (UPDATE_CATEGORY_DATA) {
|
3005 |
+
echo "Update category_data \n";
|
3006 |
+
|
3007 |
+
$q = "
|
3008 |
+
INSERT INTO $catalog_category_entity_varchar
|
3009 |
+
(
|
3010 |
+
entity_type_id,
|
3011 |
+
attribute_id,
|
3012 |
+
store_id,
|
3013 |
+
entity_id,
|
3014 |
+
value
|
3015 |
+
)
|
3016 |
+
(SELECT
|
3017 |
+
$_categoryEntityTypeId,
|
3018 |
+
$name_attrid,
|
3019 |
+
0,
|
3020 |
+
scm.shop_entity_id,
|
3021 |
+
c.category_name
|
3022 |
+
FROM $categories_temp c
|
3023 |
+
JOIN $stINch_categories_mapping scm
|
3024 |
+
ON c.store_category_id = scm.store_category_id
|
3025 |
+
)
|
3026 |
+
ON DUPLICATE KEY UPDATE
|
3027 |
+
value = c.category_name";
|
3028 |
+
$this->db_do($q);
|
3029 |
+
|
3030 |
+
$q = "
|
3031 |
+
INSERT INTO $catalog_category_entity_varchar
|
3032 |
+
(
|
3033 |
+
entity_type_id,
|
3034 |
+
attribute_id,
|
3035 |
+
store_id,
|
3036 |
+
entity_id,
|
3037 |
+
value
|
3038 |
+
)
|
3039 |
+
(SELECT
|
3040 |
+
$_categoryEntityTypeId,
|
3041 |
+
$name_attrid,
|
3042 |
+
1,
|
3043 |
+
scm.shop_entity_id,
|
3044 |
+
c.category_name
|
3045 |
+
FROM $categories_temp c
|
3046 |
+
JOIN $stINch_categories_mapping scm
|
3047 |
+
ON c.store_category_id = scm.store_category_id
|
3048 |
+
)
|
3049 |
+
ON DUPLICATE KEY UPDATE
|
3050 |
+
value = c.category_name";
|
3051 |
+
$this->db_do($q);
|
3052 |
+
|
3053 |
+
$q = "
|
3054 |
+
INSERT INTO $catalog_category_entity
|
3055 |
+
(
|
3056 |
+
entity_type_id,
|
3057 |
+
attribute_id,
|
3058 |
+
store_id,
|
3059 |
+
entity_id,
|
3060 |
+
value
|
3061 |
+
)
|
3062 |
+
(SELECT
|
3063 |
+
$_categoryEntityTypeId,
|
3064 |
+
$attr_is_active,
|
3065 |
+
0,
|
3066 |
+
scm.shop_entity_id,
|
3067 |
+
1
|
3068 |
+
FROM $categories_temp c
|
3069 |
+
JOIN $stINch_categories_mapping scm
|
3070 |
+
ON c.store_category_id = scm.store_category_id
|
3071 |
+
)
|
3072 |
+
ON DUPLICATE KEY UPDATE
|
3073 |
+
value = 1";
|
3074 |
+
$this->db_do($q);
|
3075 |
+
|
3076 |
+
$q = "
|
3077 |
+
INSERT INTO $catalog_category_entity_int
|
3078 |
+
(
|
3079 |
+
entity_type_id,
|
3080 |
+
attribute_id,
|
3081 |
+
store_id,
|
3082 |
+
entity_id,
|
3083 |
+
value
|
3084 |
+
)
|
3085 |
+
(SELECT
|
3086 |
+
$_categoryEntityTypeId,
|
3087 |
+
$attr_is_active,
|
3088 |
+
1,
|
3089 |
+
scm.shop_entity_id,
|
3090 |
+
1
|
3091 |
+
FROM $categories_temp c
|
3092 |
+
JOIN $stINch_categories_mapping scm
|
3093 |
+
ON c.store_category_id = scm.store_category_id
|
3094 |
+
)
|
3095 |
+
ON DUPLICATE KEY UPDATE
|
3096 |
+
value = 1";
|
3097 |
+
$this->db_do($q);
|
3098 |
+
|
3099 |
+
$q = "
|
3100 |
+
INSERT INTO $catalog_category_entity_int
|
3101 |
+
(
|
3102 |
+
entity_type_id,
|
3103 |
+
attribute_id,
|
3104 |
+
store_id,
|
3105 |
+
entity_id,
|
3106 |
+
value
|
3107 |
+
)
|
3108 |
+
(SELECT
|
3109 |
+
$_categoryEntityTypeId,
|
3110 |
+
$attr_include_in_menu,
|
3111 |
+
0,
|
3112 |
+
scm.shop_entity_id,
|
3113 |
+
c.include_in_menu
|
3114 |
+
FROM $categories_temp c
|
3115 |
+
JOIN $stINch_categories_mapping scm
|
3116 |
+
ON c.store_category_id = scm.store_category_id
|
3117 |
+
)
|
3118 |
+
ON DUPLICATE KEY UPDATE
|
3119 |
+
value = c.include_in_menu";
|
3120 |
+
$this->db_do($q);
|
3121 |
+
|
3122 |
+
$q = "
|
3123 |
+
INSERT INTO $catalog_category_entity_int
|
3124 |
+
(
|
3125 |
+
entity_type_id,
|
3126 |
+
attribute_id,
|
3127 |
+
store_id,
|
3128 |
+
entity_id,
|
3129 |
+
value
|
3130 |
+
)
|
3131 |
+
(SELECT
|
3132 |
+
$_categoryEntityTypeId,
|
3133 |
+
$is_anchor_attrid,
|
3134 |
+
1,
|
3135 |
+
scm.shop_entity_id,
|
3136 |
+
c.is_anchor
|
3137 |
+
FROM $categories_temp c
|
3138 |
+
JOIN $stINch_categories_mapping scm
|
3139 |
+
ON c.store_category_id = scm.store_category_id
|
3140 |
+
)
|
3141 |
+
ON DUPLICATE KEY UPDATE
|
3142 |
+
value = c.is_anchor";
|
3143 |
+
$this->db_do($q);
|
3144 |
+
|
3145 |
+
$q = "
|
3146 |
+
INSERT INTO $catalog_category_entity_int
|
3147 |
+
(
|
3148 |
+
entity_type_id,
|
3149 |
+
attribute_id,
|
3150 |
+
store_id,
|
3151 |
+
entity_id,
|
3152 |
+
value
|
3153 |
+
)
|
3154 |
+
(SELECT
|
3155 |
+
$_categoryEntityTypeId,
|
3156 |
+
$is_anchor_attrid,
|
3157 |
+
0,
|
3158 |
+
scm.shop_entity_id,
|
3159 |
+
c.is_anchor
|
3160 |
+
FROM $categories_temp c
|
3161 |
+
JOIN $stINch_categories_mapping scm
|
3162 |
+
ON c.store_category_id = scm.store_category_id
|
3163 |
+
)
|
3164 |
+
ON DUPLICATE KEY UPDATE
|
3165 |
+
value = c.is_anchor";
|
3166 |
+
$this->db_do($q);
|
3167 |
+
|
3168 |
+
$q = "
|
3169 |
+
INSERT INTO $catalog_category_entity_varchar
|
3170 |
+
(
|
3171 |
+
entity_type_id,
|
3172 |
+
attribute_id,
|
3173 |
+
store_id,
|
3174 |
+
entity_id,
|
3175 |
+
value
|
3176 |
+
)
|
3177 |
+
(SELECT
|
3178 |
+
$_categoryEntityTypeId,
|
3179 |
+
$image_attrid,
|
3180 |
+
0,
|
3181 |
+
scm.shop_entity_id,
|
3182 |
+
c.categories_image
|
3183 |
+
FROM $categories_temp c
|
3184 |
+
JOIN $stINch_categories_mapping scm
|
3185 |
+
ON c.store_category_id = scm.store_category_id
|
3186 |
+
)
|
3187 |
+
ON DUPLICATE KEY UPDATE
|
3188 |
+
value = c.categories_image";
|
3189 |
+
$this->db_do($q);
|
3190 |
+
|
3191 |
+
$q = "
|
3192 |
+
INSERT INTO $catalog_category_entity_varchar
|
3193 |
+
(
|
3194 |
+
entity_type_id,
|
3195 |
+
attribute_id,
|
3196 |
+
store_id,
|
3197 |
+
entity_id,
|
3198 |
+
value
|
3199 |
+
)
|
3200 |
+
(SELECT
|
3201 |
+
$this->_categoryEntityTypeId,
|
3202 |
+
$this->_categoryMetaTitleAttrId,
|
3203 |
+
0,
|
3204 |
+
scm.shop_entity_id,
|
3205 |
+
c.MetaTitle
|
3206 |
+
FROM $categories_temp c
|
3207 |
+
JOIN $stINch_categories_mapping scm
|
3208 |
+
ON c.store_category_id = scm.store_category_id
|
3209 |
+
)
|
3210 |
+
ON DUPLICATE KEY UPDATE
|
3211 |
+
value = c.MetaTitle";
|
3212 |
+
$this->db_do($q);
|
3213 |
+
|
3214 |
+
$q = "
|
3215 |
+
INSERT INTO $catalog_category_entity_varchar
|
3216 |
+
(
|
3217 |
+
entity_type_id,
|
3218 |
+
attribute_id,
|
3219 |
+
store_id,
|
3220 |
+
entity_id,
|
3221 |
+
value
|
3222 |
+
)
|
3223 |
+
(SELECT
|
3224 |
+
$this->_categoryEntityTypeId,
|
3225 |
+
$this->_categoryMetadescriptionAttrId,
|
3226 |
+
0,
|
3227 |
+
scm.shop_entity_id,
|
3228 |
+
c.MetaDescription
|
3229 |
+
FROM $categories_temp c
|
3230 |
+
JOIN $stINch_categories_mapping scm
|
3231 |
+
ON c.store_category_id = scm.store_category_id
|
3232 |
+
)
|
3233 |
+
ON DUPLICATE KEY UPDATE
|
3234 |
+
value = c.MetaDescription";
|
3235 |
+
$this->db_do($q);
|
3236 |
+
|
3237 |
+
$q = "
|
3238 |
+
INSERT INTO $catalog_category_entity_varchar
|
3239 |
+
(
|
3240 |
+
entity_type_id,
|
3241 |
+
attribute_id,
|
3242 |
+
store_id,
|
3243 |
+
entity_id,
|
3244 |
+
value
|
3245 |
+
)
|
3246 |
+
(SELECT
|
3247 |
+
$this->_categoryEntityTypeId,
|
3248 |
+
$this->_categoryDescriptionAttrId,
|
3249 |
+
0,
|
3250 |
+
scm.shop_entity_id,
|
3251 |
+
c.Description
|
3252 |
+
FROM $categories_temp c
|
3253 |
+
JOIN $stINch_categories_mapping scm
|
3254 |
+
ON c.store_category_id = scm.store_category_id
|
3255 |
+
)
|
3256 |
+
ON DUPLICATE KEY UPDATE
|
3257 |
+
value = c.Description";
|
3258 |
+
$this->db_do($q);
|
3259 |
+
} else {
|
3260 |
+
echo "Insert ignore category_data \n";
|
3261 |
+
|
3262 |
+
$q = "
|
3263 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
3264 |
+
(
|
3265 |
+
entity_type_id,
|
3266 |
+
attribute_id,
|
3267 |
+
store_id,
|
3268 |
+
entity_id,
|
3269 |
+
value
|
3270 |
+
)
|
3271 |
+
(SELECT
|
3272 |
+
$_categoryEntityTypeId,
|
3273 |
+
$name_attrid,
|
3274 |
+
0,
|
3275 |
+
scm.shop_entity_id,
|
3276 |
+
c.category_name
|
3277 |
+
FROM $categories_temp c
|
3278 |
+
JOIN $stINch_categories_mapping scm
|
3279 |
+
ON c.store_category_id = scm.store_category_id
|
3280 |
+
)";
|
3281 |
+
$this->db_do($q);
|
3282 |
+
|
3283 |
+
$q = "
|
3284 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
3285 |
+
(
|
3286 |
+
entity_type_id,
|
3287 |
+
attribute_id,
|
3288 |
+
store_id,
|
3289 |
+
entity_id,
|
3290 |
+
value
|
3291 |
+
)
|
3292 |
+
(SELECT
|
3293 |
+
$_categoryEntityTypeId,
|
3294 |
+
$attr_is_active,
|
3295 |
+
0,
|
3296 |
+
scm.shop_entity_id,
|
3297 |
+
1
|
3298 |
+
FROM $categories_temp c
|
3299 |
+
JOIN $stINch_categories_mapping scm
|
3300 |
+
ON c.store_category_id = scm.store_category_id
|
3301 |
+
)";
|
3302 |
+
$this->db_do($q);
|
3303 |
+
|
3304 |
+
$q = "
|
3305 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
3306 |
+
(
|
3307 |
+
entity_type_id,
|
3308 |
+
attribute_id,
|
3309 |
+
store_id,
|
3310 |
+
entity_id,
|
3311 |
+
value
|
3312 |
+
)
|
3313 |
+
(SELECT
|
3314 |
+
$_categoryEntityTypeId,
|
3315 |
+
$attr_include_in_menu,
|
3316 |
+
0,
|
3317 |
+
scm.shop_entity_id,
|
3318 |
+
c.include_in_menu
|
3319 |
+
FROM $categories_temp c
|
3320 |
+
JOIN $stINch_categories_mapping scm
|
3321 |
+
ON c.store_category_id = scm.store_category_id
|
3322 |
+
)";
|
3323 |
+
$this->db_do($q);
|
3324 |
+
|
3325 |
+
$q = "
|
3326 |
+
INSERT IGNORE INTO $catalog_category_entity_int
|
3327 |
+
(
|
3328 |
+
entity_type_id,
|
3329 |
+
attribute_id,
|
3330 |
+
store_id,
|
3331 |
+
entity_id,
|
3332 |
+
value
|
3333 |
+
)
|
3334 |
+
(SELECT
|
3335 |
+
$_categoryEntityTypeId,
|
3336 |
+
$is_anchor_attrid,
|
3337 |
+
0,
|
3338 |
+
scm.shop_entity_id,
|
3339 |
+
c.is_anchor
|
3340 |
+
FROM $categories_temp c
|
3341 |
+
JOIN $stINch_categories_mapping scm
|
3342 |
+
ON c.store_category_id = scm.store_category_id
|
3343 |
+
)";
|
3344 |
+
$this->db_do($q);
|
3345 |
+
|
3346 |
+
$q = "
|
3347 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
3348 |
+
(
|
3349 |
+
entity_type_id,
|
3350 |
+
attribute_id,
|
3351 |
+
store_id,
|
3352 |
+
entity_id,
|
3353 |
+
value
|
3354 |
+
)
|
3355 |
+
(SELECT
|
3356 |
+
$_categoryEntityTypeId,
|
3357 |
+
$image_attrid,
|
3358 |
+
0,
|
3359 |
+
scm.shop_entity_id,
|
3360 |
+
c.categories_image
|
3361 |
+
FROM $categories_temp c
|
3362 |
+
JOIN $stINch_categories_mapping scm
|
3363 |
+
ON c.store_category_id = scm.store_category_id
|
3364 |
+
)";
|
3365 |
+
$this->db_do($q);
|
3366 |
+
|
3367 |
+
$q = "
|
3368 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
3369 |
+
(
|
3370 |
+
entity_type_id,
|
3371 |
+
attribute_id,
|
3372 |
+
store_id,
|
3373 |
+
entity_id,
|
3374 |
+
value
|
3375 |
+
)
|
3376 |
+
(SELECT
|
3377 |
+
$this->_categoryEntityTypeId,
|
3378 |
+
$this->_categoryMetaTitleAttrId,
|
3379 |
+
0,
|
3380 |
+
scm.shop_entity_id,
|
3381 |
+
c.MetaTitle
|
3382 |
+
FROM $categories_temp c
|
3383 |
+
JOIN $stINch_categories_mapping scm
|
3384 |
+
ON c.store_category_id = scm.store_category_id
|
3385 |
+
)
|
3386 |
+
";
|
3387 |
+
$this->db_do($q);
|
3388 |
+
|
3389 |
+
$q = "
|
3390 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
3391 |
+
(
|
3392 |
+
entity_type_id,
|
3393 |
+
attribute_id,
|
3394 |
+
store_id,
|
3395 |
+
entity_id,
|
3396 |
+
value
|
3397 |
+
)
|
3398 |
+
(SELECT
|
3399 |
+
$this->_categoryEntityTypeId,
|
3400 |
+
$this->_categoryMetadescriptionAttrId,
|
3401 |
+
0,
|
3402 |
+
scm.shop_entity_id,
|
3403 |
+
c.MetaDescription
|
3404 |
+
FROM $categories_temp c
|
3405 |
+
JOIN $stINch_categories_mapping scm
|
3406 |
+
ON c.store_category_id = scm.store_category_id
|
3407 |
+
)
|
3408 |
+
";
|
3409 |
+
$this->db_do($q);
|
3410 |
+
|
3411 |
+
$q = "
|
3412 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
3413 |
+
(
|
3414 |
+
entity_type_id,
|
3415 |
+
attribute_id,
|
3416 |
+
store_id,
|
3417 |
+
entity_id,
|
3418 |
+
value
|
3419 |
+
)
|
3420 |
+
(SELECT
|
3421 |
+
$this->_categoryEntityTypeId,
|
3422 |
+
$this->_categoryDescriptionAttrId,
|
3423 |
+
0,
|
3424 |
+
scm.shop_entity_id,
|
3425 |
+
c.Description
|
3426 |
+
FROM $categories_temp c
|
3427 |
+
JOIN $stINch_categories_mapping scm
|
3428 |
+
ON c.store_category_id = scm.store_category_id
|
3429 |
+
)
|
3430 |
+
";
|
3431 |
+
$this->db_do($q);
|
3432 |
+
}
|
3433 |
+
|
3434 |
+
$this->db_do("DROP TABLE IF EXISTS $stINch_categories\n\n");
|
3435 |
+
$this->db_do("RENAME TABLE $categories_temp TO $stINch_categories");
|
3436 |
+
|
3437 |
+
$this->deleteOldSinchCategoriesFromShopMerge($stINch_categories_mapping, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int);
|
3438 |
+
|
3439 |
+
echo("\n addCategoryDataMultistoreMerge done... \n *************************************************************\n");
|
3440 |
+
}
|
3441 |
+
|
3442 |
+
private function deleteOldSinchCategoriesFromShopMerge($stINch_categories_mapping, $catalog_category_entity, $catalog_category_entity_varchar, $catalog_category_entity_int)
|
3443 |
+
{
|
3444 |
+
echo("\n\n\n\n +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n deleteOldSinchCategoriesFromShopMerge start... \n");
|
3445 |
+
|
3446 |
+
$query = "DROP TABLE IF EXISTS delete_cats";
|
3447 |
+
echo("\n $query\n");
|
3448 |
+
$this->db_do($query);
|
3449 |
+
|
3450 |
+
$delete_cats = Mage::getSingleton('core/resource')->getTableName('delete_cats');
|
3451 |
+
$stINch_categories = Mage::getSingleton('core/resource')->getTableName('stINch_categories');
|
3452 |
+
|
3453 |
+
$query = "
|
3454 |
+
CREATE TABLE $delete_cats
|
3455 |
+
|
3456 |
+
SELECT entity_id
|
3457 |
+
FROM $catalog_category_entity cce
|
3458 |
+
WHERE cce.entity_id NOT IN
|
3459 |
+
(
|
3460 |
+
SELECT cce2.entity_id
|
3461 |
+
FROM $catalog_category_entity cce2
|
3462 |
+
JOIN $stINch_categories sc
|
3463 |
+
ON cce2.store_category_id = sc.store_category_id
|
3464 |
+
)
|
3465 |
+
AND cce.store_category_id IS NOT NULL
|
3466 |
+
;";
|
3467 |
+
|
3468 |
+
echo("\n $query\n");
|
3469 |
+
$this->db_do($query);
|
3470 |
+
|
3471 |
+
|
3472 |
+
$query = "DELETE cce FROM $catalog_category_entity cce JOIN $delete_cats dc USING(entity_id)";
|
3473 |
+
echo("\n $query\n");
|
3474 |
+
$this->db_do($query);
|
3475 |
+
|
3476 |
+
$query = "DROP TABLE IF EXISTS $delete_cats";
|
3477 |
+
echo("\n $query\n");
|
3478 |
+
|
3479 |
+
echo("\n deleteOldSinchCategoriesFromShopMerge done... \n +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n\n");
|
3480 |
+
}
|
3481 |
+
|
3482 |
+
private function _set_default_root_category()
|
3483 |
+
{
|
3484 |
+
$q = "UPDATE " . Mage::getSingleton('core/resource')->getTableName('core_store_group') . " csg
|
3485 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . " cce
|
3486 |
+
ON csg.root_category_id = cce.entity_id
|
3487 |
+
SET csg.root_category_id=(SELECT entity_id FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . " WHERE parent_id = 1 LIMIT 1)
|
3488 |
+
WHERE csg.root_category_id > 0 AND cce.entity_id IS NULL";
|
3489 |
+
$this->db_do($q);
|
3490 |
+
}
|
3491 |
+
|
3492 |
+
function ParseCategoryFeatures()
|
3493 |
+
{
|
3494 |
+
|
3495 |
+
$parse_file = $this->varDir . FILE_CATEGORIES_FEATURES;
|
3496 |
+
if (filesize($parse_file) || $this->_ignore_category_features) {
|
3497 |
+
$this->_LOG("Start parse " . FILE_CATEGORIES_FEATURES);
|
3498 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('categories_features_temp'));
|
3499 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('categories_features_temp') . " (
|
3500 |
+
category_feature_id int(11),
|
3501 |
+
store_category_id int(11),
|
3502 |
+
feature_name varchar(50),
|
3503 |
+
display_order_number int(11),
|
3504 |
+
KEY(store_category_id),
|
3505 |
+
KEY(category_feature_id)
|
3506 |
+
)
|
3507 |
+
");
|
3508 |
+
|
3509 |
+
if (!$this->_ignore_category_features) {
|
3510 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3511 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('categories_features_temp') . "
|
3512 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3513 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3514 |
+
LINES TERMINATED BY \"\r\n\"
|
3515 |
+
IGNORE 1 LINES ");
|
3516 |
+
}
|
3517 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_features'));
|
3518 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('categories_features_temp') . "
|
3519 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_features'));
|
3520 |
+
|
3521 |
+
$this->_LOG("Finish parse " . FILE_CATEGORIES_FEATURES);
|
3522 |
+
} else {
|
3523 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3524 |
+
}
|
3525 |
+
$this->_LOG(' ');
|
3526 |
+
}
|
3527 |
+
|
3528 |
+
function ParseDistributors()
|
3529 |
+
{
|
3530 |
+
$parse_file = $this->varDir . FILE_DISTRIBUTORS;
|
3531 |
+
if (filesize($parse_file)) {
|
3532 |
+
$this->_LOG("Start parse " . FILE_DISTRIBUTORS);
|
3533 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('distributors_temp'));
|
3534 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('distributors_temp') . "(
|
3535 |
+
distributor_id int(11),
|
3536 |
+
distributor_name varchar(255),
|
3537 |
+
website varchar(255),
|
3538 |
+
KEY(distributor_id)
|
3539 |
+
)
|
3540 |
+
");
|
3541 |
+
|
3542 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3543 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('distributors_temp') . "
|
3544 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3545 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3546 |
+
LINES TERMINATED BY \"\r\n\"
|
3547 |
+
IGNORE 1 LINES ");
|
3548 |
+
|
3549 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors'));
|
3550 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('distributors_temp') . "
|
3551 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors'));
|
3552 |
+
|
3553 |
+
$this->_LOG("Finish parse " . FILE_DISTRIBUTORS);
|
3554 |
+
} else {
|
3555 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3556 |
+
}
|
3557 |
+
$this->_LOG(' ');
|
3558 |
+
}
|
3559 |
+
|
3560 |
+
function ParseDistributorsStockAndPrice()
|
3561 |
+
{
|
3562 |
+
$parse_file = $this->varDir . FILE_DISTRIBUTORS_STOCK_AND_PRICES;
|
3563 |
+
if (filesize($parse_file)) {
|
3564 |
+
$this->_LOG("Start parse " . FILE_DISTRIBUTORS_STOCK_AND_PRICES);
|
3565 |
+
|
3566 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('distributors_stock_and_price_temp'));
|
3567 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('distributors_stock_and_price_temp') . "(
|
3568 |
+
`store_product_id` int(11) DEFAULT NULL,
|
3569 |
+
`distributor_id` int(11) DEFAULT NULL,
|
3570 |
+
`stock` int(11) DEFAULT NULL,
|
3571 |
+
`cost` decimal(15,4) DEFAULT NULL,
|
3572 |
+
`distributor_sku` varchar(255) DEFAULT NULL,
|
3573 |
+
`distributor_category` varchar(50) DEFAULT NULL,
|
3574 |
+
`eta` varchar(50) DEFAULT NULL,
|
3575 |
+
UNIQUE KEY `product_distri` (store_product_id, distributor_id)
|
3576 |
+
)");
|
3577 |
+
|
3578 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3579 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('distributors_stock_and_price_temp') . "
|
3580 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3581 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3582 |
+
LINES TERMINATED BY \"\r\n\"
|
3583 |
+
IGNORE 1 LINES ");
|
3584 |
+
|
3585 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price'));
|
3586 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('distributors_stock_and_price_temp') . "
|
3587 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price'));
|
3588 |
+
|
3589 |
+
$this->_LOG("Finish parse " . FILE_DISTRIBUTORS_STOCK_AND_PRICES);
|
3590 |
+
} else {
|
3591 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3592 |
+
}
|
3593 |
+
$this->_LOG(' ');
|
3594 |
+
}
|
3595 |
+
|
3596 |
+
function ParseProductContracts()
|
3597 |
+
{
|
3598 |
+
$parse_file = $this->varDir . FILE_PRODUCT_CONTRACTS;
|
3599 |
+
if (filesize($parse_file)) {
|
3600 |
+
$this->_LOG("Start parse " . FILE_PRODUCT_CONTRACTS);
|
3601 |
+
|
3602 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('product_contracts_temp'));
|
3603 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('product_contracts_temp') . "(
|
3604 |
+
`store_product_id` int(11) DEFAULT NULL,
|
3605 |
+
`contract_id` varchar(50) DEFAULT NULL,
|
3606 |
+
KEY `store_product_id` (store_product_id)
|
3607 |
+
)");
|
3608 |
+
|
3609 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3610 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('product_contracts_temp') . "
|
3611 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3612 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3613 |
+
LINES TERMINATED BY \"\r\n\"
|
3614 |
+
IGNORE 1 LINES ");
|
3615 |
+
|
3616 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_product_contracts'));
|
3617 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('product_contracts_temp') . "
|
3618 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_product_contracts'));
|
3619 |
+
|
3620 |
+
$this->_LOG("Finish parse " . FILE_PRODUCT_CONTRACTS);
|
3621 |
+
} else {
|
3622 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3623 |
+
}
|
3624 |
+
$this->_LOG(' ');
|
3625 |
+
}
|
3626 |
+
|
3627 |
+
function ParseEANCodes()
|
3628 |
+
{
|
3629 |
+
|
3630 |
+
$parse_file = $this->varDir . FILE_EANCODES;
|
3631 |
+
if (filesize($parse_file)) {
|
3632 |
+
$this->_LOG("Start parse " . FILE_EANCODES);
|
3633 |
+
|
3634 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('ean_codes_temp'));
|
3635 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('ean_codes_temp') . "(
|
3636 |
+
product_id int(11),
|
3637 |
+
ean_code varchar(255),
|
3638 |
+
KEY(product_id)
|
3639 |
+
)");
|
3640 |
+
|
3641 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3642 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('ean_codes_temp') . "
|
3643 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3644 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3645 |
+
LINES TERMINATED BY \"\r\n\"
|
3646 |
+
IGNORE 1 LINES ");
|
3647 |
+
|
3648 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_ean_codes'));
|
3649 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('ean_codes_temp') . "
|
3650 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_ean_codes'));
|
3651 |
+
|
3652 |
+
$this->_LOG("Finish parse " . FILE_EANCODES);
|
3653 |
+
} else {
|
3654 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3655 |
+
}
|
3656 |
+
$this->_LOG(' ');
|
3657 |
+
}
|
3658 |
+
|
3659 |
+
function ParseManufacturers()
|
3660 |
+
{
|
3661 |
+
$parse_file = $this->varDir . FILE_MANUFACTURERS;
|
3662 |
+
if (filesize($parse_file)) {
|
3663 |
+
$this->_LOG("Start parse " . FILE_MANUFACTURERS);
|
3664 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('manufacturers_temp'));
|
3665 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('manufacturers_temp') . "(
|
3666 |
+
sinch_manufacturer_id int(11),
|
3667 |
+
manufacturer_name varchar(255),
|
3668 |
+
manufacturers_image varchar(255),
|
3669 |
+
shop_option_id int(11),
|
3670 |
+
KEY(sinch_manufacturer_id),
|
3671 |
+
KEY(shop_option_id),
|
3672 |
+
KEY(manufacturer_name)
|
3673 |
+
)");
|
3674 |
+
|
3675 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3676 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('manufacturers_temp') . "
|
3677 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3678 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3679 |
+
LINES TERMINATED BY \"\r\n\"
|
3680 |
+
IGNORE 1 LINES ");
|
3681 |
+
|
3682 |
+
$q = "DELETE aov
|
3683 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option') . " ao
|
3684 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value') . " aov
|
3685 |
+
ON ao.option_id=aov.option_id left
|
3686 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('manufacturers_temp') . " mt
|
3687 |
+
ON aov.value=mt.manufacturer_name
|
3688 |
+
WHERE
|
3689 |
+
ao.attribute_id=" . $this->attributes['manufacturer'] . " AND
|
3690 |
+
mt.manufacturer_name is null";
|
3691 |
+
$this->db_do($q);
|
3692 |
+
|
3693 |
+
$q = "DELETE ao
|
3694 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option') . " ao
|
3695 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value') . " aov
|
3696 |
+
ON ao.option_id=aov.option_id
|
3697 |
+
WHERE
|
3698 |
+
attribute_id=" . $this->attributes['manufacturer'] . " AND
|
3699 |
+
aov.option_id is null";
|
3700 |
+
$this->db_do($q);
|
3701 |
+
|
3702 |
+
$q = "SELECT
|
3703 |
+
m.sinch_manufacturer_id,
|
3704 |
+
m.manufacturer_name,
|
3705 |
+
m.manufacturers_image
|
3706 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('manufacturers_temp') . " m
|
3707 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value') . " aov
|
3708 |
+
ON m.manufacturer_name=aov.value
|
3709 |
+
WHERE aov.value IS NULL";
|
3710 |
+
$quer = $this->db_do($q);
|
3711 |
+
|
3712 |
+
while ($row = mysqli_fetch_array($quer)) {
|
3713 |
+
$q0 = "INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option') . "
|
3714 |
+
(attribute_id)
|
3715 |
+
VALUES(" . $this->attributes['manufacturer'] . ")";
|
3716 |
+
$quer0 = $this->db_do($q0);
|
3717 |
+
|
3718 |
+
$q2 = "INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value') . "(
|
3719 |
+
option_id,
|
3720 |
+
value
|
3721 |
+
)(
|
3722 |
+
SELECT
|
3723 |
+
max(option_id) as option_id,
|
3724 |
+
" . "'" . mysqli_real_escape_string($this->db, $row['manufacturer_name']) . "'
|
3725 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option') . "
|
3726 |
+
WHERE attribute_id=" . $this->attributes['manufacturer'] . "
|
3727 |
+
)
|
3728 |
+
";
|
3729 |
+
$quer2 = $this->db_do($q2);
|
3730 |
+
// $option['attribute_id'] = $this->attributes['manufacturer'];
|
3731 |
+
// $option['value'][$row['sinch_manufacturer_id']][0] = $row['manufacturer_name'];
|
3732 |
+
}
|
3733 |
+
|
3734 |
+
$q = "UPDATE " . Mage::getSingleton('core/resource')->getTableName('manufacturers_temp') . " mt
|
3735 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value') . " aov
|
3736 |
+
ON mt.manufacturer_name=aov.value
|
3737 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option') . " ao
|
3738 |
+
ON ao.option_id=aov.option_id
|
3739 |
+
SET mt.shop_option_id=aov.option_id
|
3740 |
+
WHERE ao.attribute_id=" . $this->attributes['manufacturer'];
|
3741 |
+
$this->db_do($q);
|
3742 |
+
|
3743 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers'));
|
3744 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('manufacturers_temp') . "
|
3745 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers'));
|
3746 |
+
$this->_LOG("Finish parse " . FILE_MANUFACTURERS);
|
3747 |
+
} else {
|
3748 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3749 |
+
}
|
3750 |
+
$this->_LOG(' ');
|
3751 |
+
}
|
3752 |
+
|
3753 |
+
function ParseRelatedProducts()
|
3754 |
+
{
|
3755 |
+
|
3756 |
+
$parse_file = $this->varDir . FILE_RELATED_PRODUCTS;
|
3757 |
+
if (filesize($parse_file) || $this->_ignore_product_related) {
|
3758 |
+
$this->_LOG("Start parse " . FILE_RELATED_PRODUCTS);
|
3759 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('related_products_temp'));
|
3760 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('related_products_temp') . "(
|
3761 |
+
sinch_product_id int(11),
|
3762 |
+
related_sinch_product_id int(11),
|
3763 |
+
store_product_id int(11) default null,
|
3764 |
+
store_related_product_id int(11) default null,
|
3765 |
+
entity_id int(11),
|
3766 |
+
related_entity_id int(11),
|
3767 |
+
KEY(sinch_product_id),
|
3768 |
+
KEY(related_sinch_product_id),
|
3769 |
+
KEY(store_product_id)
|
3770 |
+
)DEFAULT CHARSET=utf8");
|
3771 |
+
if (!$this->_ignore_product_related) {
|
3772 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3773 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('related_products_temp') . "
|
3774 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3775 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3776 |
+
LINES TERMINATED BY \"\r\n\"
|
3777 |
+
IGNORE 1 LINES ");
|
3778 |
+
}
|
3779 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_related_products'));
|
3780 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('related_products_temp') . "
|
3781 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_related_products'));
|
3782 |
+
|
3783 |
+
$this->_LOG("Finish parse " . FILE_RELATED_PRODUCTS);
|
3784 |
+
} else {
|
3785 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3786 |
+
}
|
3787 |
+
$this->_LOG(" ");
|
3788 |
+
}
|
3789 |
+
|
3790 |
+
function ParseProductFeatures()
|
3791 |
+
{
|
3792 |
+
$parse_file = $this->varDir . FILE_PRODUCT_FEATURES;
|
3793 |
+
if (filesize($parse_file) || $this->_ignore_product_features) {
|
3794 |
+
$this->_LOG("Start parse " . FILE_PRODUCT_FEATURES);
|
3795 |
+
|
3796 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('product_features_temp'));
|
3797 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('product_features_temp') . "(
|
3798 |
+
product_feature_id int(11),
|
3799 |
+
sinch_product_id int(11),
|
3800 |
+
restricted_value_id int(11),
|
3801 |
+
KEY(sinch_product_id),
|
3802 |
+
KEY(restricted_value_id)
|
3803 |
+
)
|
3804 |
+
");
|
3805 |
+
if (!$this->_ignore_product_features) {
|
3806 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3807 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('product_features_temp') . "
|
3808 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3809 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3810 |
+
LINES TERMINATED BY \"\r\n\"
|
3811 |
+
IGNORE 1 LINES ");
|
3812 |
+
}
|
3813 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_product_features'));
|
3814 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('product_features_temp') . "
|
3815 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_product_features'));
|
3816 |
+
|
3817 |
+
$this->_LOG("Finish parse " . FILE_PRODUCT_FEATURES);
|
3818 |
+
} else {
|
3819 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3820 |
+
}
|
3821 |
+
$this->_LOG(" ");
|
3822 |
+
}
|
3823 |
+
|
3824 |
+
function ParseProductCategories()
|
3825 |
+
{
|
3826 |
+
$parse_file = $this->varDir . FILE_PRODUCT_CATEGORIES;
|
3827 |
+
if (filesize($parse_file)) {
|
3828 |
+
$this->_LOG("Start parse " . FILE_PRODUCT_CATEGORIES);
|
3829 |
+
|
3830 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('product_categories_temp'));
|
3831 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('product_categories_temp') . "(
|
3832 |
+
store_product_id int(11),
|
3833 |
+
store_category_id int(11),
|
3834 |
+
key(store_product_id),
|
3835 |
+
key(store_category_id)
|
3836 |
+
)");
|
3837 |
+
|
3838 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3839 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('product_categories_temp') . "
|
3840 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3841 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3842 |
+
LINES TERMINATED BY \"\r\n\"
|
3843 |
+
IGNORE 1 LINES ");
|
3844 |
+
|
3845 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_product_categories'));
|
3846 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('product_categories_temp') . "
|
3847 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_product_categories'));
|
3848 |
+
|
3849 |
+
$this->_LOG("Finish parse " . FILE_PRODUCT_CATEGORIES);
|
3850 |
+
} else {
|
3851 |
+
$this->_LOG("Wrong file " . $parse_file);
|
3852 |
+
}
|
3853 |
+
$this->_LOG(' ');
|
3854 |
+
}
|
3855 |
+
|
3856 |
+
function ParseProducts($coincidence)
|
3857 |
+
{
|
3858 |
+
echo("\nParseProducts 1\n");
|
3859 |
+
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
3860 |
+
$replace_merge_product = $dataConf['replace_products'];
|
3861 |
+
|
3862 |
+
$parse_file = $this->varDir . FILE_PRODUCTS;
|
3863 |
+
//$parse_file = $this->varDir . FILE_PRODUCTS_TEST;
|
3864 |
+
if (filesize($parse_file)) {
|
3865 |
+
$this->_LOG("Start parse " . FILE_PRODUCTS);
|
3866 |
+
echo("\nParseProducts 2\n");
|
3867 |
+
|
3868 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('products_temp'));
|
3869 |
+
if ($this->product_file_format == "NEW") {
|
3870 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "(
|
3871 |
+
store_product_id int(11),
|
3872 |
+
product_sku varchar(255),
|
3873 |
+
product_name varchar(255),
|
3874 |
+
sinch_manufacturer_id int(11),
|
3875 |
+
main_image_url varchar(255),
|
3876 |
+
thumb_image_url varchar(255),
|
3877 |
+
specifications text,
|
3878 |
+
description text,
|
3879 |
+
search_cache text,
|
3880 |
+
description_type varchar(50),
|
3881 |
+
medium_image_url varchar(255),
|
3882 |
+
Title varchar(255),
|
3883 |
+
Weight decimal(15,4),
|
3884 |
+
Family varchar(255),
|
3885 |
+
Reviews varchar(255),
|
3886 |
+
pdf_url varchar(512),
|
3887 |
+
product_short_description varchar(255),
|
3888 |
+
products_date_added datetime default NULL,
|
3889 |
+
products_last_modified datetime default NULL,
|
3890 |
+
availability_id_in_stock int(11) default '1',
|
3891 |
+
availability_id_out_of_stock int(11) default '2',
|
3892 |
+
products_locate varchar(30) default NULL,
|
3893 |
+
products_ordered int(11) NOT NULL default '0',
|
3894 |
+
products_url varchar(255) default NULL,
|
3895 |
+
products_viewed int(5) default '0',
|
3896 |
+
products_seo_url varchar(100) NOT NULL,
|
3897 |
+
manufacturer_name varchar(255) default NULL,
|
3898 |
+
KEY(store_product_id),
|
3899 |
+
KEY(sinch_manufacturer_id)
|
3900 |
+
)DEFAULT CHARSET=utf8
|
3901 |
+
");
|
3902 |
+
} elseif ($this->product_file_format == "OLD") {
|
3903 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "(
|
3904 |
+
store_category_product_id int(11),
|
3905 |
+
store_product_id int(11),
|
3906 |
+
sinch_product_id int(11),
|
3907 |
+
product_sku varchar(255),
|
3908 |
+
product_name varchar(255),
|
3909 |
+
sinch_manufacturer_id int(11),
|
3910 |
+
store_category_id int(11),
|
3911 |
+
main_image_url varchar(255),
|
3912 |
+
thumb_image_url varchar(255),
|
3913 |
+
specifications text,
|
3914 |
+
description text,
|
3915 |
+
search_cache text,
|
3916 |
+
spec_characte_u_count int(11),
|
3917 |
+
description_type varchar(50),
|
3918 |
+
medium_image_url varchar(255),
|
3919 |
+
products_date_added datetime default NULL,
|
3920 |
+
products_last_modified datetime default NULL,
|
3921 |
+
availability_id_in_stock int(11) default '1',
|
3922 |
+
availability_id_out_of_stock int(11) default '2',
|
3923 |
+
products_locate varchar(30) default NULL,
|
3924 |
+
products_ordered int(11) NOT NULL default '0',
|
3925 |
+
products_url varchar(255) default NULL,
|
3926 |
+
products_viewed int(5) default '0',
|
3927 |
+
products_seo_url varchar(100) NOT NULL,
|
3928 |
+
manufacturer_name varchar(255) default NULL,
|
3929 |
+
KEY(store_category_product_id),
|
3930 |
+
KEY(store_product_id),
|
3931 |
+
KEY(sinch_manufacturer_id),
|
3932 |
+
KEY(store_category_id)
|
3933 |
+
)DEFAULT CHARSET=utf8
|
3934 |
+
");
|
3935 |
+
|
3936 |
+
}
|
3937 |
+
echo("\nParseProducts 3\n");
|
3938 |
+
$this->db_do("LOAD DATA LOCAL INFILE '" . $parse_file . "'
|
3939 |
+
INTO TABLE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
3940 |
+
FIELDS TERMINATED BY '" . $this->field_terminated_char . "'
|
3941 |
+
OPTIONALLY ENCLOSED BY '\"'
|
3942 |
+
LINES TERMINATED BY \"\r\n\"
|
3943 |
+
IGNORE 1 LINES ");
|
3944 |
+
|
3945 |
+
if ($this->product_file_format == "NEW") {
|
3946 |
+
$this->db_do("ALTER TABLE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
3947 |
+
ADD COLUMN sinch_product_id int(11) AFTER store_product_id
|
3948 |
+
");
|
3949 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
3950 |
+
SET sinch_product_id=store_product_id
|
3951 |
+
");
|
3952 |
+
|
3953 |
+
$this->db_do("ALTER TABLE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
3954 |
+
ADD COLUMN store_category_id int(11) AFTER sinch_manufacturer_id
|
3955 |
+
");
|
3956 |
+
$this->db_do("ALTER TABLE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
3957 |
+
ADD KEY(store_category_id)
|
3958 |
+
");
|
3959 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
3960 |
+
SET product_name = Title WHERE Title != ''
|
3961 |
+
");
|
3962 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " pt
|
3963 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_product_categories') . " spc
|
3964 |
+
SET pt.store_category_id=spc.store_category_id
|
3965 |
+
WHERE pt.store_product_id=spc.store_product_id
|
3966 |
+
");
|
3967 |
+
|
3968 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
3969 |
+
SET main_image_url = medium_image_url WHERE main_image_url = ''
|
3970 |
+
");
|
3971 |
+
}
|
3972 |
+
|
3973 |
+
echo("\nParseProducts 4\n");
|
3974 |
+
|
3975 |
+
echo("\nParseProducts 5\n");
|
3976 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
3977 |
+
SET products_date_added=now(), products_last_modified=now()");
|
3978 |
+
echo("\nParseProducts 6\n");
|
3979 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " p
|
3980 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers') . " m
|
3981 |
+
ON p.sinch_manufacturer_id=m.sinch_manufacturer_id
|
3982 |
+
SET p.manufacturer_name=m.manufacturer_name");
|
3983 |
+
echo("\nParseProducts 7\n");
|
3984 |
+
if ($this->current_import_status_statistic_id) {
|
3985 |
+
$res = $this->db_do("SELECT COUNT(*) AS cnt
|
3986 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('products_temp'));
|
3987 |
+
$row = mysqli_fetch_assoc($res);
|
3988 |
+
$this->db_do("UPDATE " . $this->import_status_statistic_table . "
|
3989 |
+
SET number_of_products=" . $row['cnt'] . "
|
3990 |
+
WHERE id=" . $this->current_import_status_statistic_id);
|
3991 |
+
}
|
3992 |
+
|
3993 |
+
if ($replace_merge_product == "REWRITE") {
|
3994 |
+
$this->db_do("DELETE FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity'));
|
3995 |
+
|
3996 |
+
$this->db_do("SET FOREIGN_KEY_CHECKS=0");
|
3997 |
+
$this->db_do("TRUNCATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity'));
|
3998 |
+
$this->db_do("TRUNCATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar'));
|
3999 |
+
$this->db_do("TRUNCATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int'));
|
4000 |
+
$this->db_do("TRUNCATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text'));
|
4001 |
+
$this->db_do("TRUNCATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal'));
|
4002 |
+
$this->db_do("SET FOREIGN_KEY_CHECKS=1");
|
4003 |
+
}
|
4004 |
+
|
4005 |
+
// Modify catalog_product_entity_varchar - Kai
|
4006 |
+
$this->db_do("ALTER TABLE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " MODIFY value VARCHAR(512)");
|
4007 |
+
|
4008 |
+
echo("\nParseProducts 8\n");
|
4009 |
+
$this->addProductsWebsite();
|
4010 |
+
$this->mapSinchProducts($replace_merge_product);
|
4011 |
+
echo("\nParseProducts 9\n");
|
4012 |
+
|
4013 |
+
if (count($coincidence) == 1) {
|
4014 |
+
$this->replaceMagentoProducts();
|
4015 |
+
} else {
|
4016 |
+
echo("\n\n\n\n\n\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ [" . $this->im_type . "] $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n\n\n\n");
|
4017 |
+
|
4018 |
+
|
4019 |
+
switch ($this->im_type) {
|
4020 |
+
case "REWRITE":
|
4021 |
+
$this->replaceMagentoProductsMultistore($coincidence);
|
4022 |
+
break;
|
4023 |
+
case "MERGE":
|
4024 |
+
$this->replaceMagentoProductsMultistoreMERGE($coincidence);
|
4025 |
+
break;
|
4026 |
+
}
|
4027 |
+
}
|
4028 |
+
echo("\nParseProducts 10\n");
|
4029 |
+
|
4030 |
+
// Kai
|
4031 |
+
$this->mapSinchProducts($replace_merge_product, true);
|
4032 |
+
$this->addManufacturer_attribute();
|
4033 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_products'));
|
4034 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
4035 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_products'));
|
4036 |
+
$this->_LOG("Finish parse " . FILE_PRODUCTS);
|
4037 |
+
} else {
|
4038 |
+
$this->_LOG("Wrong file " . $parse_file);
|
4039 |
+
}
|
4040 |
+
$this->_LOG(" ");
|
4041 |
+
echo("\nParseProducts 11\n");
|
4042 |
+
}
|
4043 |
+
|
4044 |
+
|
4045 |
+
public function addProductsWebsite()
|
4046 |
+
{
|
4047 |
+
$this->db_do(" DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('products_website_temp'));
|
4048 |
+
|
4049 |
+
$this->db_do("
|
4050 |
+
CREATE TABLE `" . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . "` (
|
4051 |
+
`id` int(10) unsigned NOT NULL auto_increment,
|
4052 |
+
store_product_id int(11),
|
4053 |
+
sinch_product_id int(11),
|
4054 |
+
`website` int(11) default NULL,
|
4055 |
+
`website_id` int(11) default NULL,
|
4056 |
+
PRIMARY KEY (`id`),
|
4057 |
+
KEY store_product_id (`store_product_id`)
|
4058 |
+
)
|
4059 |
+
");
|
4060 |
+
$result = $this->db_do("SELECT
|
4061 |
+
website_id,
|
4062 |
+
store_id as website
|
4063 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('core_store') . "
|
4064 |
+
WHERE code!='admin'
|
4065 |
+
"); // where code!='admin' was adder for editing Featured products;
|
4066 |
+
while ($row = mysqli_fetch_assoc($result)) {
|
4067 |
+
$sql = "INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " (
|
4068 |
+
store_product_id,
|
4069 |
+
sinch_product_id,
|
4070 |
+
website,
|
4071 |
+
website_id
|
4072 |
+
)(
|
4073 |
+
SELECT
|
4074 |
+
distinct
|
4075 |
+
store_product_id,
|
4076 |
+
sinch_product_id,
|
4077 |
+
{$row['website']},
|
4078 |
+
{$row['website_id']}
|
4079 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
4080 |
+
)";
|
4081 |
+
$result2 = $this->db_do($sql);
|
4082 |
+
}
|
4083 |
+
}
|
4084 |
+
|
4085 |
+
public function mapSinchProducts($mode = 'MERGE', $mapping_again = false)
|
4086 |
+
{
|
4087 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp'));
|
4088 |
+
$this->db_do("CREATE TABLE " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp') . " (
|
4089 |
+
entity_id int(11) unsigned NOT NULL,
|
4090 |
+
manufacturer_option_id int(11),
|
4091 |
+
manufacturer_name varchar(255),
|
4092 |
+
shop_store_product_id int(11),
|
4093 |
+
shop_sinch_product_id int(11),
|
4094 |
+
sku varchar(64) default NULL,
|
4095 |
+
store_product_id int(11),
|
4096 |
+
sinch_product_id int(11),
|
4097 |
+
product_sku varchar(255),
|
4098 |
+
sinch_manufacturer_id int(11),
|
4099 |
+
sinch_manufacturer_name varchar(255),
|
4100 |
+
KEY entity_id (entity_id),
|
4101 |
+
KEY manufacturer_option_id (manufacturer_option_id),
|
4102 |
+
KEY manufacturer_name (manufacturer_name),
|
4103 |
+
KEY store_product_id (store_product_id),
|
4104 |
+
KEY sinch_product_id (sinch_product_id),
|
4105 |
+
KEY sku (sku),
|
4106 |
+
UNIQUE KEY(entity_id)
|
4107 |
+
)
|
4108 |
+
");
|
4109 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping') . "
|
4110 |
+
LIKE " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp'));
|
4111 |
+
$productEntityTable = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity');
|
4112 |
+
|
4113 |
+
// backup Product ID in REWRITE mode
|
4114 |
+
if ($mode == 'REWRITE' && !$mapping_again) {
|
4115 |
+
$catalog_product_entity_backup = Mage::getSingleton('core/resource')->getTableName('sinch_product_backup');
|
4116 |
+
if ($this->_checkDataExist($catalog_product_entity_backup)) {
|
4117 |
+
$productEntityTable = $catalog_product_entity_backup;
|
4118 |
+
}
|
4119 |
+
}
|
4120 |
+
// (end) backup Product ID in REWRITE mode
|
4121 |
+
|
4122 |
+
$result = $this->db_do("
|
4123 |
+
INSERT ignore INTO " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp') . " (
|
4124 |
+
entity_id,
|
4125 |
+
sku,
|
4126 |
+
shop_store_product_id,
|
4127 |
+
shop_sinch_product_id
|
4128 |
+
)(SELECT
|
4129 |
+
entity_id,
|
4130 |
+
sku,
|
4131 |
+
store_product_id,
|
4132 |
+
sinch_product_id
|
4133 |
+
FROM " . $productEntityTable . "
|
4134 |
+
)
|
4135 |
+
");
|
4136 |
+
|
4137 |
+
$this->addManufacturers(1);
|
4138 |
+
|
4139 |
+
$q = "UPDATE " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp') . " pmt
|
4140 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_index_eav') . " cpie
|
4141 |
+
ON pmt.entity_id=cpie.entity_id
|
4142 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value') . " aov
|
4143 |
+
ON cpie.value=aov.option_id
|
4144 |
+
SET
|
4145 |
+
manufacturer_option_id=cpie.value,
|
4146 |
+
manufacturer_name=aov.value
|
4147 |
+
WHERE cpie.attribute_id=" . $this->attributes['manufacturer'];
|
4148 |
+
$this->db_do($q);
|
4149 |
+
|
4150 |
+
$q = "UPDATE " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp') . " pmt
|
4151 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " p
|
4152 |
+
ON pmt.sku=p.product_sku
|
4153 |
+
SET
|
4154 |
+
pmt.store_product_id=p.store_product_id,
|
4155 |
+
pmt.sinch_product_id=p.sinch_product_id,
|
4156 |
+
pmt.product_sku=p.product_sku,
|
4157 |
+
pmt.sinch_manufacturer_id=p.sinch_manufacturer_id,
|
4158 |
+
pmt.sinch_manufacturer_name=p.manufacturer_name";
|
4159 |
+
|
4160 |
+
$this->db_do($q);
|
4161 |
+
|
4162 |
+
$q = "UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4163 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp') . " pmt
|
4164 |
+
ON cpe.entity_id=pmt.entity_id
|
4165 |
+
SET cpe.store_product_id=pmt.store_product_id,
|
4166 |
+
cpe.sinch_product_id=pmt.sinch_product_id
|
4167 |
+
WHERE
|
4168 |
+
cpe.sinch_product_id IS NULL
|
4169 |
+
AND pmt.sinch_product_id IS NOT NULL
|
4170 |
+
AND cpe.store_product_id IS NULL
|
4171 |
+
AND pmt.store_product_id IS NOT NULL";
|
4172 |
+
$this->db_do($q);
|
4173 |
+
|
4174 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping'));
|
4175 |
+
$this->db_do("RENAME TABLE " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp') . "
|
4176 |
+
TO " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping'));
|
4177 |
+
}
|
4178 |
+
|
4179 |
+
function addManufacturers($delete_eav = null)
|
4180 |
+
{
|
4181 |
+
// this cleanup is not needed due to foreign keys
|
4182 |
+
if (!$delete_eav) {
|
4183 |
+
$result = $this->db_do("
|
4184 |
+
DELETE FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_index_eav') . "
|
4185 |
+
WHERE attribute_id = " . $this->_getProductAttributeId('manufacturer')
|
4186 |
+
);
|
4187 |
+
}
|
4188 |
+
$this->addManufacturer_attribute();
|
4189 |
+
|
4190 |
+
$result = $this->db_do("
|
4191 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_index_eav') . " (
|
4192 |
+
entity_id,
|
4193 |
+
attribute_id,
|
4194 |
+
store_id,
|
4195 |
+
value
|
4196 |
+
)(
|
4197 |
+
SELECT
|
4198 |
+
a.entity_id,
|
4199 |
+
" . $this->_getProductAttributeId('manufacturer') . ",
|
4200 |
+
w.website,
|
4201 |
+
mn.shop_option_id
|
4202 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4203 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4204 |
+
ON a.store_product_id = b.store_product_id
|
4205 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4206 |
+
ON a.store_product_id=w.store_product_id
|
4207 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers') . " mn
|
4208 |
+
ON b.sinch_manufacturer_id=mn.sinch_manufacturer_id
|
4209 |
+
WHERE mn.shop_option_id IS NOT NULL
|
4210 |
+
)
|
4211 |
+
ON DUPLICATE KEY UPDATE
|
4212 |
+
value = mn.shop_option_id
|
4213 |
+
");
|
4214 |
+
|
4215 |
+
$result = $this->db_do("
|
4216 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_index_eav') . " (
|
4217 |
+
entity_id,
|
4218 |
+
attribute_id,
|
4219 |
+
store_id,
|
4220 |
+
value
|
4221 |
+
)(
|
4222 |
+
SELECT
|
4223 |
+
a.entity_id,
|
4224 |
+
" . $this->_getProductAttributeId('manufacturer') . ",
|
4225 |
+
0,
|
4226 |
+
mn.shop_option_id
|
4227 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4228 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4229 |
+
ON a.store_product_id = b.store_product_id
|
4230 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4231 |
+
ON a.store_product_id=w.store_product_id
|
4232 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers') . " mn
|
4233 |
+
ON b.sinch_manufacturer_id=mn.sinch_manufacturer_id
|
4234 |
+
WHERE mn.shop_option_id IS NOT NULL
|
4235 |
+
)
|
4236 |
+
ON DUPLICATE KEY UPDATE
|
4237 |
+
value = mn.shop_option_id
|
4238 |
+
");
|
4239 |
+
}
|
4240 |
+
|
4241 |
+
private function _getProductAttributeId($attributeCode)
|
4242 |
+
{
|
4243 |
+
return $this->_getAttributeId($attributeCode, 'catalog_product');
|
4244 |
+
}
|
4245 |
+
|
4246 |
+
private function addManufacturer_attribute()
|
4247 |
+
{
|
4248 |
+
$result = $this->db_do("
|
4249 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " (
|
4250 |
+
entity_type_id,
|
4251 |
+
attribute_id,
|
4252 |
+
store_id,
|
4253 |
+
entity_id,
|
4254 |
+
value
|
4255 |
+
)(
|
4256 |
+
SELECT
|
4257 |
+
" . $this->_getProductEntityTypeId() . ",
|
4258 |
+
" . $this->_getProductAttributeId('manufacturer') . ",
|
4259 |
+
0,
|
4260 |
+
a.entity_id,
|
4261 |
+
pm.manufacturer_option_id
|
4262 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4263 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping') . " pm
|
4264 |
+
ON a.entity_id = pm.entity_id
|
4265 |
+
)
|
4266 |
+
ON DUPLICATE KEY UPDATE
|
4267 |
+
value = pm.manufacturer_option_id
|
4268 |
+
");
|
4269 |
+
}
|
4270 |
+
|
4271 |
+
public function replaceMagentoProducts()
|
4272 |
+
{
|
4273 |
+
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
4274 |
+
|
4275 |
+
$result = $this->db_do("DELETE cpe
|
4276 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4277 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping') . " pm
|
4278 |
+
ON cpe.entity_id=pm.entity_id
|
4279 |
+
WHERE pm.shop_store_product_id IS NOT NULL
|
4280 |
+
AND pm.store_product_id IS NULL
|
4281 |
+
");
|
4282 |
+
|
4283 |
+
//Inserting new products and updating old others.
|
4284 |
+
$this->_getProductDefaulAttributeSetId();
|
4285 |
+
$result = $this->db_do("
|
4286 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " (
|
4287 |
+
entity_id,
|
4288 |
+
entity_type_id,
|
4289 |
+
attribute_set_id,
|
4290 |
+
type_id,
|
4291 |
+
sku,
|
4292 |
+
updated_at,
|
4293 |
+
has_options,
|
4294 |
+
store_product_id,
|
4295 |
+
sinch_product_id
|
4296 |
+
)(SELECT
|
4297 |
+
pm.entity_id,
|
4298 |
+
" . $this->_getProductEntityTypeId() . ",
|
4299 |
+
$this->defaultAttributeSetId,
|
4300 |
+
'simple',
|
4301 |
+
a.product_sku,
|
4302 |
+
NOW(),
|
4303 |
+
0,
|
4304 |
+
a.store_product_id,
|
4305 |
+
a.sinch_product_id
|
4306 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " a
|
4307 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping') . " pm
|
4308 |
+
ON a.store_product_id=pm.store_product_id
|
4309 |
+
AND a.sinch_product_id=pm.sinch_product_id
|
4310 |
+
WHERE pm.entity_id IS NOT NULL
|
4311 |
+
)
|
4312 |
+
ON DUPLICATE KEY UPDATE
|
4313 |
+
sku= a.product_sku,
|
4314 |
+
store_product_id=a.store_product_id,
|
4315 |
+
sinch_product_id=a.sinch_product_id
|
4316 |
+
");
|
4317 |
+
// store_product_id=a.store_product_id,
|
4318 |
+
// sinch_product_id=a.sinch_product_id
|
4319 |
+
|
4320 |
+
$result = $this->db_do("
|
4321 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " (
|
4322 |
+
entity_id,
|
4323 |
+
entity_type_id,
|
4324 |
+
attribute_set_id,
|
4325 |
+
type_id,
|
4326 |
+
sku,
|
4327 |
+
updated_at,
|
4328 |
+
has_options,
|
4329 |
+
store_product_id,
|
4330 |
+
sinch_product_id
|
4331 |
+
)(SELECT
|
4332 |
+
pm.entity_id,
|
4333 |
+
" . $this->_getProductEntityTypeId() . ",
|
4334 |
+
$this->defaultAttributeSetId,
|
4335 |
+
'simple',
|
4336 |
+
a.product_sku,
|
4337 |
+
NOW(),
|
4338 |
+
0,
|
4339 |
+
a.store_product_id,
|
4340 |
+
a.sinch_product_id
|
4341 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " a
|
4342 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping') . " pm
|
4343 |
+
ON a.store_product_id=pm.store_product_id
|
4344 |
+
AND a.sinch_product_id=pm.sinch_product_id
|
4345 |
+
WHERE pm.entity_id IS NULL
|
4346 |
+
)
|
4347 |
+
ON DUPLICATE KEY UPDATE
|
4348 |
+
sku= a.product_sku,
|
4349 |
+
store_product_id=a.store_product_id,
|
4350 |
+
sinch_product_id=a.sinch_product_id
|
4351 |
+
");
|
4352 |
+
|
4353 |
+
//Set enabled
|
4354 |
+
$result = $this->db_do("DELETE cpei
|
4355 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " cpei
|
4356 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4357 |
+
ON cpei.entity_id=cpe.entity_id
|
4358 |
+
WHERE cpe.entity_id IS NULL");
|
4359 |
+
|
4360 |
+
$result = $this->db_do("
|
4361 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " (
|
4362 |
+
entity_type_id,
|
4363 |
+
attribute_id,
|
4364 |
+
store_id,
|
4365 |
+
entity_id,
|
4366 |
+
value
|
4367 |
+
)(
|
4368 |
+
SELECT
|
4369 |
+
" . $this->_getProductEntityTypeId() . ",
|
4370 |
+
" . $this->_getProductAttributeId('status') . ",
|
4371 |
+
w.website,
|
4372 |
+
a.entity_id,
|
4373 |
+
1
|
4374 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4375 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4376 |
+
ON a.store_product_id=w.store_product_id
|
4377 |
+
)
|
4378 |
+
ON DUPLICATE KEY UPDATE
|
4379 |
+
value=1
|
4380 |
+
");
|
4381 |
+
// set status = 1 for all stores
|
4382 |
+
$result = $this->db_do("
|
4383 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " (
|
4384 |
+
entity_type_id,
|
4385 |
+
attribute_id,
|
4386 |
+
store_id,
|
4387 |
+
entity_id,
|
4388 |
+
value
|
4389 |
+
)(SELECT
|
4390 |
+
" . $this->_getProductEntityTypeId() . ",
|
4391 |
+
" . $this->_getProductAttributeId('status') . ",
|
4392 |
+
0,
|
4393 |
+
a.entity_id,
|
4394 |
+
1
|
4395 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4396 |
+
)
|
4397 |
+
ON DUPLICATE KEY UPDATE
|
4398 |
+
value=1
|
4399 |
+
");
|
4400 |
+
|
4401 |
+
//Unifying products with categories.
|
4402 |
+
$result = $this->db_do("DELETE ccp
|
4403 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " ccp
|
4404 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4405 |
+
ON ccp.product_id=cpe.entity_id
|
4406 |
+
WHERE cpe.entity_id IS NULL");
|
4407 |
+
|
4408 |
+
echo("\n\n\nUPDATE IGNORE " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " ccp
|
4409 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . " cce
|
4410 |
+
ON ccp.category_id=cce.entity_id
|
4411 |
+
SET ccp.category_id=" . $this->_root_cat . "
|
4412 |
+
WHERE cce.entity_id IS NULL");
|
4413 |
+
$result = $this->db_do("UPDATE IGNORE " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " ccp
|
4414 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . " cce
|
4415 |
+
ON ccp.category_id=cce.entity_id
|
4416 |
+
SET ccp.category_id=" . $this->_root_cat . "
|
4417 |
+
WHERE cce.entity_id IS NULL");
|
4418 |
+
echo("\ndone\n");
|
4419 |
+
|
4420 |
+
|
4421 |
+
echo("\n\n\nDELETE ccp FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " ccp
|
4422 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . " cce
|
4423 |
+
ON ccp.category_id=cce.entity_id
|
4424 |
+
WHERE cce.entity_id IS NULL");
|
4425 |
+
$result = $this->db_do("DELETE ccp FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " ccp
|
4426 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_category_entity') . " cce
|
4427 |
+
ON ccp.category_id=cce.entity_id
|
4428 |
+
WHERE cce.entity_id IS NULL");
|
4429 |
+
echo("\ndone\n");
|
4430 |
+
|
4431 |
+
|
4432 |
+
$this->db_do(" DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . "_for_delete_temp");
|
4433 |
+
// TEMPORARY
|
4434 |
+
$this->db_do("
|
4435 |
+
CREATE TABLE `" . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . "_for_delete_temp` (
|
4436 |
+
`category_id` int(10) unsigned NOT NULL default '0',
|
4437 |
+
`product_id` int(10) unsigned NOT NULL default '0',
|
4438 |
+
`store_product_id` int(10) NOT NULL default '0',
|
4439 |
+
`store_category_id` int(10) NOT NULL default '0',
|
4440 |
+
`new_category_id` int(10) NOT NULL default '0',
|
4441 |
+
UNIQUE KEY `UNQ_CATEGORY_PRODUCT` (`category_id`,`product_id`),
|
4442 |
+
KEY `CATALOG_CATEGORY_PRODUCT_CATEGORY` (`category_id`),
|
4443 |
+
KEY `CATALOG_CATEGORY_PRODUCT_PRODUCT` (`product_id`),
|
4444 |
+
KEY `CATALOG_NEW_CATEGORY_PRODUCT_CATEGORY` (`new_category_id`)
|
4445 |
+
)
|
4446 |
+
|
4447 |
+
");
|
4448 |
+
|
4449 |
+
$result = $this->db_do("
|
4450 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . "_for_delete_temp (
|
4451 |
+
category_id,
|
4452 |
+
product_id,
|
4453 |
+
store_product_id
|
4454 |
+
)(SELECT
|
4455 |
+
ccp.category_id,
|
4456 |
+
ccp.product_id,
|
4457 |
+
cpe.store_product_id
|
4458 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " ccp
|
4459 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4460 |
+
ON ccp.product_id=cpe.entity_id
|
4461 |
+
WHERE store_product_id is not null
|
4462 |
+
)
|
4463 |
+
");
|
4464 |
+
|
4465 |
+
$result = $this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . "_for_delete_temp ccpfd
|
4466 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " p
|
4467 |
+
ON ccpfd.store_product_id=p.store_product_id
|
4468 |
+
SET ccpfd.store_category_id=p.store_category_id
|
4469 |
+
WHERE ccpfd.store_product_id!=0
|
4470 |
+
");
|
4471 |
+
|
4472 |
+
$result = $this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . "_for_delete_temp ccpfd
|
4473 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping') . " scm
|
4474 |
+
ON ccpfd.store_category_id=scm.store_category_id
|
4475 |
+
SET ccpfd.new_category_id=scm.shop_entity_id
|
4476 |
+
WHERE ccpfd.store_category_id!=0
|
4477 |
+
");
|
4478 |
+
|
4479 |
+
$result = $this->db_do("DELETE FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . "_for_delete_temp
|
4480 |
+
WHERE category_id=new_category_id");
|
4481 |
+
|
4482 |
+
$result = $this->db_do("
|
4483 |
+
DELETE ccp
|
4484 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " ccp
|
4485 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . "_for_delete_temp ccpfd
|
4486 |
+
ON ccp.product_id=ccpfd.product_id
|
4487 |
+
AND ccp.category_id=ccpfd.category_id
|
4488 |
+
");
|
4489 |
+
|
4490 |
+
$result = $this->db_do("
|
4491 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " (
|
4492 |
+
category_id,
|
4493 |
+
product_id
|
4494 |
+
)(SELECT
|
4495 |
+
scm.shop_entity_id,
|
4496 |
+
cpe.entity_id
|
4497 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4498 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " p
|
4499 |
+
ON cpe.store_product_id=p.store_product_id
|
4500 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping') . " scm
|
4501 |
+
ON p.store_category_id=scm.store_category_id
|
4502 |
+
)
|
4503 |
+
ON DUPLICATE KEY UPDATE
|
4504 |
+
product_id = cpe.entity_id
|
4505 |
+
");
|
4506 |
+
|
4507 |
+
|
4508 |
+
//add multi categories
|
4509 |
+
$result = $this->db_do("
|
4510 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . "
|
4511 |
+
(category_id, product_id)
|
4512 |
+
(SELECT
|
4513 |
+
scm.shop_entity_id,
|
4514 |
+
cpe.entity_id
|
4515 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4516 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " p
|
4517 |
+
ON cpe.store_product_id = p.store_product_id
|
4518 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_product_categories') . " spc
|
4519 |
+
ON p.store_product_id=spc.store_product_id
|
4520 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping') . " scm
|
4521 |
+
ON spc.store_category_id = scm.store_category_id
|
4522 |
+
)
|
4523 |
+
ON DUPLICATE KEY UPDATE
|
4524 |
+
product_id = cpe.entity_id
|
4525 |
+
");
|
4526 |
+
|
4527 |
+
|
4528 |
+
//Indexing products and categories in the shop
|
4529 |
+
$result = $this->db_do("DELETE ccpi
|
4530 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index') . " ccpi
|
4531 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4532 |
+
ON ccpi.product_id=cpe.entity_id
|
4533 |
+
WHERE cpe.entity_id IS NULL");
|
4534 |
+
|
4535 |
+
$result = $this->db_do("
|
4536 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index') . " (
|
4537 |
+
category_id,
|
4538 |
+
product_id,
|
4539 |
+
position,
|
4540 |
+
is_parent,
|
4541 |
+
store_id,
|
4542 |
+
visibility
|
4543 |
+
)(
|
4544 |
+
SELECT
|
4545 |
+
a.category_id,
|
4546 |
+
a.product_id,
|
4547 |
+
a.position,
|
4548 |
+
1,
|
4549 |
+
b.store_id,
|
4550 |
+
4
|
4551 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " a
|
4552 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " b
|
4553 |
+
)
|
4554 |
+
ON DUPLICATE KEY UPDATE
|
4555 |
+
visibility = 4
|
4556 |
+
");
|
4557 |
+
|
4558 |
+
$result = $this->db_do("
|
4559 |
+
INSERT ignore INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index') . " (
|
4560 |
+
category_id,
|
4561 |
+
product_id,
|
4562 |
+
position,
|
4563 |
+
is_parent,
|
4564 |
+
store_id,
|
4565 |
+
visibility
|
4566 |
+
)(
|
4567 |
+
SELECT
|
4568 |
+
" . $this->_root_cat . ",
|
4569 |
+
a.product_id,
|
4570 |
+
a.position,
|
4571 |
+
1,
|
4572 |
+
b.store_id,
|
4573 |
+
4
|
4574 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_category_product') . " a
|
4575 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " b
|
4576 |
+
)
|
4577 |
+
ON DUPLICATE KEY UPDATE
|
4578 |
+
visibility = 4
|
4579 |
+
");
|
4580 |
+
|
4581 |
+
//Set product name for specific web sites
|
4582 |
+
$result = $this->db_do("DELETE cpev
|
4583 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " cpev
|
4584 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4585 |
+
ON cpev.entity_id=cpe.entity_id
|
4586 |
+
WHERE cpe.entity_id IS NULL");
|
4587 |
+
$result = $this->db_do("
|
4588 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
4589 |
+
entity_type_id,
|
4590 |
+
attribute_id,
|
4591 |
+
store_id,
|
4592 |
+
entity_id,
|
4593 |
+
value
|
4594 |
+
)(SELECT
|
4595 |
+
" . $this->_getProductEntityTypeId() . ",
|
4596 |
+
" . $this->_getProductAttributeId('name') . ",
|
4597 |
+
w.website,
|
4598 |
+
a.entity_id,
|
4599 |
+
b.product_name
|
4600 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4601 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4602 |
+
ON a.store_product_id= b.store_product_id
|
4603 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4604 |
+
ON a.store_product_id=w.store_product_id
|
4605 |
+
)
|
4606 |
+
ON DUPLICATE KEY UPDATE
|
4607 |
+
value = b.product_name
|
4608 |
+
");
|
4609 |
+
|
4610 |
+
// product name for all web sites
|
4611 |
+
$result = $this->db_do("
|
4612 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
4613 |
+
entity_type_id,
|
4614 |
+
attribute_id,
|
4615 |
+
store_id,
|
4616 |
+
entity_id,
|
4617 |
+
value
|
4618 |
+
)(
|
4619 |
+
SELECT
|
4620 |
+
" . $this->_getProductEntityTypeId() . ",
|
4621 |
+
" . $this->_getProductAttributeId('name') . ",
|
4622 |
+
0,
|
4623 |
+
a.entity_id,
|
4624 |
+
b.product_name
|
4625 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4626 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4627 |
+
ON a.store_product_id = b.store_product_id
|
4628 |
+
)
|
4629 |
+
ON DUPLICATE KEY UPDATE
|
4630 |
+
value = b.product_name
|
4631 |
+
");
|
4632 |
+
|
4633 |
+
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
4634 |
+
$this->addDescriptions();
|
4635 |
+
$this->cleanProductDistributors();
|
4636 |
+
if (!$this->_ignore_product_contracts) {
|
4637 |
+
$this->cleanProductContracts();
|
4638 |
+
}
|
4639 |
+
if ($this->product_file_format == "NEW") {
|
4640 |
+
$this->addReviews();
|
4641 |
+
$this->addWeight();
|
4642 |
+
$this->addSearchCache();
|
4643 |
+
$this->addPdfUrl();
|
4644 |
+
$this->addShortDescriptions();
|
4645 |
+
$this->addProductDistributors();
|
4646 |
+
if (!$this->_ignore_product_contracts) {
|
4647 |
+
$this->addProductContracts();
|
4648 |
+
}
|
4649 |
+
}
|
4650 |
+
$this->addEAN();
|
4651 |
+
$this->addSpecification();
|
4652 |
+
$this->addManufacturers();
|
4653 |
+
|
4654 |
+
//Enabling product index.
|
4655 |
+
$result = $this->db_do("DELETE cpei
|
4656 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index') . " cpei
|
4657 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4658 |
+
ON cpei.product_id=cpe.entity_id
|
4659 |
+
WHERE cpe.entity_id IS NULL");
|
4660 |
+
|
4661 |
+
$result = $this->db_do("
|
4662 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index') . " (
|
4663 |
+
product_id,
|
4664 |
+
store_id,
|
4665 |
+
visibility
|
4666 |
+
)(
|
4667 |
+
SELECT
|
4668 |
+
a.entity_id,
|
4669 |
+
w.website,
|
4670 |
+
4
|
4671 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4672 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4673 |
+
ON a.store_product_id=w.store_product_id
|
4674 |
+
)
|
4675 |
+
ON DUPLICATE KEY UPDATE
|
4676 |
+
visibility = 4
|
4677 |
+
");
|
4678 |
+
$result = $this->db_do("
|
4679 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index') . " (
|
4680 |
+
product_id,
|
4681 |
+
store_id,
|
4682 |
+
visibility
|
4683 |
+
)(
|
4684 |
+
SELECT
|
4685 |
+
a.entity_id,
|
4686 |
+
0,
|
4687 |
+
4
|
4688 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4689 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4690 |
+
ON a.store_product_id=w.store_product_id
|
4691 |
+
)
|
4692 |
+
ON DUPLICATE KEY UPDATE
|
4693 |
+
visibility = 4
|
4694 |
+
");
|
4695 |
+
|
4696 |
+
|
4697 |
+
$result = $this->db_do("
|
4698 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " (
|
4699 |
+
entity_type_id,
|
4700 |
+
attribute_id,
|
4701 |
+
store_id,
|
4702 |
+
entity_id,
|
4703 |
+
value
|
4704 |
+
)(
|
4705 |
+
SELECT
|
4706 |
+
" . $this->_getProductEntityTypeId() . ",
|
4707 |
+
" . $this->_getProductAttributeId('visibility') . ",
|
4708 |
+
w.website,
|
4709 |
+
a.entity_id,
|
4710 |
+
4
|
4711 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4712 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4713 |
+
ON a.store_product_id=w.store_product_id
|
4714 |
+
)
|
4715 |
+
ON DUPLICATE KEY UPDATE
|
4716 |
+
value = 4
|
4717 |
+
");
|
4718 |
+
|
4719 |
+
$result = $this->db_do("
|
4720 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " (
|
4721 |
+
entity_type_id,
|
4722 |
+
attribute_id,
|
4723 |
+
store_id,
|
4724 |
+
entity_id,
|
4725 |
+
value
|
4726 |
+
)(
|
4727 |
+
SELECT
|
4728 |
+
" . $this->_getProductEntityTypeId() . ",
|
4729 |
+
" . $this->_getProductAttributeId('visibility') . ",
|
4730 |
+
0,
|
4731 |
+
a.entity_id,
|
4732 |
+
4
|
4733 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4734 |
+
)
|
4735 |
+
ON DUPLICATE KEY UPDATE
|
4736 |
+
value = 4
|
4737 |
+
");
|
4738 |
+
|
4739 |
+
$result = $this->db_do("DELETE cpw
|
4740 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_website') . " cpw
|
4741 |
+
LEFT JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
4742 |
+
ON cpw.product_id=cpe.entity_id
|
4743 |
+
WHERE cpe.entity_id IS NULL");
|
4744 |
+
|
4745 |
+
$result = $this->db_do("
|
4746 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_website') . " (
|
4747 |
+
product_id,
|
4748 |
+
website_id
|
4749 |
+
)(
|
4750 |
+
SELECT a.entity_id, w.website_id
|
4751 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4752 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4753 |
+
ON a.store_product_id=w.store_product_id
|
4754 |
+
)
|
4755 |
+
ON DUPLICATE KEY UPDATE
|
4756 |
+
product_id=a.entity_id,
|
4757 |
+
website_id=w.website_id
|
4758 |
+
");
|
4759 |
+
|
4760 |
+
//Adding tax class "Taxable Goods"
|
4761 |
+
$result = $this->db_do("
|
4762 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " (
|
4763 |
+
entity_type_id,
|
4764 |
+
attribute_id,
|
4765 |
+
store_id,
|
4766 |
+
entity_id,
|
4767 |
+
value
|
4768 |
+
)(
|
4769 |
+
SELECT
|
4770 |
+
" . $this->_getProductEntityTypeId() . ",
|
4771 |
+
" . $this->_getProductAttributeId('tax_class_id') . ",
|
4772 |
+
w.website,
|
4773 |
+
a.entity_id,
|
4774 |
+
2
|
4775 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4776 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
4777 |
+
ON a.store_product_id=w.store_product_id
|
4778 |
+
)
|
4779 |
+
ON DUPLICATE KEY UPDATE
|
4780 |
+
value = 2
|
4781 |
+
");
|
4782 |
+
$result = $this->db_do("
|
4783 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int') . " (
|
4784 |
+
entity_type_id,
|
4785 |
+
attribute_id,
|
4786 |
+
store_id,
|
4787 |
+
entity_id,
|
4788 |
+
value
|
4789 |
+
)(
|
4790 |
+
SELECT
|
4791 |
+
" . $this->_getProductEntityTypeId() . ",
|
4792 |
+
" . $this->_getProductAttributeId('tax_class_id') . ",
|
4793 |
+
0,
|
4794 |
+
a.entity_id,
|
4795 |
+
2
|
4796 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4797 |
+
)
|
4798 |
+
ON DUPLICATE KEY UPDATE
|
4799 |
+
value = 2
|
4800 |
+
");
|
4801 |
+
|
4802 |
+
// Load url Image
|
4803 |
+
$result = $this->db_do("
|
4804 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
4805 |
+
entity_type_id,
|
4806 |
+
attribute_id,
|
4807 |
+
store_id,
|
4808 |
+
entity_id,
|
4809 |
+
value
|
4810 |
+
)(
|
4811 |
+
SELECT
|
4812 |
+
" . $this->_getProductEntityTypeId() . ",
|
4813 |
+
" . $this->_getProductAttributeId('image') . ",
|
4814 |
+
w.store_id,
|
4815 |
+
a.entity_id,
|
4816 |
+
b.main_image_url
|
4817 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4818 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " w
|
4819 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4820 |
+
ON a.store_product_id = b.store_product_id
|
4821 |
+
)
|
4822 |
+
ON DUPLICATE KEY UPDATE
|
4823 |
+
value = b.main_image_url
|
4824 |
+
");
|
4825 |
+
|
4826 |
+
// image for specific web sites
|
4827 |
+
$result = $this->db_do("
|
4828 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
4829 |
+
entity_type_id,
|
4830 |
+
attribute_id,
|
4831 |
+
store_id,
|
4832 |
+
entity_id,
|
4833 |
+
value
|
4834 |
+
)(
|
4835 |
+
SELECT
|
4836 |
+
" . $this->_getProductEntityTypeId() . ",
|
4837 |
+
" . $this->_getProductAttributeId('image') . ",
|
4838 |
+
0,
|
4839 |
+
a.entity_id,
|
4840 |
+
b.main_image_url
|
4841 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4842 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4843 |
+
ON a.store_product_id = b.store_product_id
|
4844 |
+
)
|
4845 |
+
ON DUPLICATE KEY UPDATE
|
4846 |
+
value = b.main_image_url
|
4847 |
+
");
|
4848 |
+
|
4849 |
+
// small_image for specific web sites
|
4850 |
+
$result = $this->db_do("
|
4851 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
4852 |
+
entity_type_id,
|
4853 |
+
attribute_id,
|
4854 |
+
store_id,
|
4855 |
+
entity_id,
|
4856 |
+
value
|
4857 |
+
)(
|
4858 |
+
SELECT
|
4859 |
+
" . $this->_getProductEntityTypeId() . ",
|
4860 |
+
" . $this->_getProductAttributeId('small_image') . ",
|
4861 |
+
w.store_id,
|
4862 |
+
a.entity_id,
|
4863 |
+
b.medium_image_url
|
4864 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4865 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " w
|
4866 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4867 |
+
ON a.store_product_id = b.store_product_id
|
4868 |
+
)
|
4869 |
+
ON DUPLICATE KEY UPDATE
|
4870 |
+
value = b.medium_image_url
|
4871 |
+
");
|
4872 |
+
|
4873 |
+
// small_image for all web sites
|
4874 |
+
$result = $this->db_do("
|
4875 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
4876 |
+
entity_type_id,
|
4877 |
+
attribute_id,
|
4878 |
+
store_id,
|
4879 |
+
entity_id,
|
4880 |
+
value
|
4881 |
+
)(
|
4882 |
+
SELECT
|
4883 |
+
" . $this->_getProductEntityTypeId() . ",
|
4884 |
+
" . $this->_getProductAttributeId('small_image') . ",
|
4885 |
+
0,
|
4886 |
+
a.entity_id,
|
4887 |
+
b.medium_image_url
|
4888 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4889 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " w
|
4890 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4891 |
+
ON a.store_product_id = b.store_product_id
|
4892 |
+
)
|
4893 |
+
ON DUPLICATE KEY UPDATE
|
4894 |
+
value = b.medium_image_url
|
4895 |
+
");
|
4896 |
+
|
4897 |
+
|
4898 |
+
// thumbnail for specific web site
|
4899 |
+
$result = $this->db_do("
|
4900 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
4901 |
+
entity_type_id,
|
4902 |
+
attribute_id,
|
4903 |
+
store_id,
|
4904 |
+
entity_id,
|
4905 |
+
value
|
4906 |
+
)(
|
4907 |
+
SELECT
|
4908 |
+
" . $this->_getProductEntityTypeId() . ",
|
4909 |
+
" . $this->_getProductAttributeId('thumbnail') . ",
|
4910 |
+
w.store_id,
|
4911 |
+
a.entity_id,
|
4912 |
+
b.thumb_image_url
|
4913 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4914 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " w
|
4915 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4916 |
+
ON a.store_product_id = b.store_product_id
|
4917 |
+
)
|
4918 |
+
ON DUPLICATE KEY UPDATE
|
4919 |
+
value = b.thumb_image_url
|
4920 |
+
");
|
4921 |
+
|
4922 |
+
// thumbnail for all web sites
|
4923 |
+
$result = $this->db_do("
|
4924 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
4925 |
+
entity_type_id,
|
4926 |
+
attribute_id,
|
4927 |
+
store_id,
|
4928 |
+
entity_id,
|
4929 |
+
value
|
4930 |
+
)(
|
4931 |
+
SELECT
|
4932 |
+
" . $this->_getProductEntityTypeId() . ",
|
4933 |
+
" . $this->_getProductAttributeId('thumbnail') . ",
|
4934 |
+
0,
|
4935 |
+
a.entity_id,
|
4936 |
+
b.thumb_image_url
|
4937 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
4938 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('core_store') . " w
|
4939 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
4940 |
+
ON a.store_product_id = b.store_product_id
|
4941 |
+
)
|
4942 |
+
ON DUPLICATE KEY UPDATE
|
4943 |
+
value = b.thumb_image_url
|
4944 |
+
|
4945 |
+
");
|
4946 |
+
|
4947 |
+
/*STP DELETE
|
4948 |
+
//Refresh fulltext search
|
4949 |
+
$result = $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp");
|
4950 |
+
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS
|
4951 |
+
".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp
|
4952 |
+
LIKE ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext'));
|
4953 |
+
|
4954 |
+
$result = $this->db_do("
|
4955 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp (
|
4956 |
+
product_id,
|
4957 |
+
store_id,
|
4958 |
+
data_index
|
4959 |
+
)(
|
4960 |
+
SELECT
|
4961 |
+
a.entity_id,
|
4962 |
+
w.website,
|
4963 |
+
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
4964 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
4965 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
4966 |
+
ON a.store_product_id=w.store_product_id
|
4967 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." b
|
4968 |
+
ON a.entity_id = b.product_id
|
4969 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." c
|
4970 |
+
ON b.category_id = c.entity_id
|
4971 |
+
AND c.attribute_id = " . $this->_getCategoryAttributeId('name'). "
|
4972 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." e
|
4973 |
+
ON a.entity_id = e.entity_id
|
4974 |
+
AND e.attribute_id = " . $this->_getProductAttributeId('name'). "
|
4975 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_website')." j
|
4976 |
+
ON a.entity_id = j.product_id
|
4977 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." f
|
4978 |
+
ON a.store_product_id = f.store_product_id
|
4979 |
+
)
|
4980 |
+
ON DUPLICATE KEY UPDATE
|
4981 |
+
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
4982 |
+
");
|
4983 |
+
|
4984 |
+
$result = $this->db_do("
|
4985 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp (
|
4986 |
+
product_id,
|
4987 |
+
store_id,
|
4988 |
+
data_index
|
4989 |
+
)(
|
4990 |
+
SELECT
|
4991 |
+
a.entity_id,
|
4992 |
+
w.website,
|
4993 |
+
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
4994 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
4995 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
4996 |
+
ON a.store_product_id=w.store_product_id
|
4997 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." b
|
4998 |
+
ON a.entity_id = b.product_id
|
4999 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." c
|
5000 |
+
ON b.category_id = c.entity_id
|
5001 |
+
AND c.attribute_id = " . $this->_getCategoryAttributeId('name'). "
|
5002 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." e
|
5003 |
+
ON a.entity_id = e.entity_id
|
5004 |
+
AND e.attribute_id = " . $this->_getProductAttributeId('name'). "
|
5005 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." f
|
5006 |
+
ON a.store_product_id = f.store_product_id
|
5007 |
+
)
|
5008 |
+
ON DUPLICATE KEY UPDATE
|
5009 |
+
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
5010 |
+
");
|
5011 |
+
|
5012 |
+
$result = $this->db_do("DELETE cf
|
5013 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')." cf
|
5014 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
5015 |
+
ON cf.product_id=cpe.entity_id
|
5016 |
+
WHERE cpe.entity_id is null");
|
5017 |
+
|
5018 |
+
$result = $this->db_do("
|
5019 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')." (
|
5020 |
+
product_id,
|
5021 |
+
store_id,
|
5022 |
+
data_index
|
5023 |
+
)(
|
5024 |
+
SELECT
|
5025 |
+
a.product_id,
|
5026 |
+
a.store_id,
|
5027 |
+
a.data_index
|
5028 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp a
|
5029 |
+
WHERE product_id = a.product_id
|
5030 |
+
)
|
5031 |
+
ON DUPLICATE KEY UPDATE
|
5032 |
+
data_index = a.data_index
|
5033 |
+
");
|
5034 |
+
|
5035 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_query')." SET is_processed = 0");
|
5036 |
+
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
5037 |
+
//TODO add something else
|
5038 |
+
STP DELETE*/
|
5039 |
+
$this->addRelatedProducts();
|
5040 |
+
}
|
5041 |
+
|
5042 |
+
private function _getProductDefaulAttributeSetId()
|
5043 |
+
{
|
5044 |
+
if (!$this->defaultAttributeSetId) {
|
5045 |
+
$sql = "
|
5046 |
+
SELECT entity_type_id, default_attribute_set_id
|
5047 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('eav_entity_type') . "
|
5048 |
+
WHERE entity_type_code = 'catalog_product'
|
5049 |
+
LIMIT 1
|
5050 |
+
";
|
5051 |
+
$result = $this->db_do($sql);
|
5052 |
+
if ($row = mysqli_fetch_assoc($result)) {
|
5053 |
+
|
5054 |
+
$this->defaultAttributeSetId = $row['default_attribute_set_id'];
|
5055 |
+
}
|
5056 |
+
}
|
5057 |
+
return $this->defaultAttributeSetId;
|
5058 |
+
}
|
5059 |
+
|
5060 |
+
|
5061 |
+
function dropHTMLentities($entity_type_id, $attribute_id)
|
5062 |
+
{
|
5063 |
+
// product name for all web sites
|
5064 |
+
$result = $this->db_do("
|
5065 |
+
SELECT value, entity_id
|
5066 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . "
|
5067 |
+
WHERE entity_type_id=" . $entity_type_id . "
|
5068 |
+
AND attribute_id=" . $attribute_id
|
5069 |
+
);
|
5070 |
+
while ($row = mysqli_fetch_array($result)) {
|
5071 |
+
$value = $this->valid_char($row['value']);
|
5072 |
+
if ($value != '' and $value != $row['value']) {
|
5073 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . "
|
5074 |
+
SET value='" . mysqli_real_escape_string($this->db, $value) . "'
|
5075 |
+
WHERE entity_id=" . $row['entity_id'] . "
|
5076 |
+
AND entity_type_id=" . $entity_type_id . "
|
5077 |
+
AND attribute_id=" . $attribute_id);
|
5078 |
+
}
|
5079 |
+
}
|
5080 |
+
}
|
5081 |
+
|
5082 |
+
function valid_char($string)
|
5083 |
+
{
|
5084 |
+
$string = preg_replace('/™/', ' ', $string);
|
5085 |
+
$string = preg_replace('/®/', ' ', $string);
|
5086 |
+
$string = preg_replace('/≈/', ' ', $string);
|
5087 |
+
$string = preg_replace('/"/', ' ', $string);
|
5088 |
+
$string = preg_replace('/′/', ' ', $string);
|
5089 |
+
$string = preg_replace('/°/', ' ', $string);
|
5090 |
+
$string = preg_replace('/±/', ' ', $string);
|
5091 |
+
$string = preg_replace('/µ/', ' ', $string);
|
5092 |
+
$string = preg_replace('/²/', ' ', $string);
|
5093 |
+
$string = preg_replace('/³/', ' ', $string);
|
5094 |
+
return $string;
|
5095 |
+
}
|
5096 |
+
|
5097 |
+
function addDescriptions()
|
5098 |
+
{
|
5099 |
+
// product description for all web sites
|
5100 |
+
$result = $this->db_do("
|
5101 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text') . " (
|
5102 |
+
entity_type_id,
|
5103 |
+
attribute_id,
|
5104 |
+
store_id,
|
5105 |
+
entity_id,
|
5106 |
+
value
|
5107 |
+
)(
|
5108 |
+
SELECT
|
5109 |
+
" . $this->_getProductEntityTypeId() . ",
|
5110 |
+
" . $this->_getProductAttributeId('description') . ",
|
5111 |
+
w.website,
|
5112 |
+
a.entity_id,
|
5113 |
+
b.description
|
5114 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5115 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5116 |
+
ON a.store_product_id = b.store_product_id
|
5117 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5118 |
+
ON a.store_product_id=w.store_product_id
|
5119 |
+
)
|
5120 |
+
ON DUPLICATE KEY UPDATE
|
5121 |
+
value = b.description
|
5122 |
+
");
|
5123 |
+
|
5124 |
+
// product description for all web sites
|
5125 |
+
$result = $this->db_do("
|
5126 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text') . " (
|
5127 |
+
entity_type_id,
|
5128 |
+
attribute_id,
|
5129 |
+
store_id,
|
5130 |
+
entity_id,
|
5131 |
+
value
|
5132 |
+
)(
|
5133 |
+
SELECT
|
5134 |
+
" . $this->_getProductEntityTypeId() . ",
|
5135 |
+
" . $this->_getProductAttributeId('description') . ",
|
5136 |
+
0,
|
5137 |
+
a.entity_id,
|
5138 |
+
b.description
|
5139 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5140 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5141 |
+
ON a.store_product_id = b.store_product_id
|
5142 |
+
)
|
5143 |
+
ON DUPLICATE KEY UPDATE
|
5144 |
+
value = b.description
|
5145 |
+
");
|
5146 |
+
}
|
5147 |
+
|
5148 |
+
function cleanProductDistributors()
|
5149 |
+
{
|
5150 |
+
for ($i = 1; $i <= 5; $i++) {
|
5151 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . "
|
5152 |
+
SET value = ''
|
5153 |
+
WHERE entity_type_id=" . $this->_getProductEntityTypeId() . " AND attribute_id=" . $this->_getProductAttributeId('supplier_' . $i));
|
5154 |
+
}
|
5155 |
+
}
|
5156 |
+
|
5157 |
+
function cleanProductContracts()
|
5158 |
+
{
|
5159 |
+
if ($contractIdAttr = $this->_getProductAttributeId('contract_id')) {
|
5160 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . "
|
5161 |
+
SET value = ''
|
5162 |
+
WHERE entity_type_id=" . $this->_getProductEntityTypeId() . " AND attribute_id=" . $contractIdAttr);
|
5163 |
+
}
|
5164 |
+
}
|
5165 |
+
|
5166 |
+
function addReviews()
|
5167 |
+
{
|
5168 |
+
// product reviews for all web sites
|
5169 |
+
$result = $this->db_do("
|
5170 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text') . " (
|
5171 |
+
entity_type_id,
|
5172 |
+
attribute_id,
|
5173 |
+
store_id,
|
5174 |
+
entity_id,
|
5175 |
+
value
|
5176 |
+
)(
|
5177 |
+
SELECT
|
5178 |
+
" . $this->_getProductEntityTypeId() . ",
|
5179 |
+
" . $this->_getProductAttributeId('reviews') . ",
|
5180 |
+
w.website,
|
5181 |
+
a.entity_id,
|
5182 |
+
b.Reviews
|
5183 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5184 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5185 |
+
ON a.store_product_id = b.store_product_id
|
5186 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5187 |
+
ON a.store_product_id=w.store_product_id
|
5188 |
+
)
|
5189 |
+
ON DUPLICATE KEY UPDATE
|
5190 |
+
value = b.Reviews
|
5191 |
+
");
|
5192 |
+
|
5193 |
+
// product Reviews for all web sites
|
5194 |
+
$result = $this->db_do("
|
5195 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text') . " (
|
5196 |
+
entity_type_id,
|
5197 |
+
attribute_id,
|
5198 |
+
store_id,
|
5199 |
+
entity_id,
|
5200 |
+
value
|
5201 |
+
)(
|
5202 |
+
SELECT
|
5203 |
+
" . $this->_getProductEntityTypeId() . ",
|
5204 |
+
" . $this->_getProductAttributeId('reviews') . ",
|
5205 |
+
0,
|
5206 |
+
a.entity_id,
|
5207 |
+
b.Reviews
|
5208 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5209 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5210 |
+
ON a.store_product_id = b.store_product_id
|
5211 |
+
)
|
5212 |
+
ON DUPLICATE KEY UPDATE
|
5213 |
+
value = b.Reviews
|
5214 |
+
");
|
5215 |
+
}
|
5216 |
+
|
5217 |
+
function addWeight()
|
5218 |
+
{
|
5219 |
+
// product weight for specific web site
|
5220 |
+
$result = $this->db_do("
|
5221 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal') . " (
|
5222 |
+
entity_type_id,
|
5223 |
+
attribute_id,
|
5224 |
+
store_id,
|
5225 |
+
entity_id,
|
5226 |
+
value
|
5227 |
+
)(
|
5228 |
+
SELECT
|
5229 |
+
" . $this->_getProductEntityTypeId() . ",
|
5230 |
+
" . $this->_getProductAttributeId('weight') . ",
|
5231 |
+
w.website,
|
5232 |
+
a.entity_id,
|
5233 |
+
b.Weight
|
5234 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5235 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5236 |
+
ON a.store_product_id = b.store_product_id
|
5237 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5238 |
+
ON a.store_product_id=w.store_product_id
|
5239 |
+
)
|
5240 |
+
ON DUPLICATE KEY UPDATE
|
5241 |
+
value = b.Weight
|
5242 |
+
");
|
5243 |
+
// product weight for all web sites
|
5244 |
+
$result = $this->db_do("
|
5245 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal') . " (
|
5246 |
+
entity_type_id,
|
5247 |
+
attribute_id,
|
5248 |
+
store_id,
|
5249 |
+
entity_id,
|
5250 |
+
value
|
5251 |
+
)(
|
5252 |
+
SELECT
|
5253 |
+
" . $this->_getProductEntityTypeId() . ",
|
5254 |
+
" . $this->_getProductAttributeId('weight') . ",
|
5255 |
+
0,
|
5256 |
+
a.entity_id,
|
5257 |
+
b.Weight
|
5258 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5259 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5260 |
+
ON a.store_product_id = b.store_product_id
|
5261 |
+
)
|
5262 |
+
ON DUPLICATE KEY UPDATE
|
5263 |
+
value = b.Weight
|
5264 |
+
|
5265 |
+
|
5266 |
+
");
|
5267 |
+
}
|
5268 |
+
|
5269 |
+
function addSearchCache()
|
5270 |
+
{
|
5271 |
+
// product search_cache for all web sites
|
5272 |
+
$result = $this->db_do("
|
5273 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text') . " (
|
5274 |
+
entity_type_id,
|
5275 |
+
attribute_id,
|
5276 |
+
store_id,
|
5277 |
+
entity_id,
|
5278 |
+
value
|
5279 |
+
)(
|
5280 |
+
SELECT
|
5281 |
+
" . $this->_getProductEntityTypeId() . ",
|
5282 |
+
" . $this->_getProductAttributeId('sinch_search_cache') . ",
|
5283 |
+
w.website,
|
5284 |
+
a.entity_id,
|
5285 |
+
b.search_cache
|
5286 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5287 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5288 |
+
ON a.store_product_id = b.store_product_id
|
5289 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5290 |
+
ON a.store_product_id=w.store_product_id
|
5291 |
+
)
|
5292 |
+
ON DUPLICATE KEY UPDATE
|
5293 |
+
value = b.search_cache
|
5294 |
+
");
|
5295 |
+
|
5296 |
+
// product search_cache for all web sites
|
5297 |
+
$result = $this->db_do("
|
5298 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text') . " (
|
5299 |
+
entity_type_id,
|
5300 |
+
attribute_id,
|
5301 |
+
store_id,
|
5302 |
+
entity_id,
|
5303 |
+
value
|
5304 |
+
)(
|
5305 |
+
SELECT
|
5306 |
+
" . $this->_getProductEntityTypeId() . ",
|
5307 |
+
" . $this->_getProductAttributeId('sinch_search_cache') . ",
|
5308 |
+
0,
|
5309 |
+
a.entity_id,
|
5310 |
+
b.search_cache
|
5311 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5312 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5313 |
+
ON a.store_product_id = b.store_product_id
|
5314 |
+
)
|
5315 |
+
ON DUPLICATE KEY UPDATE
|
5316 |
+
value = b.search_cache
|
5317 |
+
");
|
5318 |
+
}
|
5319 |
+
|
5320 |
+
function addPdfUrl()
|
5321 |
+
{
|
5322 |
+
// product PDF Url for all web sites
|
5323 |
+
$result = $this->db_do("
|
5324 |
+
UPDATE " . Mage::getSingleton('core/resource')->getTableName('products_temp') . "
|
5325 |
+
SET pdf_url = CONCAT(
|
5326 |
+
'<a href=\"#\" onclick=\"popWin(',
|
5327 |
+
\"'\",
|
5328 |
+
pdf_url,
|
5329 |
+
\"'\",
|
5330 |
+
\", 'pdf', 'width=500,height=800,left=50,top=50, location=no,status=yes,scrollbars=yes,resizable=yes'); return false;\",
|
5331 |
+
'\"',
|
5332 |
+
'>',
|
5333 |
+
pdf_url,
|
5334 |
+
'</a>')
|
5335 |
+
WHERE pdf_url != ''
|
5336 |
+
");
|
5337 |
+
$result = $this->db_do("
|
5338 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5339 |
+
entity_type_id,
|
5340 |
+
attribute_id,
|
5341 |
+
store_id,
|
5342 |
+
entity_id,
|
5343 |
+
value
|
5344 |
+
)(
|
5345 |
+
SELECT
|
5346 |
+
" . $this->_getProductEntityTypeId() . ",
|
5347 |
+
" . $this->_getProductAttributeId('pdf_url') . ",
|
5348 |
+
w.website,
|
5349 |
+
a.entity_id,
|
5350 |
+
b.pdf_url
|
5351 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5352 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5353 |
+
ON a.store_product_id = b.store_product_id
|
5354 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5355 |
+
ON a.store_product_id=w.store_product_id
|
5356 |
+
)
|
5357 |
+
ON DUPLICATE KEY UPDATE
|
5358 |
+
value = b.pdf_url
|
5359 |
+
");
|
5360 |
+
// product PDF url for all web sites
|
5361 |
+
$result = $this->db_do("
|
5362 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5363 |
+
entity_type_id,
|
5364 |
+
attribute_id,
|
5365 |
+
store_id,
|
5366 |
+
entity_id,
|
5367 |
+
value
|
5368 |
+
)(
|
5369 |
+
SELECT
|
5370 |
+
" . $this->_getProductEntityTypeId() . ",
|
5371 |
+
" . $this->_getProductAttributeId('pdf_url') . ",
|
5372 |
+
0,
|
5373 |
+
a.entity_id,
|
5374 |
+
b.pdf_url
|
5375 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5376 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5377 |
+
ON a.store_product_id = b.store_product_id
|
5378 |
+
)
|
5379 |
+
ON DUPLICATE KEY UPDATE
|
5380 |
+
value = b.pdf_url
|
5381 |
+
");
|
5382 |
+
}
|
5383 |
+
|
5384 |
+
function addShortDescriptions()
|
5385 |
+
{
|
5386 |
+
// product short description for all web sites
|
5387 |
+
$result = $this->db_do("
|
5388 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5389 |
+
entity_type_id,
|
5390 |
+
attribute_id,
|
5391 |
+
store_id,
|
5392 |
+
entity_id,
|
5393 |
+
value
|
5394 |
+
)(
|
5395 |
+
SELECT
|
5396 |
+
" . $this->_getProductEntityTypeId() . ",
|
5397 |
+
" . $this->_getProductAttributeId('short_description') . ",
|
5398 |
+
w.website,
|
5399 |
+
a.entity_id,
|
5400 |
+
b.product_short_description
|
5401 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5402 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5403 |
+
ON a.store_product_id = b.store_product_id
|
5404 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5405 |
+
ON a.store_product_id=w.store_product_id
|
5406 |
+
)
|
5407 |
+
ON DUPLICATE KEY UPDATE
|
5408 |
+
value = b.product_short_description
|
5409 |
+
");
|
5410 |
+
// product short description for all web sites
|
5411 |
+
$result = $this->db_do("
|
5412 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5413 |
+
entity_type_id,
|
5414 |
+
attribute_id,
|
5415 |
+
store_id,
|
5416 |
+
entity_id,
|
5417 |
+
value
|
5418 |
+
)(
|
5419 |
+
SELECT
|
5420 |
+
" . $this->_getProductEntityTypeId() . ",
|
5421 |
+
" . $this->_getProductAttributeId('short_description') . ",
|
5422 |
+
0,
|
5423 |
+
a.entity_id,
|
5424 |
+
b.product_short_description
|
5425 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5426 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5427 |
+
ON a.store_product_id = b.store_product_id
|
5428 |
+
)
|
5429 |
+
ON DUPLICATE KEY UPDATE
|
5430 |
+
value = b.product_short_description
|
5431 |
+
");
|
5432 |
+
}
|
5433 |
+
|
5434 |
+
function addProductDistributors()
|
5435 |
+
{
|
5436 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary'));
|
5437 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary') . "
|
5438 |
+
LIKE " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price'));
|
5439 |
+
$this->db_do("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary') . " SELECT * FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price'));
|
5440 |
+
for ($i = 1; $i <= 5; $i++) {
|
5441 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary_supplier'));
|
5442 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary_supplier') . "
|
5443 |
+
LIKE " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price'));
|
5444 |
+
$this->db_do("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary_supplier') . " SELECT * FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary') . " GROUP BY store_product_id");
|
5445 |
+
|
5446 |
+
// product Distributors for all web sites
|
5447 |
+
$result = $this->db_do("
|
5448 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5449 |
+
entity_type_id,
|
5450 |
+
attribute_id,
|
5451 |
+
store_id,
|
5452 |
+
entity_id,
|
5453 |
+
value
|
5454 |
+
)(
|
5455 |
+
SELECT
|
5456 |
+
" . $this->_getProductEntityTypeId() . ",
|
5457 |
+
" . $this->_getProductAttributeId('supplier_' . $i) . ",
|
5458 |
+
w.website,
|
5459 |
+
a.entity_id,
|
5460 |
+
d.distributor_name
|
5461 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5462 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary_supplier') . " b
|
5463 |
+
ON a.store_product_id = b.store_product_id
|
5464 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors') . " d
|
5465 |
+
ON b.distributor_id = d.distributor_id
|
5466 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5467 |
+
ON a.store_product_id=w.store_product_id
|
5468 |
+
)
|
5469 |
+
ON DUPLICATE KEY UPDATE
|
5470 |
+
value = d.distributor_name
|
5471 |
+
");
|
5472 |
+
// product Distributors for all web sites
|
5473 |
+
$result = $this->db_do("
|
5474 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5475 |
+
entity_type_id,
|
5476 |
+
attribute_id,
|
5477 |
+
store_id,
|
5478 |
+
entity_id,
|
5479 |
+
value
|
5480 |
+
)(
|
5481 |
+
SELECT
|
5482 |
+
" . $this->_getProductEntityTypeId() . ",
|
5483 |
+
" . $this->_getProductAttributeId('supplier_' . $i) . ",
|
5484 |
+
0,
|
5485 |
+
a.entity_id,
|
5486 |
+
d.distributor_name
|
5487 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5488 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary_supplier') . " b
|
5489 |
+
ON a.store_product_id = b.store_product_id
|
5490 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors') . " d
|
5491 |
+
ON b.distributor_id = d.distributor_id
|
5492 |
+
)
|
5493 |
+
ON DUPLICATE KEY UPDATE
|
5494 |
+
value = d.distributor_name
|
5495 |
+
");
|
5496 |
+
|
5497 |
+
$this->db_do("DELETE sdsapt FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary') . " sdsapt JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price_temporary_supplier') . " sdsapts ON sdsapt.store_product_id = sdsapts.store_product_id AND sdsapt.distributor_id = sdsapts.distributor_id");
|
5498 |
+
}
|
5499 |
+
}
|
5500 |
+
|
5501 |
+
function addProductContracts()
|
5502 |
+
{
|
5503 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_product_contracts_temporary'));
|
5504 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS " . Mage::getSingleton('core/resource')->getTableName('stINch_product_contracts_temporary') . "(
|
5505 |
+
`store_product_id` int(11) DEFAULT NULL,
|
5506 |
+
`contract_id_str` varchar(255) DEFAULT NULL,
|
5507 |
+
KEY `store_product_id` (store_product_id)
|
5508 |
+
)
|
5509 |
+
");
|
5510 |
+
$this->db_do("INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('stINch_product_contracts_temporary') . " SELECT store_product_id, group_concat(contract_id) FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_product_contracts') . " GROUP BY store_product_id");
|
5511 |
+
// product Distributors for all web sites
|
5512 |
+
$result = $this->db_do("
|
5513 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5514 |
+
entity_type_id,
|
5515 |
+
attribute_id,
|
5516 |
+
store_id,
|
5517 |
+
entity_id,
|
5518 |
+
value
|
5519 |
+
)(
|
5520 |
+
SELECT
|
5521 |
+
" . $this->_getProductEntityTypeId() . ",
|
5522 |
+
" . $this->_getProductAttributeId('contract_id') . ",
|
5523 |
+
w.website,
|
5524 |
+
a.entity_id,
|
5525 |
+
b.contract_id_str
|
5526 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5527 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_product_contracts_temporary') . " b
|
5528 |
+
ON a.store_product_id = b.store_product_id
|
5529 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5530 |
+
ON a.store_product_id=w.store_product_id
|
5531 |
+
)
|
5532 |
+
ON DUPLICATE KEY UPDATE
|
5533 |
+
value = b.contract_id_str
|
5534 |
+
");
|
5535 |
+
// product Distributors for all web sites
|
5536 |
+
$result = $this->db_do("
|
5537 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5538 |
+
entity_type_id,
|
5539 |
+
attribute_id,
|
5540 |
+
store_id,
|
5541 |
+
entity_id,
|
5542 |
+
value
|
5543 |
+
)(
|
5544 |
+
SELECT
|
5545 |
+
" . $this->_getProductEntityTypeId() . ",
|
5546 |
+
" . $this->_getProductAttributeId('contract_id') . ",
|
5547 |
+
0,
|
5548 |
+
a.entity_id,
|
5549 |
+
b.contract_id_str
|
5550 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5551 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_product_contracts_temporary') . " b
|
5552 |
+
ON a.store_product_id = b.store_product_id
|
5553 |
+
)
|
5554 |
+
ON DUPLICATE KEY UPDATE
|
5555 |
+
value = b.contract_id_str
|
5556 |
+
");
|
5557 |
+
}
|
5558 |
+
|
5559 |
+
function addEAN()
|
5560 |
+
{
|
5561 |
+
//gather EAN codes for each product
|
5562 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('EANs_temp'));
|
5563 |
+
$this->db_do("
|
5564 |
+
CREATE TEMPORARY TABLE " . Mage::getSingleton('core/resource')->getTableName('EANs_temp') . " (
|
5565 |
+
sinch_product_id int(11),
|
5566 |
+
store_product_id int(11),
|
5567 |
+
EANs text,
|
5568 |
+
KEY `sinch_product_id` (`sinch_product_id`),
|
5569 |
+
KEY `store_product_id` (`store_product_id`)
|
5570 |
+
)
|
5571 |
+
");
|
5572 |
+
$this->db_do("
|
5573 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('EANs_temp') . " (
|
5574 |
+
sinch_product_id,
|
5575 |
+
EANs
|
5576 |
+
)(SELECT
|
5577 |
+
sec.product_id,
|
5578 |
+
GROUP_CONCAT(DISTINCT ean_code ORDER BY ean_code DESC SEPARATOR ', ') AS eans
|
5579 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_ean_codes') . " sec
|
5580 |
+
GROUP BY sec.product_id
|
5581 |
+
)
|
5582 |
+
");
|
5583 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('EANs_temp') . " e
|
5584 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " p
|
5585 |
+
ON e.sinch_product_id=p.sinch_product_id
|
5586 |
+
SET e.store_product_id=p.store_product_id");
|
5587 |
+
// product EANs for all web sites
|
5588 |
+
$result = $this->db_do("
|
5589 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5590 |
+
entity_type_id,
|
5591 |
+
attribute_id,
|
5592 |
+
store_id,
|
5593 |
+
entity_id,
|
5594 |
+
value
|
5595 |
+
)(
|
5596 |
+
SELECT
|
5597 |
+
" . $this->_getProductEntityTypeId() . ",
|
5598 |
+
" . $this->_getProductAttributeId('ean') . ",
|
5599 |
+
w.website,
|
5600 |
+
a.entity_id,
|
5601 |
+
e.EANs
|
5602 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5603 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('EANs_temp') . " e
|
5604 |
+
ON a.store_product_id = e.store_product_id
|
5605 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5606 |
+
ON a.store_product_id=w.store_product_id
|
5607 |
+
)
|
5608 |
+
ON DUPLICATE KEY UPDATE
|
5609 |
+
value = e.EANs
|
5610 |
+
");
|
5611 |
+
|
5612 |
+
// product EANs for all web sites
|
5613 |
+
$result = $this->db_do("
|
5614 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar') . " (
|
5615 |
+
entity_type_id,
|
5616 |
+
attribute_id,
|
5617 |
+
store_id,
|
5618 |
+
entity_id,
|
5619 |
+
value
|
5620 |
+
)(
|
5621 |
+
SELECT
|
5622 |
+
" . $this->_getProductEntityTypeId() . ",
|
5623 |
+
" . $this->_getProductAttributeId('ean') . ",
|
5624 |
+
0,
|
5625 |
+
a.entity_id,
|
5626 |
+
e.EANs
|
5627 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5628 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('EANs_temp') . " e
|
5629 |
+
ON a.store_product_id = e.store_product_id
|
5630 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5631 |
+
ON a.store_product_id=w.store_product_id
|
5632 |
+
)
|
5633 |
+
ON DUPLICATE KEY UPDATE
|
5634 |
+
value = e.EANs
|
5635 |
+
");
|
5636 |
+
|
5637 |
+
}
|
5638 |
+
|
5639 |
+
function addSpecification()
|
5640 |
+
{
|
5641 |
+
// product specification for all web sites
|
5642 |
+
$result = $this->db_do("
|
5643 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text') . " (
|
5644 |
+
entity_type_id,
|
5645 |
+
attribute_id,
|
5646 |
+
store_id,
|
5647 |
+
entity_id,
|
5648 |
+
value
|
5649 |
+
)(
|
5650 |
+
SELECT
|
5651 |
+
" . $this->_getProductEntityTypeId() . ",
|
5652 |
+
" . $this->_getProductAttributeId('specification') . ",
|
5653 |
+
w.website,
|
5654 |
+
a.entity_id,
|
5655 |
+
b.specifications
|
5656 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5657 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5658 |
+
ON a.store_product_id = b.store_product_id
|
5659 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_website_temp') . " w
|
5660 |
+
ON a.store_product_id=w.store_product_id
|
5661 |
+
)
|
5662 |
+
ON DUPLICATE KEY UPDATE
|
5663 |
+
value = b.specifications
|
5664 |
+
");
|
5665 |
+
// product specification for all web sites
|
5666 |
+
$result = $this->db_do("
|
5667 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text') . " (
|
5668 |
+
entity_type_id,
|
5669 |
+
attribute_id,
|
5670 |
+
store_id,
|
5671 |
+
entity_id,
|
5672 |
+
value
|
5673 |
+
)(
|
5674 |
+
SELECT
|
5675 |
+
" . $this->_getProductEntityTypeId() . ",
|
5676 |
+
" . $this->_getProductAttributeId('specification') . ",
|
5677 |
+
0,
|
5678 |
+
a.entity_id,
|
5679 |
+
b.specifications
|
5680 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " a
|
5681 |
+
INNER JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " b
|
5682 |
+
ON a.store_product_id = b.store_product_id
|
5683 |
+
)
|
5684 |
+
ON DUPLICATE KEY UPDATE
|
5685 |
+
value = b.specifications
|
5686 |
+
");
|
5687 |
+
}
|
5688 |
+
|
5689 |
+
function addRelatedProducts()
|
5690 |
+
{
|
5691 |
+
|
5692 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('stINch_related_products') . " rpt
|
5693 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " p
|
5694 |
+
ON rpt.sinch_product_id=p.sinch_product_id
|
5695 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
5696 |
+
ON p.store_product_id=cpe.store_product_id
|
5697 |
+
SET rpt.store_product_id=p.store_product_id, rpt.entity_id=cpe.entity_id");
|
5698 |
+
|
5699 |
+
$this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('stINch_related_products') . " rpt
|
5700 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('products_temp') . " p
|
5701 |
+
ON rpt.related_sinch_product_id=p.sinch_product_id
|
5702 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity') . " cpe
|
5703 |
+
ON p.store_product_id=cpe.store_product_id
|
5704 |
+
SET rpt.store_related_product_id=p.store_product_id, rpt.related_entity_id=cpe.entity_id");
|
5705 |
+
|
5706 |
+
$result = $this->db_do("SELECT
|
5707 |
+
link_type_id,
|
5708 |
+
code
|
5709 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link_type')
|
5710 |
+
);
|
5711 |
+
$link_type = array();
|
5712 |
+
while ($row = mysqli_fetch_array($result)) {
|
5713 |
+
$link_type[$row['code']] = $row['link_type_id'];
|
5714 |
+
}
|
5715 |
+
|
5716 |
+
$result = $this->db_do("
|
5717 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link') . " (
|
5718 |
+
product_id,
|
5719 |
+
linked_product_id,
|
5720 |
+
link_type_id
|
5721 |
+
)(
|
5722 |
+
SELECT
|
5723 |
+
entity_id,
|
5724 |
+
related_entity_id,
|
5725 |
+
" . $link_type['relation'] . "
|
5726 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('stINch_related_products') . "
|
5727 |
+
WHERE store_product_id IS NOT NULL
|
5728 |
+
AND store_related_product_id IS NOT NULL
|
5729 |
+
)
|
5730 |
+
ON DUPLICATE KEY UPDATE
|
5731 |
+
product_id = entity_id,
|
5732 |
+
linked_product_id = related_entity_id
|
5733 |
+
");
|
5734 |
+
$this->db_do("DROP TABLE IF EXISTS " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int') . "_tmp");
|
5735 |
+
|
5736 |
+
$this->db_do("CREATE TEMPORARY TABLE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int') . "_tmp (
|
5737 |
+
`value_id` int(11) default NULL,
|
5738 |
+
`product_link_attribute_id` smallint(6) unsigned default NULL,
|
5739 |
+
`link_id` int(11) unsigned default NULL,
|
5740 |
+
`value` int(11) NOT NULL default '0',
|
5741 |
+
KEY `FK_INT_PRODUCT_LINK_ATTRIBUTE` (`product_link_attribute_id`),
|
5742 |
+
KEY `FK_INT_PRODUCT_LINK` (`link_id`)
|
5743 |
+
)
|
5744 |
+
");
|
5745 |
+
|
5746 |
+
$result = $this->db_do("
|
5747 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int') . "_tmp(
|
5748 |
+
product_link_attribute_id,
|
5749 |
+
link_id,
|
5750 |
+
value
|
5751 |
+
)(
|
5752 |
+
SELECT
|
5753 |
+
2,
|
5754 |
+
cpl.link_id,
|
5755 |
+
0
|
5756 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link') . " cpl
|
5757 |
+
)
|
5758 |
+
");
|
5759 |
+
|
5760 |
+
$result = $this->db_do("UPDATE " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int') . "_tmp ct
|
5761 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int') . " c
|
5762 |
+
ON ct.link_id=c.link_id
|
5763 |
+
SET ct.value_id=c.value_id
|
5764 |
+
WHERE c.product_link_attribute_id=2
|
5765 |
+
");
|
5766 |
+
|
5767 |
+
$result = $this->db_do("
|
5768 |
+
INSERT INTO " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int') . " (
|
5769 |
+
value_id,
|
5770 |
+
product_link_attribute_id,
|
5771 |
+
link_id,
|
5772 |
+
value
|
5773 |
+
)(
|
5774 |
+
SELECT
|
5775 |
+
value_id,
|
5776 |
+
product_link_attribute_id,
|
5777 |
+
link_id,
|
5778 |
+
value
|
5779 |
+
FROM " . Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int') . "_tmp ct
|
5780 |
+
)
|
5781 |
+
ON DUPLICATE KEY UPDATE
|
5782 |
+
link_id=ct.link_id
|
5783 |
+
|
5784 |
+
");
|
5785 |
+
}
|
5786 |
+
|
5787 |
+
public function replaceMagentoProductsMultistore($coincidence)
|
5788 |
+
{
|
5789 |
+
echo("\n replaceMagentoProductsMultistore 1\n");
|
5790 |
+
|
5791 |
+
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
5792 |
+
|
5793 |
+
$products_temp = Mage::getSingleton('core/resource')->getTableName('products_temp');
|
5794 |
+
$products_website_temp = Mage::getSingleton('core/resource')->getTableName('products_website_temp');
|
5795 |
+
$catalog_product_entity = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity');
|
5796 |
+
$catalog_product_entity_int = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int');
|
5797 |
+
$catalog_product_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar');
|
5798 |
+
$catalog_category_product = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
5799 |
+
$stINch_products_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping');
|
5800 |
+
$catalog_category_entity = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity');
|
5801 |
+
$stINch_categories_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping');
|
5802 |
+
$catalog_category_product_index = Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index');
|
5803 |
+
$core_store = Mage::getSingleton('core/resource')->getTableName('core_store');
|
5804 |
+
$catalog_product_enabled_index = Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index');
|
5805 |
+
$catalog_product_website = Mage::getSingleton('core/resource')->getTableName('catalog_product_website');
|
5806 |
+
//$catalogsearch_fulltext = Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext');
|
5807 |
+
//$catalogsearch_query = Mage::getSingleton('core/resource')->getTableName('catalogsearch_query');
|
5808 |
+
$catalog_category_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar');
|
5809 |
+
|
5810 |
+
$_getProductEntityTypeId = $this->_getProductEntityTypeId();
|
5811 |
+
$_defaultAttributeSetId = $this->_getProductDefaulAttributeSetId();
|
5812 |
+
|
5813 |
+
$attr_atatus = $this->_getProductAttributeId('status');
|
5814 |
+
$attr_name = $this->_getProductAttributeId('name');
|
5815 |
+
$attr_visibility = $this->_getProductAttributeId('visibility');
|
5816 |
+
$attr_tax_class_id = $this->_getProductAttributeId('tax_class_id');
|
5817 |
+
$attr_image = $this->_getProductAttributeId('image');
|
5818 |
+
$attr_small_image = $this->_getProductAttributeId('small_image');
|
5819 |
+
$attr_thumbnail = $this->_getProductAttributeId('thumbnail');
|
5820 |
+
|
5821 |
+
$cat_attr_name = $this->_getCategoryAttributeId('name');
|
5822 |
+
echo("\n replaceMagentoProductsMultistore 2\n");
|
5823 |
+
|
5824 |
+
//clear products, inserting new products and updating old others.
|
5825 |
+
$query = "
|
5826 |
+
DELETE cpe
|
5827 |
+
FROM $catalog_product_entity cpe
|
5828 |
+
JOIN $stINch_products_mapping pm
|
5829 |
+
ON cpe.entity_id = pm.entity_id
|
5830 |
+
WHERE pm.shop_store_product_id IS NOT NULL
|
5831 |
+
AND pm.store_product_id IS NULL";
|
5832 |
+
$result = $this->db_do($query);
|
5833 |
+
|
5834 |
+
|
5835 |
+
echo("\n replaceMagentoProductsMultistore 3\n");
|
5836 |
+
|
5837 |
+
$result = $this->db_do("
|
5838 |
+
INSERT INTO $catalog_product_entity
|
5839 |
+
(entity_id, entity_type_id, attribute_set_id, type_id, sku, updated_at, has_options, store_product_id, sinch_product_id)
|
5840 |
+
(SELECT
|
5841 |
+
pm.entity_id,
|
5842 |
+
$_getProductEntityTypeId,
|
5843 |
+
$_defaultAttributeSetId,
|
5844 |
+
'simple',
|
5845 |
+
a.product_sku,
|
5846 |
+
NOW(),
|
5847 |
+
0,
|
5848 |
+
a.store_product_id,
|
5849 |
+
a.sinch_product_id
|
5850 |
+
FROM $products_temp a
|
5851 |
+
LEFT JOIN $stINch_products_mapping pm
|
5852 |
+
ON a.store_product_id = pm.store_product_id
|
5853 |
+
AND a.sinch_product_id = pm.sinch_product_id
|
5854 |
+
WHERE pm.entity_id IS NULL
|
5855 |
+
)
|
5856 |
+
ON DUPLICATE KEY UPDATE
|
5857 |
+
sku = a.product_sku,
|
5858 |
+
store_product_id = a.store_product_id,
|
5859 |
+
sinch_product_id = a.sinch_product_id");
|
5860 |
+
// store_product_id = a.store_product_id,
|
5861 |
+
// sinch_product_id = a.sinch_product_id
|
5862 |
+
|
5863 |
+
$result = $this->db_do("
|
5864 |
+
INSERT INTO $catalog_product_entity
|
5865 |
+
(entity_id, entity_type_id, attribute_set_id, type_id, sku, updated_at, has_options, store_product_id, sinch_product_id)
|
5866 |
+
(SELECT
|
5867 |
+
pm.entity_id,
|
5868 |
+
$_getProductEntityTypeId,
|
5869 |
+
$_defaultAttributeSetId,
|
5870 |
+
'simple',
|
5871 |
+
a.product_sku,
|
5872 |
+
NOW(),
|
5873 |
+
0,
|
5874 |
+
a.store_product_id,
|
5875 |
+
a.sinch_product_id
|
5876 |
+
FROM $products_temp a
|
5877 |
+
LEFT JOIN $stINch_products_mapping pm
|
5878 |
+
ON a.store_product_id = pm.store_product_id
|
5879 |
+
AND a.sinch_product_id = pm.sinch_product_id
|
5880 |
+
WHERE pm.entity_id IS NOT NULL
|
5881 |
+
)
|
5882 |
+
ON DUPLICATE KEY UPDATE
|
5883 |
+
sku = a.product_sku,
|
5884 |
+
store_product_id = a.store_product_id,
|
5885 |
+
sinch_product_id = a.sinch_product_id");
|
5886 |
+
// store_product_id = a.store_product_id,
|
5887 |
+
// sinch_product_id = a.sinch_product_id
|
5888 |
+
|
5889 |
+
echo("\n replaceMagentoProductsMultistore 4\n");
|
5890 |
+
|
5891 |
+
//Set enabled
|
5892 |
+
$result = $this->db_do("
|
5893 |
+
DELETE cpei
|
5894 |
+
FROM $catalog_product_entity_int cpei
|
5895 |
+
LEFT JOIN $catalog_product_entity cpe
|
5896 |
+
ON cpei.entity_id = cpe.entity_id
|
5897 |
+
WHERE cpe.entity_id IS NULL");
|
5898 |
+
|
5899 |
+
$result = $this->db_do("
|
5900 |
+
INSERT INTO $catalog_product_entity_int
|
5901 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
5902 |
+
(SELECT
|
5903 |
+
$_getProductEntityTypeId,
|
5904 |
+
$attr_atatus,
|
5905 |
+
w.website,
|
5906 |
+
a.entity_id,
|
5907 |
+
1
|
5908 |
+
FROM $catalog_product_entity a
|
5909 |
+
JOIN $products_website_temp w
|
5910 |
+
ON a.store_product_id = w.store_product_id
|
5911 |
+
)
|
5912 |
+
ON DUPLICATE KEY UPDATE
|
5913 |
+
value = 1");
|
5914 |
+
|
5915 |
+
echo("\n replaceMagentoProductsMultistore 5\n");
|
5916 |
+
|
5917 |
+
// set status = 1 for all stores
|
5918 |
+
$result = $this->db_do("
|
5919 |
+
INSERT INTO $catalog_product_entity_int
|
5920 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
5921 |
+
(SELECT
|
5922 |
+
$_getProductEntityTypeId,
|
5923 |
+
$attr_atatus,
|
5924 |
+
0,
|
5925 |
+
a.entity_id,
|
5926 |
+
1
|
5927 |
+
FROM $catalog_product_entity a
|
5928 |
+
)
|
5929 |
+
ON DUPLICATE KEY UPDATE
|
5930 |
+
value = 1");
|
5931 |
+
|
5932 |
+
echo("\n replaceMagentoProductsMultistore 6\n");
|
5933 |
+
|
5934 |
+
//Unifying products with categories.
|
5935 |
+
$result = $this->db_do("
|
5936 |
+
DELETE ccp
|
5937 |
+
FROM $catalog_category_product ccp
|
5938 |
+
LEFT JOIN $catalog_product_entity cpe
|
5939 |
+
ON ccp.product_id = cpe.entity_id
|
5940 |
+
WHERE cpe.entity_id IS NULL");
|
5941 |
+
|
5942 |
+
echo("\n replaceMagentoProductsMultistore 7\n");
|
5943 |
+
|
5944 |
+
$root_cats = Mage::getSingleton('core/resource')->getTableName('root_cats');
|
5945 |
+
|
5946 |
+
$result = $this->db_do("DROP TABLE IF EXISTS $root_cats");
|
5947 |
+
$result = $this->db_do("
|
5948 |
+
CREATE TABLE $root_cats
|
5949 |
+
SELECT
|
5950 |
+
entity_id,
|
5951 |
+
path,
|
5952 |
+
SUBSTRING(path, LOCATE('/', path)+1) AS short_path,
|
5953 |
+
LOCATE('/', SUBSTRING(path, LOCATE('/', path)+1)) AS end_pos,
|
5954 |
+
SUBSTRING(SUBSTRING(path, LOCATE('/', path)+1), 1, LOCATE('/', SUBSTRING(path, LOCATE('/', path)+1))-1) as root_cat
|
5955 |
+
FROM $catalog_category_entity
|
5956 |
+
");
|
5957 |
+
$result = $this->db_do("UPDATE $root_cats SET root_cat = entity_id WHERE CHAR_LENGTH(root_cat) = 0");
|
5958 |
+
|
5959 |
+
echo("\n replaceMagentoProductsMultistore 8\n");
|
5960 |
+
|
5961 |
+
$result = $this->db_do("
|
5962 |
+
UPDATE IGNORE $catalog_category_product ccp
|
5963 |
+
LEFT JOIN $catalog_category_entity cce
|
5964 |
+
ON ccp.category_id = cce.entity_id
|
5965 |
+
JOIN $root_cats rc
|
5966 |
+
ON cce.entity_id = rc.entity_id
|
5967 |
+
SET ccp.category_id = rc.root_cat
|
5968 |
+
WHERE cce.entity_id IS NULL");
|
5969 |
+
|
5970 |
+
|
5971 |
+
echo("\n replaceMagentoProductsMultistore 9\n");
|
5972 |
+
|
5973 |
+
|
5974 |
+
$result = $this->db_do("
|
5975 |
+
DELETE ccp
|
5976 |
+
FROM $catalog_category_product ccp
|
5977 |
+
LEFT JOIN $catalog_category_entity cce
|
5978 |
+
ON ccp.category_id = cce.entity_id
|
5979 |
+
WHERE cce.entity_id IS NULL");
|
5980 |
+
|
5981 |
+
echo("\n replaceMagentoProductsMultistore 10\n");
|
5982 |
+
|
5983 |
+
$catalog_category_product_for_delete_temp = $catalog_category_product . "_for_delete_temp";
|
5984 |
+
|
5985 |
+
// TEMPORARY
|
5986 |
+
$this->db_do(" DROP TABLE IF EXISTS $catalog_category_product_for_delete_temp");
|
5987 |
+
$this->db_do("
|
5988 |
+
CREATE TABLE $catalog_category_product_for_delete_temp
|
5989 |
+
(
|
5990 |
+
`category_id` int(10) unsigned NOT NULL default '0',
|
5991 |
+
`product_id` int(10) unsigned NOT NULL default '0',
|
5992 |
+
`store_product_id` int(10) NOT NULL default '0',
|
5993 |
+
`store_category_id` int(10) NOT NULL default '0',
|
5994 |
+
`new_category_id` int(10) NOT NULL default '0',
|
5995 |
+
|
5996 |
+
UNIQUE KEY `UNQ_CATEGORY_PRODUCT` (`category_id`,`product_id`),
|
5997 |
+
KEY `CATALOG_CATEGORY_PRODUCT_CATEGORY` (`category_id`),
|
5998 |
+
KEY `CATALOG_CATEGORY_PRODUCT_PRODUCT` (`product_id`),
|
5999 |
+
KEY `CATALOG_NEW_CATEGORY_PRODUCT_CATEGORY` (`new_category_id`)
|
6000 |
+
)");
|
6001 |
+
|
6002 |
+
echo("\n replaceMagentoProductsMultistore 11\n");
|
6003 |
+
|
6004 |
+
$result = $this->db_do("
|
6005 |
+
INSERT INTO $catalog_category_product_for_delete_temp
|
6006 |
+
(category_id, product_id, store_product_id)
|
6007 |
+
(SELECT
|
6008 |
+
ccp.category_id,
|
6009 |
+
ccp.product_id,
|
6010 |
+
cpe.store_product_id
|
6011 |
+
FROM $catalog_category_product ccp
|
6012 |
+
JOIN $catalog_product_entity cpe
|
6013 |
+
ON ccp.product_id = cpe.entity_id
|
6014 |
+
WHERE store_product_id IS NOT NULL)");
|
6015 |
+
|
6016 |
+
echo("\n replaceMagentoProductsMultistore 12\n");
|
6017 |
+
|
6018 |
+
$result = $this->db_do("
|
6019 |
+
UPDATE $catalog_category_product_for_delete_temp ccpfd
|
6020 |
+
JOIN $products_temp p
|
6021 |
+
ON ccpfd.store_product_id = p.store_product_id
|
6022 |
+
SET ccpfd.store_category_id = p.store_category_id
|
6023 |
+
WHERE ccpfd.store_product_id != 0");
|
6024 |
+
|
6025 |
+
echo("\n replaceMagentoProductsMultistore 13\n");
|
6026 |
+
|
6027 |
+
$result = $this->db_do("
|
6028 |
+
UPDATE $catalog_category_product_for_delete_temp ccpfd
|
6029 |
+
JOIN $stINch_categories_mapping scm
|
6030 |
+
ON ccpfd.store_category_id = scm.store_category_id
|
6031 |
+
SET ccpfd.new_category_id = scm.shop_entity_id
|
6032 |
+
WHERE ccpfd.store_category_id != 0");
|
6033 |
+
|
6034 |
+
echo("\n replaceMagentoProductsMultistore 14\n");
|
6035 |
+
|
6036 |
+
$result = $this->db_do("DELETE FROM $catalog_category_product_for_delete_temp WHERE category_id = new_category_id");
|
6037 |
+
|
6038 |
+
|
6039 |
+
$result = $this->db_do("
|
6040 |
+
DELETE ccp
|
6041 |
+
FROM $catalog_category_product ccp
|
6042 |
+
JOIN $catalog_category_product_for_delete_temp ccpfd
|
6043 |
+
ON ccp.product_id = ccpfd.product_id
|
6044 |
+
AND ccp.category_id = ccpfd.category_id");
|
6045 |
+
|
6046 |
+
echo("\n replaceMagentoProductsMultistore 15\n");
|
6047 |
+
|
6048 |
+
$result = $this->db_do("
|
6049 |
+
INSERT INTO $catalog_category_product
|
6050 |
+
(category_id, product_id)
|
6051 |
+
(SELECT
|
6052 |
+
scm.shop_entity_id,
|
6053 |
+
cpe.entity_id
|
6054 |
+
FROM $catalog_product_entity cpe
|
6055 |
+
JOIN $products_temp p
|
6056 |
+
ON cpe.store_product_id = p.store_product_id
|
6057 |
+
JOIN $stINch_categories_mapping scm
|
6058 |
+
ON p.store_category_id = scm.store_category_id
|
6059 |
+
)
|
6060 |
+
ON DUPLICATE KEY UPDATE
|
6061 |
+
product_id = cpe.entity_id");
|
6062 |
+
|
6063 |
+
|
6064 |
+
echo("\n replaceMagentoProductsMultistore 15.1 (add multi categories)\n");
|
6065 |
+
|
6066 |
+
$result = $this->db_do("
|
6067 |
+
INSERT INTO $catalog_category_product
|
6068 |
+
(category_id, product_id)
|
6069 |
+
(SELECT
|
6070 |
+
scm.shop_entity_id,
|
6071 |
+
cpe.entity_id
|
6072 |
+
FROM $catalog_product_entity cpe
|
6073 |
+
JOIN $products_temp p
|
6074 |
+
ON cpe.store_product_id = p.store_product_id
|
6075 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_product_categories') . " spc
|
6076 |
+
ON p.store_product_id=spc.store_product_id
|
6077 |
+
JOIN $stINch_categories_mapping scm
|
6078 |
+
ON spc.store_category_id = scm.store_category_id
|
6079 |
+
)
|
6080 |
+
ON DUPLICATE KEY UPDATE
|
6081 |
+
product_id = cpe.entity_id
|
6082 |
+
");
|
6083 |
+
|
6084 |
+
echo("\n replaceMagentoProductsMultistore 16\n");
|
6085 |
+
|
6086 |
+
//Indexing products and categories in the shop
|
6087 |
+
$result = $this->db_do("
|
6088 |
+
DELETE ccpi
|
6089 |
+
FROM $catalog_category_product_index ccpi
|
6090 |
+
LEFT JOIN $catalog_product_entity cpe
|
6091 |
+
ON ccpi.product_id = cpe.entity_id
|
6092 |
+
WHERE cpe.entity_id IS NULL");
|
6093 |
+
|
6094 |
+
echo("\n replaceMagentoProductsMultistore 16.2\n");
|
6095 |
+
|
6096 |
+
$result = $this->db_do("
|
6097 |
+
INSERT INTO $catalog_category_product_index
|
6098 |
+
(category_id, product_id, position, is_parent, store_id, visibility)
|
6099 |
+
(SELECT
|
6100 |
+
a.category_id,
|
6101 |
+
a.product_id,
|
6102 |
+
a.position,
|
6103 |
+
1,
|
6104 |
+
b.store_id,
|
6105 |
+
4
|
6106 |
+
FROM $catalog_category_product a
|
6107 |
+
JOIN $core_store b
|
6108 |
+
)
|
6109 |
+
ON DUPLICATE KEY UPDATE
|
6110 |
+
visibility = 4");
|
6111 |
+
|
6112 |
+
echo("\n replaceMagentoProductsMultistore 17\n");
|
6113 |
+
|
6114 |
+
$result = $this->db_do("
|
6115 |
+
INSERT ignore INTO $catalog_category_product_index
|
6116 |
+
(category_id, product_id, position, is_parent, store_id, visibility)
|
6117 |
+
(SELECT
|
6118 |
+
rc.root_cat,
|
6119 |
+
a.product_id,
|
6120 |
+
a.position,
|
6121 |
+
1,
|
6122 |
+
b.store_id,
|
6123 |
+
4
|
6124 |
+
FROM $catalog_category_product a
|
6125 |
+
JOIN $root_cats rc
|
6126 |
+
ON a.category_id = rc.entity_id
|
6127 |
+
JOIN $core_store b
|
6128 |
+
)
|
6129 |
+
ON DUPLICATE KEY UPDATE
|
6130 |
+
visibility = 4");
|
6131 |
+
|
6132 |
+
echo("\n replaceMagentoProductsMultistore 18\n");
|
6133 |
+
|
6134 |
+
//Set product name for specific web sites
|
6135 |
+
$result = $this->db_do("
|
6136 |
+
DELETE cpev
|
6137 |
+
FROM $catalog_product_entity_varchar cpev
|
6138 |
+
LEFT JOIN $catalog_product_entity cpe
|
6139 |
+
ON cpev.entity_id = cpe.entity_id
|
6140 |
+
WHERE cpe.entity_id IS NULL");
|
6141 |
+
|
6142 |
+
$result = $this->db_do("
|
6143 |
+
INSERT INTO $catalog_product_entity_varchar
|
6144 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6145 |
+
(SELECT
|
6146 |
+
$_getProductEntityTypeId,
|
6147 |
+
$attr_name,
|
6148 |
+
w.website,
|
6149 |
+
a.entity_id,
|
6150 |
+
b.product_name
|
6151 |
+
FROM $catalog_product_entity a
|
6152 |
+
JOIN $products_temp b
|
6153 |
+
ON a.store_product_id = b.store_product_id
|
6154 |
+
JOIN $products_website_temp w
|
6155 |
+
ON a.store_product_id = w.store_product_id
|
6156 |
+
)
|
6157 |
+
ON DUPLICATE KEY UPDATE
|
6158 |
+
value = b.product_name");
|
6159 |
+
|
6160 |
+
echo("\n replaceMagentoProductsMultistore 19\n");
|
6161 |
+
|
6162 |
+
// product name for all web sites
|
6163 |
+
$result = $this->db_do("
|
6164 |
+
INSERT INTO $catalog_product_entity_varchar
|
6165 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6166 |
+
(SELECT
|
6167 |
+
$_getProductEntityTypeId,
|
6168 |
+
$attr_name,
|
6169 |
+
0,
|
6170 |
+
a.entity_id,
|
6171 |
+
b.product_name
|
6172 |
+
FROM $catalog_product_entity a
|
6173 |
+
JOIN $products_temp b
|
6174 |
+
ON a.store_product_id = b.store_product_id
|
6175 |
+
)
|
6176 |
+
ON DUPLICATE KEY UPDATE
|
6177 |
+
value = b.product_name");
|
6178 |
+
|
6179 |
+
echo("\n replaceMagentoProductsMultistore 20\n");
|
6180 |
+
|
6181 |
+
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
6182 |
+
$this->addDescriptions();
|
6183 |
+
$this->cleanProductDistributors();
|
6184 |
+
if ($this->product_file_format == "NEW") {
|
6185 |
+
$this->addReviews();
|
6186 |
+
$this->addWeight();
|
6187 |
+
$this->addSearchCache();
|
6188 |
+
$this->addPdfUrl();
|
6189 |
+
$this->addShortDescriptions();
|
6190 |
+
$this->addProductDistributors();
|
6191 |
+
}
|
6192 |
+
$this->addEAN();
|
6193 |
+
$this->addSpecification();
|
6194 |
+
$this->addManufacturers();
|
6195 |
+
|
6196 |
+
echo("\n replaceMagentoProductsMultistore 21\n");
|
6197 |
+
|
6198 |
+
//Enabling product index.
|
6199 |
+
$result = $this->db_do("
|
6200 |
+
DELETE cpei
|
6201 |
+
FROM $catalog_product_enabled_index cpei
|
6202 |
+
LEFT JOIN $catalog_product_entity cpe
|
6203 |
+
ON cpei.product_id = cpe.entity_id
|
6204 |
+
WHERE cpe.entity_id IS NULL");
|
6205 |
+
|
6206 |
+
echo("\n replaceMagentoProductsMultistore 22\n");
|
6207 |
+
|
6208 |
+
$result = $this->db_do("
|
6209 |
+
INSERT INTO $catalog_product_enabled_index
|
6210 |
+
(product_id, store_id, visibility)
|
6211 |
+
(SELECT
|
6212 |
+
a.entity_id,
|
6213 |
+
w.website,
|
6214 |
+
4
|
6215 |
+
FROM $catalog_product_entity a
|
6216 |
+
JOIN $products_website_temp w
|
6217 |
+
ON a.store_product_id = w.store_product_id
|
6218 |
+
)
|
6219 |
+
ON DUPLICATE KEY UPDATE
|
6220 |
+
visibility = 4");
|
6221 |
+
|
6222 |
+
echo("\n replaceMagentoProductsMultistore 23\n");
|
6223 |
+
|
6224 |
+
$result = $this->db_do("
|
6225 |
+
INSERT INTO $catalog_product_enabled_index
|
6226 |
+
(product_id, store_id, visibility)
|
6227 |
+
(SELECT
|
6228 |
+
a.entity_id,
|
6229 |
+
0,
|
6230 |
+
4
|
6231 |
+
FROM $catalog_product_entity a
|
6232 |
+
JOIN $products_website_temp w
|
6233 |
+
ON a.store_product_id = w.store_product_id
|
6234 |
+
)
|
6235 |
+
ON DUPLICATE KEY UPDATE
|
6236 |
+
visibility = 4");
|
6237 |
+
|
6238 |
+
echo("\n replaceMagentoProductsMultistore 24\n");
|
6239 |
+
|
6240 |
+
$result = $this->db_do("
|
6241 |
+
INSERT INTO $catalog_product_entity_int
|
6242 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6243 |
+
(SELECT
|
6244 |
+
$_getProductEntityTypeId,
|
6245 |
+
$attr_visibility,
|
6246 |
+
w.website,
|
6247 |
+
a.entity_id,
|
6248 |
+
4
|
6249 |
+
FROM $catalog_product_entity a
|
6250 |
+
JOIN $products_website_temp w
|
6251 |
+
ON a.store_product_id = w.store_product_id
|
6252 |
+
)
|
6253 |
+
ON DUPLICATE KEY UPDATE
|
6254 |
+
value = 4");
|
6255 |
+
|
6256 |
+
echo("\n replaceMagentoProductsMultistore 25\n");
|
6257 |
+
|
6258 |
+
$result = $this->db_do("
|
6259 |
+
INSERT INTO $catalog_product_entity_int
|
6260 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6261 |
+
(SELECT
|
6262 |
+
$_getProductEntityTypeId,
|
6263 |
+
$attr_visibility,
|
6264 |
+
0,
|
6265 |
+
a.entity_id,
|
6266 |
+
4
|
6267 |
+
FROM $catalog_product_entity a
|
6268 |
+
)
|
6269 |
+
ON DUPLICATE KEY UPDATE
|
6270 |
+
value = 4");
|
6271 |
+
|
6272 |
+
echo("\n replaceMagentoProductsMultistore 26\n");
|
6273 |
+
|
6274 |
+
$result = $this->db_do("
|
6275 |
+
DELETE cpw
|
6276 |
+
FROM $catalog_product_website cpw
|
6277 |
+
LEFT JOIN $catalog_product_entity cpe
|
6278 |
+
ON cpw.product_id = cpe.entity_id
|
6279 |
+
WHERE cpe.entity_id IS NULL");
|
6280 |
+
|
6281 |
+
echo("\n replaceMagentoProductsMultistore 27\n");
|
6282 |
+
|
6283 |
+
$result = $this->db_do("
|
6284 |
+
INSERT INTO $catalog_product_website
|
6285 |
+
(product_id, website_id)
|
6286 |
+
(SELECT
|
6287 |
+
a.entity_id,
|
6288 |
+
w.website_id
|
6289 |
+
FROM $catalog_product_entity a
|
6290 |
+
JOIN $products_website_temp w
|
6291 |
+
ON a.store_product_id = w.store_product_id
|
6292 |
+
)
|
6293 |
+
ON DUPLICATE KEY UPDATE
|
6294 |
+
product_id = a.entity_id,
|
6295 |
+
website_id = w.website_id");
|
6296 |
+
|
6297 |
+
echo("\n replaceMagentoProductsMultistore 28\n");
|
6298 |
+
|
6299 |
+
//Adding tax class "Taxable Goods"
|
6300 |
+
$result = $this->db_do("
|
6301 |
+
INSERT INTO $catalog_product_entity_int
|
6302 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6303 |
+
(SELECT
|
6304 |
+
$_getProductEntityTypeId,
|
6305 |
+
$attr_tax_class_id,
|
6306 |
+
w.website,
|
6307 |
+
a.entity_id,
|
6308 |
+
2
|
6309 |
+
FROM $catalog_product_entity a
|
6310 |
+
JOIN $products_website_temp w
|
6311 |
+
ON a.store_product_id = w.store_product_id
|
6312 |
+
)
|
6313 |
+
ON DUPLICATE KEY UPDATE
|
6314 |
+
value = 2");
|
6315 |
+
|
6316 |
+
echo("\n replaceMagentoProductsMultistore 29\n");
|
6317 |
+
|
6318 |
+
$result = $this->db_do("
|
6319 |
+
INSERT INTO $catalog_product_entity_int
|
6320 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6321 |
+
(SELECT
|
6322 |
+
$_getProductEntityTypeId,
|
6323 |
+
$attr_tax_class_id,
|
6324 |
+
0,
|
6325 |
+
a.entity_id,
|
6326 |
+
2
|
6327 |
+
FROM $catalog_product_entity a
|
6328 |
+
)
|
6329 |
+
ON DUPLICATE KEY UPDATE
|
6330 |
+
value = 2");
|
6331 |
+
|
6332 |
+
echo("\n replaceMagentoProductsMultistore 30\n");
|
6333 |
+
|
6334 |
+
// Load url Image
|
6335 |
+
$result = $this->db_do("
|
6336 |
+
INSERT INTO $catalog_product_entity_varchar
|
6337 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6338 |
+
(SELECT
|
6339 |
+
$_getProductEntityTypeId,
|
6340 |
+
$attr_image,
|
6341 |
+
w.store_id,
|
6342 |
+
a.entity_id,
|
6343 |
+
b.main_image_url
|
6344 |
+
FROM $catalog_product_entity a
|
6345 |
+
JOIN $core_store w
|
6346 |
+
JOIN $products_temp b
|
6347 |
+
ON a.store_product_id = b.store_product_id
|
6348 |
+
)
|
6349 |
+
ON DUPLICATE KEY UPDATE
|
6350 |
+
value = b.main_image_url");
|
6351 |
+
|
6352 |
+
echo("\n replaceMagentoProductsMultistore 31\n");
|
6353 |
+
|
6354 |
+
// image for specific web sites
|
6355 |
+
$result = $this->db_do("
|
6356 |
+
INSERT INTO $catalog_product_entity_varchar
|
6357 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6358 |
+
(SELECT
|
6359 |
+
$_getProductEntityTypeId,
|
6360 |
+
$attr_image,
|
6361 |
+
0,
|
6362 |
+
a.entity_id,
|
6363 |
+
b.main_image_url
|
6364 |
+
FROM $catalog_product_entity a
|
6365 |
+
JOIN $products_temp b
|
6366 |
+
ON a.store_product_id = b.store_product_id
|
6367 |
+
)
|
6368 |
+
ON DUPLICATE KEY UPDATE
|
6369 |
+
value = b.main_image_url");
|
6370 |
+
|
6371 |
+
echo("\n replaceMagentoProductsMultistore 32\n");
|
6372 |
+
|
6373 |
+
// small_image for specific web sites
|
6374 |
+
$result = $this->db_do("
|
6375 |
+
INSERT INTO $catalog_product_entity_varchar
|
6376 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6377 |
+
(SELECT
|
6378 |
+
$_getProductEntityTypeId,
|
6379 |
+
$attr_small_image,
|
6380 |
+
w.store_id,
|
6381 |
+
a.entity_id,
|
6382 |
+
b.medium_image_url
|
6383 |
+
FROM $catalog_product_entity a
|
6384 |
+
JOIN $core_store w
|
6385 |
+
JOIN $products_temp b
|
6386 |
+
ON a.store_product_id = b.store_product_id
|
6387 |
+
)
|
6388 |
+
ON DUPLICATE KEY UPDATE
|
6389 |
+
value = b.medium_image_url");
|
6390 |
+
|
6391 |
+
echo("\n replaceMagentoProductsMultistore 33\n");
|
6392 |
+
|
6393 |
+
// small_image for all web sites
|
6394 |
+
$result = $this->db_do("
|
6395 |
+
INSERT INTO $catalog_product_entity_varchar
|
6396 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6397 |
+
(SELECT
|
6398 |
+
$_getProductEntityTypeId,
|
6399 |
+
$attr_small_image,
|
6400 |
+
0,
|
6401 |
+
a.entity_id,
|
6402 |
+
b.medium_image_url
|
6403 |
+
FROM $catalog_product_entity a
|
6404 |
+
JOIN $core_store w
|
6405 |
+
JOIN $products_temp b
|
6406 |
+
ON a.store_product_id = b.store_product_id
|
6407 |
+
)
|
6408 |
+
ON DUPLICATE KEY UPDATE
|
6409 |
+
value = b.medium_image_url");
|
6410 |
+
|
6411 |
+
echo("\n replaceMagentoProductsMultistore 34\n");
|
6412 |
+
|
6413 |
+
// thumbnail for specific web site
|
6414 |
+
$result = $this->db_do("
|
6415 |
+
INSERT INTO $catalog_product_entity_varchar
|
6416 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6417 |
+
(SELECT
|
6418 |
+
$_getProductEntityTypeId,
|
6419 |
+
$attr_thumbnail,
|
6420 |
+
w.store_id,
|
6421 |
+
a.entity_id,
|
6422 |
+
b.thumb_image_url
|
6423 |
+
FROM $catalog_product_entity a
|
6424 |
+
JOIN $core_store w
|
6425 |
+
JOIN $products_temp b
|
6426 |
+
ON a.store_product_id = b.store_product_id
|
6427 |
+
)
|
6428 |
+
ON DUPLICATE KEY UPDATE
|
6429 |
+
value = b.thumb_image_url");
|
6430 |
+
|
6431 |
+
echo("\n replaceMagentoProductsMultistore 35\n");
|
6432 |
+
|
6433 |
+
// thumbnail for all web sites
|
6434 |
+
$result = $this->db_do("
|
6435 |
+
INSERT INTO $catalog_product_entity_varchar
|
6436 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6437 |
+
(SELECT
|
6438 |
+
$_getProductEntityTypeId,
|
6439 |
+
$attr_thumbnail,
|
6440 |
+
0,
|
6441 |
+
a.entity_id,
|
6442 |
+
b.thumb_image_url
|
6443 |
+
FROM $catalog_product_entity a
|
6444 |
+
JOIN $core_store w
|
6445 |
+
JOIN $products_temp b
|
6446 |
+
ON a.store_product_id = b.store_product_id
|
6447 |
+
)
|
6448 |
+
ON DUPLICATE KEY UPDATE
|
6449 |
+
value = b.thumb_image_url");
|
6450 |
+
|
6451 |
+
echo("\n replaceMagentoProductsMultistore 36\n");
|
6452 |
+
|
6453 |
+
/*STP DELETE
|
6454 |
+
//Refresh fulltext search
|
6455 |
+
$result = $this->db_do("DROP TABLE IF EXISTS {$catalogsearch_fulltext}_tmp");
|
6456 |
+
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS {$catalogsearch_fulltext}_tmp LIKE $catalogsearch_fulltext");
|
6457 |
+
|
6458 |
+
|
6459 |
+
echo("\n replaceMagentoProductsMultistore 36.2\n");
|
6460 |
+
$q = "
|
6461 |
+
INSERT INTO {$catalogsearch_fulltext}_tmp
|
6462 |
+
(product_id, store_id, data_index)
|
6463 |
+
(SELECT
|
6464 |
+
a.entity_id,
|
6465 |
+
w.website,
|
6466 |
+
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
6467 |
+
FROM $catalog_product_entity a
|
6468 |
+
JOIN $products_website_temp w
|
6469 |
+
ON a.store_product_id = w.store_product_id
|
6470 |
+
LEFT JOIN $catalog_category_product b
|
6471 |
+
ON a.entity_id = b.product_id
|
6472 |
+
LEFT JOIN $catalog_category_entity_varchar c
|
6473 |
+
ON b.category_id = c.entity_id
|
6474 |
+
AND c.attribute_id = $cat_attr_name
|
6475 |
+
LEFT JOIN $catalog_product_entity_varchar e
|
6476 |
+
ON a.entity_id = e.entity_id
|
6477 |
+
AND e.attribute_id = $attr_name
|
6478 |
+
LEFT JOIN $catalog_product_website j
|
6479 |
+
ON a.entity_id = j.product_id
|
6480 |
+
LEFT JOIN $products_temp f
|
6481 |
+
ON a.store_product_id = f.store_product_id
|
6482 |
+
)
|
6483 |
+
ON DUPLICATE KEY UPDATE
|
6484 |
+
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)";
|
6485 |
+
echo("\n\n============================\n$q\n============================\n\n");
|
6486 |
+
|
6487 |
+
|
6488 |
+
$result = $this->db_do("
|
6489 |
+
INSERT INTO {$catalogsearch_fulltext}_tmp
|
6490 |
+
(product_id, store_id, data_index)
|
6491 |
+
(SELECT
|
6492 |
+
a.entity_id,
|
6493 |
+
w.website,
|
6494 |
+
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
6495 |
+
FROM $catalog_product_entity a
|
6496 |
+
JOIN $products_website_temp w
|
6497 |
+
ON a.store_product_id = w.store_product_id
|
6498 |
+
LEFT JOIN $catalog_category_product b
|
6499 |
+
ON a.entity_id = b.product_id
|
6500 |
+
LEFT JOIN $catalog_category_entity_varchar c
|
6501 |
+
ON b.category_id = c.entity_id
|
6502 |
+
AND c.attribute_id = $cat_attr_name
|
6503 |
+
LEFT JOIN $catalog_product_entity_varchar e
|
6504 |
+
ON a.entity_id = e.entity_id
|
6505 |
+
AND e.attribute_id = $attr_name
|
6506 |
+
LEFT JOIN $catalog_product_website j
|
6507 |
+
ON a.entity_id = j.product_id
|
6508 |
+
LEFT JOIN $products_temp f
|
6509 |
+
ON a.store_product_id = f.store_product_id
|
6510 |
+
)
|
6511 |
+
ON DUPLICATE KEY UPDATE
|
6512 |
+
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
6513 |
+
|
6514 |
+
echo("\n replaceMagentoProductsMultistore 37\n");
|
6515 |
+
|
6516 |
+
|
6517 |
+
$result = $this->db_do("
|
6518 |
+
INSERT INTO {$catalogsearch_fulltext}_tmp
|
6519 |
+
(product_id, store_id, data_index)
|
6520 |
+
(SELECT
|
6521 |
+
a.entity_id,
|
6522 |
+
w.website,
|
6523 |
+
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
6524 |
+
FROM $catalog_product_entity a
|
6525 |
+
JOIN $products_website_temp w
|
6526 |
+
ON a.store_product_id = w.store_product_id
|
6527 |
+
LEFT JOIN $catalog_category_product b
|
6528 |
+
ON a.entity_id = b.product_id
|
6529 |
+
LEFT JOIN $catalog_category_entity_varchar c
|
6530 |
+
ON b.category_id = c.entity_id
|
6531 |
+
AND c.attribute_id = $cat_attr_name
|
6532 |
+
LEFT JOIN $catalog_product_entity_varchar e
|
6533 |
+
ON a.entity_id = e.entity_id
|
6534 |
+
AND e.attribute_id = $attr_name
|
6535 |
+
LEFT JOIN $products_temp f
|
6536 |
+
ON a.store_product_id = f.store_product_id
|
6537 |
+
)
|
6538 |
+
ON DUPLICATE KEY UPDATE
|
6539 |
+
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
6540 |
+
|
6541 |
+
echo("\n replaceMagentoProductsMultistore 38\n");
|
6542 |
+
|
6543 |
+
$result = $this->db_do("
|
6544 |
+
DELETE cf
|
6545 |
+
FROM $catalogsearch_fulltext cf
|
6546 |
+
LEFT JOIN $catalog_product_entity cpe
|
6547 |
+
ON cf.product_id = cpe.entity_id
|
6548 |
+
WHERE cpe.entity_id IS NULL");
|
6549 |
+
|
6550 |
+
echo("\n replaceMagentoProductsMultistore 39\n");
|
6551 |
+
|
6552 |
+
$result = $this->db_do("
|
6553 |
+
INSERT INTO $catalogsearch_fulltext
|
6554 |
+
(product_id, store_id, data_index)
|
6555 |
+
(SELECT
|
6556 |
+
a.product_id,
|
6557 |
+
a.store_id,
|
6558 |
+
a.data_index
|
6559 |
+
FROM {$catalogsearch_fulltext}_tmp a
|
6560 |
+
)
|
6561 |
+
ON DUPLICATE KEY UPDATE
|
6562 |
+
data_index = a.data_index");
|
6563 |
+
|
6564 |
+
echo("\n replaceMagentoProductsMultistore 40\n");
|
6565 |
+
|
6566 |
+
$this->db_do("UPDATE $catalogsearch_query SET is_processed = 0");
|
6567 |
+
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
6568 |
+
//TODO add something else
|
6569 |
+
STP DELETE*/
|
6570 |
+
|
6571 |
+
$this->addRelatedProducts();
|
6572 |
+
echo("\n replaceMagentoProductsMultistore 41\n");
|
6573 |
+
}
|
6574 |
+
|
6575 |
+
|
6576 |
+
public function replaceMagentoProductsMultistoreMERGE($coincidence)
|
6577 |
+
{
|
6578 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 1\n");
|
6579 |
+
|
6580 |
+
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
6581 |
+
|
6582 |
+
$products_temp = Mage::getSingleton('core/resource')->getTableName('products_temp');
|
6583 |
+
$products_website_temp = Mage::getSingleton('core/resource')->getTableName('products_website_temp');
|
6584 |
+
$catalog_product_entity = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity');
|
6585 |
+
$catalog_product_entity_int = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int');
|
6586 |
+
$catalog_product_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar');
|
6587 |
+
$catalog_category_product = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
6588 |
+
$stINch_products_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping');
|
6589 |
+
$stINch_products = Mage::getSingleton('core/resource')->getTableName('stINch_products');
|
6590 |
+
$catalog_category_entity = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity');
|
6591 |
+
$stINch_categories_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping');
|
6592 |
+
$catalog_category_product_index = Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index');
|
6593 |
+
$core_store = Mage::getSingleton('core/resource')->getTableName('core_store');
|
6594 |
+
$catalog_product_enabled_index = Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index');
|
6595 |
+
$catalog_product_website = Mage::getSingleton('core/resource')->getTableName('catalog_product_website');
|
6596 |
+
//$catalogsearch_fulltext = Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext');
|
6597 |
+
//$catalogsearch_query = Mage::getSingleton('core/resource')->getTableName('catalogsearch_query');
|
6598 |
+
$catalog_category_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar');
|
6599 |
+
|
6600 |
+
$_getProductEntityTypeId = $this->_getProductEntityTypeId();
|
6601 |
+
$_defaultAttributeSetId = $this->_getProductDefaulAttributeSetId();
|
6602 |
+
|
6603 |
+
$attr_atatus = $this->_getProductAttributeId('status');
|
6604 |
+
$attr_name = $this->_getProductAttributeId('name');
|
6605 |
+
$attr_visibility = $this->_getProductAttributeId('visibility');
|
6606 |
+
$attr_tax_class_id = $this->_getProductAttributeId('tax_class_id');
|
6607 |
+
$attr_image = $this->_getProductAttributeId('image');
|
6608 |
+
$attr_small_image = $this->_getProductAttributeId('small_image');
|
6609 |
+
$attr_thumbnail = $this->_getProductAttributeId('thumbnail');
|
6610 |
+
|
6611 |
+
$cat_attr_name = $this->_getCategoryAttributeId('name');
|
6612 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 2\n");
|
6613 |
+
|
6614 |
+
//clear products, inserting new products and updating old others.
|
6615 |
+
$query = "
|
6616 |
+
DELETE cpe
|
6617 |
+
FROM $catalog_product_entity cpe
|
6618 |
+
JOIN $stINch_products_mapping pm
|
6619 |
+
ON cpe.entity_id = pm.entity_id
|
6620 |
+
WHERE pm.shop_store_product_id IS NOT NULL
|
6621 |
+
AND pm.store_product_id IS NULL";
|
6622 |
+
$result = $this->db_do($query);
|
6623 |
+
|
6624 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 3\n");
|
6625 |
+
|
6626 |
+
$result = $this->db_do("
|
6627 |
+
INSERT INTO $catalog_product_entity
|
6628 |
+
(entity_id, entity_type_id, attribute_set_id, type_id, sku, updated_at, has_options, store_product_id, sinch_product_id)
|
6629 |
+
(SELECT
|
6630 |
+
pm.entity_id,
|
6631 |
+
$_getProductEntityTypeId,
|
6632 |
+
$_defaultAttributeSetId,
|
6633 |
+
'simple',
|
6634 |
+
a.product_sku,
|
6635 |
+
NOW(),
|
6636 |
+
0,
|
6637 |
+
a.store_product_id,
|
6638 |
+
a.sinch_product_id
|
6639 |
+
FROM $products_temp a
|
6640 |
+
LEFT JOIN $stINch_products_mapping pm
|
6641 |
+
ON a.store_product_id = pm.store_product_id
|
6642 |
+
AND a.sinch_product_id = pm.sinch_product_id
|
6643 |
+
WHERE pm.entity_id IS NOT NULL
|
6644 |
+
)
|
6645 |
+
ON DUPLICATE KEY UPDATE
|
6646 |
+
sku = a.product_sku,
|
6647 |
+
store_product_id = a.store_product_id,
|
6648 |
+
sinch_product_id = a.sinch_product_id");
|
6649 |
+
// store_product_id = a.store_product_id,
|
6650 |
+
// sinch_product_id = a.sinch_product_id
|
6651 |
+
|
6652 |
+
$result = $this->db_do("
|
6653 |
+
INSERT INTO $catalog_product_entity
|
6654 |
+
(entity_id, entity_type_id, attribute_set_id, type_id, sku, updated_at, has_options, store_product_id, sinch_product_id)
|
6655 |
+
(SELECT
|
6656 |
+
pm.entity_id,
|
6657 |
+
$_getProductEntityTypeId,
|
6658 |
+
$_defaultAttributeSetId,
|
6659 |
+
'simple',
|
6660 |
+
a.product_sku,
|
6661 |
+
NOW(),
|
6662 |
+
0,
|
6663 |
+
a.store_product_id,
|
6664 |
+
a.sinch_product_id
|
6665 |
+
FROM $products_temp a
|
6666 |
+
LEFT JOIN $stINch_products_mapping pm
|
6667 |
+
ON a.store_product_id = pm.store_product_id
|
6668 |
+
AND a.sinch_product_id = pm.sinch_product_id
|
6669 |
+
WHERE pm.entity_id IS NULL
|
6670 |
+
)
|
6671 |
+
ON DUPLICATE KEY UPDATE
|
6672 |
+
sku = a.product_sku,
|
6673 |
+
store_product_id = a.store_product_id,
|
6674 |
+
sinch_product_id = a.sinch_product_id");
|
6675 |
+
// store_product_id = a.store_product_id,
|
6676 |
+
// sinch_product_id = a.sinch_product_id
|
6677 |
+
|
6678 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 4\n");
|
6679 |
+
|
6680 |
+
//Set enabled
|
6681 |
+
$result = $this->db_do("
|
6682 |
+
DELETE cpei
|
6683 |
+
FROM $catalog_product_entity_int cpei
|
6684 |
+
LEFT JOIN $catalog_product_entity cpe
|
6685 |
+
ON cpei.entity_id = cpe.entity_id
|
6686 |
+
WHERE cpe.entity_id IS NULL");
|
6687 |
+
|
6688 |
+
$result = $this->db_do("
|
6689 |
+
INSERT INTO $catalog_product_entity_int
|
6690 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6691 |
+
(SELECT
|
6692 |
+
$_getProductEntityTypeId,
|
6693 |
+
$attr_atatus,
|
6694 |
+
w.website,
|
6695 |
+
a.entity_id,
|
6696 |
+
1
|
6697 |
+
FROM $catalog_product_entity a
|
6698 |
+
JOIN $products_website_temp w
|
6699 |
+
ON a.store_product_id = w.store_product_id
|
6700 |
+
)
|
6701 |
+
ON DUPLICATE KEY UPDATE
|
6702 |
+
value = 1");
|
6703 |
+
|
6704 |
+
|
6705 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 5\n");
|
6706 |
+
|
6707 |
+
|
6708 |
+
// set status = 1 for all stores
|
6709 |
+
$result = $this->db_do("
|
6710 |
+
INSERT INTO $catalog_product_entity_int
|
6711 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6712 |
+
(SELECT
|
6713 |
+
$_getProductEntityTypeId,
|
6714 |
+
$attr_atatus,
|
6715 |
+
0,
|
6716 |
+
a.entity_id,
|
6717 |
+
1
|
6718 |
+
FROM $catalog_product_entity a
|
6719 |
+
)
|
6720 |
+
ON DUPLICATE KEY UPDATE
|
6721 |
+
value = 1");
|
6722 |
+
|
6723 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 6\n");
|
6724 |
+
|
6725 |
+
//Unifying products with categories.
|
6726 |
+
$result = $this->db_do("
|
6727 |
+
DELETE ccp
|
6728 |
+
FROM $catalog_category_product ccp
|
6729 |
+
LEFT JOIN $catalog_product_entity cpe
|
6730 |
+
ON ccp.product_id = cpe.entity_id
|
6731 |
+
WHERE cpe.entity_id IS NULL");
|
6732 |
+
|
6733 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 7\n");
|
6734 |
+
|
6735 |
+
$root_cats = Mage::getSingleton('core/resource')->getTableName('root_cats');
|
6736 |
+
|
6737 |
+
$result = $this->db_do("DROP TABLE IF EXISTS $root_cats");
|
6738 |
+
$result = $this->db_do("
|
6739 |
+
CREATE TABLE $root_cats
|
6740 |
+
SELECT
|
6741 |
+
entity_id,
|
6742 |
+
path,
|
6743 |
+
SUBSTRING(path, LOCATE('/', path)+1) AS short_path,
|
6744 |
+
LOCATE('/', SUBSTRING(path, LOCATE('/', path)+1)) AS end_pos,
|
6745 |
+
SUBSTRING(SUBSTRING(path, LOCATE('/', path)+1), 1, LOCATE('/', SUBSTRING(path, LOCATE('/', path)+1))-1) as root_cat
|
6746 |
+
FROM $catalog_category_entity
|
6747 |
+
");
|
6748 |
+
$result = $this->db_do("UPDATE $root_cats SET root_cat = entity_id WHERE CHAR_LENGTH(root_cat) = 0");
|
6749 |
+
|
6750 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 8\n");
|
6751 |
+
|
6752 |
+
$result = $this->db_do("
|
6753 |
+
UPDATE IGNORE $catalog_category_product ccp
|
6754 |
+
LEFT JOIN $catalog_category_entity cce
|
6755 |
+
ON ccp.category_id = cce.entity_id
|
6756 |
+
JOIN $root_cats rc
|
6757 |
+
ON cce.entity_id = rc.entity_id
|
6758 |
+
SET ccp.category_id = rc.root_cat
|
6759 |
+
WHERE cce.entity_id IS NULL");
|
6760 |
+
|
6761 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 9\n");
|
6762 |
+
|
6763 |
+
$result = $this->db_do("
|
6764 |
+
DELETE ccp
|
6765 |
+
FROM $catalog_category_product ccp
|
6766 |
+
LEFT JOIN $catalog_category_entity cce
|
6767 |
+
ON ccp.category_id = cce.entity_id
|
6768 |
+
WHERE cce.entity_id IS NULL");
|
6769 |
+
|
6770 |
+
$stinch_products_delete = Mage::getSingleton('core/resource')->getTableName('stinch_products_delete');
|
6771 |
+
|
6772 |
+
$result = $this->db_do("DROP TABLE IF EXISTS $stinch_products_delete");
|
6773 |
+
$result = $this->db_do("
|
6774 |
+
CREATE TABLE $stinch_products_delete
|
6775 |
+
SELECT cpe.entity_id
|
6776 |
+
FROM $catalog_product_entity cpe
|
6777 |
+
WHERE cpe.entity_id NOT IN
|
6778 |
+
(
|
6779 |
+
SELECT cpe2.entity_id
|
6780 |
+
FROM $catalog_product_entity cpe2
|
6781 |
+
JOIN $stINch_products sp
|
6782 |
+
ON cpe2.sinch_product_id = sp.sinch_product_id
|
6783 |
+
)");
|
6784 |
+
|
6785 |
+
$result = $this->db_do("DELETE cpe FROM $catalog_product_entity cpe JOIN $stinch_products_delete spd USING(entity_id)");
|
6786 |
+
|
6787 |
+
$result = $this->db_do("DROP TABLE IF EXISTS $stinch_products_delete");
|
6788 |
+
|
6789 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 15\n");
|
6790 |
+
|
6791 |
+
$result = $this->db_do("
|
6792 |
+
INSERT INTO $catalog_category_product
|
6793 |
+
(category_id, product_id)
|
6794 |
+
(SELECT
|
6795 |
+
scm.shop_entity_id,
|
6796 |
+
cpe.entity_id
|
6797 |
+
FROM $catalog_product_entity cpe
|
6798 |
+
JOIN $products_temp p
|
6799 |
+
ON cpe.store_product_id = p.store_product_id
|
6800 |
+
JOIN $stINch_categories_mapping scm
|
6801 |
+
ON p.store_category_id = scm.store_category_id
|
6802 |
+
)
|
6803 |
+
ON DUPLICATE KEY UPDATE
|
6804 |
+
product_id = cpe.entity_id");
|
6805 |
+
|
6806 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 15.1 (add multi categories)\n");
|
6807 |
+
|
6808 |
+
$result = $this->db_do("
|
6809 |
+
INSERT INTO $catalog_category_product
|
6810 |
+
(category_id, product_id)
|
6811 |
+
(SELECT
|
6812 |
+
scm.shop_entity_id,
|
6813 |
+
cpe.entity_id
|
6814 |
+
FROM $catalog_product_entity cpe
|
6815 |
+
JOIN $products_temp p
|
6816 |
+
ON cpe.store_product_id = p.store_product_id
|
6817 |
+
JOIN " . Mage::getSingleton('core/resource')->getTableName('stINch_product_categories') . " spc
|
6818 |
+
ON p.store_product_id=spc.store_product_id
|
6819 |
+
JOIN $stINch_categories_mapping scm
|
6820 |
+
ON spc.store_category_id = scm.store_category_id
|
6821 |
+
)
|
6822 |
+
ON DUPLICATE KEY UPDATE
|
6823 |
+
product_id = cpe.entity_id
|
6824 |
+
");
|
6825 |
+
|
6826 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 16\n");
|
6827 |
+
|
6828 |
+
//Indexing products and categories in the shop
|
6829 |
+
$result = $this->db_do("
|
6830 |
+
DELETE ccpi
|
6831 |
+
FROM $catalog_category_product_index ccpi
|
6832 |
+
LEFT JOIN $catalog_product_entity cpe
|
6833 |
+
ON ccpi.product_id = cpe.entity_id
|
6834 |
+
WHERE cpe.entity_id IS NULL");
|
6835 |
+
|
6836 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 16.2\n");
|
6837 |
+
|
6838 |
+
$result = $this->db_do("
|
6839 |
+
INSERT INTO $catalog_category_product_index
|
6840 |
+
(category_id, product_id, position, is_parent, store_id, visibility)
|
6841 |
+
(SELECT
|
6842 |
+
a.category_id,
|
6843 |
+
a.product_id,
|
6844 |
+
a.position,
|
6845 |
+
1,
|
6846 |
+
b.store_id,
|
6847 |
+
4
|
6848 |
+
FROM $catalog_category_product a
|
6849 |
+
JOIN $core_store b
|
6850 |
+
)
|
6851 |
+
ON DUPLICATE KEY UPDATE
|
6852 |
+
visibility = 4");
|
6853 |
+
|
6854 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 17\n");
|
6855 |
+
$root_cats = Mage::getSingleton('core/resource')->getTableName('root_cats');
|
6856 |
+
// !!! $this->_root_cat
|
6857 |
+
$result = $this->db_do("
|
6858 |
+
INSERT ignore INTO $catalog_category_product_index
|
6859 |
+
(category_id, product_id, position, is_parent, store_id, visibility)
|
6860 |
+
(SELECT
|
6861 |
+
rc.root_cat,
|
6862 |
+
a.product_id,
|
6863 |
+
a.position,
|
6864 |
+
1,
|
6865 |
+
b.store_id,
|
6866 |
+
4
|
6867 |
+
FROM $catalog_category_product a
|
6868 |
+
JOIN $root_cats rc
|
6869 |
+
ON a.category_id = rc.entity_id
|
6870 |
+
JOIN $core_store b
|
6871 |
+
)
|
6872 |
+
ON DUPLICATE KEY UPDATE
|
6873 |
+
visibility = 4");
|
6874 |
+
|
6875 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 18\n");
|
6876 |
+
|
6877 |
+
//Set product name for specific web sites
|
6878 |
+
$result = $this->db_do("
|
6879 |
+
DELETE cpev
|
6880 |
+
FROM $catalog_product_entity_varchar cpev
|
6881 |
+
LEFT JOIN $catalog_product_entity cpe
|
6882 |
+
ON cpev.entity_id = cpe.entity_id
|
6883 |
+
WHERE cpe.entity_id IS NULL");
|
6884 |
+
|
6885 |
+
$result = $this->db_do("
|
6886 |
+
INSERT INTO $catalog_product_entity_varchar
|
6887 |
+
(entity_type_id, attribute_id, store_id, entity_id, value)
|
6888 |
+
(SELECT
|
6889 |
+
$_getProductEntityTypeId,
|
6890 |
+
$attr_name,
|
6891 |
+
w.website,
|
6892 |
+
a.entity_id,
|
6893 |
+
b.product_name
|
6894 |
+
FROM $catalog_product_entity a
|
6895 |
+
JOIN $products_temp b
|
6896 |
+
ON a.store_product_id = b.store_product_id
|
6897 |
+
JOIN $products_website_temp w
|
6898 |
+
ON a.store_product_id = w.store_product_id
|
6899 |
+
)
|
6900 |
+
ON DUPLICATE KEY UPDATE
|
6901 |
+
value = b.product_name");
|
6902 |
+
|
6903 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 19\n");
|
6904 |
+
|
6905 |
+
// product name for all web sites
|
6906 |
+
$result = $this->db_do("
|
6907 |
+
INSERT INTO $catalog_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|