Version Notes
Version 2.0.8:
* Add Demo site to server list
Download this release
Release Info
Developer | stockinchannel |
Extension | stockinthechannel2012 |
Version | 2.0.8 |
Comparing to | |
See all releases |
Code changes from version 2.0.7 to 2.0.8
- app/code/local/Bintime/Sinchimport/Block/Adminhtml/Catalog/Product/Sinchdistributors.php +25 -25
- app/code/local/Bintime/Sinchimport/Block/Importenvironment.php +210 -210
- 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/Helper/Image.php +73 -73
- 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 +260 -260
- app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Price.php +194 -194
- app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php +384 -384
- app/code/local/Bintime/Sinchimport/Model/System/Config/ServerList.php +26 -25
- app/code/local/Bintime/Sinchimport/etc/api.xml +34 -34
- app/code/local/Bintime/Sinchimport/etc/config.xml +267 -267
- app/code/local/Bintime/Sinchimport/etc/system.xml +194 -194
- app/code/local/Bintime/Sinchimport/sinch_import_start_ajax.php +13 -13
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/filter_sinch_products_s.sql +207 -207
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-install-0.1.0.php +142 -142
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.0-0.1.1.php +67 -67
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.1-0.1.2.php +63 -63
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.2-0.1.3.php +133 -133
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.3-0.1.4.php +53 -53
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.4-0.1.5.php +33 -33
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.5-0.1.6.php +15 -15
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.6-0.1.7.php +274 -274
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.7-0.1.8.php +108 -108
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.8-0.1.9.php +16 -16
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.9-0.2.0.php +123 -123
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.0-0.2.1.php +108 -108
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.1-0.2.2.php +230 -230
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.0-3.0.1.php +307 -307
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.1-3.0.2.php +108 -108
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.2-3.0.3.php +42 -42
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.3-3.0.4.php +50 -50
- app/code/local/Bintime/Sinchimport/stock_price_sinch_import_start_ajax.php +14 -14
- package.xml +6 -6
app/code/local/Bintime/Sinchimport/Block/Adminhtml/Catalog/Product/Sinchdistributors.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
class Bintime_Sinchimport_Block_Adminhtml_Catalog_Product_Sinchdistributors extends Mage_Core_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
3 |
-
{
|
4 |
-
public function __construct(){
|
5 |
-
$this->setTemplate('sinchimport/sinchdistributors.phtml');
|
6 |
-
parent::__construct();
|
7 |
-
}
|
8 |
-
|
9 |
-
//Label to be shown in the tab
|
10 |
-
public function getTabLabel(){
|
11 |
-
return Mage::helper('core')->__('Suppliers');
|
12 |
-
}
|
13 |
-
|
14 |
-
public function getTabTitle(){
|
15 |
-
return Mage::helper('core')->__('Suppliers');
|
16 |
-
}
|
17 |
-
|
18 |
-
public function canShowTab(){
|
19 |
-
return true;
|
20 |
-
}
|
21 |
-
|
22 |
-
public function isHidden(){
|
23 |
-
return false;
|
24 |
-
}
|
25 |
-
}
|
1 |
+
<?php
|
2 |
+
class Bintime_Sinchimport_Block_Adminhtml_Catalog_Product_Sinchdistributors extends Mage_Core_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
3 |
+
{
|
4 |
+
public function __construct(){
|
5 |
+
$this->setTemplate('sinchimport/sinchdistributors.phtml');
|
6 |
+
parent::__construct();
|
7 |
+
}
|
8 |
+
|
9 |
+
//Label to be shown in the tab
|
10 |
+
public function getTabLabel(){
|
11 |
+
return Mage::helper('core')->__('Suppliers');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getTabTitle(){
|
15 |
+
return Mage::helper('core')->__('Suppliers');
|
16 |
+
}
|
17 |
+
|
18 |
+
public function canShowTab(){
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function isHidden(){
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
}
|
app/code/local/Bintime/Sinchimport/Block/Importenvironment.php
CHANGED
@@ -1,210 +1,210 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field {
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
12 |
-
$this->setElement($element);
|
13 |
-
$url = $this->getUrl('sinchimport/index');
|
14 |
-
$this->setElement($element);
|
15 |
-
|
16 |
-
$html = '';
|
17 |
-
|
18 |
-
//$html .= '<div class="comment"><H3>'.("Your Stock In The Channel Environment Check Summary" ).'</H3></div>';
|
19 |
-
|
20 |
-
//$html .= '<div class="comment"><H3>'.("In order for this extension to work, your server needs to be configured in a particular way and have sufficient memory." ).'</H3></div>';
|
21 |
-
|
22 |
-
|
23 |
-
$html .= '
|
24 |
-
<table class="history">
|
25 |
-
<thead>
|
26 |
-
<tr>
|
27 |
-
<th>Checked</th>
|
28 |
-
<th>Necessary, Error And Fix</th>
|
29 |
-
|
30 |
-
</tr>
|
31 |
-
</thead><tbody>';
|
32 |
-
// <th>Necessary</th>
|
33 |
-
// <th>Fix</th>
|
34 |
-
|
35 |
-
$errors_count = 0;
|
36 |
-
|
37 |
-
// Memory total
|
38 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkMemory();
|
39 |
-
if ($status == 'error') $errors_count++;
|
40 |
-
if ($status == 'error') {
|
41 |
-
$html .= // $caption: $value $measure
|
42 |
-
"
|
43 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
44 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
45 |
-
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
46 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
47 |
-
";
|
48 |
-
};
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
// Mysql parameter LOCAL DATA LOCAL
|
53 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkLoaddata();
|
54 |
-
if ($status == 'error') $errors_count++;
|
55 |
-
if ($status == 'error') {
|
56 |
-
$html .= // $caption: $value $measure
|
57 |
-
"
|
58 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
59 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
60 |
-
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
61 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
62 |
-
";
|
63 |
-
};
|
64 |
-
|
65 |
-
|
66 |
-
// PHP safe mode
|
67 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhpsafemode();
|
68 |
-
if ($status == 'error') $errors_count++;
|
69 |
-
if ($status == 'error') {
|
70 |
-
$html .= // $caption: $value $measure
|
71 |
-
"
|
72 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
73 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
74 |
-
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
75 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
76 |
-
";
|
77 |
-
};
|
78 |
-
|
79 |
-
|
80 |
-
// Mysql parameter wait_timeout
|
81 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkWaittimeout();
|
82 |
-
if ($status == 'error') $errors_count++;
|
83 |
-
if ($status == 'error') {
|
84 |
-
$html .= // $caption: $value $measure
|
85 |
-
"
|
86 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
87 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
88 |
-
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
89 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
90 |
-
";
|
91 |
-
};
|
92 |
-
|
93 |
-
|
94 |
-
// Mysql parameter innodb_buffer_pool_size
|
95 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkInnodbbufferpoolsize();
|
96 |
-
if ($status == 'error') $errors_count++;
|
97 |
-
if ($status == 'error') {
|
98 |
-
$html .= // $caption: $value $measure
|
99 |
-
"
|
100 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
101 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
102 |
-
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
103 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
104 |
-
";
|
105 |
-
};
|
106 |
-
|
107 |
-
|
108 |
-
// Conflict with installed module
|
109 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkConflictsWithInstalledModules();
|
110 |
-
if ($status == 'error') $errors_count++;
|
111 |
-
if ($status == 'error') {
|
112 |
-
$html .= // $caption: $value $measure
|
113 |
-
"
|
114 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
115 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
116 |
-
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
117 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
118 |
-
";
|
119 |
-
};
|
120 |
-
|
121 |
-
|
122 |
-
// PHP run string
|
123 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhprunstring();
|
124 |
-
if ($status == 'error') $errors_count++;
|
125 |
-
if ($status == 'error') {
|
126 |
-
$html .= // $caption: $value $measure
|
127 |
-
"
|
128 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
129 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
130 |
-
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
131 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
132 |
-
";
|
133 |
-
};
|
134 |
-
|
135 |
-
|
136 |
-
// Chmod wget file
|
137 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetdatafile();
|
138 |
-
if ($status == 'error') $errors_count++;
|
139 |
-
if ($status == 'error') {
|
140 |
-
$html .= // $caption: $value $measure
|
141 |
-
"
|
142 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
143 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
144 |
-
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
145 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
146 |
-
";
|
147 |
-
};
|
148 |
-
|
149 |
-
|
150 |
-
// Chmod wget cron.php file
|
151 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronphpfile();
|
152 |
-
if ($status == 'error') $errors_count++;
|
153 |
-
if ($status == 'error') {
|
154 |
-
$html .= // $caption: $value $measure
|
155 |
-
"
|
156 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
157 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
158 |
-
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
159 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
160 |
-
";
|
161 |
-
};
|
162 |
-
|
163 |
-
// Chmod wget cron.sh file
|
164 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronshfile();
|
165 |
-
if ($status == 'error') $errors_count++;
|
166 |
-
if ($status == 'error') {
|
167 |
-
$html .= // $caption: $value $measure
|
168 |
-
"
|
169 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
170 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
171 |
-
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
172 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
173 |
-
";
|
174 |
-
};
|
175 |
-
|
176 |
-
// Mysql stored procedure filter_sinch_products_s
|
177 |
-
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkProcedure();
|
178 |
-
if ($status == 'error') $errors_count++;
|
179 |
-
if ($status == 'error') {
|
180 |
-
$html .= // $caption: $value $measure
|
181 |
-
"
|
182 |
-
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
183 |
-
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
184 |
-
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
185 |
-
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
186 |
-
";
|
187 |
-
};
|
188 |
-
|
189 |
-
|
190 |
-
$html .= '
|
191 |
-
</tbody>
|
192 |
-
</table>';
|
193 |
-
|
194 |
-
$html .= '<div class="comment"><H3>'.("There are $errors_count notices." ).'</H3></div>';
|
195 |
-
|
196 |
-
// all checks
|
197 |
-
return $html;
|
198 |
-
|
199 |
-
} // protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
200 |
-
|
201 |
-
protected function _colored($str, $color){
|
202 |
-
return "<b><span style='color:{$color}'>{$str}</span></b>";
|
203 |
-
}
|
204 |
-
|
205 |
-
|
206 |
-
} // class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field {
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
12 |
+
$this->setElement($element);
|
13 |
+
$url = $this->getUrl('sinchimport/index');
|
14 |
+
$this->setElement($element);
|
15 |
+
|
16 |
+
$html = '';
|
17 |
+
|
18 |
+
//$html .= '<div class="comment"><H3>'.("Your Stock In The Channel Environment Check Summary" ).'</H3></div>';
|
19 |
+
|
20 |
+
//$html .= '<div class="comment"><H3>'.("In order for this extension to work, your server needs to be configured in a particular way and have sufficient memory." ).'</H3></div>';
|
21 |
+
|
22 |
+
|
23 |
+
$html .= '
|
24 |
+
<table class="history">
|
25 |
+
<thead>
|
26 |
+
<tr>
|
27 |
+
<th>Checked</th>
|
28 |
+
<th>Necessary, Error And Fix</th>
|
29 |
+
|
30 |
+
</tr>
|
31 |
+
</thead><tbody>';
|
32 |
+
// <th>Necessary</th>
|
33 |
+
// <th>Fix</th>
|
34 |
+
|
35 |
+
$errors_count = 0;
|
36 |
+
|
37 |
+
// Memory total
|
38 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkMemory();
|
39 |
+
if ($status == 'error') $errors_count++;
|
40 |
+
if ($status == 'error') {
|
41 |
+
$html .= // $caption: $value $measure
|
42 |
+
"
|
43 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
44 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
45 |
+
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
46 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
47 |
+
";
|
48 |
+
};
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
// Mysql parameter LOCAL DATA LOCAL
|
53 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkLoaddata();
|
54 |
+
if ($status == 'error') $errors_count++;
|
55 |
+
if ($status == 'error') {
|
56 |
+
$html .= // $caption: $value $measure
|
57 |
+
"
|
58 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
59 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
60 |
+
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
61 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
62 |
+
";
|
63 |
+
};
|
64 |
+
|
65 |
+
|
66 |
+
// PHP safe mode
|
67 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhpsafemode();
|
68 |
+
if ($status == 'error') $errors_count++;
|
69 |
+
if ($status == 'error') {
|
70 |
+
$html .= // $caption: $value $measure
|
71 |
+
"
|
72 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
73 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
74 |
+
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
75 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
76 |
+
";
|
77 |
+
};
|
78 |
+
|
79 |
+
|
80 |
+
// Mysql parameter wait_timeout
|
81 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkWaittimeout();
|
82 |
+
if ($status == 'error') $errors_count++;
|
83 |
+
if ($status == 'error') {
|
84 |
+
$html .= // $caption: $value $measure
|
85 |
+
"
|
86 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
87 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
88 |
+
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
89 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
90 |
+
";
|
91 |
+
};
|
92 |
+
|
93 |
+
|
94 |
+
// Mysql parameter innodb_buffer_pool_size
|
95 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkInnodbbufferpoolsize();
|
96 |
+
if ($status == 'error') $errors_count++;
|
97 |
+
if ($status == 'error') {
|
98 |
+
$html .= // $caption: $value $measure
|
99 |
+
"
|
100 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
101 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
102 |
+
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
103 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
104 |
+
";
|
105 |
+
};
|
106 |
+
|
107 |
+
|
108 |
+
// Conflict with installed module
|
109 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkConflictsWithInstalledModules();
|
110 |
+
if ($status == 'error') $errors_count++;
|
111 |
+
if ($status == 'error') {
|
112 |
+
$html .= // $caption: $value $measure
|
113 |
+
"
|
114 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
115 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
116 |
+
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
117 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
118 |
+
";
|
119 |
+
};
|
120 |
+
|
121 |
+
|
122 |
+
// PHP run string
|
123 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhprunstring();
|
124 |
+
if ($status == 'error') $errors_count++;
|
125 |
+
if ($status == 'error') {
|
126 |
+
$html .= // $caption: $value $measure
|
127 |
+
"
|
128 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
129 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
130 |
+
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
131 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
132 |
+
";
|
133 |
+
};
|
134 |
+
|
135 |
+
|
136 |
+
// Chmod wget file
|
137 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetdatafile();
|
138 |
+
if ($status == 'error') $errors_count++;
|
139 |
+
if ($status == 'error') {
|
140 |
+
$html .= // $caption: $value $measure
|
141 |
+
"
|
142 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
143 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
144 |
+
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
145 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
146 |
+
";
|
147 |
+
};
|
148 |
+
|
149 |
+
|
150 |
+
// Chmod wget cron.php file
|
151 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronphpfile();
|
152 |
+
if ($status == 'error') $errors_count++;
|
153 |
+
if ($status == 'error') {
|
154 |
+
$html .= // $caption: $value $measure
|
155 |
+
"
|
156 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
157 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
158 |
+
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
159 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
160 |
+
";
|
161 |
+
};
|
162 |
+
|
163 |
+
// Chmod wget cron.sh file
|
164 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronshfile();
|
165 |
+
if ($status == 'error') $errors_count++;
|
166 |
+
if ($status == 'error') {
|
167 |
+
$html .= // $caption: $value $measure
|
168 |
+
"
|
169 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
170 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
171 |
+
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
172 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
173 |
+
";
|
174 |
+
};
|
175 |
+
|
176 |
+
// Mysql stored procedure filter_sinch_products_s
|
177 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkProcedure();
|
178 |
+
if ($status == 'error') $errors_count++;
|
179 |
+
if ($status == 'error') {
|
180 |
+
$html .= // $caption: $value $measure
|
181 |
+
"
|
182 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
183 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'red')} $critical $measure </td> </tr>
|
184 |
+
<tr> <td nowrap> {$this->_colored('Error:', 'red')} $errmsg </td> </tr>
|
185 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'red')} $fixmsg </td> </tr>
|
186 |
+
";
|
187 |
+
};
|
188 |
+
|
189 |
+
|
190 |
+
$html .= '
|
191 |
+
</tbody>
|
192 |
+
</table>';
|
193 |
+
|
194 |
+
$html .= '<div class="comment"><H3>'.("There are $errors_count notices." ).'</H3></div>';
|
195 |
+
|
196 |
+
// all checks
|
197 |
+
return $html;
|
198 |
+
|
199 |
+
} // protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
200 |
+
|
201 |
+
protected function _colored($str, $color){
|
202 |
+
return "<b><span style='color:{$color}'>{$str}</span></b>";
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
} // class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field
|
207 |
+
|
208 |
+
|
209 |
+
|
210 |
+
|
app/code/local/Bintime/Sinchimport/Block/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/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/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,260 +1,260 @@
|
|
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 = $feature['limit_direction'];
|
113 |
-
|
114 |
-
$data = array();
|
115 |
-
$options = explode("\n", $feature['restricted_values']);
|
116 |
-
if ($feature['order_val'] == '2') {
|
117 |
-
$options = array_reverse($options);
|
118 |
-
}
|
119 |
-
|
120 |
-
if (count($options)) {
|
121 |
-
if ($limitDirection != self::LESS && $limitDirection != self::GREATER) {
|
122 |
-
|
123 |
-
$optionsCount = $this->_getResource()->getCount($this);
|
124 |
-
foreach ($options as $option) {
|
125 |
-
if ($pos = strpos($option, '::')) {
|
126 |
-
$value = substr($option, 0, $pos);
|
127 |
-
$presentation_value = substr($option, $pos + 2);
|
128 |
-
//var_dump($option, $value, $presentation_value); die('sadf');
|
129 |
-
}
|
130 |
-
else {
|
131 |
-
$value = $presentation_value = $option;
|
132 |
-
}
|
133 |
-
if (isset($optionsCount[$value]) && $optionsCount[$value] > 0) {
|
134 |
-
$data[] = array(
|
135 |
-
'label' => $presentation_value,
|
136 |
-
'value' => $value,
|
137 |
-
'count' => $optionsCount[$value],
|
138 |
-
);
|
139 |
-
}
|
140 |
-
}
|
141 |
-
}
|
142 |
-
else {
|
143 |
-
$oCount = count($options);
|
144 |
-
|
145 |
-
$intervals = array();
|
146 |
-
if ($feature['order_val'] == '2') {
|
147 |
-
for ($i = 0; $i < $oCount -1; $i++) {
|
148 |
-
$intervals[$i]['high'] = $options[$i];
|
149 |
-
$intervals[$i]['low'] = $options[$i +1];
|
150 |
-
}
|
151 |
-
}
|
152 |
-
else {
|
153 |
-
for ($i = 0; $i < $oCount -1; $i++) {
|
154 |
-
$intervals[$i]['low'] = $options[$i];
|
155 |
-
$intervals[$i]['high'] = $options[$i +1];
|
156 |
-
}
|
157 |
-
}
|
158 |
-
//FIXME: this is ugly
|
159 |
-
if ($feature['order_val'] == '2') {
|
160 |
-
array_push ($intervals, array(
|
161 |
-
'high' => $options[$oCount -1],
|
162 |
-
));
|
163 |
-
|
164 |
-
array_unshift($intervals, array(
|
165 |
-
'low' => $options[0],
|
166 |
-
));
|
167 |
-
}
|
168 |
-
else {
|
169 |
-
array_push ($intervals, array(
|
170 |
-
'low' => $options[$oCount -1],
|
171 |
-
));
|
172 |
-
|
173 |
-
array_unshift($intervals, array(
|
174 |
-
'high' => $options[0],
|
175 |
-
));
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
$this->setData('intervals', $intervals);
|
180 |
-
|
181 |
-
$defaultSign = $feature['default_sign'];
|
182 |
-
for($i = 0; $i < count($intervals); $i++) {
|
183 |
-
if ($feature['order_val'] == '2') {
|
184 |
-
$interval = $intervals[$i];
|
185 |
-
$label = isset($interval['high']) ? $interval['high'] . " $defaultSign" : '>';
|
186 |
-
if ($label == '>' && isset($intervals[$i + 1])) {
|
187 |
-
$pad = strlen($intervals[$i + 1]['high'] . $defaultSign) + 2;
|
188 |
-
$label = str_pad($label, $pad*2, ' ', STR_PAD_LEFT);
|
189 |
-
$label = str_replace(' ', ' ', $label);
|
190 |
-
}
|
191 |
-
$label .= isset($interval['high'], $interval['high']) ? ' - ' : ' ';
|
192 |
-
$label .= isset($interval['low']) ? $interval['low'] . " $defaultSign" : '>';
|
193 |
-
$value = isset($interval['low']) ? $interval['low'] : '-';
|
194 |
-
$value .= ',';
|
195 |
-
$value .= isset($interval['high']) ? $interval['high'] : '-';
|
196 |
-
if (isset($interval['high']) AND !isset($interval['low'])) { $value = '-,'.$interval['high'];}
|
197 |
-
if ($this->_getResource()->getIntervalsCountDescending($this, $interval) > 0){
|
198 |
-
$data[] = array(
|
199 |
-
'label' => $label,
|
200 |
-
'value' => $value,
|
201 |
-
'count' => $this->_getResource()->getIntervalsCountDescending($this, $interval),
|
202 |
-
);
|
203 |
-
|
204 |
-
}
|
205 |
-
}
|
206 |
-
else {
|
207 |
-
$interval = $intervals[$i];
|
208 |
-
$label = isset($interval['low']) ? $interval['low'] . " $defaultSign" : '<';
|
209 |
-
if ($label == '<' && isset($intervals[$i + 1])) {
|
210 |
-
$pad = strlen($intervals[$i + 1]['low'] . $defaultSign) + 2;
|
211 |
-
$label = str_pad($label, $pad*2, ' ', STR_PAD_LEFT);
|
212 |
-
$label = str_replace(' ', ' ', $label);
|
213 |
-
}
|
214 |
-
$label .= isset($interval['low'], $interval['high']) ? ' - ' : ' ';
|
215 |
-
$label .= isset($interval['high']) ? $interval['high'] . " $defaultSign" : '<';
|
216 |
-
|
217 |
-
$value = isset($interval['low']) ? $interval['low'] : '-';
|
218 |
-
$value .= ',';
|
219 |
-
$value .= isset($interval['high']) ? $interval['high'] : '-';
|
220 |
-
if ($this->_getResource()->getIntervalsCount($this, $interval) > 0){
|
221 |
-
$data[] = array(
|
222 |
-
'label' => $label,
|
223 |
-
'value' => $value,
|
224 |
-
'count' => $this->_getResource()->getIntervalsCount($this, $interval),
|
225 |
-
);
|
226 |
-
|
227 |
-
}
|
228 |
-
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
}
|
233 |
-
}
|
234 |
-
|
235 |
-
Varien_Profiler::stop(__METHOD__);
|
236 |
-
return $data;
|
237 |
-
}
|
238 |
-
|
239 |
-
public function getOrderValues($category_feature_id,$categoryId)
|
240 |
-
{
|
241 |
-
$select = "
|
242 |
-
SELECT COUNT(e.entity_id) AS count
|
243 |
-
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." AS e
|
244 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." AS cat_index
|
245 |
-
ON cat_index.product_id=e.entity_id
|
246 |
-
AND cat_index.store_id='1'
|
247 |
-
AND cat_index.visibility IN(2, 4)
|
248 |
-
AND cat_index.category_id='".$categoryId."'
|
249 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
250 |
-
ON price_index.entity_id = e.entity_id
|
251 |
-
AND price_index.website_id = '1'
|
252 |
-
AND price_index.customer_group_id = 0
|
253 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_feature_'.$feature['category_feature_id'])." AS idx_".$category_feature_id."
|
254 |
-
ON idx_".$category_feature_id.".entity_id = e.icecat_product_id;
|
255 |
-
";
|
256 |
-
|
257 |
-
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($select);
|
258 |
-
}
|
259 |
-
|
260 |
-
}
|
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 = $feature['limit_direction'];
|
113 |
+
|
114 |
+
$data = array();
|
115 |
+
$options = explode("\n", $feature['restricted_values']);
|
116 |
+
if ($feature['order_val'] == '2') {
|
117 |
+
$options = array_reverse($options);
|
118 |
+
}
|
119 |
+
|
120 |
+
if (count($options)) {
|
121 |
+
if ($limitDirection != self::LESS && $limitDirection != self::GREATER) {
|
122 |
+
|
123 |
+
$optionsCount = $this->_getResource()->getCount($this);
|
124 |
+
foreach ($options as $option) {
|
125 |
+
if ($pos = strpos($option, '::')) {
|
126 |
+
$value = substr($option, 0, $pos);
|
127 |
+
$presentation_value = substr($option, $pos + 2);
|
128 |
+
//var_dump($option, $value, $presentation_value); die('sadf');
|
129 |
+
}
|
130 |
+
else {
|
131 |
+
$value = $presentation_value = $option;
|
132 |
+
}
|
133 |
+
if (isset($optionsCount[$value]) && $optionsCount[$value] > 0) {
|
134 |
+
$data[] = array(
|
135 |
+
'label' => $presentation_value,
|
136 |
+
'value' => $value,
|
137 |
+
'count' => $optionsCount[$value],
|
138 |
+
);
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
else {
|
143 |
+
$oCount = count($options);
|
144 |
+
|
145 |
+
$intervals = array();
|
146 |
+
if ($feature['order_val'] == '2') {
|
147 |
+
for ($i = 0; $i < $oCount -1; $i++) {
|
148 |
+
$intervals[$i]['high'] = $options[$i];
|
149 |
+
$intervals[$i]['low'] = $options[$i +1];
|
150 |
+
}
|
151 |
+
}
|
152 |
+
else {
|
153 |
+
for ($i = 0; $i < $oCount -1; $i++) {
|
154 |
+
$intervals[$i]['low'] = $options[$i];
|
155 |
+
$intervals[$i]['high'] = $options[$i +1];
|
156 |
+
}
|
157 |
+
}
|
158 |
+
//FIXME: this is ugly
|
159 |
+
if ($feature['order_val'] == '2') {
|
160 |
+
array_push ($intervals, array(
|
161 |
+
'high' => $options[$oCount -1],
|
162 |
+
));
|
163 |
+
|
164 |
+
array_unshift($intervals, array(
|
165 |
+
'low' => $options[0],
|
166 |
+
));
|
167 |
+
}
|
168 |
+
else {
|
169 |
+
array_push ($intervals, array(
|
170 |
+
'low' => $options[$oCount -1],
|
171 |
+
));
|
172 |
+
|
173 |
+
array_unshift($intervals, array(
|
174 |
+
'high' => $options[0],
|
175 |
+
));
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
$this->setData('intervals', $intervals);
|
180 |
+
|
181 |
+
$defaultSign = $feature['default_sign'];
|
182 |
+
for($i = 0; $i < count($intervals); $i++) {
|
183 |
+
if ($feature['order_val'] == '2') {
|
184 |
+
$interval = $intervals[$i];
|
185 |
+
$label = isset($interval['high']) ? $interval['high'] . " $defaultSign" : '>';
|
186 |
+
if ($label == '>' && isset($intervals[$i + 1])) {
|
187 |
+
$pad = strlen($intervals[$i + 1]['high'] . $defaultSign) + 2;
|
188 |
+
$label = str_pad($label, $pad*2, ' ', STR_PAD_LEFT);
|
189 |
+
$label = str_replace(' ', ' ', $label);
|
190 |
+
}
|
191 |
+
$label .= isset($interval['high'], $interval['high']) ? ' - ' : ' ';
|
192 |
+
$label .= isset($interval['low']) ? $interval['low'] . " $defaultSign" : '>';
|
193 |
+
$value = isset($interval['low']) ? $interval['low'] : '-';
|
194 |
+
$value .= ',';
|
195 |
+
$value .= isset($interval['high']) ? $interval['high'] : '-';
|
196 |
+
if (isset($interval['high']) AND !isset($interval['low'])) { $value = '-,'.$interval['high'];}
|
197 |
+
if ($this->_getResource()->getIntervalsCountDescending($this, $interval) > 0){
|
198 |
+
$data[] = array(
|
199 |
+
'label' => $label,
|
200 |
+
'value' => $value,
|
201 |
+
'count' => $this->_getResource()->getIntervalsCountDescending($this, $interval),
|
202 |
+
);
|
203 |
+
|
204 |
+
}
|
205 |
+
}
|
206 |
+
else {
|
207 |
+
$interval = $intervals[$i];
|
208 |
+
$label = isset($interval['low']) ? $interval['low'] . " $defaultSign" : '<';
|
209 |
+
if ($label == '<' && isset($intervals[$i + 1])) {
|
210 |
+
$pad = strlen($intervals[$i + 1]['low'] . $defaultSign) + 2;
|
211 |
+
$label = str_pad($label, $pad*2, ' ', STR_PAD_LEFT);
|
212 |
+
$label = str_replace(' ', ' ', $label);
|
213 |
+
}
|
214 |
+
$label .= isset($interval['low'], $interval['high']) ? ' - ' : ' ';
|
215 |
+
$label .= isset($interval['high']) ? $interval['high'] . " $defaultSign" : '<';
|
216 |
+
|
217 |
+
$value = isset($interval['low']) ? $interval['low'] : '-';
|
218 |
+
$value .= ',';
|
219 |
+
$value .= isset($interval['high']) ? $interval['high'] : '-';
|
220 |
+
if ($this->_getResource()->getIntervalsCount($this, $interval) > 0){
|
221 |
+
$data[] = array(
|
222 |
+
'label' => $label,
|
223 |
+
'value' => $value,
|
224 |
+
'count' => $this->_getResource()->getIntervalsCount($this, $interval),
|
225 |
+
);
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
Varien_Profiler::stop(__METHOD__);
|
236 |
+
return $data;
|
237 |
+
}
|
238 |
+
|
239 |
+
public function getOrderValues($category_feature_id,$categoryId)
|
240 |
+
{
|
241 |
+
$select = "
|
242 |
+
SELECT COUNT(e.entity_id) AS count
|
243 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." AS e
|
244 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." AS cat_index
|
245 |
+
ON cat_index.product_id=e.entity_id
|
246 |
+
AND cat_index.store_id='1'
|
247 |
+
AND cat_index.visibility IN(2, 4)
|
248 |
+
AND cat_index.category_id='".$categoryId."'
|
249 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
250 |
+
ON price_index.entity_id = e.entity_id
|
251 |
+
AND price_index.website_id = '1'
|
252 |
+
AND price_index.customer_group_id = 0
|
253 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_feature_'.$feature['category_feature_id'])." AS idx_".$category_feature_id."
|
254 |
+
ON idx_".$category_feature_id.".entity_id = e.icecat_product_id;
|
255 |
+
";
|
256 |
+
|
257 |
+
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($select);
|
258 |
+
}
|
259 |
+
|
260 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Price.php
CHANGED
@@ -1,194 +1,194 @@
|
|
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 |
-
* Get price range for building filter steps
|
14 |
-
*
|
15 |
-
* @return int
|
16 |
-
*//*
|
17 |
-
public function getPriceRange()
|
18 |
-
{
|
19 |
-
|
20 |
-
$range = $this->getData('price_range');
|
21 |
-
if (is_null($range)) {
|
22 |
-
$maxPrice = $this->getMaxPriceInt();
|
23 |
-
$index = 2;
|
24 |
-
if ($maxPrice<1000) {
|
25 |
-
$index = 1;
|
26 |
-
}
|
27 |
-
do {
|
28 |
-
$range = pow(10, (strlen(floor($maxPrice))-$index));
|
29 |
-
$items = $this->getRangeItemCounts($range);
|
30 |
-
$index++;
|
31 |
-
}
|
32 |
-
while($range>self::MIN_RANGE_POWER && count($items)<2);
|
33 |
-
|
34 |
-
$this->setData('price_range', $range);
|
35 |
-
}
|
36 |
-
return $range;
|
37 |
-
}
|
38 |
-
|
39 |
-
*/
|
40 |
-
/**
|
41 |
-
* Apply price range filter to collection
|
42 |
-
*
|
43 |
-
* @param Zend_Controller_Request_Abstract $request
|
44 |
-
* @param $filterBlock
|
45 |
-
*
|
46 |
-
* @return Mage_Catalog_Model_Layer_Filter_Price
|
47 |
-
*/
|
48 |
-
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
49 |
-
{
|
50 |
-
/**
|
51 |
-
* Filter must be string: $index,$range
|
52 |
-
*/
|
53 |
-
$filter = $request->getParam($this->getRequestVar());
|
54 |
-
if (!$filter) {
|
55 |
-
return $this;
|
56 |
-
}
|
57 |
-
/* echo "<pre>";
|
58 |
-
var_dump($filter);
|
59 |
-
echo "</pre>";
|
60 |
-
*/
|
61 |
-
if(strstr($filter, ',')){
|
62 |
-
$filter = explode(',', $filter);
|
63 |
-
if (count($filter) != 2) {
|
64 |
-
return $this;
|
65 |
-
}
|
66 |
-
list($index, $range) = $filter;
|
67 |
-
// echo $index.$range."AAAAAAAa";
|
68 |
-
if ((int)$index && (int)$range) {
|
69 |
-
$this->setPriceRange((int)$range);
|
70 |
-
|
71 |
-
$this->_applyToCollection($range, $index);
|
72 |
-
$this->getLayer()->getState()->addFilter(
|
73 |
-
$this->_createItem($this->_renderItemLabel($range, $index), $filter)
|
74 |
-
);
|
75 |
-
|
76 |
-
$this->_items = array();
|
77 |
-
}
|
78 |
-
|
79 |
-
}elseif(strstr($filter, '-')){
|
80 |
-
$filter = explode('-', $filter);
|
81 |
-
if (count($filter) != 2) {
|
82 |
-
return $this;
|
83 |
-
}
|
84 |
-
|
85 |
-
list($minPrice, $maxPrice) = $filter;
|
86 |
-
// echo $minPrice."BBBBBB".$maxPrice;
|
87 |
-
|
88 |
-
// if ((int)$minPrice && (int)$maxPrice) {
|
89 |
-
if(((int)$minPrice || $minPrice==0) && ((int)$maxPrice || $maxPrice=='*')){
|
90 |
-
// $this->setPriceRange((int)$range);
|
91 |
-
|
92 |
-
$this->_applyToCollectionMinMaxPrice($minPrice, $maxPrice);
|
93 |
-
$this->getLayer()->getState()->addFilter(
|
94 |
-
$this->_createItem($this->_renderItemLabelMinMaxPrice($minPrice, $maxPrice), $filter)
|
95 |
-
);
|
96 |
-
|
97 |
-
$this->_items = array();
|
98 |
-
}
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
return $this;
|
103 |
-
}
|
104 |
-
/**
|
105 |
-
* Prepare text of item label
|
106 |
-
*
|
107 |
-
* @param int $fromPrice
|
108 |
-
* @param int
|
109 |
-
* @return string
|
110 |
-
*/
|
111 |
-
|
112 |
-
protected function _renderItemLabelMinMaxPrice($fromPrice, $toPrice)
|
113 |
-
{
|
114 |
-
$store = Mage::app()->getStore();
|
115 |
-
$toPriceLabel=$toPrice;
|
116 |
-
$fromPrice = $store->formatPrice($fromPrice);
|
117 |
-
$toPrice = $store->formatPrice($toPrice);
|
118 |
-
$label= Mage::helper('catalog')->__('%s - %s', $fromPrice, $toPrice);
|
119 |
-
if( $toPriceLabel=='' || $toPriceLabel=='*'){
|
120 |
-
$label=$fromPrice." + ";
|
121 |
-
}
|
122 |
-
|
123 |
-
return $label;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Get data for build price filter items
|
128 |
-
*
|
129 |
-
* @return array
|
130 |
-
*/
|
131 |
-
protected function _getItemsData()
|
132 |
-
{
|
133 |
-
// $dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
134 |
-
// $price_breaks=$dataConf['price_breaks'];
|
135 |
-
$import=Mage::getModel('sinchimport/sinch');
|
136 |
-
$price_breaks=$import->price_breaks_filter;
|
137 |
-
|
138 |
-
if(strstr($price_breaks, ';')){
|
139 |
-
$price_ranges = explode(';', $price_breaks);
|
140 |
-
|
141 |
-
foreach ($price_ranges as $price_range) {
|
142 |
-
$price_range_value=trim($price_range);
|
143 |
-
if($price_range && $price_range!=''){
|
144 |
-
|
145 |
-
$price_range = explode('-', $price_range);
|
146 |
-
list($minPrice, $maxPrice) = $price_range;
|
147 |
-
if(((int)$minPrice || $minPrice==0) && ((int)$maxPrice || $maxPrice=='*')){
|
148 |
-
$count=$this->_getResource()->getCountMinMaxPrice($this, $minPrice, $maxPrice);
|
149 |
-
if($count){
|
150 |
-
$data[] = array(
|
151 |
-
'label' => $this->_renderItemLabelMinMaxPrice($minPrice, $maxPrice),
|
152 |
-
'value' =>$price_range_value,
|
153 |
-
'count' => $count,
|
154 |
-
);
|
155 |
-
}
|
156 |
-
}
|
157 |
-
}
|
158 |
-
}
|
159 |
-
if($data){
|
160 |
-
return $data;
|
161 |
-
}
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
$range = $this->getPriceRange();
|
166 |
-
$dbRanges = $this->getRangeItemCounts($range);
|
167 |
-
$data = array();
|
168 |
-
|
169 |
-
foreach ($dbRanges as $index=>$count) {
|
170 |
-
$data[] = array(
|
171 |
-
'label' => $this->_renderItemLabel($range, $index),
|
172 |
-
'value' => $index . ',' . $range,
|
173 |
-
'count' => $count,
|
174 |
-
);
|
175 |
-
}
|
176 |
-
|
177 |
-
return $data;
|
178 |
-
}
|
179 |
-
|
180 |
-
/**
|
181 |
-
* Apply filter value to product collection based on customer price breaks and selected value
|
182 |
-
*
|
183 |
-
* @param int $minPrice
|
184 |
-
* @param int $maxPrice
|
185 |
-
* @return Mage_Catalog_Model_Layer_Filter_Price
|
186 |
-
*/
|
187 |
-
|
188 |
-
protected function _applyToCollectionMinMaxPrice($minPrice, $maxPrice)
|
189 |
-
{
|
190 |
-
$this->_getResource()->applyFilterToCollectionMinMaxPrice($this, $minPrice, $maxPrice);
|
191 |
-
return $this;
|
192 |
-
}
|
193 |
-
|
194 |
-
}
|
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 |
+
* Get price range for building filter steps
|
14 |
+
*
|
15 |
+
* @return int
|
16 |
+
*//*
|
17 |
+
public function getPriceRange()
|
18 |
+
{
|
19 |
+
|
20 |
+
$range = $this->getData('price_range');
|
21 |
+
if (is_null($range)) {
|
22 |
+
$maxPrice = $this->getMaxPriceInt();
|
23 |
+
$index = 2;
|
24 |
+
if ($maxPrice<1000) {
|
25 |
+
$index = 1;
|
26 |
+
}
|
27 |
+
do {
|
28 |
+
$range = pow(10, (strlen(floor($maxPrice))-$index));
|
29 |
+
$items = $this->getRangeItemCounts($range);
|
30 |
+
$index++;
|
31 |
+
}
|
32 |
+
while($range>self::MIN_RANGE_POWER && count($items)<2);
|
33 |
+
|
34 |
+
$this->setData('price_range', $range);
|
35 |
+
}
|
36 |
+
return $range;
|
37 |
+
}
|
38 |
+
|
39 |
+
*/
|
40 |
+
/**
|
41 |
+
* Apply price range filter to collection
|
42 |
+
*
|
43 |
+
* @param Zend_Controller_Request_Abstract $request
|
44 |
+
* @param $filterBlock
|
45 |
+
*
|
46 |
+
* @return Mage_Catalog_Model_Layer_Filter_Price
|
47 |
+
*/
|
48 |
+
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
|
49 |
+
{
|
50 |
+
/**
|
51 |
+
* Filter must be string: $index,$range
|
52 |
+
*/
|
53 |
+
$filter = $request->getParam($this->getRequestVar());
|
54 |
+
if (!$filter) {
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
/* echo "<pre>";
|
58 |
+
var_dump($filter);
|
59 |
+
echo "</pre>";
|
60 |
+
*/
|
61 |
+
if(strstr($filter, ',')){
|
62 |
+
$filter = explode(',', $filter);
|
63 |
+
if (count($filter) != 2) {
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
list($index, $range) = $filter;
|
67 |
+
// echo $index.$range."AAAAAAAa";
|
68 |
+
if ((int)$index && (int)$range) {
|
69 |
+
$this->setPriceRange((int)$range);
|
70 |
+
|
71 |
+
$this->_applyToCollection($range, $index);
|
72 |
+
$this->getLayer()->getState()->addFilter(
|
73 |
+
$this->_createItem($this->_renderItemLabel($range, $index), $filter)
|
74 |
+
);
|
75 |
+
|
76 |
+
$this->_items = array();
|
77 |
+
}
|
78 |
+
|
79 |
+
}elseif(strstr($filter, '-')){
|
80 |
+
$filter = explode('-', $filter);
|
81 |
+
if (count($filter) != 2) {
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
list($minPrice, $maxPrice) = $filter;
|
86 |
+
// echo $minPrice."BBBBBB".$maxPrice;
|
87 |
+
|
88 |
+
// if ((int)$minPrice && (int)$maxPrice) {
|
89 |
+
if(((int)$minPrice || $minPrice==0) && ((int)$maxPrice || $maxPrice=='*')){
|
90 |
+
// $this->setPriceRange((int)$range);
|
91 |
+
|
92 |
+
$this->_applyToCollectionMinMaxPrice($minPrice, $maxPrice);
|
93 |
+
$this->getLayer()->getState()->addFilter(
|
94 |
+
$this->_createItem($this->_renderItemLabelMinMaxPrice($minPrice, $maxPrice), $filter)
|
95 |
+
);
|
96 |
+
|
97 |
+
$this->_items = array();
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
return $this;
|
103 |
+
}
|
104 |
+
/**
|
105 |
+
* Prepare text of item label
|
106 |
+
*
|
107 |
+
* @param int $fromPrice
|
108 |
+
* @param int
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
|
112 |
+
protected function _renderItemLabelMinMaxPrice($fromPrice, $toPrice)
|
113 |
+
{
|
114 |
+
$store = Mage::app()->getStore();
|
115 |
+
$toPriceLabel=$toPrice;
|
116 |
+
$fromPrice = $store->formatPrice($fromPrice);
|
117 |
+
$toPrice = $store->formatPrice($toPrice);
|
118 |
+
$label= Mage::helper('catalog')->__('%s - %s', $fromPrice, $toPrice);
|
119 |
+
if( $toPriceLabel=='' || $toPriceLabel=='*'){
|
120 |
+
$label=$fromPrice." + ";
|
121 |
+
}
|
122 |
+
|
123 |
+
return $label;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Get data for build price filter items
|
128 |
+
*
|
129 |
+
* @return array
|
130 |
+
*/
|
131 |
+
protected function _getItemsData()
|
132 |
+
{
|
133 |
+
// $dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
134 |
+
// $price_breaks=$dataConf['price_breaks'];
|
135 |
+
$import=Mage::getModel('sinchimport/sinch');
|
136 |
+
$price_breaks=$import->price_breaks_filter;
|
137 |
+
|
138 |
+
if(strstr($price_breaks, ';')){
|
139 |
+
$price_ranges = explode(';', $price_breaks);
|
140 |
+
|
141 |
+
foreach ($price_ranges as $price_range) {
|
142 |
+
$price_range_value=trim($price_range);
|
143 |
+
if($price_range && $price_range!=''){
|
144 |
+
|
145 |
+
$price_range = explode('-', $price_range);
|
146 |
+
list($minPrice, $maxPrice) = $price_range;
|
147 |
+
if(((int)$minPrice || $minPrice==0) && ((int)$maxPrice || $maxPrice=='*')){
|
148 |
+
$count=$this->_getResource()->getCountMinMaxPrice($this, $minPrice, $maxPrice);
|
149 |
+
if($count){
|
150 |
+
$data[] = array(
|
151 |
+
'label' => $this->_renderItemLabelMinMaxPrice($minPrice, $maxPrice),
|
152 |
+
'value' =>$price_range_value,
|
153 |
+
'count' => $count,
|
154 |
+
);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
if($data){
|
160 |
+
return $data;
|
161 |
+
}
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
$range = $this->getPriceRange();
|
166 |
+
$dbRanges = $this->getRangeItemCounts($range);
|
167 |
+
$data = array();
|
168 |
+
|
169 |
+
foreach ($dbRanges as $index=>$count) {
|
170 |
+
$data[] = array(
|
171 |
+
'label' => $this->_renderItemLabel($range, $index),
|
172 |
+
'value' => $index . ',' . $range,
|
173 |
+
'count' => $count,
|
174 |
+
);
|
175 |
+
}
|
176 |
+
|
177 |
+
return $data;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Apply filter value to product collection based on customer price breaks and selected value
|
182 |
+
*
|
183 |
+
* @param int $minPrice
|
184 |
+
* @param int $maxPrice
|
185 |
+
* @return Mage_Catalog_Model_Layer_Filter_Price
|
186 |
+
*/
|
187 |
+
|
188 |
+
protected function _applyToCollectionMinMaxPrice($minPrice, $maxPrice)
|
189 |
+
{
|
190 |
+
$this->_getResource()->applyFilterToCollectionMinMaxPrice($this, $minPrice, $maxPrice);
|
191 |
+
return $this;
|
192 |
+
}
|
193 |
+
|
194 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php
CHANGED
@@ -1,384 +1,384 @@
|
|
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->_getReadAdapter();
|
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 |
-
//TODO: this table must be temporary
|
59 |
-
$sql = "
|
60 |
-
CREATE TABLE IF NOT EXISTS `{$resultTable}`(
|
61 |
-
`entity_id` int(10) unsigned,
|
62 |
-
`category_id` int(10) unsigned,
|
63 |
-
`product_id` int,
|
64 |
-
`sinch_category_id` int,
|
65 |
-
`name` varchar(255),
|
66 |
-
`image` varchar(255),
|
67 |
-
`supplier_id` int,
|
68 |
-
`category_feature_id` int,
|
69 |
-
`feature_id` int,
|
70 |
-
`feature_name` varchar(255),
|
71 |
-
`feature_value` text
|
72 |
-
);
|
73 |
-
";
|
74 |
-
$connection->exec($sql);
|
75 |
-
|
76 |
-
$sql = "TRUNCATE TABLE {$resultTable}";
|
77 |
-
$connection->exec($sql);
|
78 |
-
|
79 |
-
$featuresTable = $this->_getTableName('FilterListOfFeatures');
|
80 |
-
$sql = "TRUNCATE TABLE `$featuresTable`";
|
81 |
-
$connection->exec($sql);
|
82 |
-
|
83 |
-
$feature = $filter->getAttributeModel();
|
84 |
-
if ($feature['limit_direction'] != 1 && $feature['limit_direction'] != 2) {
|
85 |
-
if (!is_null($value)) {
|
86 |
-
$sql = "INSERT INTO `$featuresTable` (category_feature_id, feature_value) VALUES (?)";
|
87 |
-
$sql = $connection->quoteInto($sql, array($cfid, $value));
|
88 |
-
$connection->exec($sql);
|
89 |
-
}
|
90 |
-
$params = 'null, null';
|
91 |
-
}
|
92 |
-
else {
|
93 |
-
$bounds = explode(',', $value);
|
94 |
-
|
95 |
-
$params = $bounds[0] != '-' ? (int)$bounds[0] : 'null';
|
96 |
-
$params .= ', ';
|
97 |
-
$params .= $bounds[1] != '-' ? (int)$bounds[1] : 'null';
|
98 |
-
}
|
99 |
-
//$connection->query("CALL `filter_icecat_products_s`($cfid, $catId,0,$cfid, $params)"));
|
100 |
-
$tablePrefix = (string)Mage::app()->getConfig()->getTablePrefix();
|
101 |
-
$result = $connection->raw_query("CALL ".$this->_getTableName('filter_sinch_products_s')."($cfid, $catId,0, $cfid, $params, '$tablePrefix')");
|
102 |
-
Varien_Profiler::stop(__METHOD__);
|
103 |
-
return $resultTable;
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Apply attribute filter to product collection
|
109 |
-
*
|
110 |
-
* @param Bintime_Icelayered_Model_Layer_Filter_Feature $filter
|
111 |
-
* @param string $value
|
112 |
-
* @return Bintime_Icelayered_Model_Resource_Mysql4_Layer_Filter_Feature
|
113 |
-
*/
|
114 |
-
public function applyFilterToCollection($filter, $value)
|
115 |
-
{
|
116 |
-
Varien_Profiler::start(__METHOD__);
|
117 |
-
$searchTable = $this->_prepareSearch($filter, $value);
|
118 |
-
self::$lastResultTable = $searchTable;
|
119 |
-
|
120 |
-
$collection = $filter->getLayer()->getProductCollection();
|
121 |
-
$feature = $filter->getAttributeModel();
|
122 |
-
$connection = $this->_getReadAdapter();
|
123 |
-
|
124 |
-
$collection->getSelect()->join(
|
125 |
-
$searchTable,
|
126 |
-
"{$searchTable}.entity_id = e.entity_id",
|
127 |
-
array()
|
128 |
-
);
|
129 |
-
|
130 |
-
Varien_Profiler::stop(__METHOD__);
|
131 |
-
return $this;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Retrieve array with products counts per attribute option
|
136 |
-
*
|
137 |
-
* @param Bintime_Icelayered_Model_Layer_Filter_Feature $filter
|
138 |
-
* @return array
|
139 |
-
*/
|
140 |
-
public function getCount($filter)
|
141 |
-
{
|
142 |
-
Varien_Profiler::start(__METHOD__);
|
143 |
-
|
144 |
-
// clone select from collection with filters
|
145 |
-
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
146 |
-
|
147 |
-
// reset columns, order and limitation conditions
|
148 |
-
$select->reset(Zend_Db_Select::COLUMNS);
|
149 |
-
$select->reset(Zend_Db_Select::ORDER);
|
150 |
-
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
151 |
-
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
152 |
-
$connection = $this->_getReadAdapter();
|
153 |
-
$feature = $filter->getAttributeModel();
|
154 |
-
$tableAlias = 'idx_' . $feature['category_feature_id'];
|
155 |
-
|
156 |
-
$conditions = array(
|
157 |
-
"{$tableAlias}.entity_id = e.entity_id",
|
158 |
-
//"{$tableAlias}.category_feature_id = {$feature['category_feature_id']}",
|
159 |
-
);
|
160 |
-
|
161 |
-
$select->joinInner(
|
162 |
-
array($tableAlias => $this->_getTableName('stINch_products_feature_'.$feature['category_feature_id'])),
|
163 |
-
join(' AND ', $conditions),
|
164 |
-
array('value', 'count' => "COUNT(e.entity_id)")
|
165 |
-
)
|
166 |
-
->group("{$tableAlias}.value");
|
167 |
-
|
168 |
-
$tablePattern = $this->_getTableName('stINch_products_feature_'.$feature['category_feature_id']);
|
169 |
-
$query = "SHOW TABLES LIKE '$tablePattern'";
|
170 |
-
$featureTables = $connection->fetchCol($query);
|
171 |
-
$presentFeatures = array();
|
172 |
-
foreach($featureTables as $t) {
|
173 |
-
if (preg_match("#$tablePattern#", $t, $matches)) {
|
174 |
-
$table_feat_exist=true;
|
175 |
-
}
|
176 |
-
}
|
177 |
-
|
178 |
-
Varien_Profiler::stop(__METHOD__);
|
179 |
-
if($table_feat_exist){
|
180 |
-
return $connection->fetchPairs($select);
|
181 |
-
}else{
|
182 |
-
return null;
|
183 |
-
}
|
184 |
-
|
185 |
-
}
|
186 |
-
|
187 |
-
public function getIntervalsCount($filter, $interval)
|
188 |
-
{
|
189 |
-
Varien_Profiler::start(__METHOD__);
|
190 |
-
|
191 |
-
// clone select from collection with filters
|
192 |
-
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
193 |
-
|
194 |
-
// reset columns, order and limitation conditions
|
195 |
-
$select->reset(Zend_Db_Select::COLUMNS);
|
196 |
-
$select->reset(Zend_Db_Select::ORDER);
|
197 |
-
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
198 |
-
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
199 |
-
|
200 |
-
$connection = $this->_getReadAdapter();
|
201 |
-
$feature = $filter->getAttributeModel();
|
202 |
-
$tableAlias = 'idx_' . $feature['category_feature_id'];
|
203 |
-
|
204 |
-
$conditions = array(
|
205 |
-
"{$tableAlias}.entity_id = e.entity_id",
|
206 |
-
//"{$tableAlias}.category_feature_id = {$feature['category_feature_id']}",
|
207 |
-
);
|
208 |
-
|
209 |
-
$select->joinInner(
|
210 |
-
array($tableAlias => $this->_getTableName('icecat_products_feature_'.$feature['category_feature_id'])),
|
211 |
-
join(' AND ', $conditions),
|
212 |
-
array('count' => "COUNT(e.entity_id)")
|
213 |
-
);
|
214 |
-
if (isset($interval['low'], $interval['high'])) {
|
215 |
-
$select->where('CAST('.$tableAlias.'.value AS SIGNED) >= ?', $interval['low'])->where('CAST('.$tableAlias.'.value AS SIGNED) < ?', $interval['high']);
|
216 |
-
}
|
217 |
-
else if (isset($interval['low'])) {
|
218 |
-
$select->where('CAST('.$tableAlias.'.value AS SIGNED) >= ?', $interval['low']);
|
219 |
-
}
|
220 |
-
else if (isset($interval['high'])) {
|
221 |
-
$select->where('CAST('.$tableAlias.'.value AS SIGNED) < ?', $interval['high']);
|
222 |
-
}
|
223 |
-
$count = $connection->fetchOne($select);
|
224 |
-
Varien_Profiler::stop(__METHOD__);
|
225 |
-
return $count;
|
226 |
-
}
|
227 |
-
|
228 |
-
function getIntervalsCountDescending($filter, $interval)
|
229 |
-
{
|
230 |
-
Varien_Profiler::start(__METHOD__);
|
231 |
-
|
232 |
-
// clone select from collection with filters
|
233 |
-
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
234 |
-
|
235 |
-
// reset columns, order and limitation conditions
|
236 |
-
$select->reset(Zend_Db_Select::COLUMNS);
|
237 |
-
$select->reset(Zend_Db_Select::ORDER);
|
238 |
-
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
239 |
-
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
240 |
-
|
241 |
-
$connection = $this->_getReadAdapter();
|
242 |
-
$feature = $filter->getAttributeModel();
|
243 |
-
$tableAlias = 'idx_' . $feature['category_feature_id'];
|
244 |
-
|
245 |
-
$conditions = array(
|
246 |
-
"{$tableAlias}.entity_id = e.entity_id",
|
247 |
-
//"{$tableAlias}.category_feature_id = {$feature['category_feature_id']}",
|
248 |
-
);
|
249 |
-
|
250 |
-
$select->joinInner(
|
251 |
-
array($tableAlias => $this->_getTableName('icecat_products_feature_'.$feature['category_feature_id'])),
|
252 |
-
join(' AND ', $conditions),
|
253 |
-
array('count' => "COUNT(e.entity_id)")
|
254 |
-
);
|
255 |
-
if (isset($interval['low'], $interval['high'])) {
|
256 |
-
$select->where('CAST('.$tableAlias.'.value AS SIGNED) >= ?', $interval['low'])->where('CAST('.$tableAlias.'.value AS SIGNED) < ?', $interval['high']);
|
257 |
-
}
|
258 |
-
else if (isset($interval['low'])) {
|
259 |
-
$select->where('CAST('.$tableAlias.'.value AS SIGNED) >= ?', $interval['low']);
|
260 |
-
}
|
261 |
-
else if (isset($interval['high'])) {
|
262 |
-
$select->where('CAST('.$tableAlias.'.value AS SIGNED) < ?', $interval['high']);
|
263 |
-
}
|
264 |
-
$count = $connection->fetchOne($select);
|
265 |
-
|
266 |
-
Varien_Profiler::stop(__METHOD__);
|
267 |
-
return $count;
|
268 |
-
}
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
/*
|
273 |
-
* INDEXES FOLLOW.
|
274 |
-
*/
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Запускает процедуры индексации.
|
278 |
-
* Слушает событие Mage::dispatchEvent('iceimport_model_import_after',..)
|
279 |
-
* @param <type> $observer
|
280 |
-
*/
|
281 |
-
public function reindex($observer)
|
282 |
-
{
|
283 |
-
$this->splitProductsFeature();
|
284 |
-
}
|
285 |
-
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Разбивает таблицу icecat_product_feature на таблицы вида icecat_product_feature_%category_feature_id% для каждой фичи.
|
289 |
-
*
|
290 |
-
*/
|
291 |
-
public function splitProductsFeature()
|
292 |
-
{
|
293 |
-
Mage::log(__METHOD__ . " start at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
294 |
-
$featureIds = $this->getProductFeatures4indexig();
|
295 |
-
|
296 |
-
$resource = Mage::getSingleton('core/resource');
|
297 |
-
// $tProudctsFeature = $resource->getTableName("icecat_products_feature");
|
298 |
-
$connection = $this->_getWriteAdapter();
|
299 |
-
|
300 |
-
//удаление таблиц с фичами не используемыми больше для навигации.
|
301 |
-
$tablePattern = $resource->getTableName('stINch_products_feature_');
|
302 |
-
$query = "SHOW TABLES LIKE '%$tablePattern%'";
|
303 |
-
$featureTables = $connection->fetchCol($query);
|
304 |
-
$presentFeatures = array();
|
305 |
-
foreach($featureTables as $t) {
|
306 |
-
if (preg_match("#$tablePattern(\d+)#", $t, $matches)) {
|
307 |
-
$presentFeatures[] = $matches[1];
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
311 |
-
$features2delete = array_diff($presentFeatures, $featureIds);
|
312 |
-
if (count($features2delete)) {
|
313 |
-
foreach ($features2delete as & $drop) {
|
314 |
-
$drop = $tablePattern . $drop;
|
315 |
-
}
|
316 |
-
$dropSql = "DROP TABLE " . implode(',', $features2delete);
|
317 |
-
$connection->exec($dropSql);
|
318 |
-
}
|
319 |
-
//
|
320 |
-
|
321 |
-
//Создание таблиц с фичами используемыми в навигации.
|
322 |
-
$i = 0; $storeId = Mage::app()->getStore()->getId(); $websiteId = Mage::app()->getWebsite()->getId();
|
323 |
-
foreach ($featureIds as $featureId) {
|
324 |
-
$tFeature = $resource->getTableName("stINch_products_feature_$featureId");
|
325 |
-
$query = "DROP TABLE IF EXISTS $tFeature";
|
326 |
-
$connection->exec($query);
|
327 |
-
|
328 |
-
$query = "CREATE TABLE IF NOT EXISTS $tFeature (
|
329 |
-
`entity_id` int(11) default NULL,
|
330 |
-
`feature_id` int(11) NOT NULL,
|
331 |
-
`product_id` int(11) default NULL,
|
332 |
-
`category_feature_id` int(11) default NULL,
|
333 |
-
`value` text,
|
334 |
-
`presentation_value` text,
|
335 |
-
INDEX (`feature_id`),
|
336 |
-
KEY `category_feature_id` (`category_feature_id`)
|
337 |
-
) ENGINE=MyISAM DEFAULT CHARSET=utf8
|
338 |
-
";
|
339 |
-
$connection->exec($query);
|
340 |
-
|
341 |
-
$query = "TRUNCATE TABLE $tFeature";
|
342 |
-
$connection->exec($query);
|
343 |
-
|
344 |
-
/*$query = "
|
345 |
-
INSERT INTO $tFeature (feature_id, product_id, category_feature_id, value, presentation_value)
|
346 |
-
SELECT feature_id, product_id, category_feature_id, value, presentation_value FROM $tProudctsFeature
|
347 |
-
WHERE category_feature_id = $featureId
|
348 |
-
";*/
|
349 |
-
$query = "
|
350 |
-
REPLACE INTO $tFeature (entity_id,feature_id, product_id, category_feature_id, value, presentation_value)
|
351 |
-
SELECT E.entity_id, RV.category_feature_id,E.entity_id, RV.category_feature_id, RV.text , RV.text
|
352 |
-
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." E
|
353 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." PCind
|
354 |
-
ON (E.entity_id = PCind.product_id AND PCind.store_id='{$storeId}' AND PCind.visibility IN(2,4))
|
355 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
356 |
-
ON price_index.entity_id = E.entity_id AND price_index.website_id = '{$websiteId}' AND price_index.customer_group_id = 0
|
357 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." PR
|
358 |
-
ON (PR.store_product_id = E.store_product_id)
|
359 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features')." PF
|
360 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
361 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values')." RV
|
362 |
-
ON (PF.restricted_value_id=RV.restricted_value_id AND RV.category_feature_id= $featureId)
|
363 |
-
GROUP BY E.entity_id;
|
364 |
-
";
|
365 |
-
$connection->exec($query);
|
366 |
-
}
|
367 |
-
Mage::log(__METHOD__ . " end at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Список фич подлежащих индексации.
|
372 |
-
*
|
373 |
-
* @return array
|
374 |
-
*/
|
375 |
-
private function getProductFeatures4indexig()
|
376 |
-
{
|
377 |
-
$connection = $this->_getReadAdapter();
|
378 |
-
|
379 |
-
$tCatFeature = Mage::getSingleton('core/resource')->getTableName('stINch_categories_features');
|
380 |
-
$query = "SELECT category_feature_id FROM $tCatFeature ";
|
381 |
-
|
382 |
-
return $connection->fetchCol($query);
|
383 |
-
}
|
384 |
-
}
|
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->_getReadAdapter();
|
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 |
+
//TODO: this table must be temporary
|
59 |
+
$sql = "
|
60 |
+
CREATE TABLE IF NOT EXISTS `{$resultTable}`(
|
61 |
+
`entity_id` int(10) unsigned,
|
62 |
+
`category_id` int(10) unsigned,
|
63 |
+
`product_id` int,
|
64 |
+
`sinch_category_id` int,
|
65 |
+
`name` varchar(255),
|
66 |
+
`image` varchar(255),
|
67 |
+
`supplier_id` int,
|
68 |
+
`category_feature_id` int,
|
69 |
+
`feature_id` int,
|
70 |
+
`feature_name` varchar(255),
|
71 |
+
`feature_value` text
|
72 |
+
);
|
73 |
+
";
|
74 |
+
$connection->exec($sql);
|
75 |
+
|
76 |
+
$sql = "TRUNCATE TABLE {$resultTable}";
|
77 |
+
$connection->exec($sql);
|
78 |
+
|
79 |
+
$featuresTable = $this->_getTableName('FilterListOfFeatures');
|
80 |
+
$sql = "TRUNCATE TABLE `$featuresTable`";
|
81 |
+
$connection->exec($sql);
|
82 |
+
|
83 |
+
$feature = $filter->getAttributeModel();
|
84 |
+
if ($feature['limit_direction'] != 1 && $feature['limit_direction'] != 2) {
|
85 |
+
if (!is_null($value)) {
|
86 |
+
$sql = "INSERT INTO `$featuresTable` (category_feature_id, feature_value) VALUES (?)";
|
87 |
+
$sql = $connection->quoteInto($sql, array($cfid, $value));
|
88 |
+
$connection->exec($sql);
|
89 |
+
}
|
90 |
+
$params = 'null, null';
|
91 |
+
}
|
92 |
+
else {
|
93 |
+
$bounds = explode(',', $value);
|
94 |
+
|
95 |
+
$params = $bounds[0] != '-' ? (int)$bounds[0] : 'null';
|
96 |
+
$params .= ', ';
|
97 |
+
$params .= $bounds[1] != '-' ? (int)$bounds[1] : 'null';
|
98 |
+
}
|
99 |
+
//$connection->query("CALL `filter_icecat_products_s`($cfid, $catId,0,$cfid, $params)"));
|
100 |
+
$tablePrefix = (string)Mage::app()->getConfig()->getTablePrefix();
|
101 |
+
$result = $connection->raw_query("CALL ".$this->_getTableName('filter_sinch_products_s')."($cfid, $catId,0, $cfid, $params, '$tablePrefix')");
|
102 |
+
Varien_Profiler::stop(__METHOD__);
|
103 |
+
return $resultTable;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Apply attribute filter to product collection
|
109 |
+
*
|
110 |
+
* @param Bintime_Icelayered_Model_Layer_Filter_Feature $filter
|
111 |
+
* @param string $value
|
112 |
+
* @return Bintime_Icelayered_Model_Resource_Mysql4_Layer_Filter_Feature
|
113 |
+
*/
|
114 |
+
public function applyFilterToCollection($filter, $value)
|
115 |
+
{
|
116 |
+
Varien_Profiler::start(__METHOD__);
|
117 |
+
$searchTable = $this->_prepareSearch($filter, $value);
|
118 |
+
self::$lastResultTable = $searchTable;
|
119 |
+
|
120 |
+
$collection = $filter->getLayer()->getProductCollection();
|
121 |
+
$feature = $filter->getAttributeModel();
|
122 |
+
$connection = $this->_getReadAdapter();
|
123 |
+
|
124 |
+
$collection->getSelect()->join(
|
125 |
+
$searchTable,
|
126 |
+
"{$searchTable}.entity_id = e.entity_id",
|
127 |
+
array()
|
128 |
+
);
|
129 |
+
|
130 |
+
Varien_Profiler::stop(__METHOD__);
|
131 |
+
return $this;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Retrieve array with products counts per attribute option
|
136 |
+
*
|
137 |
+
* @param Bintime_Icelayered_Model_Layer_Filter_Feature $filter
|
138 |
+
* @return array
|
139 |
+
*/
|
140 |
+
public function getCount($filter)
|
141 |
+
{
|
142 |
+
Varien_Profiler::start(__METHOD__);
|
143 |
+
|
144 |
+
// clone select from collection with filters
|
145 |
+
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
146 |
+
|
147 |
+
// reset columns, order and limitation conditions
|
148 |
+
$select->reset(Zend_Db_Select::COLUMNS);
|
149 |
+
$select->reset(Zend_Db_Select::ORDER);
|
150 |
+
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
151 |
+
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
152 |
+
$connection = $this->_getReadAdapter();
|
153 |
+
$feature = $filter->getAttributeModel();
|
154 |
+
$tableAlias = 'idx_' . $feature['category_feature_id'];
|
155 |
+
|
156 |
+
$conditions = array(
|
157 |
+
"{$tableAlias}.entity_id = e.entity_id",
|
158 |
+
//"{$tableAlias}.category_feature_id = {$feature['category_feature_id']}",
|
159 |
+
);
|
160 |
+
|
161 |
+
$select->joinInner(
|
162 |
+
array($tableAlias => $this->_getTableName('stINch_products_feature_'.$feature['category_feature_id'])),
|
163 |
+
join(' AND ', $conditions),
|
164 |
+
array('value', 'count' => "COUNT(e.entity_id)")
|
165 |
+
)
|
166 |
+
->group("{$tableAlias}.value");
|
167 |
+
|
168 |
+
$tablePattern = $this->_getTableName('stINch_products_feature_'.$feature['category_feature_id']);
|
169 |
+
$query = "SHOW TABLES LIKE '$tablePattern'";
|
170 |
+
$featureTables = $connection->fetchCol($query);
|
171 |
+
$presentFeatures = array();
|
172 |
+
foreach($featureTables as $t) {
|
173 |
+
if (preg_match("#$tablePattern#", $t, $matches)) {
|
174 |
+
$table_feat_exist=true;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
Varien_Profiler::stop(__METHOD__);
|
179 |
+
if($table_feat_exist){
|
180 |
+
return $connection->fetchPairs($select);
|
181 |
+
}else{
|
182 |
+
return null;
|
183 |
+
}
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
public function getIntervalsCount($filter, $interval)
|
188 |
+
{
|
189 |
+
Varien_Profiler::start(__METHOD__);
|
190 |
+
|
191 |
+
// clone select from collection with filters
|
192 |
+
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
193 |
+
|
194 |
+
// reset columns, order and limitation conditions
|
195 |
+
$select->reset(Zend_Db_Select::COLUMNS);
|
196 |
+
$select->reset(Zend_Db_Select::ORDER);
|
197 |
+
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
198 |
+
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
199 |
+
|
200 |
+
$connection = $this->_getReadAdapter();
|
201 |
+
$feature = $filter->getAttributeModel();
|
202 |
+
$tableAlias = 'idx_' . $feature['category_feature_id'];
|
203 |
+
|
204 |
+
$conditions = array(
|
205 |
+
"{$tableAlias}.entity_id = e.entity_id",
|
206 |
+
//"{$tableAlias}.category_feature_id = {$feature['category_feature_id']}",
|
207 |
+
);
|
208 |
+
|
209 |
+
$select->joinInner(
|
210 |
+
array($tableAlias => $this->_getTableName('icecat_products_feature_'.$feature['category_feature_id'])),
|
211 |
+
join(' AND ', $conditions),
|
212 |
+
array('count' => "COUNT(e.entity_id)")
|
213 |
+
);
|
214 |
+
if (isset($interval['low'], $interval['high'])) {
|
215 |
+
$select->where('CAST('.$tableAlias.'.value AS SIGNED) >= ?', $interval['low'])->where('CAST('.$tableAlias.'.value AS SIGNED) < ?', $interval['high']);
|
216 |
+
}
|
217 |
+
else if (isset($interval['low'])) {
|
218 |
+
$select->where('CAST('.$tableAlias.'.value AS SIGNED) >= ?', $interval['low']);
|
219 |
+
}
|
220 |
+
else if (isset($interval['high'])) {
|
221 |
+
$select->where('CAST('.$tableAlias.'.value AS SIGNED) < ?', $interval['high']);
|
222 |
+
}
|
223 |
+
$count = $connection->fetchOne($select);
|
224 |
+
Varien_Profiler::stop(__METHOD__);
|
225 |
+
return $count;
|
226 |
+
}
|
227 |
+
|
228 |
+
function getIntervalsCountDescending($filter, $interval)
|
229 |
+
{
|
230 |
+
Varien_Profiler::start(__METHOD__);
|
231 |
+
|
232 |
+
// clone select from collection with filters
|
233 |
+
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
|
234 |
+
|
235 |
+
// reset columns, order and limitation conditions
|
236 |
+
$select->reset(Zend_Db_Select::COLUMNS);
|
237 |
+
$select->reset(Zend_Db_Select::ORDER);
|
238 |
+
$select->reset(Zend_Db_Select::LIMIT_COUNT);
|
239 |
+
$select->reset(Zend_Db_Select::LIMIT_OFFSET);
|
240 |
+
|
241 |
+
$connection = $this->_getReadAdapter();
|
242 |
+
$feature = $filter->getAttributeModel();
|
243 |
+
$tableAlias = 'idx_' . $feature['category_feature_id'];
|
244 |
+
|
245 |
+
$conditions = array(
|
246 |
+
"{$tableAlias}.entity_id = e.entity_id",
|
247 |
+
//"{$tableAlias}.category_feature_id = {$feature['category_feature_id']}",
|
248 |
+
);
|
249 |
+
|
250 |
+
$select->joinInner(
|
251 |
+
array($tableAlias => $this->_getTableName('icecat_products_feature_'.$feature['category_feature_id'])),
|
252 |
+
join(' AND ', $conditions),
|
253 |
+
array('count' => "COUNT(e.entity_id)")
|
254 |
+
);
|
255 |
+
if (isset($interval['low'], $interval['high'])) {
|
256 |
+
$select->where('CAST('.$tableAlias.'.value AS SIGNED) >= ?', $interval['low'])->where('CAST('.$tableAlias.'.value AS SIGNED) < ?', $interval['high']);
|
257 |
+
}
|
258 |
+
else if (isset($interval['low'])) {
|
259 |
+
$select->where('CAST('.$tableAlias.'.value AS SIGNED) >= ?', $interval['low']);
|
260 |
+
}
|
261 |
+
else if (isset($interval['high'])) {
|
262 |
+
$select->where('CAST('.$tableAlias.'.value AS SIGNED) < ?', $interval['high']);
|
263 |
+
}
|
264 |
+
$count = $connection->fetchOne($select);
|
265 |
+
|
266 |
+
Varien_Profiler::stop(__METHOD__);
|
267 |
+
return $count;
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
|
272 |
+
/*
|
273 |
+
* INDEXES FOLLOW.
|
274 |
+
*/
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Запускает процедуры индексации.
|
278 |
+
* Слушает событие Mage::dispatchEvent('iceimport_model_import_after',..)
|
279 |
+
* @param <type> $observer
|
280 |
+
*/
|
281 |
+
public function reindex($observer)
|
282 |
+
{
|
283 |
+
$this->splitProductsFeature();
|
284 |
+
}
|
285 |
+
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Разбивает таблицу icecat_product_feature на таблицы вида icecat_product_feature_%category_feature_id% для каждой фичи.
|
289 |
+
*
|
290 |
+
*/
|
291 |
+
public function splitProductsFeature()
|
292 |
+
{
|
293 |
+
Mage::log(__METHOD__ . " start at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
294 |
+
$featureIds = $this->getProductFeatures4indexig();
|
295 |
+
|
296 |
+
$resource = Mage::getSingleton('core/resource');
|
297 |
+
// $tProudctsFeature = $resource->getTableName("icecat_products_feature");
|
298 |
+
$connection = $this->_getWriteAdapter();
|
299 |
+
|
300 |
+
//удаление таблиц с фичами не используемыми больше для навигации.
|
301 |
+
$tablePattern = $resource->getTableName('stINch_products_feature_');
|
302 |
+
$query = "SHOW TABLES LIKE '%$tablePattern%'";
|
303 |
+
$featureTables = $connection->fetchCol($query);
|
304 |
+
$presentFeatures = array();
|
305 |
+
foreach($featureTables as $t) {
|
306 |
+
if (preg_match("#$tablePattern(\d+)#", $t, $matches)) {
|
307 |
+
$presentFeatures[] = $matches[1];
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
$features2delete = array_diff($presentFeatures, $featureIds);
|
312 |
+
if (count($features2delete)) {
|
313 |
+
foreach ($features2delete as & $drop) {
|
314 |
+
$drop = $tablePattern . $drop;
|
315 |
+
}
|
316 |
+
$dropSql = "DROP TABLE " . implode(',', $features2delete);
|
317 |
+
$connection->exec($dropSql);
|
318 |
+
}
|
319 |
+
//
|
320 |
+
|
321 |
+
//Создание таблиц с фичами используемыми в навигации.
|
322 |
+
$i = 0; $storeId = Mage::app()->getStore()->getId(); $websiteId = Mage::app()->getWebsite()->getId();
|
323 |
+
foreach ($featureIds as $featureId) {
|
324 |
+
$tFeature = $resource->getTableName("stINch_products_feature_$featureId");
|
325 |
+
$query = "DROP TABLE IF EXISTS $tFeature";
|
326 |
+
$connection->exec($query);
|
327 |
+
|
328 |
+
$query = "CREATE TABLE IF NOT EXISTS $tFeature (
|
329 |
+
`entity_id` int(11) default NULL,
|
330 |
+
`feature_id` int(11) NOT NULL,
|
331 |
+
`product_id` int(11) default NULL,
|
332 |
+
`category_feature_id` int(11) default NULL,
|
333 |
+
`value` text,
|
334 |
+
`presentation_value` text,
|
335 |
+
INDEX (`feature_id`),
|
336 |
+
KEY `category_feature_id` (`category_feature_id`)
|
337 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8
|
338 |
+
";
|
339 |
+
$connection->exec($query);
|
340 |
+
|
341 |
+
$query = "TRUNCATE TABLE $tFeature";
|
342 |
+
$connection->exec($query);
|
343 |
+
|
344 |
+
/*$query = "
|
345 |
+
INSERT INTO $tFeature (feature_id, product_id, category_feature_id, value, presentation_value)
|
346 |
+
SELECT feature_id, product_id, category_feature_id, value, presentation_value FROM $tProudctsFeature
|
347 |
+
WHERE category_feature_id = $featureId
|
348 |
+
";*/
|
349 |
+
$query = "
|
350 |
+
REPLACE INTO $tFeature (entity_id,feature_id, product_id, category_feature_id, value, presentation_value)
|
351 |
+
SELECT E.entity_id, RV.category_feature_id,E.entity_id, RV.category_feature_id, RV.text , RV.text
|
352 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." E
|
353 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." PCind
|
354 |
+
ON (E.entity_id = PCind.product_id AND PCind.store_id='{$storeId}' AND PCind.visibility IN(2,4))
|
355 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
356 |
+
ON price_index.entity_id = E.entity_id AND price_index.website_id = '{$websiteId}' AND price_index.customer_group_id = 0
|
357 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." PR
|
358 |
+
ON (PR.store_product_id = E.store_product_id)
|
359 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features')." PF
|
360 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
361 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values')." RV
|
362 |
+
ON (PF.restricted_value_id=RV.restricted_value_id AND RV.category_feature_id= $featureId)
|
363 |
+
GROUP BY E.entity_id;
|
364 |
+
";
|
365 |
+
$connection->exec($query);
|
366 |
+
}
|
367 |
+
Mage::log(__METHOD__ . " end at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Список фич подлежащих индексации.
|
372 |
+
*
|
373 |
+
* @return array
|
374 |
+
*/
|
375 |
+
private function getProductFeatures4indexig()
|
376 |
+
{
|
377 |
+
$connection = $this->_getReadAdapter();
|
378 |
+
|
379 |
+
$tCatFeature = Mage::getSingleton('core/resource')->getTableName('stINch_categories_features');
|
380 |
+
$query = "SELECT category_feature_id FROM $tCatFeature ";
|
381 |
+
|
382 |
+
return $connection->fetchCol($query);
|
383 |
+
}
|
384 |
+
}
|
app/code/local/Bintime/Sinchimport/Model/System/Config/ServerList.php
CHANGED
@@ -1,25 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class provides data for Magento BO
|
4 |
-
* @author malex <malex@bintime.com>
|
5 |
-
*
|
6 |
-
*/
|
7 |
-
class Bintime_Sinchimport_Model_System_Config_ServerList
|
8 |
-
{
|
9 |
-
public function toOptionArray()
|
10 |
-
{
|
11 |
-
$paramsArray = array(
|
12 |
-
'ftp.stockinthechannel.com' => 'UK - ftp.stockinthechannel.com',
|
13 |
-
'ftpus.stockinthechannel.com' => 'USA - ftpus.stockinthechannel.com',
|
14 |
-
'ftp.canalstock.es' => 'Spain - ftp.canalstock.es',
|
15 |
-
'ftp.canalstock.mx' => 'Mexico - ftp.canalstock.mx',
|
16 |
-
'ftp.stockradar.be' => 'Belgium - ftp.stockradar.be',
|
17 |
-
'ftpau.stockinthechannel.com' => 'Australia - ftpau.stockinthechannel.com',
|
18 |
-
'ftpfr.stockinthechannel.com' => 'France - ftpfr.stockinthechannel.com',
|
19 |
-
'ftpit.stockinthechannel.com' => 'Italy - ftpit.stockinthechannel.com',
|
20 |
-
'ftpnl.stockinthechannel.com' => 'Holland - ftpnl.stockinthechannel.com',
|
21 |
-
'ftpde.stockinthechannel.com' => 'Germany - ftpde.stockinthechannel.com',
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
}
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class provides data for Magento BO
|
4 |
+
* @author malex <malex@bintime.com>
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class Bintime_Sinchimport_Model_System_Config_ServerList
|
8 |
+
{
|
9 |
+
public function toOptionArray()
|
10 |
+
{
|
11 |
+
$paramsArray = array(
|
12 |
+
'ftp.stockinthechannel.com' => 'UK - ftp.stockinthechannel.com',
|
13 |
+
'ftpus.stockinthechannel.com' => 'USA - ftpus.stockinthechannel.com',
|
14 |
+
'ftp.canalstock.es' => 'Spain - ftp.canalstock.es',
|
15 |
+
'ftp.canalstock.mx' => 'Mexico - ftp.canalstock.mx',
|
16 |
+
'ftp.stockradar.be' => 'Belgium - ftp.stockradar.be',
|
17 |
+
'ftpau.stockinthechannel.com' => 'Australia - ftpau.stockinthechannel.com',
|
18 |
+
'ftpfr.stockinthechannel.com' => 'France - ftpfr.stockinthechannel.com',
|
19 |
+
'ftpit.stockinthechannel.com' => 'Italy - ftpit.stockinthechannel.com',
|
20 |
+
'ftpnl.stockinthechannel.com' => 'Holland - ftpnl.stockinthechannel.com',
|
21 |
+
'ftpde.stockinthechannel.com' => 'Germany - ftpde.stockinthechannel.com',
|
22 |
+
'ftpdemo.stockinthechannel.com' => 'Demo - ftpdemo.stockinthechannel.com',
|
23 |
+
);
|
24 |
+
return $paramsArray;
|
25 |
+
}
|
26 |
+
}
|
app/code/local/Bintime/Sinchimport/etc/api.xml
CHANGED
@@ -1,34 +1,34 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<api>
|
4 |
-
<resources>
|
5 |
-
<sinchimport_soap translate="title" module="sinchimport">
|
6 |
-
<title>Bintime Sinchimport Soap</title>
|
7 |
-
<model>sinchimport/api</model>
|
8 |
-
<methods>
|
9 |
-
|
10 |
-
<test translate="title" module="sinchimport">
|
11 |
-
<title>Bintime Sinchimport Soap method "test"</title>
|
12 |
-
<method>test</method>
|
13 |
-
</test>
|
14 |
-
|
15 |
-
<run_Full_Import>
|
16 |
-
<title>Bintime Sinchimport Soap method "run_Full_Import"</title>
|
17 |
-
<method>run_full_import</method>
|
18 |
-
</run_Full_Import>
|
19 |
-
|
20 |
-
<run_Price_Stock_Import>
|
21 |
-
<title>Bintime Sinchimport Soap method "run_Price_Stock_Import"</title>
|
22 |
-
<method>run_ps_import</method>
|
23 |
-
</run_Price_Stock_Import>
|
24 |
-
|
25 |
-
<get_Import_Status>
|
26 |
-
<title>Bintime Sinchimport Soap method "get_Import_Status"</title>
|
27 |
-
<method>get_import_status</method>
|
28 |
-
</get_Import_Status>
|
29 |
-
|
30 |
-
</methods>
|
31 |
-
</sinchimport_soap>
|
32 |
-
</resources>
|
33 |
-
</api>
|
34 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api>
|
4 |
+
<resources>
|
5 |
+
<sinchimport_soap translate="title" module="sinchimport">
|
6 |
+
<title>Bintime Sinchimport Soap</title>
|
7 |
+
<model>sinchimport/api</model>
|
8 |
+
<methods>
|
9 |
+
|
10 |
+
<test translate="title" module="sinchimport">
|
11 |
+
<title>Bintime Sinchimport Soap method "test"</title>
|
12 |
+
<method>test</method>
|
13 |
+
</test>
|
14 |
+
|
15 |
+
<run_Full_Import>
|
16 |
+
<title>Bintime Sinchimport Soap method "run_Full_Import"</title>
|
17 |
+
<method>run_full_import</method>
|
18 |
+
</run_Full_Import>
|
19 |
+
|
20 |
+
<run_Price_Stock_Import>
|
21 |
+
<title>Bintime Sinchimport Soap method "run_Price_Stock_Import"</title>
|
22 |
+
<method>run_ps_import</method>
|
23 |
+
</run_Price_Stock_Import>
|
24 |
+
|
25 |
+
<get_Import_Status>
|
26 |
+
<title>Bintime Sinchimport Soap method "get_Import_Status"</title>
|
27 |
+
<method>get_import_status</method>
|
28 |
+
</get_Import_Status>
|
29 |
+
|
30 |
+
</methods>
|
31 |
+
</sinchimport_soap>
|
32 |
+
</resources>
|
33 |
+
</api>
|
34 |
+
</config>
|
app/code/local/Bintime/Sinchimport/etc/config.xml
CHANGED
@@ -1,267 +1,267 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
|
3 |
-
<config>
|
4 |
-
|
5 |
-
<modules>
|
6 |
-
<Bintime_Sinchimport>
|
7 |
-
<version>3.0.4</version>
|
8 |
-
<depends>
|
9 |
-
<!-- no dependencies -->
|
10 |
-
</depends>
|
11 |
-
</Bintime_Sinchimport>
|
12 |
-
</modules>
|
13 |
-
|
14 |
-
<global>
|
15 |
-
<helpers>
|
16 |
-
<sinchimport>
|
17 |
-
<class>Bintime_Sinchimport_Helper</class>
|
18 |
-
</sinchimport>
|
19 |
-
<catalog>
|
20 |
-
<rewrite>
|
21 |
-
<image>Bintime_Sinchimport_Helper_Image</image>
|
22 |
-
</rewrite>
|
23 |
-
</catalog>
|
24 |
-
|
25 |
-
</helpers>
|
26 |
-
<models>
|
27 |
-
<catalog>
|
28 |
-
<rewrite>
|
29 |
-
<product_image>Bintime_Sinchimport_Model_Image</product_image>
|
30 |
-
</rewrite>
|
31 |
-
</catalog>
|
32 |
-
<catalog>
|
33 |
-
<rewrite>
|
34 |
-
<category>Bintime_Sinchimport_Model_Category</category>
|
35 |
-
</rewrite>
|
36 |
-
</catalog>
|
37 |
-
</models>
|
38 |
-
<models>
|
39 |
-
<sinchimport>
|
40 |
-
<class>Bintime_Sinchimport_Model</class>
|
41 |
-
</sinchimport>
|
42 |
-
</models>
|
43 |
-
<blocks>
|
44 |
-
<catalog>
|
45 |
-
<rewrite>
|
46 |
-
<product_compare_list>Bintime_Sinchimport_Block_List</product_compare_list>
|
47 |
-
</rewrite>
|
48 |
-
</catalog>
|
49 |
-
<catalog>
|
50 |
-
<rewrite>
|
51 |
-
<product_view_media>Bintime_Sinchimport_Block_Product_View_Media</product_view_media>
|
52 |
-
</rewrite>
|
53 |
-
</catalog>
|
54 |
-
</blocks>
|
55 |
-
<models>
|
56 |
-
<catalog>
|
57 |
-
<rewrite>
|
58 |
-
<product>Bintime_Sinchimport_Model_Product</product>
|
59 |
-
</rewrite>
|
60 |
-
</catalog>
|
61 |
-
</models>
|
62 |
-
<models>
|
63 |
-
<catalog>
|
64 |
-
<rewrite>
|
65 |
-
<layer_filter_price>Bintime_Sinchimport_Model_Layer_Filter_Price</layer_filter_price>
|
66 |
-
</rewrite>
|
67 |
-
</catalog>
|
68 |
-
</models>
|
69 |
-
|
70 |
-
<resources>
|
71 |
-
<sinchimport_write>
|
72 |
-
<connection><use>core_write</use></connection>
|
73 |
-
</sinchimport_write>
|
74 |
-
<sinchimport_read>
|
75 |
-
<connection><use>core_read</use></connection>
|
76 |
-
</sinchimport_read>
|
77 |
-
|
78 |
-
<sinchimport_setup>
|
79 |
-
<setup>
|
80 |
-
<module>Bintime_Sinchimport</module>
|
81 |
-
<class>Bintime_Sinchimport_Model_Resource_Mysql4_Setup</class>
|
82 |
-
</setup>
|
83 |
-
<connection>
|
84 |
-
<use>core_setup</use>
|
85 |
-
</connection>
|
86 |
-
</sinchimport_setup>
|
87 |
-
|
88 |
-
</resources>
|
89 |
-
<!-- <routers>
|
90 |
-
<catalog>
|
91 |
-
<rewrite>
|
92 |
-
<product>
|
93 |
-
<to>Bintime_Sinchimport/product</to>
|
94 |
-
<override_actions>false</override_actions>
|
95 |
-
<actions>
|
96 |
-
<view><to>Bintime_Sinchimport/product/view</to></view>
|
97 |
-
</actions>
|
98 |
-
</product>
|
99 |
-
</rewrite>
|
100 |
-
</catalog>
|
101 |
-
</routers>
|
102 |
-
-->
|
103 |
-
<blocks>
|
104 |
-
<catalog>
|
105 |
-
<rewrite>
|
106 |
-
<layer_view>Bintime_Sinchimport_Block_Layer_View</layer_view>
|
107 |
-
</rewrite>
|
108 |
-
</catalog>
|
109 |
-
<sinchimport>
|
110 |
-
<class>Bintime_Sinchimport_Block</class>
|
111 |
-
</sinchimport>
|
112 |
-
</blocks>
|
113 |
-
<models>
|
114 |
-
<catalog>
|
115 |
-
<rewrite>
|
116 |
-
<layer>Bintime_Sinchimport_Model_Layer</layer>
|
117 |
-
</rewrite>
|
118 |
-
</catalog>
|
119 |
-
<sinchimport>
|
120 |
-
<class>Bintime_Sinchimport_Model</class>
|
121 |
-
<resourceModel>sinchimport_mysql4</resourceModel>
|
122 |
-
</sinchimport>
|
123 |
-
|
124 |
-
<catalog_resource_eav_mysql4>
|
125 |
-
<rewrite>
|
126 |
-
<layer_filter_price>Bintime_Sinchimport_Model_Resource_Layer_Filter_Price</layer_filter_price>
|
127 |
-
</rewrite>
|
128 |
-
</catalog_resource_eav_mysql4>
|
129 |
-
|
130 |
-
<sinchimport_mysql4>
|
131 |
-
<class>Bintime_Sinchimport_Model_Resource_Mysql4</class>
|
132 |
-
<!-- <entities>
|
133 |
-
<ice_feature><table>icecat_category_feature</table></ice_feature>
|
134 |
-
</entities>
|
135 |
-
-->
|
136 |
-
</sinchimport_mysql4>
|
137 |
-
|
138 |
-
<!-- <sinchimport>
|
139 |
-
<class>Bintime_Icelayered_Block</class>
|
140 |
-
</sinchimport>
|
141 |
-
-->
|
142 |
-
|
143 |
-
</models>
|
144 |
-
<events>
|
145 |
-
<sinchimport_model_import_after>
|
146 |
-
<observers>
|
147 |
-
<sinchimport_reindex>
|
148 |
-
<class>sinchimport/resource_mysql4_layer_filter_feature</class>
|
149 |
-
<method>reindex</method>
|
150 |
-
</sinchimport_reindex>
|
151 |
-
</observers>
|
152 |
-
</sinchimport_model_import_after>
|
153 |
-
</events>
|
154 |
-
|
155 |
-
</global>
|
156 |
-
|
157 |
-
<frontend>
|
158 |
-
<routers>
|
159 |
-
<sinchimport>
|
160 |
-
<use>standard</use>
|
161 |
-
<args>
|
162 |
-
<module>Bintime_Sinchimport</module>
|
163 |
-
<frontName>sinchimport</frontName>
|
164 |
-
</args>
|
165 |
-
</sinchimport>
|
166 |
-
</routers>
|
167 |
-
<layout>
|
168 |
-
<updates>
|
169 |
-
<sinchimport>
|
170 |
-
<file>sinchimport.xml</file>
|
171 |
-
</sinchimport>
|
172 |
-
</updates>
|
173 |
-
</layout>
|
174 |
-
|
175 |
-
</frontend>
|
176 |
-
<admin>
|
177 |
-
<routers>
|
178 |
-
<sinchimport>
|
179 |
-
<use>admin</use>
|
180 |
-
<args>
|
181 |
-
<module>Bintime_Sinchimport</module>
|
182 |
-
<frontName>sinchimport</frontName>
|
183 |
-
</args>
|
184 |
-
</sinchimport>
|
185 |
-
</routers>
|
186 |
-
</admin>
|
187 |
-
|
188 |
-
<adminhtml>
|
189 |
-
<menu>
|
190 |
-
<sinch translate="title">
|
191 |
-
<title>Stock in the Channel</title>
|
192 |
-
<sort_order>200</sort_order>
|
193 |
-
<children>
|
194 |
-
<sinchimport translate="title">
|
195 |
-
<sort_order>10</sort_order>
|
196 |
-
<title>Stock In The Channel Import</title>
|
197 |
-
<action>adminhtml/system_config/edit/section/sinchimport_root</action>
|
198 |
-
</sinchimport>
|
199 |
-
</children>
|
200 |
-
</sinch>
|
201 |
-
</menu>
|
202 |
-
|
203 |
-
<acl>
|
204 |
-
<resources>
|
205 |
-
<admin>
|
206 |
-
<children>
|
207 |
-
<system>
|
208 |
-
<children>
|
209 |
-
<config>
|
210 |
-
<children>
|
211 |
-
<sinchimport_root translate="title" module="customer">
|
212 |
-
<title> Stock In The Channel model powered by Bintime company</title>
|
213 |
-
<sort_order>250</sort_order>
|
214 |
-
</sinchimport_root>
|
215 |
-
</children>
|
216 |
-
</config>
|
217 |
-
</children>
|
218 |
-
</system>
|
219 |
-
</children>
|
220 |
-
</admin>
|
221 |
-
</resources>
|
222 |
-
</acl>
|
223 |
-
<events></events>
|
224 |
-
<translate>
|
225 |
-
<modules>
|
226 |
-
<mage_adminhtml>
|
227 |
-
<files>
|
228 |
-
<sinchimport>Bintime_Sinchimport.csv</sinchimport>
|
229 |
-
</files>
|
230 |
-
</mage_adminhtml>
|
231 |
-
</modules>
|
232 |
-
</translate>
|
233 |
-
|
234 |
-
<layout>
|
235 |
-
<updates>
|
236 |
-
<sinchimport>
|
237 |
-
<file>sinchimport.xml</file>
|
238 |
-
</sinchimport>
|
239 |
-
</updates>
|
240 |
-
</layout>
|
241 |
-
|
242 |
-
</adminhtml>
|
243 |
-
|
244 |
-
<default>
|
245 |
-
<sinchimport_root>
|
246 |
-
<sinch_cron>
|
247 |
-
<sinch_cron_time>8 am</sinch_cron_time>
|
248 |
-
</sinch_cron>
|
249 |
-
</sinchimport_root>
|
250 |
-
</default>
|
251 |
-
<crontab>
|
252 |
-
<jobs>
|
253 |
-
<fullsinchimport>
|
254 |
-
<schedule><cron_expr>0 22 * * 6</cron_expr></schedule>
|
255 |
-
<run><model>sinchimport/sinch::cron_start_full_import</model></run>
|
256 |
-
|
257 |
-
</fullsinchimport>
|
258 |
-
<stockpricesinchimport>
|
259 |
-
|
260 |
-
<schedule><cron_expr>0 8 * * *</cron_expr></schedule>
|
261 |
-
<run><model>sinchimport/sinch::cron_start_stock_price_import</model></run>
|
262 |
-
|
263 |
-
</stockpricesinchimport>
|
264 |
-
</jobs>
|
265 |
-
</crontab>
|
266 |
-
</config>
|
267 |
-
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
|
5 |
+
<modules>
|
6 |
+
<Bintime_Sinchimport>
|
7 |
+
<version>3.0.4</version>
|
8 |
+
<depends>
|
9 |
+
<!-- no dependencies -->
|
10 |
+
</depends>
|
11 |
+
</Bintime_Sinchimport>
|
12 |
+
</modules>
|
13 |
+
|
14 |
+
<global>
|
15 |
+
<helpers>
|
16 |
+
<sinchimport>
|
17 |
+
<class>Bintime_Sinchimport_Helper</class>
|
18 |
+
</sinchimport>
|
19 |
+
<catalog>
|
20 |
+
<rewrite>
|
21 |
+
<image>Bintime_Sinchimport_Helper_Image</image>
|
22 |
+
</rewrite>
|
23 |
+
</catalog>
|
24 |
+
|
25 |
+
</helpers>
|
26 |
+
<models>
|
27 |
+
<catalog>
|
28 |
+
<rewrite>
|
29 |
+
<product_image>Bintime_Sinchimport_Model_Image</product_image>
|
30 |
+
</rewrite>
|
31 |
+
</catalog>
|
32 |
+
<catalog>
|
33 |
+
<rewrite>
|
34 |
+
<category>Bintime_Sinchimport_Model_Category</category>
|
35 |
+
</rewrite>
|
36 |
+
</catalog>
|
37 |
+
</models>
|
38 |
+
<models>
|
39 |
+
<sinchimport>
|
40 |
+
<class>Bintime_Sinchimport_Model</class>
|
41 |
+
</sinchimport>
|
42 |
+
</models>
|
43 |
+
<blocks>
|
44 |
+
<catalog>
|
45 |
+
<rewrite>
|
46 |
+
<product_compare_list>Bintime_Sinchimport_Block_List</product_compare_list>
|
47 |
+
</rewrite>
|
48 |
+
</catalog>
|
49 |
+
<catalog>
|
50 |
+
<rewrite>
|
51 |
+
<product_view_media>Bintime_Sinchimport_Block_Product_View_Media</product_view_media>
|
52 |
+
</rewrite>
|
53 |
+
</catalog>
|
54 |
+
</blocks>
|
55 |
+
<models>
|
56 |
+
<catalog>
|
57 |
+
<rewrite>
|
58 |
+
<product>Bintime_Sinchimport_Model_Product</product>
|
59 |
+
</rewrite>
|
60 |
+
</catalog>
|
61 |
+
</models>
|
62 |
+
<models>
|
63 |
+
<catalog>
|
64 |
+
<rewrite>
|
65 |
+
<layer_filter_price>Bintime_Sinchimport_Model_Layer_Filter_Price</layer_filter_price>
|
66 |
+
</rewrite>
|
67 |
+
</catalog>
|
68 |
+
</models>
|
69 |
+
|
70 |
+
<resources>
|
71 |
+
<sinchimport_write>
|
72 |
+
<connection><use>core_write</use></connection>
|
73 |
+
</sinchimport_write>
|
74 |
+
<sinchimport_read>
|
75 |
+
<connection><use>core_read</use></connection>
|
76 |
+
</sinchimport_read>
|
77 |
+
|
78 |
+
<sinchimport_setup>
|
79 |
+
<setup>
|
80 |
+
<module>Bintime_Sinchimport</module>
|
81 |
+
<class>Bintime_Sinchimport_Model_Resource_Mysql4_Setup</class>
|
82 |
+
</setup>
|
83 |
+
<connection>
|
84 |
+
<use>core_setup</use>
|
85 |
+
</connection>
|
86 |
+
</sinchimport_setup>
|
87 |
+
|
88 |
+
</resources>
|
89 |
+
<!-- <routers>
|
90 |
+
<catalog>
|
91 |
+
<rewrite>
|
92 |
+
<product>
|
93 |
+
<to>Bintime_Sinchimport/product</to>
|
94 |
+
<override_actions>false</override_actions>
|
95 |
+
<actions>
|
96 |
+
<view><to>Bintime_Sinchimport/product/view</to></view>
|
97 |
+
</actions>
|
98 |
+
</product>
|
99 |
+
</rewrite>
|
100 |
+
</catalog>
|
101 |
+
</routers>
|
102 |
+
-->
|
103 |
+
<blocks>
|
104 |
+
<catalog>
|
105 |
+
<rewrite>
|
106 |
+
<layer_view>Bintime_Sinchimport_Block_Layer_View</layer_view>
|
107 |
+
</rewrite>
|
108 |
+
</catalog>
|
109 |
+
<sinchimport>
|
110 |
+
<class>Bintime_Sinchimport_Block</class>
|
111 |
+
</sinchimport>
|
112 |
+
</blocks>
|
113 |
+
<models>
|
114 |
+
<catalog>
|
115 |
+
<rewrite>
|
116 |
+
<layer>Bintime_Sinchimport_Model_Layer</layer>
|
117 |
+
</rewrite>
|
118 |
+
</catalog>
|
119 |
+
<sinchimport>
|
120 |
+
<class>Bintime_Sinchimport_Model</class>
|
121 |
+
<resourceModel>sinchimport_mysql4</resourceModel>
|
122 |
+
</sinchimport>
|
123 |
+
|
124 |
+
<catalog_resource_eav_mysql4>
|
125 |
+
<rewrite>
|
126 |
+
<layer_filter_price>Bintime_Sinchimport_Model_Resource_Layer_Filter_Price</layer_filter_price>
|
127 |
+
</rewrite>
|
128 |
+
</catalog_resource_eav_mysql4>
|
129 |
+
|
130 |
+
<sinchimport_mysql4>
|
131 |
+
<class>Bintime_Sinchimport_Model_Resource_Mysql4</class>
|
132 |
+
<!-- <entities>
|
133 |
+
<ice_feature><table>icecat_category_feature</table></ice_feature>
|
134 |
+
</entities>
|
135 |
+
-->
|
136 |
+
</sinchimport_mysql4>
|
137 |
+
|
138 |
+
<!-- <sinchimport>
|
139 |
+
<class>Bintime_Icelayered_Block</class>
|
140 |
+
</sinchimport>
|
141 |
+
-->
|
142 |
+
|
143 |
+
</models>
|
144 |
+
<events>
|
145 |
+
<sinchimport_model_import_after>
|
146 |
+
<observers>
|
147 |
+
<sinchimport_reindex>
|
148 |
+
<class>sinchimport/resource_mysql4_layer_filter_feature</class>
|
149 |
+
<method>reindex</method>
|
150 |
+
</sinchimport_reindex>
|
151 |
+
</observers>
|
152 |
+
</sinchimport_model_import_after>
|
153 |
+
</events>
|
154 |
+
|
155 |
+
</global>
|
156 |
+
|
157 |
+
<frontend>
|
158 |
+
<routers>
|
159 |
+
<sinchimport>
|
160 |
+
<use>standard</use>
|
161 |
+
<args>
|
162 |
+
<module>Bintime_Sinchimport</module>
|
163 |
+
<frontName>sinchimport</frontName>
|
164 |
+
</args>
|
165 |
+
</sinchimport>
|
166 |
+
</routers>
|
167 |
+
<layout>
|
168 |
+
<updates>
|
169 |
+
<sinchimport>
|
170 |
+
<file>sinchimport.xml</file>
|
171 |
+
</sinchimport>
|
172 |
+
</updates>
|
173 |
+
</layout>
|
174 |
+
|
175 |
+
</frontend>
|
176 |
+
<admin>
|
177 |
+
<routers>
|
178 |
+
<sinchimport>
|
179 |
+
<use>admin</use>
|
180 |
+
<args>
|
181 |
+
<module>Bintime_Sinchimport</module>
|
182 |
+
<frontName>sinchimport</frontName>
|
183 |
+
</args>
|
184 |
+
</sinchimport>
|
185 |
+
</routers>
|
186 |
+
</admin>
|
187 |
+
|
188 |
+
<adminhtml>
|
189 |
+
<menu>
|
190 |
+
<sinch translate="title">
|
191 |
+
<title>Stock in the Channel</title>
|
192 |
+
<sort_order>200</sort_order>
|
193 |
+
<children>
|
194 |
+
<sinchimport translate="title">
|
195 |
+
<sort_order>10</sort_order>
|
196 |
+
<title>Stock In The Channel Import</title>
|
197 |
+
<action>adminhtml/system_config/edit/section/sinchimport_root</action>
|
198 |
+
</sinchimport>
|
199 |
+
</children>
|
200 |
+
</sinch>
|
201 |
+
</menu>
|
202 |
+
|
203 |
+
<acl>
|
204 |
+
<resources>
|
205 |
+
<admin>
|
206 |
+
<children>
|
207 |
+
<system>
|
208 |
+
<children>
|
209 |
+
<config>
|
210 |
+
<children>
|
211 |
+
<sinchimport_root translate="title" module="customer">
|
212 |
+
<title> Stock In The Channel model powered by Bintime company</title>
|
213 |
+
<sort_order>250</sort_order>
|
214 |
+
</sinchimport_root>
|
215 |
+
</children>
|
216 |
+
</config>
|
217 |
+
</children>
|
218 |
+
</system>
|
219 |
+
</children>
|
220 |
+
</admin>
|
221 |
+
</resources>
|
222 |
+
</acl>
|
223 |
+
<events></events>
|
224 |
+
<translate>
|
225 |
+
<modules>
|
226 |
+
<mage_adminhtml>
|
227 |
+
<files>
|
228 |
+
<sinchimport>Bintime_Sinchimport.csv</sinchimport>
|
229 |
+
</files>
|
230 |
+
</mage_adminhtml>
|
231 |
+
</modules>
|
232 |
+
</translate>
|
233 |
+
|
234 |
+
<layout>
|
235 |
+
<updates>
|
236 |
+
<sinchimport>
|
237 |
+
<file>sinchimport.xml</file>
|
238 |
+
</sinchimport>
|
239 |
+
</updates>
|
240 |
+
</layout>
|
241 |
+
|
242 |
+
</adminhtml>
|
243 |
+
|
244 |
+
<default>
|
245 |
+
<sinchimport_root>
|
246 |
+
<sinch_cron>
|
247 |
+
<sinch_cron_time>8 am</sinch_cron_time>
|
248 |
+
</sinch_cron>
|
249 |
+
</sinchimport_root>
|
250 |
+
</default>
|
251 |
+
<crontab>
|
252 |
+
<jobs>
|
253 |
+
<fullsinchimport>
|
254 |
+
<schedule><cron_expr>0 22 * * 6</cron_expr></schedule>
|
255 |
+
<run><model>sinchimport/sinch::cron_start_full_import</model></run>
|
256 |
+
|
257 |
+
</fullsinchimport>
|
258 |
+
<stockpricesinchimport>
|
259 |
+
|
260 |
+
<schedule><cron_expr>0 8 * * *</cron_expr></schedule>
|
261 |
+
<run><model>sinchimport/sinch::cron_start_stock_price_import</model></run>
|
262 |
+
|
263 |
+
</stockpricesinchimport>
|
264 |
+
</jobs>
|
265 |
+
</crontab>
|
266 |
+
</config>
|
267 |
+
|
app/code/local/Bintime/Sinchimport/etc/system.xml
CHANGED
@@ -1,194 +1,194 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<config>
|
3 |
-
<sections>
|
4 |
-
<sinchimport_root translate="label" module="catalog">
|
5 |
-
<class>separator-top</class>
|
6 |
-
<label>Stock in the Channel</label>
|
7 |
-
<tab>catalog</tab>
|
8 |
-
<frontend_type>text</frontend_type>
|
9 |
-
<sort_order>200</sort_order>
|
10 |
-
<show_in_default>1</show_in_default>
|
11 |
-
<show_in_website>1</show_in_website>
|
12 |
-
<show_in_store>1</show_in_store>
|
13 |
-
<groups>
|
14 |
-
<sinch_ftp translate="label">
|
15 |
-
<label>FTP Login Details</label>
|
16 |
-
<frontend_type>text</frontend_type>
|
17 |
-
<comment>Get these details from Stock in the Channel for the pricelist you want this store to use. This is not your Stock in the Channel username and password</comment>
|
18 |
-
<sort_order>50</sort_order>
|
19 |
-
<show_in_default>1</show_in_default>
|
20 |
-
<show_in_website>1</show_in_website>
|
21 |
-
<show_in_store>1</show_in_store>
|
22 |
-
<fields>
|
23 |
-
<ftp_server translate="label">
|
24 |
-
<label>FTP Server</label>
|
25 |
-
<frontend_type>select</frontend_type>
|
26 |
-
<source_model>sinchimport/system_config_ServerList</source_model>
|
27 |
-
<sort_order>10</sort_order>
|
28 |
-
<show_in_default>1</show_in_default>
|
29 |
-
<show_in_website>1</show_in_website>
|
30 |
-
<show_in_store>1</show_in_store>
|
31 |
-
</ftp_server>
|
32 |
-
<login translate="label">
|
33 |
-
<label>FTP User Name</label>
|
34 |
-
<frontend_type>text</frontend_type>
|
35 |
-
<sort_order>15</sort_order>
|
36 |
-
<show_in_default>1</show_in_default>
|
37 |
-
<show_in_website>1</show_in_website>
|
38 |
-
<show_in_store>1</show_in_store>
|
39 |
-
</login>
|
40 |
-
<password translate="label">
|
41 |
-
<label>FTP Password</label>
|
42 |
-
<frontend_type>text</frontend_type>
|
43 |
-
<sort_order>20</sort_order>
|
44 |
-
<show_in_default>1</show_in_default>
|
45 |
-
<show_in_website>1</show_in_website>
|
46 |
-
<show_in_store>1</show_in_store>
|
47 |
-
</password>
|
48 |
-
<!--
|
49 |
-
<field_terminated_char>
|
50 |
-
<label>Field terminated char</label>
|
51 |
-
<frontend_type>text</frontend_type>
|
52 |
-
<sort_order>30</sort_order>
|
53 |
-
<show_in_default>1</show_in_default>
|
54 |
-
<show_in_website>1</show_in_website>
|
55 |
-
<show_in_store>1</show_in_store>
|
56 |
-
</field_terminated_char>
|
57 |
-
-->
|
58 |
-
<replace_category>
|
59 |
-
<label>Merge or Overwrite Categories</label>
|
60 |
-
<frontend_type>select</frontend_type>
|
61 |
-
<source_model>sinchimport/system_config_CatRewrite</source_model>
|
62 |
-
<sort_order>30</sort_order>
|
63 |
-
<show_in_default>1</show_in_default>
|
64 |
-
<show_in_website>1</show_in_website>
|
65 |
-
<show_in_store>1</show_in_store>
|
66 |
-
</replace_category>
|
67 |
-
<replace_products>
|
68 |
-
<label>Merge or Overwrite Products</label>
|
69 |
-
<frontend_type>select</frontend_type>
|
70 |
-
<source_model>sinchimport/system_config_ProdRewrite</source_model>
|
71 |
-
<sort_order>40</sort_order>
|
72 |
-
<show_in_default>1</show_in_default>
|
73 |
-
<show_in_website>1</show_in_website>
|
74 |
-
<show_in_store>1</show_in_store>
|
75 |
-
</replace_products>
|
76 |
-
<!--
|
77 |
-
<price_breaks translate="label">
|
78 |
-
<label>Inser price breaks (insert ranges like 0-10; 10-100; etc.)</label>
|
79 |
-
<frontend_type>textarea</frontend_type>
|
80 |
-
<sort_order>40</sort_order>
|
81 |
-
<show_in_default>1</show_in_default>
|
82 |
-
<show_in_website>1</show_in_website>
|
83 |
-
<show_in_store>1</show_in_store>
|
84 |
-
</price_breaks>
|
85 |
-
-->
|
86 |
-
</fields>
|
87 |
-
</sinch_ftp>
|
88 |
-
<!--
|
89 |
-
<sinch_cron translate="label">
|
90 |
-
<label>Schedule Import Time</label>
|
91 |
-
<frontend_type>text</frontend_type>
|
92 |
-
<comment>Choose the time you want the file to be imported to your Magento store, bear in mind some distributors do not publish their days prices until quite late, so set 8 AM as the earliest</comment>
|
93 |
-
<sort_order>100</sort_order>
|
94 |
-
<show_in_default>1</show_in_default>
|
95 |
-
<show_in_website>1</show_in_website>
|
96 |
-
<show_in_store>1</show_in_store>
|
97 |
-
<fields>
|
98 |
-
<sinch_cron_time translate="label">
|
99 |
-
<label>Schedule Import Time</label>
|
100 |
-
<frontend_type>select</frontend_type>
|
101 |
-
<source_model>sinchimport/system_config_subscription</source_model>
|
102 |
-
<sort_order>10</sort_order>
|
103 |
-
<show_in_default>1</show_in_default>
|
104 |
-
<show_in_website>1</show_in_website>
|
105 |
-
<show_in_store>1</show_in_store>
|
106 |
-
</sinch_cron_time>
|
107 |
-
</fields>
|
108 |
-
</sinch_cron>
|
109 |
-
-->
|
110 |
-
<sinch_import_fullstatus translate="label">
|
111 |
-
<label>Import Full Catalogue</label>
|
112 |
-
<frontend_type>text</frontend_type>
|
113 |
-
<comment>An import of 100000 products will take approximately 1 hour.Larger catalogues will take substantially longer.</comment>
|
114 |
-
<sort_order>150</sort_order>
|
115 |
-
<show_in_default>1</show_in_default>
|
116 |
-
<show_in_website>1</show_in_website>
|
117 |
-
<show_in_store>1</show_in_store>
|
118 |
-
<fields>
|
119 |
-
<start_sinch_import translate="label">
|
120 |
-
<frontend_type>button</frontend_type>
|
121 |
-
<frontend_model>sinchimport/startimportbutton</frontend_model>
|
122 |
-
<sort_order>4</sort_order>
|
123 |
-
<show_in_default>1</show_in_default>
|
124 |
-
<show_in_website>0</show_in_website>
|
125 |
-
<show_in_store>0</show_in_store>
|
126 |
-
</start_sinch_import>
|
127 |
-
</fields>
|
128 |
-
</sinch_import_fullstatus>
|
129 |
-
<sinch_import_stockpricestatus translate="label">
|
130 |
-
<label>Import Stock & Prices</label>
|
131 |
-
<frontend_type>text</frontend_type>
|
132 |
-
<comment>This will import stock and prices ONLY. This process should not take longer 5 minutes.</comment>
|
133 |
-
<sort_order>160</sort_order>
|
134 |
-
<show_in_default>1</show_in_default>
|
135 |
-
<show_in_website>1</show_in_website>
|
136 |
-
<show_in_store>1</show_in_store>
|
137 |
-
<fields>
|
138 |
-
<start_sinch_import translate="label">
|
139 |
-
<frontend_type>button</frontend_type>
|
140 |
-
<frontend_model>sinchimport/startstockpriceimportbutton</frontend_model>
|
141 |
-
<sort_order>4</sort_order>
|
142 |
-
<show_in_default>1</show_in_default>
|
143 |
-
<show_in_website>0</show_in_website>
|
144 |
-
<show_in_store>0</show_in_store>
|
145 |
-
</start_sinch_import>
|
146 |
-
</fields>
|
147 |
-
</sinch_import_stockpricestatus>
|
148 |
-
|
149 |
-
<sinch_import_history>
|
150 |
-
<label>Import History</label>
|
151 |
-
<frontend_type>text</frontend_type>
|
152 |
-
<comment></comment>
|
153 |
-
<sort_order>170</sort_order>
|
154 |
-
<show_in_default>1</show_in_default>
|
155 |
-
<show_in_website>1</show_in_website>
|
156 |
-
<show_in_store>1</show_in_store>
|
157 |
-
<fields>
|
158 |
-
<sinch_import_hist translate="label">
|
159 |
-
<frontend_type>button</frontend_type>
|
160 |
-
<frontend_model>sinchimport/importhistory</frontend_model>
|
161 |
-
<sort_order>4</sort_order>
|
162 |
-
<show_in_default>1</show_in_default>
|
163 |
-
<show_in_website>0</show_in_website>
|
164 |
-
<show_in_store>0</show_in_store>
|
165 |
-
</sinch_import_hist>
|
166 |
-
</fields>
|
167 |
-
</sinch_import_history>
|
168 |
-
|
169 |
-
|
170 |
-
<sinch_import_environment>
|
171 |
-
<label>Check Server Configuration</label>
|
172 |
-
<frontend_type>text</frontend_type>
|
173 |
-
<comment>In order for this extension to work, your server needs to be configured in a particular way and have sufficient memory.</comment>
|
174 |
-
<sort_order>20</sort_order>
|
175 |
-
<show_in_default>1</show_in_default>
|
176 |
-
<show_in_website>1</show_in_website>
|
177 |
-
<show_in_store>1</show_in_store>
|
178 |
-
<fields>
|
179 |
-
<sinch_import_env translate="label">
|
180 |
-
<!--label>Your Stock In The Channel Environment Check Summary</label-->
|
181 |
-
<frontend_model>sinchimport/importenvironment</frontend_model>
|
182 |
-
<sort_order>4</sort_order>
|
183 |
-
<show_in_default>1</show_in_default>
|
184 |
-
<show_in_website>1</show_in_website>
|
185 |
-
<show_in_store>1</show_in_store>
|
186 |
-
</sinch_import_env>
|
187 |
-
</fields>
|
188 |
-
</sinch_import_environment>
|
189 |
-
|
190 |
-
|
191 |
-
</groups>
|
192 |
-
</sinchimport_root>
|
193 |
-
</sections>
|
194 |
-
</config>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<sinchimport_root translate="label" module="catalog">
|
5 |
+
<class>separator-top</class>
|
6 |
+
<label>Stock in the Channel</label>
|
7 |
+
<tab>catalog</tab>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>200</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<groups>
|
14 |
+
<sinch_ftp translate="label">
|
15 |
+
<label>FTP Login Details</label>
|
16 |
+
<frontend_type>text</frontend_type>
|
17 |
+
<comment>Get these details from Stock in the Channel for the pricelist you want this store to use. This is not your Stock in the Channel username and password</comment>
|
18 |
+
<sort_order>50</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>1</show_in_store>
|
22 |
+
<fields>
|
23 |
+
<ftp_server translate="label">
|
24 |
+
<label>FTP Server</label>
|
25 |
+
<frontend_type>select</frontend_type>
|
26 |
+
<source_model>sinchimport/system_config_ServerList</source_model>
|
27 |
+
<sort_order>10</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
</ftp_server>
|
32 |
+
<login translate="label">
|
33 |
+
<label>FTP User Name</label>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>15</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
</login>
|
40 |
+
<password translate="label">
|
41 |
+
<label>FTP Password</label>
|
42 |
+
<frontend_type>text</frontend_type>
|
43 |
+
<sort_order>20</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
</password>
|
48 |
+
<!--
|
49 |
+
<field_terminated_char>
|
50 |
+
<label>Field terminated char</label>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<sort_order>30</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
</field_terminated_char>
|
57 |
+
-->
|
58 |
+
<replace_category>
|
59 |
+
<label>Merge or Overwrite Categories</label>
|
60 |
+
<frontend_type>select</frontend_type>
|
61 |
+
<source_model>sinchimport/system_config_CatRewrite</source_model>
|
62 |
+
<sort_order>30</sort_order>
|
63 |
+
<show_in_default>1</show_in_default>
|
64 |
+
<show_in_website>1</show_in_website>
|
65 |
+
<show_in_store>1</show_in_store>
|
66 |
+
</replace_category>
|
67 |
+
<replace_products>
|
68 |
+
<label>Merge or Overwrite Products</label>
|
69 |
+
<frontend_type>select</frontend_type>
|
70 |
+
<source_model>sinchimport/system_config_ProdRewrite</source_model>
|
71 |
+
<sort_order>40</sort_order>
|
72 |
+
<show_in_default>1</show_in_default>
|
73 |
+
<show_in_website>1</show_in_website>
|
74 |
+
<show_in_store>1</show_in_store>
|
75 |
+
</replace_products>
|
76 |
+
<!--
|
77 |
+
<price_breaks translate="label">
|
78 |
+
<label>Inser price breaks (insert ranges like 0-10; 10-100; etc.)</label>
|
79 |
+
<frontend_type>textarea</frontend_type>
|
80 |
+
<sort_order>40</sort_order>
|
81 |
+
<show_in_default>1</show_in_default>
|
82 |
+
<show_in_website>1</show_in_website>
|
83 |
+
<show_in_store>1</show_in_store>
|
84 |
+
</price_breaks>
|
85 |
+
-->
|
86 |
+
</fields>
|
87 |
+
</sinch_ftp>
|
88 |
+
<!--
|
89 |
+
<sinch_cron translate="label">
|
90 |
+
<label>Schedule Import Time</label>
|
91 |
+
<frontend_type>text</frontend_type>
|
92 |
+
<comment>Choose the time you want the file to be imported to your Magento store, bear in mind some distributors do not publish their days prices until quite late, so set 8 AM as the earliest</comment>
|
93 |
+
<sort_order>100</sort_order>
|
94 |
+
<show_in_default>1</show_in_default>
|
95 |
+
<show_in_website>1</show_in_website>
|
96 |
+
<show_in_store>1</show_in_store>
|
97 |
+
<fields>
|
98 |
+
<sinch_cron_time translate="label">
|
99 |
+
<label>Schedule Import Time</label>
|
100 |
+
<frontend_type>select</frontend_type>
|
101 |
+
<source_model>sinchimport/system_config_subscription</source_model>
|
102 |
+
<sort_order>10</sort_order>
|
103 |
+
<show_in_default>1</show_in_default>
|
104 |
+
<show_in_website>1</show_in_website>
|
105 |
+
<show_in_store>1</show_in_store>
|
106 |
+
</sinch_cron_time>
|
107 |
+
</fields>
|
108 |
+
</sinch_cron>
|
109 |
+
-->
|
110 |
+
<sinch_import_fullstatus translate="label">
|
111 |
+
<label>Import Full Catalogue</label>
|
112 |
+
<frontend_type>text</frontend_type>
|
113 |
+
<comment>An import of 100000 products will take approximately 1 hour.Larger catalogues will take substantially longer.</comment>
|
114 |
+
<sort_order>150</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>1</show_in_website>
|
117 |
+
<show_in_store>1</show_in_store>
|
118 |
+
<fields>
|
119 |
+
<start_sinch_import translate="label">
|
120 |
+
<frontend_type>button</frontend_type>
|
121 |
+
<frontend_model>sinchimport/startimportbutton</frontend_model>
|
122 |
+
<sort_order>4</sort_order>
|
123 |
+
<show_in_default>1</show_in_default>
|
124 |
+
<show_in_website>0</show_in_website>
|
125 |
+
<show_in_store>0</show_in_store>
|
126 |
+
</start_sinch_import>
|
127 |
+
</fields>
|
128 |
+
</sinch_import_fullstatus>
|
129 |
+
<sinch_import_stockpricestatus translate="label">
|
130 |
+
<label>Import Stock & Prices</label>
|
131 |
+
<frontend_type>text</frontend_type>
|
132 |
+
<comment>This will import stock and prices ONLY. This process should not take longer 5 minutes.</comment>
|
133 |
+
<sort_order>160</sort_order>
|
134 |
+
<show_in_default>1</show_in_default>
|
135 |
+
<show_in_website>1</show_in_website>
|
136 |
+
<show_in_store>1</show_in_store>
|
137 |
+
<fields>
|
138 |
+
<start_sinch_import translate="label">
|
139 |
+
<frontend_type>button</frontend_type>
|
140 |
+
<frontend_model>sinchimport/startstockpriceimportbutton</frontend_model>
|
141 |
+
<sort_order>4</sort_order>
|
142 |
+
<show_in_default>1</show_in_default>
|
143 |
+
<show_in_website>0</show_in_website>
|
144 |
+
<show_in_store>0</show_in_store>
|
145 |
+
</start_sinch_import>
|
146 |
+
</fields>
|
147 |
+
</sinch_import_stockpricestatus>
|
148 |
+
|
149 |
+
<sinch_import_history>
|
150 |
+
<label>Import History</label>
|
151 |
+
<frontend_type>text</frontend_type>
|
152 |
+
<comment></comment>
|
153 |
+
<sort_order>170</sort_order>
|
154 |
+
<show_in_default>1</show_in_default>
|
155 |
+
<show_in_website>1</show_in_website>
|
156 |
+
<show_in_store>1</show_in_store>
|
157 |
+
<fields>
|
158 |
+
<sinch_import_hist translate="label">
|
159 |
+
<frontend_type>button</frontend_type>
|
160 |
+
<frontend_model>sinchimport/importhistory</frontend_model>
|
161 |
+
<sort_order>4</sort_order>
|
162 |
+
<show_in_default>1</show_in_default>
|
163 |
+
<show_in_website>0</show_in_website>
|
164 |
+
<show_in_store>0</show_in_store>
|
165 |
+
</sinch_import_hist>
|
166 |
+
</fields>
|
167 |
+
</sinch_import_history>
|
168 |
+
|
169 |
+
|
170 |
+
<sinch_import_environment>
|
171 |
+
<label>Check Server Configuration</label>
|
172 |
+
<frontend_type>text</frontend_type>
|
173 |
+
<comment>In order for this extension to work, your server needs to be configured in a particular way and have sufficient memory.</comment>
|
174 |
+
<sort_order>20</sort_order>
|
175 |
+
<show_in_default>1</show_in_default>
|
176 |
+
<show_in_website>1</show_in_website>
|
177 |
+
<show_in_store>1</show_in_store>
|
178 |
+
<fields>
|
179 |
+
<sinch_import_env translate="label">
|
180 |
+
<!--label>Your Stock In The Channel Environment Check Summary</label-->
|
181 |
+
<frontend_model>sinchimport/importenvironment</frontend_model>
|
182 |
+
<sort_order>4</sort_order>
|
183 |
+
<show_in_default>1</show_in_default>
|
184 |
+
<show_in_website>1</show_in_website>
|
185 |
+
<show_in_store>1</show_in_store>
|
186 |
+
</sinch_import_env>
|
187 |
+
</fields>
|
188 |
+
</sinch_import_environment>
|
189 |
+
|
190 |
+
|
191 |
+
</groups>
|
192 |
+
</sinchimport_root>
|
193 |
+
</sections>
|
194 |
+
</config>
|
app/code/local/Bintime/Sinchimport/sinch_import_start_ajax.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
<?php
|
2 |
-
$baseDir = dirname(__FILE__);
|
3 |
-
require $baseDir . '/../../../../../app/Mage.php';
|
4 |
-
|
5 |
-
Mage::app();
|
6 |
-
|
7 |
-
$import=Mage::getModel('sinchimport/sinch');
|
8 |
-
|
9 |
-
$import->run_sinch_import();
|
10 |
-
|
11 |
-
$import->addImportStatus('Finish import', 1);
|
12 |
-
|
13 |
-
?>
|
1 |
+
<?php
|
2 |
+
$baseDir = dirname(__FILE__);
|
3 |
+
require $baseDir . '/../../../../../app/Mage.php';
|
4 |
+
|
5 |
+
Mage::app();
|
6 |
+
|
7 |
+
$import=Mage::getModel('sinchimport/sinch');
|
8 |
+
|
9 |
+
$import->run_sinch_import();
|
10 |
+
|
11 |
+
$import->addImportStatus('Finish import', 1);
|
12 |
+
|
13 |
+
?>
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/filter_sinch_products_s.sql
CHANGED
@@ -1,207 +1,207 @@
|
|
1 |
-
DROP PROCEDURE IF EXISTS `filter_sinch_products_s`;
|
2 |
-
delimiter =/=
|
3 |
-
|
4 |
-
CREATE PROCEDURE `filter_sinch_products_s`(
|
5 |
-
IN arg_table INT,
|
6 |
-
IN arg_category_id INT,
|
7 |
-
IN arg_image INT,
|
8 |
-
IN arg_category_feature INT,
|
9 |
-
IN arg_least INT,
|
10 |
-
IN arg_greatest INT
|
11 |
-
)
|
12 |
-
BEGIN
|
13 |
-
DROP TABLE IF EXISTS `tmp_result`;
|
14 |
-
|
15 |
-
CREATE TEMPORARY TABLE `tmp_result`(
|
16 |
-
`entity_id` int(10) unsigned,
|
17 |
-
`category_id` int(10) unsigned,
|
18 |
-
`product_id` int,
|
19 |
-
`sinch_category_id` int,
|
20 |
-
`name` varchar(255),
|
21 |
-
`image` varchar(255),
|
22 |
-
`supplier_id` int,
|
23 |
-
`category_feature_id` int,
|
24 |
-
`feature_id` int,
|
25 |
-
`feature_name` varchar(255),
|
26 |
-
`feature_value` text
|
27 |
-
);
|
28 |
-
|
29 |
-
|
30 |
-
IF arg_image = 1 THEN
|
31 |
-
INSERT INTO `tmp_result` (
|
32 |
-
entity_id,
|
33 |
-
category_id,
|
34 |
-
product_id,
|
35 |
-
sinch_category_id,
|
36 |
-
`name`,
|
37 |
-
`image`,
|
38 |
-
supplier_id,
|
39 |
-
category_feature_id,
|
40 |
-
feature_id,
|
41 |
-
feature_name,
|
42 |
-
feature_value
|
43 |
-
)(
|
44 |
-
SELECT
|
45 |
-
E.entity_id,
|
46 |
-
PCind.category_id,
|
47 |
-
E.entity_id,
|
48 |
-
PCind.category_id as `sinch_category`,
|
49 |
-
PR.`product_name`,
|
50 |
-
PR.main_image_url,
|
51 |
-
PR.sinch_manufacturer_id,
|
52 |
-
CF.category_feature_id,
|
53 |
-
CF.category_feature_id,
|
54 |
-
CF.`feature_name`,
|
55 |
-
RV.`text`
|
56 |
-
FROM catalog_product_entity E
|
57 |
-
INNER JOIN catalog_category_product_index PCind
|
58 |
-
ON (E.entity_id = PCind.product_id)
|
59 |
-
INNER JOIN stINch_categories_mapping scm
|
60 |
-
ON PCind.category_id=scm.shop_entity_id
|
61 |
-
INNER JOIN stINch_categories_features CF
|
62 |
-
ON (scm.store_category_id=CF.store_category_id)
|
63 |
-
INNER JOIN stINch_products PR
|
64 |
-
ON (PR.store_product_id = E.store_product_id)
|
65 |
-
INNER JOIN stINch_product_features PF
|
66 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
67 |
-
INNER JOIN stINch_restricted_values RV
|
68 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
69 |
-
WHERE
|
70 |
-
scm.shop_entity_id = arg_category_id
|
71 |
-
AND PR.main_image_url <> ''
|
72 |
-
);
|
73 |
-
|
74 |
-
ELSE
|
75 |
-
|
76 |
-
INSERT INTO `tmp_result` (
|
77 |
-
entity_id,
|
78 |
-
category_id,
|
79 |
-
product_id,
|
80 |
-
sinch_category_id,
|
81 |
-
`name`,
|
82 |
-
`image`,
|
83 |
-
supplier_id,
|
84 |
-
category_feature_id,
|
85 |
-
feature_id,
|
86 |
-
feature_name,
|
87 |
-
feature_value
|
88 |
-
)(
|
89 |
-
SELECT
|
90 |
-
E.entity_id,
|
91 |
-
PCind.category_id,
|
92 |
-
E.entity_id,
|
93 |
-
PCind.category_id as `sinch_category`,
|
94 |
-
PR.`product_name`,
|
95 |
-
PR.main_image_url,
|
96 |
-
PR.sinch_manufacturer_id,
|
97 |
-
CF.category_feature_id,
|
98 |
-
CF.category_feature_id,
|
99 |
-
CF.`feature_name`,
|
100 |
-
RV.`text`
|
101 |
-
FROM catalog_product_entity E
|
102 |
-
INNER JOIN catalog_category_product_index PCind
|
103 |
-
ON (E.entity_id = PCind.product_id)
|
104 |
-
INNER JOIN stINch_categories_mapping scm
|
105 |
-
ON PCind.category_id=scm.shop_entity_id
|
106 |
-
INNER JOIN stINch_categories_features CF
|
107 |
-
ON (scm.store_category_id=CF.store_category_id)
|
108 |
-
INNER JOIN stINch_products PR
|
109 |
-
ON (PR.store_product_id = E.store_product_id)
|
110 |
-
INNER JOIN stINch_product_features PF
|
111 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
112 |
-
INNER JOIN stINch_restricted_values RV
|
113 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
114 |
-
WHERE
|
115 |
-
scm.shop_entity_id = arg_category_id
|
116 |
-
|
117 |
-
);
|
118 |
-
|
119 |
-
END IF;
|
120 |
-
|
121 |
-
IF (SELECT COUNT(*) FROM FilterListOfFeatures) > 0 THEN
|
122 |
-
SET @query = CONCAT('
|
123 |
-
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
124 |
-
entity_id,
|
125 |
-
category_id,
|
126 |
-
product_id,
|
127 |
-
sinch_category_id,
|
128 |
-
`name`,
|
129 |
-
`image`,
|
130 |
-
supplier_id,
|
131 |
-
category_feature_id,
|
132 |
-
feature_id,
|
133 |
-
feature_name,
|
134 |
-
feature_value
|
135 |
-
)(
|
136 |
-
SELECT
|
137 |
-
TR.entity_id,
|
138 |
-
TR.category_id,
|
139 |
-
TR.product_id,
|
140 |
-
TR.sinch_category_id,
|
141 |
-
TR.`name`,
|
142 |
-
TR.`image`,
|
143 |
-
TR.supplier_id,
|
144 |
-
TR.category_feature_id,
|
145 |
-
TR.feature_id,
|
146 |
-
TR.feature_name,
|
147 |
-
TR.feature_value
|
148 |
-
FROM `tmp_result` AS TR
|
149 |
-
INNER JOIN `FilterListOfFeatures` AS LF
|
150 |
-
ON (TR.category_feature_id = LF.category_feature_id)
|
151 |
-
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
152 |
-
)
|
153 |
-
');
|
154 |
-
|
155 |
-
ELSE
|
156 |
-
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
157 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
158 |
-
ELSE
|
159 |
-
IF arg_least IS null THEN
|
160 |
-
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
161 |
-
ELSE
|
162 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
163 |
-
END IF;
|
164 |
-
END IF;
|
165 |
-
|
166 |
-
SET @query = CONCAT('
|
167 |
-
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
168 |
-
entity_id,
|
169 |
-
category_id,
|
170 |
-
product_id,
|
171 |
-
sinch_category_id,
|
172 |
-
`name`,
|
173 |
-
`image`,
|
174 |
-
supplier_id,
|
175 |
-
category_feature_id,
|
176 |
-
feature_id,
|
177 |
-
feature_name,
|
178 |
-
feature_value
|
179 |
-
)(
|
180 |
-
SELECT
|
181 |
-
TR.entity_id,
|
182 |
-
TR.category_id,
|
183 |
-
TR.product_id,
|
184 |
-
TR.sinch_category_id,
|
185 |
-
TR.`name`,
|
186 |
-
TR.`image`,
|
187 |
-
TR.supplier_id,
|
188 |
-
TR.category_feature_id,
|
189 |
-
TR.feature_id,
|
190 |
-
TR.feature_name,
|
191 |
-
TR.feature_value
|
192 |
-
FROM `tmp_result` AS TR
|
193 |
-
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
194 |
-
@where,
|
195 |
-
'GROUP BY entity_id
|
196 |
-
)
|
197 |
-
');
|
198 |
-
|
199 |
-
END IF;
|
200 |
-
|
201 |
-
PREPARE myquery FROM @query;
|
202 |
-
EXECUTE myquery;
|
203 |
-
DROP PREPARE myquery;
|
204 |
-
|
205 |
-
END=/=
|
206 |
-
|
207 |
-
delimiter ;
|
1 |
+
DROP PROCEDURE IF EXISTS `filter_sinch_products_s`;
|
2 |
+
delimiter =/=
|
3 |
+
|
4 |
+
CREATE PROCEDURE `filter_sinch_products_s`(
|
5 |
+
IN arg_table INT,
|
6 |
+
IN arg_category_id INT,
|
7 |
+
IN arg_image INT,
|
8 |
+
IN arg_category_feature INT,
|
9 |
+
IN arg_least INT,
|
10 |
+
IN arg_greatest INT
|
11 |
+
)
|
12 |
+
BEGIN
|
13 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
14 |
+
|
15 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
16 |
+
`entity_id` int(10) unsigned,
|
17 |
+
`category_id` int(10) unsigned,
|
18 |
+
`product_id` int,
|
19 |
+
`sinch_category_id` int,
|
20 |
+
`name` varchar(255),
|
21 |
+
`image` varchar(255),
|
22 |
+
`supplier_id` int,
|
23 |
+
`category_feature_id` int,
|
24 |
+
`feature_id` int,
|
25 |
+
`feature_name` varchar(255),
|
26 |
+
`feature_value` text
|
27 |
+
);
|
28 |
+
|
29 |
+
|
30 |
+
IF arg_image = 1 THEN
|
31 |
+
INSERT INTO `tmp_result` (
|
32 |
+
entity_id,
|
33 |
+
category_id,
|
34 |
+
product_id,
|
35 |
+
sinch_category_id,
|
36 |
+
`name`,
|
37 |
+
`image`,
|
38 |
+
supplier_id,
|
39 |
+
category_feature_id,
|
40 |
+
feature_id,
|
41 |
+
feature_name,
|
42 |
+
feature_value
|
43 |
+
)(
|
44 |
+
SELECT
|
45 |
+
E.entity_id,
|
46 |
+
PCind.category_id,
|
47 |
+
E.entity_id,
|
48 |
+
PCind.category_id as `sinch_category`,
|
49 |
+
PR.`product_name`,
|
50 |
+
PR.main_image_url,
|
51 |
+
PR.sinch_manufacturer_id,
|
52 |
+
CF.category_feature_id,
|
53 |
+
CF.category_feature_id,
|
54 |
+
CF.`feature_name`,
|
55 |
+
RV.`text`
|
56 |
+
FROM catalog_product_entity E
|
57 |
+
INNER JOIN catalog_category_product_index PCind
|
58 |
+
ON (E.entity_id = PCind.product_id)
|
59 |
+
INNER JOIN stINch_categories_mapping scm
|
60 |
+
ON PCind.category_id=scm.shop_entity_id
|
61 |
+
INNER JOIN stINch_categories_features CF
|
62 |
+
ON (scm.store_category_id=CF.store_category_id)
|
63 |
+
INNER JOIN stINch_products PR
|
64 |
+
ON (PR.store_product_id = E.store_product_id)
|
65 |
+
INNER JOIN stINch_product_features PF
|
66 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
67 |
+
INNER JOIN stINch_restricted_values RV
|
68 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
69 |
+
WHERE
|
70 |
+
scm.shop_entity_id = arg_category_id
|
71 |
+
AND PR.main_image_url <> ''
|
72 |
+
);
|
73 |
+
|
74 |
+
ELSE
|
75 |
+
|
76 |
+
INSERT INTO `tmp_result` (
|
77 |
+
entity_id,
|
78 |
+
category_id,
|
79 |
+
product_id,
|
80 |
+
sinch_category_id,
|
81 |
+
`name`,
|
82 |
+
`image`,
|
83 |
+
supplier_id,
|
84 |
+
category_feature_id,
|
85 |
+
feature_id,
|
86 |
+
feature_name,
|
87 |
+
feature_value
|
88 |
+
)(
|
89 |
+
SELECT
|
90 |
+
E.entity_id,
|
91 |
+
PCind.category_id,
|
92 |
+
E.entity_id,
|
93 |
+
PCind.category_id as `sinch_category`,
|
94 |
+
PR.`product_name`,
|
95 |
+
PR.main_image_url,
|
96 |
+
PR.sinch_manufacturer_id,
|
97 |
+
CF.category_feature_id,
|
98 |
+
CF.category_feature_id,
|
99 |
+
CF.`feature_name`,
|
100 |
+
RV.`text`
|
101 |
+
FROM catalog_product_entity E
|
102 |
+
INNER JOIN catalog_category_product_index PCind
|
103 |
+
ON (E.entity_id = PCind.product_id)
|
104 |
+
INNER JOIN stINch_categories_mapping scm
|
105 |
+
ON PCind.category_id=scm.shop_entity_id
|
106 |
+
INNER JOIN stINch_categories_features CF
|
107 |
+
ON (scm.store_category_id=CF.store_category_id)
|
108 |
+
INNER JOIN stINch_products PR
|
109 |
+
ON (PR.store_product_id = E.store_product_id)
|
110 |
+
INNER JOIN stINch_product_features PF
|
111 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
112 |
+
INNER JOIN stINch_restricted_values RV
|
113 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
114 |
+
WHERE
|
115 |
+
scm.shop_entity_id = arg_category_id
|
116 |
+
|
117 |
+
);
|
118 |
+
|
119 |
+
END IF;
|
120 |
+
|
121 |
+
IF (SELECT COUNT(*) FROM FilterListOfFeatures) > 0 THEN
|
122 |
+
SET @query = CONCAT('
|
123 |
+
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
124 |
+
entity_id,
|
125 |
+
category_id,
|
126 |
+
product_id,
|
127 |
+
sinch_category_id,
|
128 |
+
`name`,
|
129 |
+
`image`,
|
130 |
+
supplier_id,
|
131 |
+
category_feature_id,
|
132 |
+
feature_id,
|
133 |
+
feature_name,
|
134 |
+
feature_value
|
135 |
+
)(
|
136 |
+
SELECT
|
137 |
+
TR.entity_id,
|
138 |
+
TR.category_id,
|
139 |
+
TR.product_id,
|
140 |
+
TR.sinch_category_id,
|
141 |
+
TR.`name`,
|
142 |
+
TR.`image`,
|
143 |
+
TR.supplier_id,
|
144 |
+
TR.category_feature_id,
|
145 |
+
TR.feature_id,
|
146 |
+
TR.feature_name,
|
147 |
+
TR.feature_value
|
148 |
+
FROM `tmp_result` AS TR
|
149 |
+
INNER JOIN `FilterListOfFeatures` AS LF
|
150 |
+
ON (TR.category_feature_id = LF.category_feature_id)
|
151 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
152 |
+
)
|
153 |
+
');
|
154 |
+
|
155 |
+
ELSE
|
156 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
157 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
158 |
+
ELSE
|
159 |
+
IF arg_least IS null THEN
|
160 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
161 |
+
ELSE
|
162 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
163 |
+
END IF;
|
164 |
+
END IF;
|
165 |
+
|
166 |
+
SET @query = CONCAT('
|
167 |
+
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
168 |
+
entity_id,
|
169 |
+
category_id,
|
170 |
+
product_id,
|
171 |
+
sinch_category_id,
|
172 |
+
`name`,
|
173 |
+
`image`,
|
174 |
+
supplier_id,
|
175 |
+
category_feature_id,
|
176 |
+
feature_id,
|
177 |
+
feature_name,
|
178 |
+
feature_value
|
179 |
+
)(
|
180 |
+
SELECT
|
181 |
+
TR.entity_id,
|
182 |
+
TR.category_id,
|
183 |
+
TR.product_id,
|
184 |
+
TR.sinch_category_id,
|
185 |
+
TR.`name`,
|
186 |
+
TR.`image`,
|
187 |
+
TR.supplier_id,
|
188 |
+
TR.category_feature_id,
|
189 |
+
TR.feature_id,
|
190 |
+
TR.feature_name,
|
191 |
+
TR.feature_value
|
192 |
+
FROM `tmp_result` AS TR
|
193 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
194 |
+
@where,
|
195 |
+
'GROUP BY entity_id
|
196 |
+
)
|
197 |
+
');
|
198 |
+
|
199 |
+
END IF;
|
200 |
+
|
201 |
+
PREPARE myquery FROM @query;
|
202 |
+
EXECUTE myquery;
|
203 |
+
DROP PREPARE myquery;
|
204 |
+
|
205 |
+
END=/=
|
206 |
+
|
207 |
+
delimiter ;
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-install-0.1.0.php
CHANGED
@@ -1,142 +1,142 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
-
$config = $installer->getConnection()->getConfig();
|
7 |
-
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
-
if (!$cnx) {
|
9 |
-
throw new Exception('Failed to connect to database.');
|
10 |
-
}
|
11 |
-
|
12 |
-
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
-
throw new Exception('Failed to select a database.');
|
14 |
-
}
|
15 |
-
|
16 |
-
$installer->startSetup();
|
17 |
-
|
18 |
-
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('FilterListOfFeatures')}");
|
19 |
-
|
20 |
-
$installer->run("CREATE TABLE {$installer->getTable('FilterListOfFeatures')}(
|
21 |
-
`id` int PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
22 |
-
`category_feature_id` int NOT NULL,
|
23 |
-
`feature_id` int NULL,
|
24 |
-
`feature_value` text
|
25 |
-
)");
|
26 |
-
|
27 |
-
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
28 |
-
|
29 |
-
$query = "
|
30 |
-
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
31 |
-
IN arg_table INT,
|
32 |
-
IN arg_category_id INT,
|
33 |
-
IN arg_image INT,
|
34 |
-
IN arg_category_feature INT,
|
35 |
-
IN arg_least INT,
|
36 |
-
IN arg_greatest INT
|
37 |
-
)
|
38 |
-
BEGIN
|
39 |
-
DROP TABLE IF EXISTS `tmp_result`;
|
40 |
-
|
41 |
-
CREATE TEMPORARY TABLE `tmp_result`(
|
42 |
-
`entity_id` int(10) unsigned,
|
43 |
-
`category_id` int(10) unsigned,
|
44 |
-
`product_id` int,
|
45 |
-
`sinch_category_id` int,
|
46 |
-
`name` varchar(255),
|
47 |
-
`image` varchar(255),
|
48 |
-
`supplier_id` int,
|
49 |
-
`category_feature_id` int,
|
50 |
-
`feature_id` int,
|
51 |
-
`feature_name` varchar(255),
|
52 |
-
`feature_value` text
|
53 |
-
);
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
IF arg_image = 1 THEN
|
58 |
-
INSERT INTO `tmp_result` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
59 |
-
(
|
60 |
-
SELECT E.entity_id, PCind.category_id, E.entity_id, PCind.category_id as `sinch_category`, PR.`product_name`, PR.main_image_url, PR.sinch_manufacturer_id, CF.category_feature_id, CF.category_feature_id, CF.`feature_name`, RV.`text`
|
61 |
-
FROM ".$installer->getTable('catalog_product_entity')." E
|
62 |
-
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
63 |
-
ON (E.entity_id = PCind.product_id)
|
64 |
-
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
65 |
-
ON (PCind.category_id=CF.store_category_id)
|
66 |
-
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
67 |
-
ON (PR.store_product_id = E.entity_id)
|
68 |
-
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
69 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
70 |
-
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
71 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
72 |
-
WHERE
|
73 |
-
PCind.category_id = arg_category_id
|
74 |
-
AND PR.main_image_url <> ''
|
75 |
-
);
|
76 |
-
ELSE
|
77 |
-
INSERT INTO `tmp_result` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
78 |
-
(
|
79 |
-
SELECT E.entity_id, PCind.category_id, E.entity_id, PCind.category_id as `sinch_category`, PR.`product_name`, PR.main_image_url, PR.sinch_manufacturer_id, CF.category_feature_id, CF.category_feature_id, CF.`feature_name`, RV.`text`
|
80 |
-
FROM ".$installer->getTable('catalog_product_entity')." E
|
81 |
-
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
82 |
-
ON (E.entity_id = PCind.product_id)
|
83 |
-
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
84 |
-
ON (PCind.category_id=CF.store_category_id)
|
85 |
-
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
86 |
-
ON (PR.store_product_id = E.entity_id)
|
87 |
-
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
88 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
89 |
-
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
90 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
91 |
-
WHERE
|
92 |
-
PCind.category_id = arg_category_id
|
93 |
-
|
94 |
-
);
|
95 |
-
|
96 |
-
END IF;
|
97 |
-
|
98 |
-
IF (SELECT COUNT(*) FROM `FilterListOfFeatures`) > 0 THEN
|
99 |
-
SET @query = CONCAT('INSERT INTO `SinchFilterResult_', arg_table, '` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
100 |
-
(
|
101 |
-
SELECT TR.entity_id, TR.category_id, TR.product_id, TR.sinch_category_id, TR.`name`, TR.`image`, TR.supplier_id, TR.category_feature_id, TR.feature_id, TR.feature_name, TR.feature_value
|
102 |
-
FROM `tmp_result` AS TR
|
103 |
-
INNER JOIN `FilterListOfFeatures` AS LF ON (TR.category_feature_id = LF.category_feature_id)
|
104 |
-
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
105 |
-
)');
|
106 |
-
|
107 |
-
ELSE
|
108 |
-
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
109 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
110 |
-
ELSE
|
111 |
-
IF arg_least IS null THEN
|
112 |
-
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
113 |
-
ELSE
|
114 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
115 |
-
END IF;
|
116 |
-
END IF;
|
117 |
-
|
118 |
-
SET @query = CONCAT('INSERT INTO `SinchFilterResult_', arg_table, '` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
119 |
-
(
|
120 |
-
SELECT TR.entity_id, TR.category_id, TR.product_id, TR.sinch_category_id, TR.`name`, TR.`image`, TR.supplier_id, TR.category_feature_id, TR.feature_id, TR.feature_name, TR.feature_value
|
121 |
-
FROM `tmp_result` AS TR
|
122 |
-
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
123 |
-
@where,
|
124 |
-
'GROUP BY entity_id
|
125 |
-
)');
|
126 |
-
|
127 |
-
END IF;
|
128 |
-
|
129 |
-
PREPARE myquery FROM @query;
|
130 |
-
EXECUTE myquery;
|
131 |
-
DROP PREPARE myquery;
|
132 |
-
|
133 |
-
END
|
134 |
-
";
|
135 |
-
|
136 |
-
if (!mysqli_query($cnx, $query)) {
|
137 |
-
throw new Exception("Failed to create stored procedure");
|
138 |
-
}
|
139 |
-
|
140 |
-
mysqli_close($cnx);
|
141 |
-
|
142 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
+
$config = $installer->getConnection()->getConfig();
|
7 |
+
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
+
if (!$cnx) {
|
9 |
+
throw new Exception('Failed to connect to database.');
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
+
throw new Exception('Failed to select a database.');
|
14 |
+
}
|
15 |
+
|
16 |
+
$installer->startSetup();
|
17 |
+
|
18 |
+
$installer->run("DROP TABLE IF EXISTS {$installer->getTable('FilterListOfFeatures')}");
|
19 |
+
|
20 |
+
$installer->run("CREATE TABLE {$installer->getTable('FilterListOfFeatures')}(
|
21 |
+
`id` int PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
22 |
+
`category_feature_id` int NOT NULL,
|
23 |
+
`feature_id` int NULL,
|
24 |
+
`feature_value` text
|
25 |
+
)");
|
26 |
+
|
27 |
+
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
28 |
+
|
29 |
+
$query = "
|
30 |
+
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
31 |
+
IN arg_table INT,
|
32 |
+
IN arg_category_id INT,
|
33 |
+
IN arg_image INT,
|
34 |
+
IN arg_category_feature INT,
|
35 |
+
IN arg_least INT,
|
36 |
+
IN arg_greatest INT
|
37 |
+
)
|
38 |
+
BEGIN
|
39 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
40 |
+
|
41 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
42 |
+
`entity_id` int(10) unsigned,
|
43 |
+
`category_id` int(10) unsigned,
|
44 |
+
`product_id` int,
|
45 |
+
`sinch_category_id` int,
|
46 |
+
`name` varchar(255),
|
47 |
+
`image` varchar(255),
|
48 |
+
`supplier_id` int,
|
49 |
+
`category_feature_id` int,
|
50 |
+
`feature_id` int,
|
51 |
+
`feature_name` varchar(255),
|
52 |
+
`feature_value` text
|
53 |
+
);
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
IF arg_image = 1 THEN
|
58 |
+
INSERT INTO `tmp_result` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
59 |
+
(
|
60 |
+
SELECT E.entity_id, PCind.category_id, E.entity_id, PCind.category_id as `sinch_category`, PR.`product_name`, PR.main_image_url, PR.sinch_manufacturer_id, CF.category_feature_id, CF.category_feature_id, CF.`feature_name`, RV.`text`
|
61 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
62 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
63 |
+
ON (E.entity_id = PCind.product_id)
|
64 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
65 |
+
ON (PCind.category_id=CF.store_category_id)
|
66 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
67 |
+
ON (PR.store_product_id = E.entity_id)
|
68 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
69 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
70 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
71 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
72 |
+
WHERE
|
73 |
+
PCind.category_id = arg_category_id
|
74 |
+
AND PR.main_image_url <> ''
|
75 |
+
);
|
76 |
+
ELSE
|
77 |
+
INSERT INTO `tmp_result` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
78 |
+
(
|
79 |
+
SELECT E.entity_id, PCind.category_id, E.entity_id, PCind.category_id as `sinch_category`, PR.`product_name`, PR.main_image_url, PR.sinch_manufacturer_id, CF.category_feature_id, CF.category_feature_id, CF.`feature_name`, RV.`text`
|
80 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
81 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
82 |
+
ON (E.entity_id = PCind.product_id)
|
83 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
84 |
+
ON (PCind.category_id=CF.store_category_id)
|
85 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
86 |
+
ON (PR.store_product_id = E.entity_id)
|
87 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
88 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
89 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
90 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
91 |
+
WHERE
|
92 |
+
PCind.category_id = arg_category_id
|
93 |
+
|
94 |
+
);
|
95 |
+
|
96 |
+
END IF;
|
97 |
+
|
98 |
+
IF (SELECT COUNT(*) FROM `FilterListOfFeatures`) > 0 THEN
|
99 |
+
SET @query = CONCAT('INSERT INTO `SinchFilterResult_', arg_table, '` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
100 |
+
(
|
101 |
+
SELECT TR.entity_id, TR.category_id, TR.product_id, TR.sinch_category_id, TR.`name`, TR.`image`, TR.supplier_id, TR.category_feature_id, TR.feature_id, TR.feature_name, TR.feature_value
|
102 |
+
FROM `tmp_result` AS TR
|
103 |
+
INNER JOIN `FilterListOfFeatures` AS LF ON (TR.category_feature_id = LF.category_feature_id)
|
104 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
105 |
+
)');
|
106 |
+
|
107 |
+
ELSE
|
108 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
109 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
110 |
+
ELSE
|
111 |
+
IF arg_least IS null THEN
|
112 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
113 |
+
ELSE
|
114 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
115 |
+
END IF;
|
116 |
+
END IF;
|
117 |
+
|
118 |
+
SET @query = CONCAT('INSERT INTO `SinchFilterResult_', arg_table, '` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
119 |
+
(
|
120 |
+
SELECT TR.entity_id, TR.category_id, TR.product_id, TR.sinch_category_id, TR.`name`, TR.`image`, TR.supplier_id, TR.category_feature_id, TR.feature_id, TR.feature_name, TR.feature_value
|
121 |
+
FROM `tmp_result` AS TR
|
122 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
123 |
+
@where,
|
124 |
+
'GROUP BY entity_id
|
125 |
+
)');
|
126 |
+
|
127 |
+
END IF;
|
128 |
+
|
129 |
+
PREPARE myquery FROM @query;
|
130 |
+
EXECUTE myquery;
|
131 |
+
DROP PREPARE myquery;
|
132 |
+
|
133 |
+
END
|
134 |
+
";
|
135 |
+
|
136 |
+
if (!mysqli_query($cnx, $query)) {
|
137 |
+
throw new Exception("Failed to create stored procedure");
|
138 |
+
}
|
139 |
+
|
140 |
+
mysqli_close($cnx);
|
141 |
+
|
142 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.0-0.1.1.php
CHANGED
@@ -1,67 +1,67 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
stepan
|
4 |
-
*/
|
5 |
-
$installer = $this;
|
6 |
-
|
7 |
-
$installer->startSetup();
|
8 |
-
|
9 |
-
$attr_varchar=array(
|
10 |
-
'ean' => 'EAN'
|
11 |
-
);
|
12 |
-
|
13 |
-
foreach($attr_varchar as $key=>$value){
|
14 |
-
|
15 |
-
$installer->addAttribute('catalog_product', $key,array(
|
16 |
-
'label' => $value,
|
17 |
-
'type' => 'varchar',
|
18 |
-
'input' => 'text',
|
19 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
20 |
-
'frontend' => '',
|
21 |
-
'source' => '',
|
22 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
23 |
-
'visible' => true,
|
24 |
-
'required' => false,
|
25 |
-
'user_defined' => false,
|
26 |
-
'searchable' => false,
|
27 |
-
'filterable' => false,
|
28 |
-
'comparable' => false,
|
29 |
-
'visible_on_front' => true,
|
30 |
-
'visible_in_advanced_search' => false,
|
31 |
-
'unique' => false
|
32 |
-
));
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
$attr_text=array(
|
37 |
-
'specification' => 'Specification'
|
38 |
-
);
|
39 |
-
|
40 |
-
foreach($attr_text as $key=>$value){
|
41 |
-
|
42 |
-
$installer->addAttribute('catalog_product', $key,array(
|
43 |
-
'label' => $value,
|
44 |
-
'type' => 'text',
|
45 |
-
'input' => 'textarea',
|
46 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
47 |
-
'frontend' => '',
|
48 |
-
'source' => '',
|
49 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
50 |
-
'visible' => true,
|
51 |
-
'required' => false,
|
52 |
-
'user_defined' => false,
|
53 |
-
'searchable' => false,
|
54 |
-
'filterable' => false,
|
55 |
-
'comparable' => false,
|
56 |
-
'visible_on_front' => true,
|
57 |
-
'is_visible_on_front' => true,
|
58 |
-
'is_html_allowed_on_front' => true,
|
59 |
-
'visible_in_advanced_search' => false,
|
60 |
-
'unique' => false
|
61 |
-
));
|
62 |
-
}
|
63 |
-
|
64 |
-
|
65 |
-
//$installer->installEntities();
|
66 |
-
|
67 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
stepan
|
4 |
+
*/
|
5 |
+
$installer = $this;
|
6 |
+
|
7 |
+
$installer->startSetup();
|
8 |
+
|
9 |
+
$attr_varchar=array(
|
10 |
+
'ean' => 'EAN'
|
11 |
+
);
|
12 |
+
|
13 |
+
foreach($attr_varchar as $key=>$value){
|
14 |
+
|
15 |
+
$installer->addAttribute('catalog_product', $key,array(
|
16 |
+
'label' => $value,
|
17 |
+
'type' => 'varchar',
|
18 |
+
'input' => 'text',
|
19 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
20 |
+
'frontend' => '',
|
21 |
+
'source' => '',
|
22 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
23 |
+
'visible' => true,
|
24 |
+
'required' => false,
|
25 |
+
'user_defined' => false,
|
26 |
+
'searchable' => false,
|
27 |
+
'filterable' => false,
|
28 |
+
'comparable' => false,
|
29 |
+
'visible_on_front' => true,
|
30 |
+
'visible_in_advanced_search' => false,
|
31 |
+
'unique' => false
|
32 |
+
));
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
$attr_text=array(
|
37 |
+
'specification' => 'Specification'
|
38 |
+
);
|
39 |
+
|
40 |
+
foreach($attr_text as $key=>$value){
|
41 |
+
|
42 |
+
$installer->addAttribute('catalog_product', $key,array(
|
43 |
+
'label' => $value,
|
44 |
+
'type' => 'text',
|
45 |
+
'input' => 'textarea',
|
46 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
47 |
+
'frontend' => '',
|
48 |
+
'source' => '',
|
49 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
50 |
+
'visible' => true,
|
51 |
+
'required' => false,
|
52 |
+
'user_defined' => false,
|
53 |
+
'searchable' => false,
|
54 |
+
'filterable' => false,
|
55 |
+
'comparable' => false,
|
56 |
+
'visible_on_front' => true,
|
57 |
+
'is_visible_on_front' => true,
|
58 |
+
'is_html_allowed_on_front' => true,
|
59 |
+
'visible_in_advanced_search' => false,
|
60 |
+
'unique' => false
|
61 |
+
));
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
//$installer->installEntities();
|
66 |
+
|
67 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.1-0.1.2.php
CHANGED
@@ -1,63 +1,63 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
stepan
|
4 |
-
*/
|
5 |
-
$installer = $this;
|
6 |
-
|
7 |
-
$config = $installer->getConnection()->getConfig();
|
8 |
-
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
9 |
-
if (!$cnx) {
|
10 |
-
throw new Exception('Failed to connect to database.');
|
11 |
-
}
|
12 |
-
|
13 |
-
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
14 |
-
throw new Exception('Failed to select a database.');
|
15 |
-
}
|
16 |
-
|
17 |
-
$check_store_product_id=1;
|
18 |
-
$check_sinch_product_id=1;
|
19 |
-
$q="show columns from catalog_product_entity";
|
20 |
-
$res=mysqli_query($cnx, $q);
|
21 |
-
while($row=mysqli_fetch_assoc($res)){
|
22 |
-
if($row['Field']=='store_product_id'){
|
23 |
-
$check_store_product_id=0;
|
24 |
-
}elseif($row['Field']=='sinch_product_id'){
|
25 |
-
$check_sinch_product_id=0;
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
|
30 |
-
$installer->startSetup();
|
31 |
-
|
32 |
-
if($check_store_product_id){
|
33 |
-
try{
|
34 |
-
$installer->run("
|
35 |
-
ALTER TABLE {$this->getTable('catalog_product_entity')}
|
36 |
-
ADD COLUMN `store_product_id` INT(11) UNSIGNED NULL
|
37 |
-
");
|
38 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
39 |
-
try{
|
40 |
-
$installer->run("
|
41 |
-
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
42 |
-
ADD INDEX `store_product_id` (`store_product_id`);
|
43 |
-
");
|
44 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
45 |
-
}
|
46 |
-
if($check_sinch_product_id){
|
47 |
-
try{
|
48 |
-
$installer->run("
|
49 |
-
ALTER TABLE {$this->getTable('catalog_product_entity')}
|
50 |
-
ADD COLUMN `sinch_product_id` INT(11) UNSIGNED NULL
|
51 |
-
");
|
52 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
53 |
-
try{
|
54 |
-
$installer->run("
|
55 |
-
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
56 |
-
ADD INDEX `sinch_product_id` (`sinch_product_id`);
|
57 |
-
");
|
58 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
59 |
-
}
|
60 |
-
|
61 |
-
//$installer->installEntities();
|
62 |
-
|
63 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
stepan
|
4 |
+
*/
|
5 |
+
$installer = $this;
|
6 |
+
|
7 |
+
$config = $installer->getConnection()->getConfig();
|
8 |
+
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
9 |
+
if (!$cnx) {
|
10 |
+
throw new Exception('Failed to connect to database.');
|
11 |
+
}
|
12 |
+
|
13 |
+
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
14 |
+
throw new Exception('Failed to select a database.');
|
15 |
+
}
|
16 |
+
|
17 |
+
$check_store_product_id=1;
|
18 |
+
$check_sinch_product_id=1;
|
19 |
+
$q="show columns from catalog_product_entity";
|
20 |
+
$res=mysqli_query($cnx, $q);
|
21 |
+
while($row=mysqli_fetch_assoc($res)){
|
22 |
+
if($row['Field']=='store_product_id'){
|
23 |
+
$check_store_product_id=0;
|
24 |
+
}elseif($row['Field']=='sinch_product_id'){
|
25 |
+
$check_sinch_product_id=0;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
$installer->startSetup();
|
31 |
+
|
32 |
+
if($check_store_product_id){
|
33 |
+
try{
|
34 |
+
$installer->run("
|
35 |
+
ALTER TABLE {$this->getTable('catalog_product_entity')}
|
36 |
+
ADD COLUMN `store_product_id` INT(11) UNSIGNED NULL
|
37 |
+
");
|
38 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
39 |
+
try{
|
40 |
+
$installer->run("
|
41 |
+
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
42 |
+
ADD INDEX `store_product_id` (`store_product_id`);
|
43 |
+
");
|
44 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
45 |
+
}
|
46 |
+
if($check_sinch_product_id){
|
47 |
+
try{
|
48 |
+
$installer->run("
|
49 |
+
ALTER TABLE {$this->getTable('catalog_product_entity')}
|
50 |
+
ADD COLUMN `sinch_product_id` INT(11) UNSIGNED NULL
|
51 |
+
");
|
52 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
53 |
+
try{
|
54 |
+
$installer->run("
|
55 |
+
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
56 |
+
ADD INDEX `sinch_product_id` (`sinch_product_id`);
|
57 |
+
");
|
58 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
59 |
+
}
|
60 |
+
|
61 |
+
//$installer->installEntities();
|
62 |
+
|
63 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.2-0.1.3.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
-
$config = $installer->getConnection()->getConfig();
|
7 |
-
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
-
if (!$cnx) {
|
9 |
-
throw new Exception('Failed to connect to database.');
|
10 |
-
}
|
11 |
-
|
12 |
-
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
-
throw new Exception('Failed to select a database.');
|
14 |
-
}
|
15 |
-
|
16 |
-
$installer->startSetup();
|
17 |
-
|
18 |
-
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
19 |
-
|
20 |
-
$query = "
|
21 |
-
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
22 |
-
IN arg_table INT,
|
23 |
-
IN arg_category_id INT,
|
24 |
-
IN arg_image INT,
|
25 |
-
IN arg_category_feature INT,
|
26 |
-
IN arg_least INT,
|
27 |
-
IN arg_greatest INT
|
28 |
-
)
|
29 |
-
BEGIN
|
30 |
-
DROP TABLE IF EXISTS `tmp_result`;
|
31 |
-
|
32 |
-
CREATE TEMPORARY TABLE `tmp_result`(
|
33 |
-
`entity_id` int(10) unsigned,
|
34 |
-
`category_id` int(10) unsigned,
|
35 |
-
`product_id` int,
|
36 |
-
`sinch_category_id` int,
|
37 |
-
`name` varchar(255),
|
38 |
-
`image` varchar(255),
|
39 |
-
`supplier_id` int,
|
40 |
-
`category_feature_id` int,
|
41 |
-
`feature_id` int,
|
42 |
-
`feature_name` varchar(255),
|
43 |
-
`feature_value` text
|
44 |
-
);
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
IF arg_image = 1 THEN
|
49 |
-
INSERT INTO `tmp_result` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
50 |
-
(
|
51 |
-
SELECT E.entity_id, PCind.category_id, E.entity_id, PCind.category_id as `sinch_category`, PR.`product_name`, PR.main_image_url, PR.sinch_manufacturer_id, CF.category_feature_id, CF.category_feature_id, CF.`feature_name`, RV.`text`
|
52 |
-
FROM ".$installer->getTable('catalog_product_entity')." E
|
53 |
-
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
54 |
-
ON (E.entity_id = PCind.product_id)
|
55 |
-
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
56 |
-
ON (PCind.category_id=CF.store_category_id)
|
57 |
-
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
58 |
-
ON (PR.store_product_id = E.store_product_id)
|
59 |
-
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
60 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
61 |
-
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
62 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
63 |
-
WHERE
|
64 |
-
PCind.category_id = arg_category_id
|
65 |
-
AND PR.main_image_url <> ''
|
66 |
-
);
|
67 |
-
ELSE
|
68 |
-
INSERT INTO `tmp_result` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
69 |
-
(
|
70 |
-
SELECT E.entity_id, PCind.category_id, E.entity_id, PCind.category_id as `sinch_category`, PR.`product_name`, PR.main_image_url, PR.sinch_manufacturer_id, CF.category_feature_id, CF.category_feature_id, CF.`feature_name`, RV.`text`
|
71 |
-
FROM ".$installer->getTable('catalog_product_entity')." E
|
72 |
-
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
73 |
-
ON (E.entity_id = PCind.product_id)
|
74 |
-
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
75 |
-
ON (PCind.category_id=CF.store_category_id)
|
76 |
-
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
77 |
-
ON (PR.store_product_id = E.store_product_id)
|
78 |
-
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
79 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
80 |
-
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
81 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
82 |
-
WHERE
|
83 |
-
PCind.category_id = arg_category_id
|
84 |
-
|
85 |
-
);
|
86 |
-
|
87 |
-
END IF;
|
88 |
-
|
89 |
-
IF (SELECT COUNT(*) FROM `FilterListOfFeatures`) > 0 THEN
|
90 |
-
SET @query = CONCAT('INSERT INTO `SinchFilterResult_', arg_table, '` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
91 |
-
(
|
92 |
-
SELECT TR.entity_id, TR.category_id, TR.product_id, TR.sinch_category_id, TR.`name`, TR.`image`, TR.supplier_id, TR.category_feature_id, TR.feature_id, TR.feature_name, TR.feature_value
|
93 |
-
FROM `tmp_result` AS TR
|
94 |
-
INNER JOIN `FilterListOfFeatures` AS LF ON (TR.category_feature_id = LF.category_feature_id)
|
95 |
-
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
96 |
-
)');
|
97 |
-
|
98 |
-
ELSE
|
99 |
-
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
100 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
101 |
-
ELSE
|
102 |
-
IF arg_least IS null THEN
|
103 |
-
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
104 |
-
ELSE
|
105 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
106 |
-
END IF;
|
107 |
-
END IF;
|
108 |
-
|
109 |
-
SET @query = CONCAT('INSERT INTO `SinchFilterResult_', arg_table, '` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
110 |
-
(
|
111 |
-
SELECT TR.entity_id, TR.category_id, TR.product_id, TR.sinch_category_id, TR.`name`, TR.`image`, TR.supplier_id, TR.category_feature_id, TR.feature_id, TR.feature_name, TR.feature_value
|
112 |
-
FROM `tmp_result` AS TR
|
113 |
-
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
114 |
-
@where,
|
115 |
-
'GROUP BY entity_id
|
116 |
-
)');
|
117 |
-
|
118 |
-
END IF;
|
119 |
-
|
120 |
-
PREPARE myquery FROM @query;
|
121 |
-
EXECUTE myquery;
|
122 |
-
DROP PREPARE myquery;
|
123 |
-
|
124 |
-
END
|
125 |
-
";
|
126 |
-
|
127 |
-
if (!mysqli_query($cnx, $query)) {
|
128 |
-
throw new Exception("Failed to create stored procedure");
|
129 |
-
}
|
130 |
-
|
131 |
-
mysqli_close($cnx);
|
132 |
-
|
133 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
+
$config = $installer->getConnection()->getConfig();
|
7 |
+
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
+
if (!$cnx) {
|
9 |
+
throw new Exception('Failed to connect to database.');
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
+
throw new Exception('Failed to select a database.');
|
14 |
+
}
|
15 |
+
|
16 |
+
$installer->startSetup();
|
17 |
+
|
18 |
+
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
19 |
+
|
20 |
+
$query = "
|
21 |
+
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
22 |
+
IN arg_table INT,
|
23 |
+
IN arg_category_id INT,
|
24 |
+
IN arg_image INT,
|
25 |
+
IN arg_category_feature INT,
|
26 |
+
IN arg_least INT,
|
27 |
+
IN arg_greatest INT
|
28 |
+
)
|
29 |
+
BEGIN
|
30 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
31 |
+
|
32 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
33 |
+
`entity_id` int(10) unsigned,
|
34 |
+
`category_id` int(10) unsigned,
|
35 |
+
`product_id` int,
|
36 |
+
`sinch_category_id` int,
|
37 |
+
`name` varchar(255),
|
38 |
+
`image` varchar(255),
|
39 |
+
`supplier_id` int,
|
40 |
+
`category_feature_id` int,
|
41 |
+
`feature_id` int,
|
42 |
+
`feature_name` varchar(255),
|
43 |
+
`feature_value` text
|
44 |
+
);
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
IF arg_image = 1 THEN
|
49 |
+
INSERT INTO `tmp_result` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
50 |
+
(
|
51 |
+
SELECT E.entity_id, PCind.category_id, E.entity_id, PCind.category_id as `sinch_category`, PR.`product_name`, PR.main_image_url, PR.sinch_manufacturer_id, CF.category_feature_id, CF.category_feature_id, CF.`feature_name`, RV.`text`
|
52 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
53 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
54 |
+
ON (E.entity_id = PCind.product_id)
|
55 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
56 |
+
ON (PCind.category_id=CF.store_category_id)
|
57 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
58 |
+
ON (PR.store_product_id = E.store_product_id)
|
59 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
60 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
61 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
62 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
63 |
+
WHERE
|
64 |
+
PCind.category_id = arg_category_id
|
65 |
+
AND PR.main_image_url <> ''
|
66 |
+
);
|
67 |
+
ELSE
|
68 |
+
INSERT INTO `tmp_result` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
69 |
+
(
|
70 |
+
SELECT E.entity_id, PCind.category_id, E.entity_id, PCind.category_id as `sinch_category`, PR.`product_name`, PR.main_image_url, PR.sinch_manufacturer_id, CF.category_feature_id, CF.category_feature_id, CF.`feature_name`, RV.`text`
|
71 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
72 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
73 |
+
ON (E.entity_id = PCind.product_id)
|
74 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
75 |
+
ON (PCind.category_id=CF.store_category_id)
|
76 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
77 |
+
ON (PR.store_product_id = E.store_product_id)
|
78 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
79 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
80 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
81 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
82 |
+
WHERE
|
83 |
+
PCind.category_id = arg_category_id
|
84 |
+
|
85 |
+
);
|
86 |
+
|
87 |
+
END IF;
|
88 |
+
|
89 |
+
IF (SELECT COUNT(*) FROM `FilterListOfFeatures`) > 0 THEN
|
90 |
+
SET @query = CONCAT('INSERT INTO `SinchFilterResult_', arg_table, '` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
91 |
+
(
|
92 |
+
SELECT TR.entity_id, TR.category_id, TR.product_id, TR.sinch_category_id, TR.`name`, TR.`image`, TR.supplier_id, TR.category_feature_id, TR.feature_id, TR.feature_name, TR.feature_value
|
93 |
+
FROM `tmp_result` AS TR
|
94 |
+
INNER JOIN `FilterListOfFeatures` AS LF ON (TR.category_feature_id = LF.category_feature_id)
|
95 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
96 |
+
)');
|
97 |
+
|
98 |
+
ELSE
|
99 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
100 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
101 |
+
ELSE
|
102 |
+
IF arg_least IS null THEN
|
103 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
104 |
+
ELSE
|
105 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
106 |
+
END IF;
|
107 |
+
END IF;
|
108 |
+
|
109 |
+
SET @query = CONCAT('INSERT INTO `SinchFilterResult_', arg_table, '` (entity_id, category_id, product_id, sinch_category_id, `name`, `image`, supplier_id, category_feature_id, feature_id, feature_name, feature_value)
|
110 |
+
(
|
111 |
+
SELECT TR.entity_id, TR.category_id, TR.product_id, TR.sinch_category_id, TR.`name`, TR.`image`, TR.supplier_id, TR.category_feature_id, TR.feature_id, TR.feature_name, TR.feature_value
|
112 |
+
FROM `tmp_result` AS TR
|
113 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
114 |
+
@where,
|
115 |
+
'GROUP BY entity_id
|
116 |
+
)');
|
117 |
+
|
118 |
+
END IF;
|
119 |
+
|
120 |
+
PREPARE myquery FROM @query;
|
121 |
+
EXECUTE myquery;
|
122 |
+
DROP PREPARE myquery;
|
123 |
+
|
124 |
+
END
|
125 |
+
";
|
126 |
+
|
127 |
+
if (!mysqli_query($cnx, $query)) {
|
128 |
+
throw new Exception("Failed to create stored procedure");
|
129 |
+
}
|
130 |
+
|
131 |
+
mysqli_close($cnx);
|
132 |
+
|
133 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.3-0.1.4.php
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
stepan
|
4 |
-
*/
|
5 |
-
$installer = $this;
|
6 |
-
|
7 |
-
$installer->startSetup();
|
8 |
-
|
9 |
-
|
10 |
-
$attr_text=array(
|
11 |
-
'specification' => 'Specification',
|
12 |
-
'manufacturer' => 'Manufacturer',
|
13 |
-
'ean' => 'EAN',
|
14 |
-
'sku' => 'SKU'
|
15 |
-
);
|
16 |
-
|
17 |
-
foreach($attr_text as $key=>$value){
|
18 |
-
$data=array(
|
19 |
-
'is_visible_on_front' => 1,
|
20 |
-
'is_html_allowed_on_front' => 1
|
21 |
-
);
|
22 |
-
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
23 |
-
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
24 |
-
$installer->updateAttribute($entityTypeId, $id, $data);
|
25 |
-
}
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
$attr_filt=array(
|
30 |
-
'manufacturer' => 'Manufacturer'
|
31 |
-
);
|
32 |
-
|
33 |
-
foreach($attr_filt as $key=>$value){
|
34 |
-
$data=array(
|
35 |
-
'is_filterable' => 1,
|
36 |
-
'is_global' => 1
|
37 |
-
);
|
38 |
-
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
39 |
-
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
40 |
-
$installer->updateAttribute($entityTypeId, $id, $data);
|
41 |
-
}
|
42 |
-
|
43 |
-
$sets = $installer->_conn->fetchAll('select * from '.$installer->getTable('eav/attribute_set').' where entity_type_id=?', $entityTypeId);
|
44 |
-
foreach ($sets as $set) {
|
45 |
-
$installer->addAttributeToSet($entityTypeId, $set['attribute_set_id'], 'Global', 'manufacturer');
|
46 |
-
}
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
//$installer->installEntities();
|
52 |
-
|
53 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
stepan
|
4 |
+
*/
|
5 |
+
$installer = $this;
|
6 |
+
|
7 |
+
$installer->startSetup();
|
8 |
+
|
9 |
+
|
10 |
+
$attr_text=array(
|
11 |
+
'specification' => 'Specification',
|
12 |
+
'manufacturer' => 'Manufacturer',
|
13 |
+
'ean' => 'EAN',
|
14 |
+
'sku' => 'SKU'
|
15 |
+
);
|
16 |
+
|
17 |
+
foreach($attr_text as $key=>$value){
|
18 |
+
$data=array(
|
19 |
+
'is_visible_on_front' => 1,
|
20 |
+
'is_html_allowed_on_front' => 1
|
21 |
+
);
|
22 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
23 |
+
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
24 |
+
$installer->updateAttribute($entityTypeId, $id, $data);
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
$attr_filt=array(
|
30 |
+
'manufacturer' => 'Manufacturer'
|
31 |
+
);
|
32 |
+
|
33 |
+
foreach($attr_filt as $key=>$value){
|
34 |
+
$data=array(
|
35 |
+
'is_filterable' => 1,
|
36 |
+
'is_global' => 1
|
37 |
+
);
|
38 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
39 |
+
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
40 |
+
$installer->updateAttribute($entityTypeId, $id, $data);
|
41 |
+
}
|
42 |
+
|
43 |
+
$sets = $installer->_conn->fetchAll('select * from '.$installer->getTable('eav/attribute_set').' where entity_type_id=?', $entityTypeId);
|
44 |
+
foreach ($sets as $set) {
|
45 |
+
$installer->addAttributeToSet($entityTypeId, $set['attribute_set_id'], 'Global', 'manufacturer');
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
//$installer->installEntities();
|
52 |
+
|
53 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.4-0.1.5.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
|
6 |
-
$installer->startSetup();
|
7 |
-
|
8 |
-
$installer->run("
|
9 |
-
DROP TABLE IF EXISTS ".$installer->getTable('stINch_import_status_statistic').";
|
10 |
-
|
11 |
-
CREATE TABLE ".$installer->getTable('stINch_import_status_statistic')."(
|
12 |
-
id int(11) NOT NULL auto_increment PRIMARY KEY,
|
13 |
-
start_import timestamp NOT NULL default '0000-00-00 00:00:00',
|
14 |
-
finish_import timestamp NOT NULL default '0000-00-00 00:00:00',
|
15 |
-
number_of_products int(11) default '0',
|
16 |
-
global_status_import varchar(255) default '',
|
17 |
-
detail_status_import varchar(255) default '',
|
18 |
-
error_report_message text not null default ''
|
19 |
-
);
|
20 |
-
|
21 |
-
|
22 |
-
");
|
23 |
-
/*
|
24 |
-
DROP TABLE IF EXISTS `stINch_import_log;
|
25 |
-
|
26 |
-
CREATE TABLE `stINch_import_log`(
|
27 |
-
`entity_id` bigint NOT NULL auto_increment PRIMARY KEY,
|
28 |
-
`message_date` timestamp NOT NULL default '0000-00-00 00:00:00',
|
29 |
-
`message` text
|
30 |
-
);
|
31 |
-
|
32 |
-
*/
|
33 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->run("
|
9 |
+
DROP TABLE IF EXISTS ".$installer->getTable('stINch_import_status_statistic').";
|
10 |
+
|
11 |
+
CREATE TABLE ".$installer->getTable('stINch_import_status_statistic')."(
|
12 |
+
id int(11) NOT NULL auto_increment PRIMARY KEY,
|
13 |
+
start_import timestamp NOT NULL default '0000-00-00 00:00:00',
|
14 |
+
finish_import timestamp NOT NULL default '0000-00-00 00:00:00',
|
15 |
+
number_of_products int(11) default '0',
|
16 |
+
global_status_import varchar(255) default '',
|
17 |
+
detail_status_import varchar(255) default '',
|
18 |
+
error_report_message text not null default ''
|
19 |
+
);
|
20 |
+
|
21 |
+
|
22 |
+
");
|
23 |
+
/*
|
24 |
+
DROP TABLE IF EXISTS `stINch_import_log;
|
25 |
+
|
26 |
+
CREATE TABLE `stINch_import_log`(
|
27 |
+
`entity_id` bigint NOT NULL auto_increment PRIMARY KEY,
|
28 |
+
`message_date` timestamp NOT NULL default '0000-00-00 00:00:00',
|
29 |
+
`message` text
|
30 |
+
);
|
31 |
+
|
32 |
+
*/
|
33 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.5-0.1.6.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
|
6 |
-
$installer->startSetup();
|
7 |
-
|
8 |
-
try{
|
9 |
-
$installer->run("
|
10 |
-
ALTER IGNORE TABLE ".$installer->getTable('stINch_import_status_statistic')."
|
11 |
-
ADD COLUMN `import_type` ENUM('FULL', 'PRICE STOCK') default NULL after finish_import
|
12 |
-
");
|
13 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
14 |
-
|
15 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
try{
|
9 |
+
$installer->run("
|
10 |
+
ALTER IGNORE TABLE ".$installer->getTable('stINch_import_status_statistic')."
|
11 |
+
ADD COLUMN `import_type` ENUM('FULL', 'PRICE STOCK') default NULL after finish_import
|
12 |
+
");
|
13 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
14 |
+
|
15 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.6-0.1.7.php
CHANGED
@@ -1,274 +1,274 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
-
$config = $installer->getConnection()->getConfig();
|
7 |
-
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
-
if (!$cnx) {
|
9 |
-
throw new Exception('Failed to connect to database.');
|
10 |
-
}
|
11 |
-
|
12 |
-
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
-
throw new Exception('Failed to select a database.');
|
14 |
-
}
|
15 |
-
|
16 |
-
$installer->startSetup();
|
17 |
-
|
18 |
-
|
19 |
-
$check_store_category_id=1;
|
20 |
-
$check_parent_store_category_id=1;
|
21 |
-
$q="show columns from catalog_category_entity";
|
22 |
-
$res=mysqli_query($cnx, $q);
|
23 |
-
while($row=mysqli_fetch_assoc($res)){
|
24 |
-
if($row['Field']=='store_category_id'){
|
25 |
-
$check_store_category_id=0;
|
26 |
-
}elseif($row['Field']=='parent_store_category_id'){
|
27 |
-
$check_parent_store_category_id=0;
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
if($check_store_category_id){
|
32 |
-
try{
|
33 |
-
$installer->run("
|
34 |
-
ALTER TABLE {$this->getTable('catalog_category_entity')}
|
35 |
-
ADD COLUMN `store_category_id` INT(11) UNSIGNED NULL
|
36 |
-
");
|
37 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
38 |
-
try{
|
39 |
-
$installer->run("
|
40 |
-
ALTER IGNORE TABLE {$this->getTable('catalog_category_entity')}
|
41 |
-
ADD INDEX `store_category_id` (`store_category_id`);
|
42 |
-
");
|
43 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
44 |
-
}
|
45 |
-
|
46 |
-
if($check_parent_store_category_id){
|
47 |
-
try{
|
48 |
-
$installer->run("
|
49 |
-
ALTER TABLE {$this->getTable('catalog_category_entity')}
|
50 |
-
ADD COLUMN `parent_store_category_id` INT(11) UNSIGNED NULL
|
51 |
-
");
|
52 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
53 |
-
try{
|
54 |
-
$installer->run("
|
55 |
-
ALTER IGNORE TABLE {$this->getTable('catalog_category_entity')}
|
56 |
-
ADD INDEX `parent_store_category_id` (`parent_store_category_id`);
|
57 |
-
");
|
58 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
59 |
-
|
60 |
-
}
|
61 |
-
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
62 |
-
|
63 |
-
$query = "
|
64 |
-
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
65 |
-
IN arg_table INT,
|
66 |
-
IN arg_category_id INT,
|
67 |
-
IN arg_image INT,
|
68 |
-
IN arg_category_feature INT,
|
69 |
-
IN arg_least INT,
|
70 |
-
IN arg_greatest INT
|
71 |
-
)
|
72 |
-
BEGIN
|
73 |
-
DROP TABLE IF EXISTS `tmp_result`;
|
74 |
-
|
75 |
-
CREATE TEMPORARY TABLE `tmp_result`(
|
76 |
-
`entity_id` int(10) unsigned,
|
77 |
-
`category_id` int(10) unsigned,
|
78 |
-
`product_id` int,
|
79 |
-
`sinch_category_id` int,
|
80 |
-
`name` varchar(255),
|
81 |
-
`image` varchar(255),
|
82 |
-
`supplier_id` int,
|
83 |
-
`category_feature_id` int,
|
84 |
-
`feature_id` int,
|
85 |
-
`feature_name` varchar(255),
|
86 |
-
`feature_value` text
|
87 |
-
);
|
88 |
-
|
89 |
-
|
90 |
-
IF arg_image = 1 THEN
|
91 |
-
INSERT INTO `tmp_result` (
|
92 |
-
entity_id,
|
93 |
-
category_id,
|
94 |
-
product_id,
|
95 |
-
sinch_category_id,
|
96 |
-
`name`,
|
97 |
-
`image`,
|
98 |
-
supplier_id,
|
99 |
-
category_feature_id,
|
100 |
-
feature_id,
|
101 |
-
feature_name,
|
102 |
-
feature_value
|
103 |
-
)(
|
104 |
-
SELECT
|
105 |
-
E.entity_id,
|
106 |
-
PCind.category_id,
|
107 |
-
E.entity_id,
|
108 |
-
PCind.category_id as `sinch_category`,
|
109 |
-
PR.`product_name`,
|
110 |
-
PR.main_image_url,
|
111 |
-
PR.sinch_manufacturer_id,
|
112 |
-
CF.category_feature_id,
|
113 |
-
CF.category_feature_id,
|
114 |
-
CF.`feature_name`,
|
115 |
-
RV.`text`
|
116 |
-
FROM ".$installer->getTable('catalog_product_entity')." E
|
117 |
-
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
118 |
-
ON (E.entity_id = PCind.product_id)
|
119 |
-
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
120 |
-
ON PCind.category_id=scm.shop_entity_id
|
121 |
-
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
122 |
-
ON (scm.store_category_id=CF.store_category_id)
|
123 |
-
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
124 |
-
ON (PR.store_product_id = E.store_product_id)
|
125 |
-
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
126 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
127 |
-
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
128 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
129 |
-
WHERE
|
130 |
-
scm.shop_entity_id = arg_category_id
|
131 |
-
AND PR.main_image_url <> ''
|
132 |
-
);
|
133 |
-
|
134 |
-
ELSE
|
135 |
-
|
136 |
-
INSERT INTO `tmp_result` (
|
137 |
-
entity_id,
|
138 |
-
category_id,
|
139 |
-
product_id,
|
140 |
-
sinch_category_id,
|
141 |
-
`name`,
|
142 |
-
`image`,
|
143 |
-
supplier_id,
|
144 |
-
category_feature_id,
|
145 |
-
feature_id,
|
146 |
-
feature_name,
|
147 |
-
feature_value
|
148 |
-
)(
|
149 |
-
SELECT
|
150 |
-
E.entity_id,
|
151 |
-
PCind.category_id,
|
152 |
-
E.entity_id,
|
153 |
-
PCind.category_id as `sinch_category`,
|
154 |
-
PR.`product_name`,
|
155 |
-
PR.main_image_url,
|
156 |
-
PR.sinch_manufacturer_id,
|
157 |
-
CF.category_feature_id,
|
158 |
-
CF.category_feature_id,
|
159 |
-
CF.`feature_name`,
|
160 |
-
RV.`text`
|
161 |
-
FROM ".$installer->getTable('catalog_product_entity')." E
|
162 |
-
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
163 |
-
ON (E.entity_id = PCind.product_id)
|
164 |
-
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
165 |
-
ON PCind.category_id=scm.shop_entity_id
|
166 |
-
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
167 |
-
ON (scm.store_category_id=CF.store_category_id)
|
168 |
-
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
169 |
-
ON (PR.store_product_id = E.store_product_id)
|
170 |
-
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
171 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
172 |
-
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
173 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
174 |
-
WHERE
|
175 |
-
scm.shop_entity_id = arg_category_id
|
176 |
-
|
177 |
-
);
|
178 |
-
|
179 |
-
END IF;
|
180 |
-
|
181 |
-
IF (SELECT COUNT(*) FROM `FilterListOfFeatures`) > 0 THEN
|
182 |
-
SET @query = CONCAT('
|
183 |
-
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
184 |
-
entity_id,
|
185 |
-
category_id,
|
186 |
-
product_id,
|
187 |
-
sinch_category_id,
|
188 |
-
`name`,
|
189 |
-
`image`,
|
190 |
-
supplier_id,
|
191 |
-
category_feature_id,
|
192 |
-
feature_id,
|
193 |
-
feature_name,
|
194 |
-
feature_value
|
195 |
-
)(
|
196 |
-
SELECT
|
197 |
-
TR.entity_id,
|
198 |
-
TR.category_id,
|
199 |
-
TR.product_id,
|
200 |
-
TR.sinch_category_id,
|
201 |
-
TR.`name`,
|
202 |
-
TR.`image`,
|
203 |
-
TR.supplier_id,
|
204 |
-
TR.category_feature_id,
|
205 |
-
TR.feature_id,
|
206 |
-
TR.feature_name,
|
207 |
-
TR.feature_value
|
208 |
-
FROM `tmp_result` AS TR
|
209 |
-
INNER JOIN `FilterListOfFeatures` AS LF
|
210 |
-
ON (TR.category_feature_id = LF.category_feature_id)
|
211 |
-
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
212 |
-
)
|
213 |
-
');
|
214 |
-
|
215 |
-
ELSE
|
216 |
-
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
217 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
218 |
-
ELSE
|
219 |
-
IF arg_least IS null THEN
|
220 |
-
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
221 |
-
ELSE
|
222 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
223 |
-
END IF;
|
224 |
-
END IF;
|
225 |
-
|
226 |
-
SET @query = CONCAT('
|
227 |
-
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
228 |
-
entity_id,
|
229 |
-
category_id,
|
230 |
-
product_id,
|
231 |
-
sinch_category_id,
|
232 |
-
`name`,
|
233 |
-
`image`,
|
234 |
-
supplier_id,
|
235 |
-
category_feature_id,
|
236 |
-
feature_id,
|
237 |
-
feature_name,
|
238 |
-
feature_value
|
239 |
-
)(
|
240 |
-
SELECT
|
241 |
-
TR.entity_id,
|
242 |
-
TR.category_id,
|
243 |
-
TR.product_id,
|
244 |
-
TR.sinch_category_id,
|
245 |
-
TR.`name`,
|
246 |
-
TR.`image`,
|
247 |
-
TR.supplier_id,
|
248 |
-
TR.category_feature_id,
|
249 |
-
TR.feature_id,
|
250 |
-
TR.feature_name,
|
251 |
-
TR.feature_value
|
252 |
-
FROM `tmp_result` AS TR
|
253 |
-
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
254 |
-
@where,
|
255 |
-
'GROUP BY entity_id
|
256 |
-
)
|
257 |
-
');
|
258 |
-
|
259 |
-
END IF;
|
260 |
-
|
261 |
-
PREPARE myquery FROM @query;
|
262 |
-
EXECUTE myquery;
|
263 |
-
DROP PREPARE myquery;
|
264 |
-
|
265 |
-
END
|
266 |
-
";
|
267 |
-
|
268 |
-
if (!mysqli_query($cnx, $query)) {
|
269 |
-
throw new Exception("Failed to create stored procedure");
|
270 |
-
}
|
271 |
-
|
272 |
-
mysqli_close($cnx);
|
273 |
-
|
274 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
+
$config = $installer->getConnection()->getConfig();
|
7 |
+
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
+
if (!$cnx) {
|
9 |
+
throw new Exception('Failed to connect to database.');
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
+
throw new Exception('Failed to select a database.');
|
14 |
+
}
|
15 |
+
|
16 |
+
$installer->startSetup();
|
17 |
+
|
18 |
+
|
19 |
+
$check_store_category_id=1;
|
20 |
+
$check_parent_store_category_id=1;
|
21 |
+
$q="show columns from catalog_category_entity";
|
22 |
+
$res=mysqli_query($cnx, $q);
|
23 |
+
while($row=mysqli_fetch_assoc($res)){
|
24 |
+
if($row['Field']=='store_category_id'){
|
25 |
+
$check_store_category_id=0;
|
26 |
+
}elseif($row['Field']=='parent_store_category_id'){
|
27 |
+
$check_parent_store_category_id=0;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
if($check_store_category_id){
|
32 |
+
try{
|
33 |
+
$installer->run("
|
34 |
+
ALTER TABLE {$this->getTable('catalog_category_entity')}
|
35 |
+
ADD COLUMN `store_category_id` INT(11) UNSIGNED NULL
|
36 |
+
");
|
37 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
38 |
+
try{
|
39 |
+
$installer->run("
|
40 |
+
ALTER IGNORE TABLE {$this->getTable('catalog_category_entity')}
|
41 |
+
ADD INDEX `store_category_id` (`store_category_id`);
|
42 |
+
");
|
43 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
44 |
+
}
|
45 |
+
|
46 |
+
if($check_parent_store_category_id){
|
47 |
+
try{
|
48 |
+
$installer->run("
|
49 |
+
ALTER TABLE {$this->getTable('catalog_category_entity')}
|
50 |
+
ADD COLUMN `parent_store_category_id` INT(11) UNSIGNED NULL
|
51 |
+
");
|
52 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
53 |
+
try{
|
54 |
+
$installer->run("
|
55 |
+
ALTER IGNORE TABLE {$this->getTable('catalog_category_entity')}
|
56 |
+
ADD INDEX `parent_store_category_id` (`parent_store_category_id`);
|
57 |
+
");
|
58 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
59 |
+
|
60 |
+
}
|
61 |
+
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
62 |
+
|
63 |
+
$query = "
|
64 |
+
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
65 |
+
IN arg_table INT,
|
66 |
+
IN arg_category_id INT,
|
67 |
+
IN arg_image INT,
|
68 |
+
IN arg_category_feature INT,
|
69 |
+
IN arg_least INT,
|
70 |
+
IN arg_greatest INT
|
71 |
+
)
|
72 |
+
BEGIN
|
73 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
74 |
+
|
75 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
76 |
+
`entity_id` int(10) unsigned,
|
77 |
+
`category_id` int(10) unsigned,
|
78 |
+
`product_id` int,
|
79 |
+
`sinch_category_id` int,
|
80 |
+
`name` varchar(255),
|
81 |
+
`image` varchar(255),
|
82 |
+
`supplier_id` int,
|
83 |
+
`category_feature_id` int,
|
84 |
+
`feature_id` int,
|
85 |
+
`feature_name` varchar(255),
|
86 |
+
`feature_value` text
|
87 |
+
);
|
88 |
+
|
89 |
+
|
90 |
+
IF arg_image = 1 THEN
|
91 |
+
INSERT INTO `tmp_result` (
|
92 |
+
entity_id,
|
93 |
+
category_id,
|
94 |
+
product_id,
|
95 |
+
sinch_category_id,
|
96 |
+
`name`,
|
97 |
+
`image`,
|
98 |
+
supplier_id,
|
99 |
+
category_feature_id,
|
100 |
+
feature_id,
|
101 |
+
feature_name,
|
102 |
+
feature_value
|
103 |
+
)(
|
104 |
+
SELECT
|
105 |
+
E.entity_id,
|
106 |
+
PCind.category_id,
|
107 |
+
E.entity_id,
|
108 |
+
PCind.category_id as `sinch_category`,
|
109 |
+
PR.`product_name`,
|
110 |
+
PR.main_image_url,
|
111 |
+
PR.sinch_manufacturer_id,
|
112 |
+
CF.category_feature_id,
|
113 |
+
CF.category_feature_id,
|
114 |
+
CF.`feature_name`,
|
115 |
+
RV.`text`
|
116 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
117 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
118 |
+
ON (E.entity_id = PCind.product_id)
|
119 |
+
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
120 |
+
ON PCind.category_id=scm.shop_entity_id
|
121 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
122 |
+
ON (scm.store_category_id=CF.store_category_id)
|
123 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
124 |
+
ON (PR.store_product_id = E.store_product_id)
|
125 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
126 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
127 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
128 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
129 |
+
WHERE
|
130 |
+
scm.shop_entity_id = arg_category_id
|
131 |
+
AND PR.main_image_url <> ''
|
132 |
+
);
|
133 |
+
|
134 |
+
ELSE
|
135 |
+
|
136 |
+
INSERT INTO `tmp_result` (
|
137 |
+
entity_id,
|
138 |
+
category_id,
|
139 |
+
product_id,
|
140 |
+
sinch_category_id,
|
141 |
+
`name`,
|
142 |
+
`image`,
|
143 |
+
supplier_id,
|
144 |
+
category_feature_id,
|
145 |
+
feature_id,
|
146 |
+
feature_name,
|
147 |
+
feature_value
|
148 |
+
)(
|
149 |
+
SELECT
|
150 |
+
E.entity_id,
|
151 |
+
PCind.category_id,
|
152 |
+
E.entity_id,
|
153 |
+
PCind.category_id as `sinch_category`,
|
154 |
+
PR.`product_name`,
|
155 |
+
PR.main_image_url,
|
156 |
+
PR.sinch_manufacturer_id,
|
157 |
+
CF.category_feature_id,
|
158 |
+
CF.category_feature_id,
|
159 |
+
CF.`feature_name`,
|
160 |
+
RV.`text`
|
161 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
162 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
163 |
+
ON (E.entity_id = PCind.product_id)
|
164 |
+
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
165 |
+
ON PCind.category_id=scm.shop_entity_id
|
166 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
167 |
+
ON (scm.store_category_id=CF.store_category_id)
|
168 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
169 |
+
ON (PR.store_product_id = E.store_product_id)
|
170 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
171 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
172 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
173 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
174 |
+
WHERE
|
175 |
+
scm.shop_entity_id = arg_category_id
|
176 |
+
|
177 |
+
);
|
178 |
+
|
179 |
+
END IF;
|
180 |
+
|
181 |
+
IF (SELECT COUNT(*) FROM `FilterListOfFeatures`) > 0 THEN
|
182 |
+
SET @query = CONCAT('
|
183 |
+
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
184 |
+
entity_id,
|
185 |
+
category_id,
|
186 |
+
product_id,
|
187 |
+
sinch_category_id,
|
188 |
+
`name`,
|
189 |
+
`image`,
|
190 |
+
supplier_id,
|
191 |
+
category_feature_id,
|
192 |
+
feature_id,
|
193 |
+
feature_name,
|
194 |
+
feature_value
|
195 |
+
)(
|
196 |
+
SELECT
|
197 |
+
TR.entity_id,
|
198 |
+
TR.category_id,
|
199 |
+
TR.product_id,
|
200 |
+
TR.sinch_category_id,
|
201 |
+
TR.`name`,
|
202 |
+
TR.`image`,
|
203 |
+
TR.supplier_id,
|
204 |
+
TR.category_feature_id,
|
205 |
+
TR.feature_id,
|
206 |
+
TR.feature_name,
|
207 |
+
TR.feature_value
|
208 |
+
FROM `tmp_result` AS TR
|
209 |
+
INNER JOIN `FilterListOfFeatures` AS LF
|
210 |
+
ON (TR.category_feature_id = LF.category_feature_id)
|
211 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
212 |
+
)
|
213 |
+
');
|
214 |
+
|
215 |
+
ELSE
|
216 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
217 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
218 |
+
ELSE
|
219 |
+
IF arg_least IS null THEN
|
220 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
221 |
+
ELSE
|
222 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
223 |
+
END IF;
|
224 |
+
END IF;
|
225 |
+
|
226 |
+
SET @query = CONCAT('
|
227 |
+
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
228 |
+
entity_id,
|
229 |
+
category_id,
|
230 |
+
product_id,
|
231 |
+
sinch_category_id,
|
232 |
+
`name`,
|
233 |
+
`image`,
|
234 |
+
supplier_id,
|
235 |
+
category_feature_id,
|
236 |
+
feature_id,
|
237 |
+
feature_name,
|
238 |
+
feature_value
|
239 |
+
)(
|
240 |
+
SELECT
|
241 |
+
TR.entity_id,
|
242 |
+
TR.category_id,
|
243 |
+
TR.product_id,
|
244 |
+
TR.sinch_category_id,
|
245 |
+
TR.`name`,
|
246 |
+
TR.`image`,
|
247 |
+
TR.supplier_id,
|
248 |
+
TR.category_feature_id,
|
249 |
+
TR.feature_id,
|
250 |
+
TR.feature_name,
|
251 |
+
TR.feature_value
|
252 |
+
FROM `tmp_result` AS TR
|
253 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
254 |
+
@where,
|
255 |
+
'GROUP BY entity_id
|
256 |
+
)
|
257 |
+
');
|
258 |
+
|
259 |
+
END IF;
|
260 |
+
|
261 |
+
PREPARE myquery FROM @query;
|
262 |
+
EXECUTE myquery;
|
263 |
+
DROP PREPARE myquery;
|
264 |
+
|
265 |
+
END
|
266 |
+
";
|
267 |
+
|
268 |
+
if (!mysqli_query($cnx, $query)) {
|
269 |
+
throw new Exception("Failed to create stored procedure");
|
270 |
+
}
|
271 |
+
|
272 |
+
mysqli_close($cnx);
|
273 |
+
|
274 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.7-0.1.8.php
CHANGED
@@ -1,108 +1,108 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
$installer->startSetup();
|
6 |
-
|
7 |
-
$installer->run("
|
8 |
-
DROP TABLE IF EXISTS ".$installer->getTable('stINch_sinchcheck').";
|
9 |
-
");
|
10 |
-
|
11 |
-
|
12 |
-
$installer->run("
|
13 |
-
CREATE TABLE ".$installer->getTable('stINch_sinchcheck')."
|
14 |
-
(
|
15 |
-
id INTEGER NOT NULL AUTO_INCREMENT,
|
16 |
-
caption VARCHAR(100) NOT NULL DEFAULT 'caption',
|
17 |
-
descr VARCHAR(100) NOT NULL DEFAULT 'descr',
|
18 |
-
check_code VARCHAR(100) DEFAULT NULL,
|
19 |
-
check_value VARCHAR(100) DEFAULT 'check value',
|
20 |
-
check_measure VARCHAR(100) DEFAULT 'check measure',
|
21 |
-
error_msg VARCHAR(256) DEFAULT 'error message',
|
22 |
-
fix_msg VARCHAR(256) DEFAULT 'fix message',
|
23 |
-
PRIMARY KEY (id),
|
24 |
-
UNIQUE KEY uk_check_code(check_code)
|
25 |
-
);
|
26 |
-
");
|
27 |
-
|
28 |
-
|
29 |
-
$installer->run("
|
30 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
31 |
-
error_msg, fix_msg)
|
32 |
-
VALUE('Physical memory', 'checking system memory', 'memory', '2048', 'MB',
|
33 |
-
'You have %s MB of memory', 'You need a minimum of %s');
|
34 |
-
");
|
35 |
-
|
36 |
-
$installer->run("
|
37 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
38 |
-
error_msg, fix_msg)
|
39 |
-
VALUE('Loaddata option', 'checking mysql load data', 'loaddata', 'ON', '',
|
40 |
-
'You need to enable the MySQL Loaddata option', 'You need to add set-variable=local-infile=1 or modify this line in /etc/my.cnf and restart MySQL');
|
41 |
-
");
|
42 |
-
|
43 |
-
$installer->run("
|
44 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
45 |
-
error_msg, fix_msg)
|
46 |
-
VALUE('PHP safe mode', 'checking php safe mode', 'phpsafemode', 'OFF', '',
|
47 |
-
'You need to set PHP safe mode to %s', 'You need to set safe_mode = %s in /etc/php.ini');
|
48 |
-
");
|
49 |
-
|
50 |
-
$installer->run("
|
51 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
52 |
-
error_msg, fix_msg)
|
53 |
-
VALUE('MySQL Timeout', 'checking mysql wait timeout', 'waittimeout', '28000', 'sec',
|
54 |
-
'Wait_timeout is too short:', 'You need to set wait_timeout = %s in /etc/my.cnf and restart MySQL');
|
55 |
-
");
|
56 |
-
|
57 |
-
$installer->run("
|
58 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
59 |
-
error_msg, fix_msg)
|
60 |
-
VALUE('MySQL Buffer Pool', 'checking mysql innodb buffer pool size', 'innodbbufpool', '512', 'MB',
|
61 |
-
'The innodb_buffer_pool_size in /etc/my.cnf is %s', 'It needs to be set to %s or higher');
|
62 |
-
");
|
63 |
-
|
64 |
-
$installer->run("
|
65 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
66 |
-
error_msg, fix_msg)
|
67 |
-
VALUE('PHP run string', 'checking php5 run string', 'php5run', 'php5', '',
|
68 |
-
'PHP_RUN_STRING uses value:', 'Change it to define(PHP_RUN_STRING, php5) in Bintime/Sinchimport/Model/config.php');
|
69 |
-
");
|
70 |
-
|
71 |
-
$installer->run("
|
72 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
73 |
-
error_msg, fix_msg)
|
74 |
-
VALUE('File Permissions', 'checking chmod wget', 'chmodwget', '0755', '',
|
75 |
-
'You need to assign more rights to wget', 'Run chmod a+x wget');
|
76 |
-
");
|
77 |
-
|
78 |
-
$installer->run("
|
79 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
80 |
-
error_msg, fix_msg)
|
81 |
-
VALUE('File Permissions', 'checking chmod for cron.php', 'chmodcronphp', '0755', '',
|
82 |
-
'You need to assign more rights to Magento Cron', 'Run chmod +x [shop dir]/cron.php');
|
83 |
-
");
|
84 |
-
|
85 |
-
$installer->run("
|
86 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
87 |
-
error_msg, fix_msg)
|
88 |
-
VALUE('File Permissions', 'checking chmod for cron.sh', 'chmodcronsh', '0755', '',
|
89 |
-
'You need to assign more rights to Magento Cron', 'Run chmod +x [shop dir]/cron.sh');
|
90 |
-
");
|
91 |
-
|
92 |
-
$installer->run("
|
93 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code,
|
94 |
-
check_value, check_measure,
|
95 |
-
error_msg, fix_msg)
|
96 |
-
VALUE('Missing Procedure', 'checking absense of procedure ".$installer->getTable('filter_icecat_products_s').".sql store procedue and showing hot to add it', 'routine',
|
97 |
-
'".$installer->getTable('filter_icecat_products_s')."', '',
|
98 |
-
'You are missing the MySQL stored procedure ".$installer->getTable('filter_icecat_products_s').".sql', 'You can recreate it by running the script found in [shop dir]/app/code/local/Bintime/Sinchimport/sql/ in PhpMyAdmin');
|
99 |
-
");
|
100 |
-
|
101 |
-
mysqli_close($cnx);
|
102 |
-
|
103 |
-
$installer->endSetup();
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
DROP TABLE IF EXISTS ".$installer->getTable('stINch_sinchcheck').";
|
9 |
+
");
|
10 |
+
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
CREATE TABLE ".$installer->getTable('stINch_sinchcheck')."
|
14 |
+
(
|
15 |
+
id INTEGER NOT NULL AUTO_INCREMENT,
|
16 |
+
caption VARCHAR(100) NOT NULL DEFAULT 'caption',
|
17 |
+
descr VARCHAR(100) NOT NULL DEFAULT 'descr',
|
18 |
+
check_code VARCHAR(100) DEFAULT NULL,
|
19 |
+
check_value VARCHAR(100) DEFAULT 'check value',
|
20 |
+
check_measure VARCHAR(100) DEFAULT 'check measure',
|
21 |
+
error_msg VARCHAR(256) DEFAULT 'error message',
|
22 |
+
fix_msg VARCHAR(256) DEFAULT 'fix message',
|
23 |
+
PRIMARY KEY (id),
|
24 |
+
UNIQUE KEY uk_check_code(check_code)
|
25 |
+
);
|
26 |
+
");
|
27 |
+
|
28 |
+
|
29 |
+
$installer->run("
|
30 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
31 |
+
error_msg, fix_msg)
|
32 |
+
VALUE('Physical memory', 'checking system memory', 'memory', '2048', 'MB',
|
33 |
+
'You have %s MB of memory', 'You need a minimum of %s');
|
34 |
+
");
|
35 |
+
|
36 |
+
$installer->run("
|
37 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
38 |
+
error_msg, fix_msg)
|
39 |
+
VALUE('Loaddata option', 'checking mysql load data', 'loaddata', 'ON', '',
|
40 |
+
'You need to enable the MySQL Loaddata option', 'You need to add set-variable=local-infile=1 or modify this line in /etc/my.cnf and restart MySQL');
|
41 |
+
");
|
42 |
+
|
43 |
+
$installer->run("
|
44 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
45 |
+
error_msg, fix_msg)
|
46 |
+
VALUE('PHP safe mode', 'checking php safe mode', 'phpsafemode', 'OFF', '',
|
47 |
+
'You need to set PHP safe mode to %s', 'You need to set safe_mode = %s in /etc/php.ini');
|
48 |
+
");
|
49 |
+
|
50 |
+
$installer->run("
|
51 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
52 |
+
error_msg, fix_msg)
|
53 |
+
VALUE('MySQL Timeout', 'checking mysql wait timeout', 'waittimeout', '28000', 'sec',
|
54 |
+
'Wait_timeout is too short:', 'You need to set wait_timeout = %s in /etc/my.cnf and restart MySQL');
|
55 |
+
");
|
56 |
+
|
57 |
+
$installer->run("
|
58 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
59 |
+
error_msg, fix_msg)
|
60 |
+
VALUE('MySQL Buffer Pool', 'checking mysql innodb buffer pool size', 'innodbbufpool', '512', 'MB',
|
61 |
+
'The innodb_buffer_pool_size in /etc/my.cnf is %s', 'It needs to be set to %s or higher');
|
62 |
+
");
|
63 |
+
|
64 |
+
$installer->run("
|
65 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
66 |
+
error_msg, fix_msg)
|
67 |
+
VALUE('PHP run string', 'checking php5 run string', 'php5run', 'php5', '',
|
68 |
+
'PHP_RUN_STRING uses value:', 'Change it to define(PHP_RUN_STRING, php5) in Bintime/Sinchimport/Model/config.php');
|
69 |
+
");
|
70 |
+
|
71 |
+
$installer->run("
|
72 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
73 |
+
error_msg, fix_msg)
|
74 |
+
VALUE('File Permissions', 'checking chmod wget', 'chmodwget', '0755', '',
|
75 |
+
'You need to assign more rights to wget', 'Run chmod a+x wget');
|
76 |
+
");
|
77 |
+
|
78 |
+
$installer->run("
|
79 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
80 |
+
error_msg, fix_msg)
|
81 |
+
VALUE('File Permissions', 'checking chmod for cron.php', 'chmodcronphp', '0755', '',
|
82 |
+
'You need to assign more rights to Magento Cron', 'Run chmod +x [shop dir]/cron.php');
|
83 |
+
");
|
84 |
+
|
85 |
+
$installer->run("
|
86 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
87 |
+
error_msg, fix_msg)
|
88 |
+
VALUE('File Permissions', 'checking chmod for cron.sh', 'chmodcronsh', '0755', '',
|
89 |
+
'You need to assign more rights to Magento Cron', 'Run chmod +x [shop dir]/cron.sh');
|
90 |
+
");
|
91 |
+
|
92 |
+
$installer->run("
|
93 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code,
|
94 |
+
check_value, check_measure,
|
95 |
+
error_msg, fix_msg)
|
96 |
+
VALUE('Missing Procedure', 'checking absense of procedure ".$installer->getTable('filter_icecat_products_s').".sql store procedue and showing hot to add it', 'routine',
|
97 |
+
'".$installer->getTable('filter_icecat_products_s')."', '',
|
98 |
+
'You are missing the MySQL stored procedure ".$installer->getTable('filter_icecat_products_s').".sql', 'You can recreate it by running the script found in [shop dir]/app/code/local/Bintime/Sinchimport/sql/ in PhpMyAdmin');
|
99 |
+
");
|
100 |
+
|
101 |
+
mysqli_close($cnx);
|
102 |
+
|
103 |
+
$installer->endSetup();
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.8-0.1.9.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
|
6 |
-
$installer->startSetup();
|
7 |
-
|
8 |
-
try{
|
9 |
-
$installer->run("
|
10 |
-
ALTER IGNORE TABLE ".$installer->getTable('stINch_import_status_statistic')."
|
11 |
-
ADD COLUMN import_run_type ENUM ('MANUAL', 'CRON') DEFAULt NULL
|
12 |
-
AFTER detail_status_import;
|
13 |
-
");
|
14 |
-
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
15 |
-
|
16 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
try{
|
9 |
+
$installer->run("
|
10 |
+
ALTER IGNORE TABLE ".$installer->getTable('stINch_import_status_statistic')."
|
11 |
+
ADD COLUMN import_run_type ENUM ('MANUAL', 'CRON') DEFAULt NULL
|
12 |
+
AFTER detail_status_import;
|
13 |
+
");
|
14 |
+
}catch(Exception $e){ Mage::log($e->getMessage(), null, 'Sinch.log'); }
|
15 |
+
|
16 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.9-0.2.0.php
CHANGED
@@ -1,123 +1,123 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
|
6 |
-
$installer->startSetup();
|
7 |
-
|
8 |
-
$installer->run("
|
9 |
-
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products_mapping')."(
|
10 |
-
entity_id int(11) unsigned NOT NULL,
|
11 |
-
manufacturer_option_id int(11),
|
12 |
-
manufacturer_name varchar(255),
|
13 |
-
shop_store_product_id int(11),
|
14 |
-
shop_sinch_product_id int(11),
|
15 |
-
sku varchar(64) default NULL,
|
16 |
-
store_product_id int(11),
|
17 |
-
sinch_product_id int(11),
|
18 |
-
product_sku varchar(255),
|
19 |
-
sinch_manufacturer_id int(11),
|
20 |
-
sinch_manufacturer_name varchar(255),
|
21 |
-
KEY entity_id (entity_id),
|
22 |
-
KEY manufacturer_option_id (manufacturer_option_id),
|
23 |
-
KEY manufacturer_name (manufacturer_name),
|
24 |
-
KEY store_product_id (store_product_id),
|
25 |
-
KEY sinch_product_id (sinch_product_id),
|
26 |
-
KEY sku (sku),
|
27 |
-
UNIQUE KEY(entity_id)
|
28 |
-
);
|
29 |
-
");
|
30 |
-
|
31 |
-
$installer->run("
|
32 |
-
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products')."(
|
33 |
-
store_product_id int(11),
|
34 |
-
sinch_product_id int(11),
|
35 |
-
product_sku varchar(255),
|
36 |
-
product_name varchar(255),
|
37 |
-
sinch_manufacturer_id int(11),
|
38 |
-
store_category_id int(11),
|
39 |
-
main_image_url varchar(255),
|
40 |
-
thumb_image_url varchar(255),
|
41 |
-
specifications text,
|
42 |
-
description text,
|
43 |
-
search_cache text,
|
44 |
-
spec_characte_u_count int(11),
|
45 |
-
description_type varchar(50),
|
46 |
-
medium_image_url varchar(255),
|
47 |
-
products_date_added datetime default NULL,
|
48 |
-
products_last_modified datetime default NULL,
|
49 |
-
availability_id_in_stock int(11) default '1',
|
50 |
-
availability_id_out_of_stock int(11) default '2',
|
51 |
-
products_locate varchar(30) default NULL,
|
52 |
-
products_ordered int(11) NOT NULL default '0',
|
53 |
-
products_url varchar(255) default NULL,
|
54 |
-
products_viewed int(5) default '0',
|
55 |
-
products_seo_url varchar(100) NOT NULL,
|
56 |
-
manufacturer_name varchar(255) default NULL,
|
57 |
-
KEY(store_product_id),
|
58 |
-
KEY(sinch_manufacturer_id),
|
59 |
-
KEY(store_category_id)
|
60 |
-
)DEFAULT CHARSET=utf8;
|
61 |
-
");
|
62 |
-
|
63 |
-
$installer->run("
|
64 |
-
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_categories_features')."(
|
65 |
-
category_feature_id int(11),
|
66 |
-
store_category_id int(11),
|
67 |
-
feature_name varchar(50),
|
68 |
-
display_order_number int(11),
|
69 |
-
KEY(store_category_id),
|
70 |
-
KEY(category_feature_id)
|
71 |
-
);
|
72 |
-
");
|
73 |
-
|
74 |
-
$installer->run("
|
75 |
-
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_restricted_values')."(
|
76 |
-
restricted_value_id int(11),
|
77 |
-
category_feature_id int(11),
|
78 |
-
text text,
|
79 |
-
display_order_number int(11),
|
80 |
-
KEY(restricted_value_id),
|
81 |
-
KEY(category_feature_id)
|
82 |
-
);
|
83 |
-
");
|
84 |
-
|
85 |
-
$installer->run("
|
86 |
-
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_product_features')."(
|
87 |
-
product_feature_id int(11),
|
88 |
-
sinch_product_id int(11),
|
89 |
-
restricted_value_id int(11),
|
90 |
-
KEY(sinch_product_id),
|
91 |
-
KEY(restricted_value_id)
|
92 |
-
);
|
93 |
-
");
|
94 |
-
|
95 |
-
$installer->run("
|
96 |
-
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_categories_mapping')."(
|
97 |
-
shop_entity_id int(11) unsigned NOT NULL,
|
98 |
-
shop_entity_type_id int(11),
|
99 |
-
shop_attribute_set_id int(11),
|
100 |
-
shop_parent_id int(11),
|
101 |
-
shop_store_category_id int(11),
|
102 |
-
shop_parent_store_category_id int(11),
|
103 |
-
store_category_id int(11),
|
104 |
-
parent_store_category_id int(11),
|
105 |
-
category_name varchar(255),
|
106 |
-
order_number int(11),
|
107 |
-
products_within_this_category int(11),
|
108 |
-
KEY shop_entity_id (shop_entity_id),
|
109 |
-
KEY shop_parent_id (shop_parent_id),
|
110 |
-
KEY store_category_id (store_category_id),
|
111 |
-
KEY parent_store_category_id (parent_store_category_id),
|
112 |
-
UNIQUE KEY(shop_entity_id)
|
113 |
-
);
|
114 |
-
");
|
115 |
-
|
116 |
-
/*
|
117 |
-
$installer->run("
|
118 |
-
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products_mapping')."(
|
119 |
-
);
|
120 |
-
");
|
121 |
-
*/
|
122 |
-
|
123 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->run("
|
9 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products_mapping')."(
|
10 |
+
entity_id int(11) unsigned NOT NULL,
|
11 |
+
manufacturer_option_id int(11),
|
12 |
+
manufacturer_name varchar(255),
|
13 |
+
shop_store_product_id int(11),
|
14 |
+
shop_sinch_product_id int(11),
|
15 |
+
sku varchar(64) default NULL,
|
16 |
+
store_product_id int(11),
|
17 |
+
sinch_product_id int(11),
|
18 |
+
product_sku varchar(255),
|
19 |
+
sinch_manufacturer_id int(11),
|
20 |
+
sinch_manufacturer_name varchar(255),
|
21 |
+
KEY entity_id (entity_id),
|
22 |
+
KEY manufacturer_option_id (manufacturer_option_id),
|
23 |
+
KEY manufacturer_name (manufacturer_name),
|
24 |
+
KEY store_product_id (store_product_id),
|
25 |
+
KEY sinch_product_id (sinch_product_id),
|
26 |
+
KEY sku (sku),
|
27 |
+
UNIQUE KEY(entity_id)
|
28 |
+
);
|
29 |
+
");
|
30 |
+
|
31 |
+
$installer->run("
|
32 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products')."(
|
33 |
+
store_product_id int(11),
|
34 |
+
sinch_product_id int(11),
|
35 |
+
product_sku varchar(255),
|
36 |
+
product_name varchar(255),
|
37 |
+
sinch_manufacturer_id int(11),
|
38 |
+
store_category_id int(11),
|
39 |
+
main_image_url varchar(255),
|
40 |
+
thumb_image_url varchar(255),
|
41 |
+
specifications text,
|
42 |
+
description text,
|
43 |
+
search_cache text,
|
44 |
+
spec_characte_u_count int(11),
|
45 |
+
description_type varchar(50),
|
46 |
+
medium_image_url varchar(255),
|
47 |
+
products_date_added datetime default NULL,
|
48 |
+
products_last_modified datetime default NULL,
|
49 |
+
availability_id_in_stock int(11) default '1',
|
50 |
+
availability_id_out_of_stock int(11) default '2',
|
51 |
+
products_locate varchar(30) default NULL,
|
52 |
+
products_ordered int(11) NOT NULL default '0',
|
53 |
+
products_url varchar(255) default NULL,
|
54 |
+
products_viewed int(5) default '0',
|
55 |
+
products_seo_url varchar(100) NOT NULL,
|
56 |
+
manufacturer_name varchar(255) default NULL,
|
57 |
+
KEY(store_product_id),
|
58 |
+
KEY(sinch_manufacturer_id),
|
59 |
+
KEY(store_category_id)
|
60 |
+
)DEFAULT CHARSET=utf8;
|
61 |
+
");
|
62 |
+
|
63 |
+
$installer->run("
|
64 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_categories_features')."(
|
65 |
+
category_feature_id int(11),
|
66 |
+
store_category_id int(11),
|
67 |
+
feature_name varchar(50),
|
68 |
+
display_order_number int(11),
|
69 |
+
KEY(store_category_id),
|
70 |
+
KEY(category_feature_id)
|
71 |
+
);
|
72 |
+
");
|
73 |
+
|
74 |
+
$installer->run("
|
75 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_restricted_values')."(
|
76 |
+
restricted_value_id int(11),
|
77 |
+
category_feature_id int(11),
|
78 |
+
text text,
|
79 |
+
display_order_number int(11),
|
80 |
+
KEY(restricted_value_id),
|
81 |
+
KEY(category_feature_id)
|
82 |
+
);
|
83 |
+
");
|
84 |
+
|
85 |
+
$installer->run("
|
86 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_product_features')."(
|
87 |
+
product_feature_id int(11),
|
88 |
+
sinch_product_id int(11),
|
89 |
+
restricted_value_id int(11),
|
90 |
+
KEY(sinch_product_id),
|
91 |
+
KEY(restricted_value_id)
|
92 |
+
);
|
93 |
+
");
|
94 |
+
|
95 |
+
$installer->run("
|
96 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_categories_mapping')."(
|
97 |
+
shop_entity_id int(11) unsigned NOT NULL,
|
98 |
+
shop_entity_type_id int(11),
|
99 |
+
shop_attribute_set_id int(11),
|
100 |
+
shop_parent_id int(11),
|
101 |
+
shop_store_category_id int(11),
|
102 |
+
shop_parent_store_category_id int(11),
|
103 |
+
store_category_id int(11),
|
104 |
+
parent_store_category_id int(11),
|
105 |
+
category_name varchar(255),
|
106 |
+
order_number int(11),
|
107 |
+
products_within_this_category int(11),
|
108 |
+
KEY shop_entity_id (shop_entity_id),
|
109 |
+
KEY shop_parent_id (shop_parent_id),
|
110 |
+
KEY store_category_id (store_category_id),
|
111 |
+
KEY parent_store_category_id (parent_store_category_id),
|
112 |
+
UNIQUE KEY(shop_entity_id)
|
113 |
+
);
|
114 |
+
");
|
115 |
+
|
116 |
+
/*
|
117 |
+
$installer->run("
|
118 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products_mapping')."(
|
119 |
+
);
|
120 |
+
");
|
121 |
+
*/
|
122 |
+
|
123 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.0-0.2.1.php
CHANGED
@@ -1,108 +1,108 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
$installer->startSetup();
|
6 |
-
|
7 |
-
$installer->run("
|
8 |
-
DROP TABLE IF EXISTS ".$installer->getTable('stINch_sinchcheck').";
|
9 |
-
");
|
10 |
-
|
11 |
-
|
12 |
-
$installer->run("
|
13 |
-
CREATE TABLE ".$installer->getTable('stINch_sinchcheck')."
|
14 |
-
(
|
15 |
-
id INTEGER NOT NULL AUTO_INCREMENT,
|
16 |
-
caption VARCHAR(100) NOT NULL DEFAULT 'caption',
|
17 |
-
descr VARCHAR(100) NOT NULL DEFAULT 'descr',
|
18 |
-
check_code VARCHAR(100) DEFAULT NULL,
|
19 |
-
check_value VARCHAR(100) DEFAULT 'check value',
|
20 |
-
check_measure VARCHAR(100) DEFAULT 'check measure',
|
21 |
-
error_msg VARCHAR(256) DEFAULT 'error message',
|
22 |
-
fix_msg VARCHAR(256) DEFAULT 'fix message',
|
23 |
-
PRIMARY KEY (id),
|
24 |
-
UNIQUE KEY uk_check_code(check_code)
|
25 |
-
);
|
26 |
-
");
|
27 |
-
|
28 |
-
|
29 |
-
$installer->run("
|
30 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
31 |
-
error_msg, fix_msg)
|
32 |
-
VALUE('Physical memory', 'checking system memory', 'memory', '2048', 'MB',
|
33 |
-
'You have %s MB of memory', 'You need to enlarge memory to %s');
|
34 |
-
");
|
35 |
-
|
36 |
-
$installer->run("
|
37 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
38 |
-
error_msg, fix_msg)
|
39 |
-
VALUE('Loaddata option', 'checking mysql load data', 'loaddata', 'ON', '',
|
40 |
-
'You need to enable the MySQL Loaddata option', 'You need to add set-variable=local-infile=1 or modify this line in /etc/my.cnf and restart MySQL');
|
41 |
-
");
|
42 |
-
|
43 |
-
$installer->run("
|
44 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
45 |
-
error_msg, fix_msg)
|
46 |
-
VALUE('PHP safe mode', 'checking php safe mode', 'phpsafemode', 'OFF', '',
|
47 |
-
'You need to set PHP safe mode to %s', 'You need to set safe_mode = %s in /etc/php.ini');
|
48 |
-
");
|
49 |
-
|
50 |
-
$installer->run("
|
51 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
52 |
-
error_msg, fix_msg)
|
53 |
-
VALUE('MySQL Timeout', 'checking mysql wait timeout', 'waittimeout', '28000', 'sec',
|
54 |
-
'Wait_timeout is too short:', 'You need to set wait_timeout = %s in /etc/my.cnf and restart MySQL');
|
55 |
-
");
|
56 |
-
|
57 |
-
$installer->run("
|
58 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
59 |
-
error_msg, fix_msg)
|
60 |
-
VALUE('MySQL Buffer Pool', 'checking mysql innodb buffer pool size', 'innodbbufpool', '512', 'MB',
|
61 |
-
'The innodb_buffer_pool_size in /etc/my.cnf is %s', 'It needs to be set to %s or higher');
|
62 |
-
");
|
63 |
-
|
64 |
-
$installer->run("
|
65 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
66 |
-
error_msg, fix_msg)
|
67 |
-
VALUE('PHP run string', 'checking php5 run string', 'php5run', 'php5', '',
|
68 |
-
'PHP_RUN_STRING uses value:', 'Change it to define(PHP_RUN_STRING, php5) in Bintime/Sinchimport/Model/config.php');
|
69 |
-
");
|
70 |
-
|
71 |
-
$installer->run("
|
72 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
73 |
-
error_msg, fix_msg)
|
74 |
-
VALUE('File Permissions', 'checking chmod wget', 'chmodwget', '0755', '',
|
75 |
-
'You need to assign more rights to wget', 'Run chmod a+x wget');
|
76 |
-
");
|
77 |
-
|
78 |
-
$installer->run("
|
79 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
80 |
-
error_msg, fix_msg)
|
81 |
-
VALUE('File Permissions', 'checking chmod for cron.php', 'chmodcronphp', '0755', '',
|
82 |
-
'You need to assign more rights to Magento Cron', 'Run chmod +x [shop dir]/cron.php');
|
83 |
-
");
|
84 |
-
|
85 |
-
$installer->run("
|
86 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
87 |
-
error_msg, fix_msg)
|
88 |
-
VALUE('File Permissions', 'checking chmod for cron.sh', 'chmodcronsh', '0755', '',
|
89 |
-
'You need to assign more rights to Magento Cron', 'Run chmod +x [shop dir]/cron.sh');
|
90 |
-
");
|
91 |
-
|
92 |
-
$installer->run("
|
93 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code,
|
94 |
-
check_value, check_measure,
|
95 |
-
error_msg, fix_msg)
|
96 |
-
VALUE('Missing Procedure', 'checking absense of procedure ".$installer->getTable('filter_sinch_products_s').".sql store procedue and showing hot to add it', 'routine',
|
97 |
-
'".$installer->getTable('filter_sinch_products_s')."', '',
|
98 |
-
'You are missing the MySQL stored procedure ".$installer->getTable('filter_sinch_products_s').".sql', 'You can recreate it by running the script found in [shop dir]/app/code/local/Bintime/Sinchimport/sql/ in PhpMyAdmin');
|
99 |
-
");
|
100 |
-
|
101 |
-
mysqli_close($cnx);
|
102 |
-
|
103 |
-
$installer->endSetup();
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
DROP TABLE IF EXISTS ".$installer->getTable('stINch_sinchcheck').";
|
9 |
+
");
|
10 |
+
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
CREATE TABLE ".$installer->getTable('stINch_sinchcheck')."
|
14 |
+
(
|
15 |
+
id INTEGER NOT NULL AUTO_INCREMENT,
|
16 |
+
caption VARCHAR(100) NOT NULL DEFAULT 'caption',
|
17 |
+
descr VARCHAR(100) NOT NULL DEFAULT 'descr',
|
18 |
+
check_code VARCHAR(100) DEFAULT NULL,
|
19 |
+
check_value VARCHAR(100) DEFAULT 'check value',
|
20 |
+
check_measure VARCHAR(100) DEFAULT 'check measure',
|
21 |
+
error_msg VARCHAR(256) DEFAULT 'error message',
|
22 |
+
fix_msg VARCHAR(256) DEFAULT 'fix message',
|
23 |
+
PRIMARY KEY (id),
|
24 |
+
UNIQUE KEY uk_check_code(check_code)
|
25 |
+
);
|
26 |
+
");
|
27 |
+
|
28 |
+
|
29 |
+
$installer->run("
|
30 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
31 |
+
error_msg, fix_msg)
|
32 |
+
VALUE('Physical memory', 'checking system memory', 'memory', '2048', 'MB',
|
33 |
+
'You have %s MB of memory', 'You need to enlarge memory to %s');
|
34 |
+
");
|
35 |
+
|
36 |
+
$installer->run("
|
37 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
38 |
+
error_msg, fix_msg)
|
39 |
+
VALUE('Loaddata option', 'checking mysql load data', 'loaddata', 'ON', '',
|
40 |
+
'You need to enable the MySQL Loaddata option', 'You need to add set-variable=local-infile=1 or modify this line in /etc/my.cnf and restart MySQL');
|
41 |
+
");
|
42 |
+
|
43 |
+
$installer->run("
|
44 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
45 |
+
error_msg, fix_msg)
|
46 |
+
VALUE('PHP safe mode', 'checking php safe mode', 'phpsafemode', 'OFF', '',
|
47 |
+
'You need to set PHP safe mode to %s', 'You need to set safe_mode = %s in /etc/php.ini');
|
48 |
+
");
|
49 |
+
|
50 |
+
$installer->run("
|
51 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
52 |
+
error_msg, fix_msg)
|
53 |
+
VALUE('MySQL Timeout', 'checking mysql wait timeout', 'waittimeout', '28000', 'sec',
|
54 |
+
'Wait_timeout is too short:', 'You need to set wait_timeout = %s in /etc/my.cnf and restart MySQL');
|
55 |
+
");
|
56 |
+
|
57 |
+
$installer->run("
|
58 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
59 |
+
error_msg, fix_msg)
|
60 |
+
VALUE('MySQL Buffer Pool', 'checking mysql innodb buffer pool size', 'innodbbufpool', '512', 'MB',
|
61 |
+
'The innodb_buffer_pool_size in /etc/my.cnf is %s', 'It needs to be set to %s or higher');
|
62 |
+
");
|
63 |
+
|
64 |
+
$installer->run("
|
65 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
66 |
+
error_msg, fix_msg)
|
67 |
+
VALUE('PHP run string', 'checking php5 run string', 'php5run', 'php5', '',
|
68 |
+
'PHP_RUN_STRING uses value:', 'Change it to define(PHP_RUN_STRING, php5) in Bintime/Sinchimport/Model/config.php');
|
69 |
+
");
|
70 |
+
|
71 |
+
$installer->run("
|
72 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
73 |
+
error_msg, fix_msg)
|
74 |
+
VALUE('File Permissions', 'checking chmod wget', 'chmodwget', '0755', '',
|
75 |
+
'You need to assign more rights to wget', 'Run chmod a+x wget');
|
76 |
+
");
|
77 |
+
|
78 |
+
$installer->run("
|
79 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
80 |
+
error_msg, fix_msg)
|
81 |
+
VALUE('File Permissions', 'checking chmod for cron.php', 'chmodcronphp', '0755', '',
|
82 |
+
'You need to assign more rights to Magento Cron', 'Run chmod +x [shop dir]/cron.php');
|
83 |
+
");
|
84 |
+
|
85 |
+
$installer->run("
|
86 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code, check_value, check_measure,
|
87 |
+
error_msg, fix_msg)
|
88 |
+
VALUE('File Permissions', 'checking chmod for cron.sh', 'chmodcronsh', '0755', '',
|
89 |
+
'You need to assign more rights to Magento Cron', 'Run chmod +x [shop dir]/cron.sh');
|
90 |
+
");
|
91 |
+
|
92 |
+
$installer->run("
|
93 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code,
|
94 |
+
check_value, check_measure,
|
95 |
+
error_msg, fix_msg)
|
96 |
+
VALUE('Missing Procedure', 'checking absense of procedure ".$installer->getTable('filter_sinch_products_s').".sql store procedue and showing hot to add it', 'routine',
|
97 |
+
'".$installer->getTable('filter_sinch_products_s')."', '',
|
98 |
+
'You are missing the MySQL stored procedure ".$installer->getTable('filter_sinch_products_s').".sql', 'You can recreate it by running the script found in [shop dir]/app/code/local/Bintime/Sinchimport/sql/ in PhpMyAdmin');
|
99 |
+
");
|
100 |
+
|
101 |
+
mysqli_close($cnx);
|
102 |
+
|
103 |
+
$installer->endSetup();
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.1-0.2.2.php
CHANGED
@@ -1,230 +1,230 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
-
$config = $installer->getConnection()->getConfig();
|
7 |
-
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
-
if (!$cnx) {
|
9 |
-
throw new Exception('Failed to connect to database.');
|
10 |
-
}
|
11 |
-
|
12 |
-
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
-
throw new Exception('Failed to select a database.');
|
14 |
-
}
|
15 |
-
|
16 |
-
$installer->startSetup();
|
17 |
-
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
18 |
-
|
19 |
-
$query = "
|
20 |
-
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
21 |
-
IN arg_table INT,
|
22 |
-
IN arg_category_id INT,
|
23 |
-
IN arg_image INT,
|
24 |
-
IN arg_category_feature INT,
|
25 |
-
IN arg_least INT,
|
26 |
-
IN arg_greatest INT
|
27 |
-
)
|
28 |
-
BEGIN
|
29 |
-
DROP TABLE IF EXISTS `tmp_result`;
|
30 |
-
|
31 |
-
CREATE TEMPORARY TABLE `tmp_result`(
|
32 |
-
`entity_id` int(10) unsigned,
|
33 |
-
`category_id` int(10) unsigned,
|
34 |
-
`product_id` int,
|
35 |
-
`sinch_category_id` int,
|
36 |
-
`name` varchar(255),
|
37 |
-
`image` varchar(255),
|
38 |
-
`supplier_id` int,
|
39 |
-
`category_feature_id` int,
|
40 |
-
`feature_id` int,
|
41 |
-
`feature_name` varchar(255),
|
42 |
-
`feature_value` text
|
43 |
-
);
|
44 |
-
|
45 |
-
|
46 |
-
IF arg_image = 1 THEN
|
47 |
-
INSERT INTO `tmp_result` (
|
48 |
-
entity_id,
|
49 |
-
category_id,
|
50 |
-
product_id,
|
51 |
-
sinch_category_id,
|
52 |
-
`name`,
|
53 |
-
`image`,
|
54 |
-
supplier_id,
|
55 |
-
category_feature_id,
|
56 |
-
feature_id,
|
57 |
-
feature_name,
|
58 |
-
feature_value
|
59 |
-
)(
|
60 |
-
SELECT
|
61 |
-
E.entity_id,
|
62 |
-
PCind.category_id,
|
63 |
-
E.entity_id,
|
64 |
-
PCind.category_id as `sinch_category`,
|
65 |
-
PR.`product_name`,
|
66 |
-
PR.main_image_url,
|
67 |
-
PR.sinch_manufacturer_id,
|
68 |
-
CF.category_feature_id,
|
69 |
-
CF.category_feature_id,
|
70 |
-
CF.`feature_name`,
|
71 |
-
RV.`text`
|
72 |
-
FROM ".$installer->getTable('catalog_product_entity')." E
|
73 |
-
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
74 |
-
ON (E.entity_id = PCind.product_id)
|
75 |
-
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
76 |
-
ON PCind.category_id=scm.shop_entity_id
|
77 |
-
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
78 |
-
ON (scm.store_category_id=CF.store_category_id)
|
79 |
-
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
80 |
-
ON (PR.store_product_id = E.store_product_id)
|
81 |
-
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
82 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
83 |
-
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
84 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
85 |
-
WHERE
|
86 |
-
scm.shop_entity_id = arg_category_id
|
87 |
-
AND PR.main_image_url <> ''
|
88 |
-
);
|
89 |
-
|
90 |
-
ELSE
|
91 |
-
|
92 |
-
INSERT INTO `tmp_result` (
|
93 |
-
entity_id,
|
94 |
-
category_id,
|
95 |
-
product_id,
|
96 |
-
sinch_category_id,
|
97 |
-
`name`,
|
98 |
-
`image`,
|
99 |
-
supplier_id,
|
100 |
-
category_feature_id,
|
101 |
-
feature_id,
|
102 |
-
feature_name,
|
103 |
-
feature_value
|
104 |
-
)(
|
105 |
-
SELECT
|
106 |
-
E.entity_id,
|
107 |
-
PCind.category_id,
|
108 |
-
E.entity_id,
|
109 |
-
PCind.category_id as `sinch_category`,
|
110 |
-
PR.`product_name`,
|
111 |
-
PR.main_image_url,
|
112 |
-
PR.sinch_manufacturer_id,
|
113 |
-
CF.category_feature_id,
|
114 |
-
CF.category_feature_id,
|
115 |
-
CF.`feature_name`,
|
116 |
-
RV.`text`
|
117 |
-
FROM ".$installer->getTable('catalog_product_entity')." E
|
118 |
-
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
119 |
-
ON (E.entity_id = PCind.product_id)
|
120 |
-
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
121 |
-
ON PCind.category_id=scm.shop_entity_id
|
122 |
-
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
123 |
-
ON (scm.store_category_id=CF.store_category_id)
|
124 |
-
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
125 |
-
ON (PR.store_product_id = E.store_product_id)
|
126 |
-
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
127 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
128 |
-
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
129 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
130 |
-
WHERE
|
131 |
-
scm.shop_entity_id = arg_category_id
|
132 |
-
|
133 |
-
);
|
134 |
-
|
135 |
-
END IF;
|
136 |
-
|
137 |
-
IF (SELECT COUNT(*) FROM `".$installer->getTable('FilterListOfFeatures')."`) > 0 THEN
|
138 |
-
SET @query = CONCAT('
|
139 |
-
INSERT INTO `".$installer->getTable('SinchFilterResult_')."', arg_table, '` (
|
140 |
-
entity_id,
|
141 |
-
category_id,
|
142 |
-
product_id,
|
143 |
-
sinch_category_id,
|
144 |
-
`name`,
|
145 |
-
`image`,
|
146 |
-
supplier_id,
|
147 |
-
category_feature_id,
|
148 |
-
feature_id,
|
149 |
-
feature_name,
|
150 |
-
feature_value
|
151 |
-
)(
|
152 |
-
SELECT
|
153 |
-
TR.entity_id,
|
154 |
-
TR.category_id,
|
155 |
-
TR.product_id,
|
156 |
-
TR.sinch_category_id,
|
157 |
-
TR.`name`,
|
158 |
-
TR.`image`,
|
159 |
-
TR.supplier_id,
|
160 |
-
TR.category_feature_id,
|
161 |
-
TR.feature_id,
|
162 |
-
TR.feature_name,
|
163 |
-
TR.feature_value
|
164 |
-
FROM `tmp_result` AS TR
|
165 |
-
INNER JOIN `".$installer->getTable('FilterListOfFeatures')."` AS LF
|
166 |
-
ON (TR.category_feature_id = LF.category_feature_id)
|
167 |
-
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
168 |
-
)
|
169 |
-
');
|
170 |
-
|
171 |
-
ELSE
|
172 |
-
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
173 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
174 |
-
ELSE
|
175 |
-
IF arg_least IS null THEN
|
176 |
-
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
177 |
-
ELSE
|
178 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
179 |
-
END IF;
|
180 |
-
END IF;
|
181 |
-
|
182 |
-
SET @query = CONCAT('
|
183 |
-
INSERT INTO `".$installer->getTable('SinchFilterResult_')."', arg_table, '` (
|
184 |
-
entity_id,
|
185 |
-
category_id,
|
186 |
-
product_id,
|
187 |
-
sinch_category_id,
|
188 |
-
`name`,
|
189 |
-
`image`,
|
190 |
-
supplier_id,
|
191 |
-
category_feature_id,
|
192 |
-
feature_id,
|
193 |
-
feature_name,
|
194 |
-
feature_value
|
195 |
-
)(
|
196 |
-
SELECT
|
197 |
-
TR.entity_id,
|
198 |
-
TR.category_id,
|
199 |
-
TR.product_id,
|
200 |
-
TR.sinch_category_id,
|
201 |
-
TR.`name`,
|
202 |
-
TR.`image`,
|
203 |
-
TR.supplier_id,
|
204 |
-
TR.category_feature_id,
|
205 |
-
TR.feature_id,
|
206 |
-
TR.feature_name,
|
207 |
-
TR.feature_value
|
208 |
-
FROM `tmp_result` AS TR
|
209 |
-
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
210 |
-
@where,
|
211 |
-
'GROUP BY entity_id
|
212 |
-
)
|
213 |
-
');
|
214 |
-
|
215 |
-
END IF;
|
216 |
-
|
217 |
-
PREPARE myquery FROM @query;
|
218 |
-
EXECUTE myquery;
|
219 |
-
DROP PREPARE myquery;
|
220 |
-
|
221 |
-
END
|
222 |
-
";
|
223 |
-
|
224 |
-
if (!mysqli_query($cnx, $query)) {
|
225 |
-
throw new Exception("Failed to create stored procedure");
|
226 |
-
}
|
227 |
-
|
228 |
-
mysqli_close($cnx);
|
229 |
-
|
230 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
+
$config = $installer->getConnection()->getConfig();
|
7 |
+
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
+
if (!$cnx) {
|
9 |
+
throw new Exception('Failed to connect to database.');
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
+
throw new Exception('Failed to select a database.');
|
14 |
+
}
|
15 |
+
|
16 |
+
$installer->startSetup();
|
17 |
+
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
18 |
+
|
19 |
+
$query = "
|
20 |
+
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
21 |
+
IN arg_table INT,
|
22 |
+
IN arg_category_id INT,
|
23 |
+
IN arg_image INT,
|
24 |
+
IN arg_category_feature INT,
|
25 |
+
IN arg_least INT,
|
26 |
+
IN arg_greatest INT
|
27 |
+
)
|
28 |
+
BEGIN
|
29 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
30 |
+
|
31 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
32 |
+
`entity_id` int(10) unsigned,
|
33 |
+
`category_id` int(10) unsigned,
|
34 |
+
`product_id` int,
|
35 |
+
`sinch_category_id` int,
|
36 |
+
`name` varchar(255),
|
37 |
+
`image` varchar(255),
|
38 |
+
`supplier_id` int,
|
39 |
+
`category_feature_id` int,
|
40 |
+
`feature_id` int,
|
41 |
+
`feature_name` varchar(255),
|
42 |
+
`feature_value` text
|
43 |
+
);
|
44 |
+
|
45 |
+
|
46 |
+
IF arg_image = 1 THEN
|
47 |
+
INSERT INTO `tmp_result` (
|
48 |
+
entity_id,
|
49 |
+
category_id,
|
50 |
+
product_id,
|
51 |
+
sinch_category_id,
|
52 |
+
`name`,
|
53 |
+
`image`,
|
54 |
+
supplier_id,
|
55 |
+
category_feature_id,
|
56 |
+
feature_id,
|
57 |
+
feature_name,
|
58 |
+
feature_value
|
59 |
+
)(
|
60 |
+
SELECT
|
61 |
+
E.entity_id,
|
62 |
+
PCind.category_id,
|
63 |
+
E.entity_id,
|
64 |
+
PCind.category_id as `sinch_category`,
|
65 |
+
PR.`product_name`,
|
66 |
+
PR.main_image_url,
|
67 |
+
PR.sinch_manufacturer_id,
|
68 |
+
CF.category_feature_id,
|
69 |
+
CF.category_feature_id,
|
70 |
+
CF.`feature_name`,
|
71 |
+
RV.`text`
|
72 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
73 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
74 |
+
ON (E.entity_id = PCind.product_id)
|
75 |
+
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
76 |
+
ON PCind.category_id=scm.shop_entity_id
|
77 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
78 |
+
ON (scm.store_category_id=CF.store_category_id)
|
79 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
80 |
+
ON (PR.store_product_id = E.store_product_id)
|
81 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
82 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
83 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
84 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
85 |
+
WHERE
|
86 |
+
scm.shop_entity_id = arg_category_id
|
87 |
+
AND PR.main_image_url <> ''
|
88 |
+
);
|
89 |
+
|
90 |
+
ELSE
|
91 |
+
|
92 |
+
INSERT INTO `tmp_result` (
|
93 |
+
entity_id,
|
94 |
+
category_id,
|
95 |
+
product_id,
|
96 |
+
sinch_category_id,
|
97 |
+
`name`,
|
98 |
+
`image`,
|
99 |
+
supplier_id,
|
100 |
+
category_feature_id,
|
101 |
+
feature_id,
|
102 |
+
feature_name,
|
103 |
+
feature_value
|
104 |
+
)(
|
105 |
+
SELECT
|
106 |
+
E.entity_id,
|
107 |
+
PCind.category_id,
|
108 |
+
E.entity_id,
|
109 |
+
PCind.category_id as `sinch_category`,
|
110 |
+
PR.`product_name`,
|
111 |
+
PR.main_image_url,
|
112 |
+
PR.sinch_manufacturer_id,
|
113 |
+
CF.category_feature_id,
|
114 |
+
CF.category_feature_id,
|
115 |
+
CF.`feature_name`,
|
116 |
+
RV.`text`
|
117 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
118 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
119 |
+
ON (E.entity_id = PCind.product_id)
|
120 |
+
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
121 |
+
ON PCind.category_id=scm.shop_entity_id
|
122 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
123 |
+
ON (scm.store_category_id=CF.store_category_id)
|
124 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
125 |
+
ON (PR.store_product_id = E.store_product_id)
|
126 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
127 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
128 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
129 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
130 |
+
WHERE
|
131 |
+
scm.shop_entity_id = arg_category_id
|
132 |
+
|
133 |
+
);
|
134 |
+
|
135 |
+
END IF;
|
136 |
+
|
137 |
+
IF (SELECT COUNT(*) FROM `".$installer->getTable('FilterListOfFeatures')."`) > 0 THEN
|
138 |
+
SET @query = CONCAT('
|
139 |
+
INSERT INTO `".$installer->getTable('SinchFilterResult_')."', arg_table, '` (
|
140 |
+
entity_id,
|
141 |
+
category_id,
|
142 |
+
product_id,
|
143 |
+
sinch_category_id,
|
144 |
+
`name`,
|
145 |
+
`image`,
|
146 |
+
supplier_id,
|
147 |
+
category_feature_id,
|
148 |
+
feature_id,
|
149 |
+
feature_name,
|
150 |
+
feature_value
|
151 |
+
)(
|
152 |
+
SELECT
|
153 |
+
TR.entity_id,
|
154 |
+
TR.category_id,
|
155 |
+
TR.product_id,
|
156 |
+
TR.sinch_category_id,
|
157 |
+
TR.`name`,
|
158 |
+
TR.`image`,
|
159 |
+
TR.supplier_id,
|
160 |
+
TR.category_feature_id,
|
161 |
+
TR.feature_id,
|
162 |
+
TR.feature_name,
|
163 |
+
TR.feature_value
|
164 |
+
FROM `tmp_result` AS TR
|
165 |
+
INNER JOIN `".$installer->getTable('FilterListOfFeatures')."` AS LF
|
166 |
+
ON (TR.category_feature_id = LF.category_feature_id)
|
167 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
168 |
+
)
|
169 |
+
');
|
170 |
+
|
171 |
+
ELSE
|
172 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
173 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
174 |
+
ELSE
|
175 |
+
IF arg_least IS null THEN
|
176 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
177 |
+
ELSE
|
178 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
179 |
+
END IF;
|
180 |
+
END IF;
|
181 |
+
|
182 |
+
SET @query = CONCAT('
|
183 |
+
INSERT INTO `".$installer->getTable('SinchFilterResult_')."', arg_table, '` (
|
184 |
+
entity_id,
|
185 |
+
category_id,
|
186 |
+
product_id,
|
187 |
+
sinch_category_id,
|
188 |
+
`name`,
|
189 |
+
`image`,
|
190 |
+
supplier_id,
|
191 |
+
category_feature_id,
|
192 |
+
feature_id,
|
193 |
+
feature_name,
|
194 |
+
feature_value
|
195 |
+
)(
|
196 |
+
SELECT
|
197 |
+
TR.entity_id,
|
198 |
+
TR.category_id,
|
199 |
+
TR.product_id,
|
200 |
+
TR.sinch_category_id,
|
201 |
+
TR.`name`,
|
202 |
+
TR.`image`,
|
203 |
+
TR.supplier_id,
|
204 |
+
TR.category_feature_id,
|
205 |
+
TR.feature_id,
|
206 |
+
TR.feature_name,
|
207 |
+
TR.feature_value
|
208 |
+
FROM `tmp_result` AS TR
|
209 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
210 |
+
@where,
|
211 |
+
'GROUP BY entity_id
|
212 |
+
)
|
213 |
+
');
|
214 |
+
|
215 |
+
END IF;
|
216 |
+
|
217 |
+
PREPARE myquery FROM @query;
|
218 |
+
EXECUTE myquery;
|
219 |
+
DROP PREPARE myquery;
|
220 |
+
|
221 |
+
END
|
222 |
+
";
|
223 |
+
|
224 |
+
if (!mysqli_query($cnx, $query)) {
|
225 |
+
throw new Exception("Failed to create stored procedure");
|
226 |
+
}
|
227 |
+
|
228 |
+
mysqli_close($cnx);
|
229 |
+
|
230 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.0-3.0.1.php
CHANGED
@@ -1,307 +1,307 @@
|
|
1 |
-
<?php
|
2 |
-
$installer = $this;
|
3 |
-
|
4 |
-
//прямое подключение к базе необходимо для добавления хранимки
|
5 |
-
$config = $installer->getConnection()->getConfig();
|
6 |
-
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
7 |
-
if (!$cnx) {
|
8 |
-
throw new Exception('Failed to connect to database.');
|
9 |
-
}
|
10 |
-
|
11 |
-
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
12 |
-
throw new Exception('Failed to select a database.');
|
13 |
-
}
|
14 |
-
|
15 |
-
$installer->startSetup();
|
16 |
-
|
17 |
-
|
18 |
-
$attr_text=array(
|
19 |
-
'reviews' => 'Reviews'
|
20 |
-
);
|
21 |
-
|
22 |
-
foreach($attr_text as $key=>$value){
|
23 |
-
|
24 |
-
$installer->addAttribute('catalog_product', $key,array(
|
25 |
-
'label' => $value,
|
26 |
-
'type' => 'text',
|
27 |
-
'input' => 'textarea',
|
28 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
29 |
-
'frontend' => '',
|
30 |
-
'source' => '',
|
31 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
32 |
-
'visible' => true,
|
33 |
-
'required' => false,
|
34 |
-
'user_defined' => false,
|
35 |
-
'searchable' => false,
|
36 |
-
'filterable' => false,
|
37 |
-
'comparable' => false,
|
38 |
-
'visible_on_front' => true,
|
39 |
-
'is_visible_on_front' => 1,
|
40 |
-
'is_html_allowed_on_front' => 1,
|
41 |
-
'visible_in_advanced_search' => false,
|
42 |
-
'unique' => false
|
43 |
-
));
|
44 |
-
|
45 |
-
$data=array(
|
46 |
-
'is_visible_on_front' => 1,
|
47 |
-
'is_html_allowed_on_front' => 1
|
48 |
-
);
|
49 |
-
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
50 |
-
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
51 |
-
$installer->updateAttribute($entityTypeId, $id, $data);
|
52 |
-
}
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
$installer->run("
|
59 |
-
INSERT ".$installer->getTable('stINch_sinchcheck')."(
|
60 |
-
caption,
|
61 |
-
descr,
|
62 |
-
check_code,
|
63 |
-
check_value,
|
64 |
-
check_measure,
|
65 |
-
error_msg, fix_msg
|
66 |
-
)
|
67 |
-
VALUE(
|
68 |
-
'Conflicts with installed plug-ins',
|
69 |
-
'checking conflicts with installed plug-ins and showing how to fix it',
|
70 |
-
'conflictwithinstalledmodules',
|
71 |
-
'Conflicts with installed plug-ins :',
|
72 |
-
'',
|
73 |
-
'Some of installed plug-ins rewrite Sinchimport module config',
|
74 |
-
'You can uninstall them or make inactive in [shop dir]/app/etc/modules '
|
75 |
-
);
|
76 |
-
");
|
77 |
-
|
78 |
-
|
79 |
-
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
80 |
-
|
81 |
-
$query = "
|
82 |
-
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
83 |
-
IN arg_table INT,
|
84 |
-
IN arg_category_id INT,
|
85 |
-
IN arg_image INT,
|
86 |
-
IN arg_category_feature INT,
|
87 |
-
IN arg_least INT,
|
88 |
-
IN arg_greatest INT,
|
89 |
-
IN arg_table_prefix VARCHAR(255)
|
90 |
-
)
|
91 |
-
BEGIN
|
92 |
-
DROP TABLE IF EXISTS `tmp_result`;
|
93 |
-
|
94 |
-
CREATE TEMPORARY TABLE `tmp_result`(
|
95 |
-
`entity_id` int(10) unsigned,
|
96 |
-
`category_id` int(10) unsigned,
|
97 |
-
`product_id` int,
|
98 |
-
`sinch_category_id` int,
|
99 |
-
`name` varchar(255),
|
100 |
-
`image` varchar(255),
|
101 |
-
`supplier_id` int,
|
102 |
-
`category_feature_id` int,
|
103 |
-
`feature_id` int,
|
104 |
-
`feature_name` varchar(255),
|
105 |
-
`feature_value` text
|
106 |
-
);
|
107 |
-
|
108 |
-
|
109 |
-
IF arg_image = 1 THEN
|
110 |
-
SET @updquery = CONCAT('
|
111 |
-
|
112 |
-
INSERT INTO `tmp_result` (
|
113 |
-
entity_id,
|
114 |
-
category_id,
|
115 |
-
product_id,
|
116 |
-
sinch_category_id,
|
117 |
-
`name`,
|
118 |
-
`image`,
|
119 |
-
supplier_id,
|
120 |
-
category_feature_id,
|
121 |
-
feature_id,
|
122 |
-
feature_name,
|
123 |
-
feature_value
|
124 |
-
)(
|
125 |
-
SELECT
|
126 |
-
E.entity_id,
|
127 |
-
PCind.category_id,
|
128 |
-
E.entity_id,
|
129 |
-
PCind.category_id as `sinch_category`,
|
130 |
-
PR.`product_name`,
|
131 |
-
PR.main_image_url,
|
132 |
-
PR.sinch_manufacturer_id,
|
133 |
-
CF.category_feature_id,
|
134 |
-
CF.category_feature_id,
|
135 |
-
CF.`feature_name`,
|
136 |
-
RV.`text`
|
137 |
-
FROM ', arg_table_prefix, 'catalog_product_entity E
|
138 |
-
INNER JOIN ', arg_table_prefix, 'catalog_category_product_index PCind
|
139 |
-
ON (E.entity_id = PCind.product_id)
|
140 |
-
INNER JOIN ', arg_table_prefix, 'stINch_categories_mapping scm
|
141 |
-
ON PCind.category_id=scm.shop_entity_id
|
142 |
-
INNER JOIN ',arg_table_prefix, 'stINch_categories_features CF
|
143 |
-
ON (scm.store_category_id=CF.store_category_id)
|
144 |
-
INNER JOIN ',arg_table_prefix, 'stINch_products PR
|
145 |
-
ON (PR.store_product_id = E.store_product_id)
|
146 |
-
INNER JOIN ',arg_table_prefix, 'stINch_product_features PF
|
147 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
148 |
-
INNER JOIN ',arg_table_prefix, 'stINch_restricted_values RV
|
149 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
150 |
-
WHERE
|
151 |
-
scm.shop_entity_id = ', arg_category_id, '
|
152 |
-
AND PR.main_image_url <> \'\'
|
153 |
-
)
|
154 |
-
');
|
155 |
-
ELSE
|
156 |
-
SET @updquery = CONCAT('
|
157 |
-
|
158 |
-
INSERT INTO `tmp_result` (
|
159 |
-
entity_id,
|
160 |
-
category_id,
|
161 |
-
product_id,
|
162 |
-
sinch_category_id,
|
163 |
-
`name`,
|
164 |
-
`image`,
|
165 |
-
supplier_id,
|
166 |
-
category_feature_id,
|
167 |
-
feature_id,
|
168 |
-
feature_name,
|
169 |
-
feature_value
|
170 |
-
)(
|
171 |
-
SELECT
|
172 |
-
E.entity_id,
|
173 |
-
PCind.category_id,
|
174 |
-
E.entity_id,
|
175 |
-
PCind.category_id as `sinch_category`,
|
176 |
-
PR.`product_name`,
|
177 |
-
PR.main_image_url,
|
178 |
-
PR.sinch_manufacturer_id,
|
179 |
-
CF.category_feature_id,
|
180 |
-
CF.category_feature_id,
|
181 |
-
CF.`feature_name`,
|
182 |
-
RV.`text`
|
183 |
-
FROM ', arg_table_prefix ,'catalog_product_entity E
|
184 |
-
INNER JOIN ', arg_table_prefix, 'catalog_category_product_index PCind
|
185 |
-
ON (E.entity_id = PCind.product_id)
|
186 |
-
INNER JOIN ', arg_table_prefix, 'stINch_categories_mapping scm
|
187 |
-
ON PCind.category_id=scm.shop_entity_id
|
188 |
-
INNER JOIN ', arg_table_prefix, 'stINch_categories_features CF
|
189 |
-
ON (scm.store_category_id=CF.store_category_id)
|
190 |
-
INNER JOIN ', arg_table_prefix, 'stINch_products PR
|
191 |
-
ON (PR.store_product_id = E.store_product_id)
|
192 |
-
INNER JOIN ', arg_table_prefix, 'stINch_product_features PF
|
193 |
-
ON (PR.sinch_product_id = PF.sinch_product_id )
|
194 |
-
INNER JOIN ', arg_table_prefix, 'stINch_restricted_values RV
|
195 |
-
ON (PF.restricted_value_id=RV.restricted_value_id)
|
196 |
-
WHERE
|
197 |
-
scm.shop_entity_id = ', arg_category_id, '
|
198 |
-
|
199 |
-
)
|
200 |
-
');
|
201 |
-
END IF;
|
202 |
-
|
203 |
-
PREPARE myquery FROM @updquery;
|
204 |
-
EXECUTE myquery;
|
205 |
-
DROP PREPARE myquery;
|
206 |
-
|
207 |
-
SET @filter_features_count = 0;
|
208 |
-
SET @ifquery = CONCAT('SELECT COUNT(*) INTO @filter_features_count FROM `', arg_table_prefix, 'FilterListOfFeatures`');
|
209 |
-
PREPARE myquery FROM @ifquery;
|
210 |
-
EXECUTE myquery;
|
211 |
-
DROP PREPARE myquery;
|
212 |
-
|
213 |
-
IF (@filter_features_count) > 0 THEN
|
214 |
-
SET @query = CONCAT('
|
215 |
-
INSERT INTO `', arg_table_prefix, 'SinchFilterResult_', arg_table, '` (
|
216 |
-
entity_id,
|
217 |
-
category_id,
|
218 |
-
product_id,
|
219 |
-
sinch_category_id,
|
220 |
-
`name`,
|
221 |
-
`image`,
|
222 |
-
supplier_id,
|
223 |
-
category_feature_id,
|
224 |
-
feature_id,
|
225 |
-
feature_name,
|
226 |
-
feature_value
|
227 |
-
)(
|
228 |
-
SELECT
|
229 |
-
TR.entity_id,
|
230 |
-
TR.category_id,
|
231 |
-
TR.product_id,
|
232 |
-
TR.sinch_category_id,
|
233 |
-
TR.`name`,
|
234 |
-
TR.`image`,
|
235 |
-
TR.supplier_id,
|
236 |
-
TR.category_feature_id,
|
237 |
-
TR.feature_id,
|
238 |
-
TR.feature_name,
|
239 |
-
TR.feature_value
|
240 |
-
FROM `tmp_result` AS TR
|
241 |
-
INNER JOIN `', arg_table_prefix, 'FilterListOfFeatures` AS LF
|
242 |
-
ON (TR.category_feature_id = LF.category_feature_id)
|
243 |
-
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
244 |
-
)
|
245 |
-
');
|
246 |
-
|
247 |
-
ELSE
|
248 |
-
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
249 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
250 |
-
ELSE
|
251 |
-
IF arg_least IS null THEN
|
252 |
-
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
253 |
-
ELSE
|
254 |
-
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
255 |
-
END IF;
|
256 |
-
END IF;
|
257 |
-
|
258 |
-
SET @query = CONCAT('
|
259 |
-
INSERT INTO `', arg_table_prefix, 'SinchFilterResult_', arg_table, '` (
|
260 |
-
entity_id,
|
261 |
-
category_id,
|
262 |
-
product_id,
|
263 |
-
sinch_category_id,
|
264 |
-
`name`,
|
265 |
-
`image`,
|
266 |
-
supplier_id,
|
267 |
-
category_feature_id,
|
268 |
-
feature_id,
|
269 |
-
feature_name,
|
270 |
-
feature_value
|
271 |
-
)(
|
272 |
-
SELECT
|
273 |
-
TR.entity_id,
|
274 |
-
TR.category_id,
|
275 |
-
TR.product_id,
|
276 |
-
TR.sinch_category_id,
|
277 |
-
TR.`name`,
|
278 |
-
TR.`image`,
|
279 |
-
TR.supplier_id,
|
280 |
-
TR.category_feature_id,
|
281 |
-
TR.feature_id,
|
282 |
-
TR.feature_name,
|
283 |
-
TR.feature_value
|
284 |
-
FROM `tmp_result` AS TR
|
285 |
-
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
286 |
-
@where,
|
287 |
-
'GROUP BY entity_id
|
288 |
-
)
|
289 |
-
');
|
290 |
-
|
291 |
-
END IF;
|
292 |
-
|
293 |
-
PREPARE myquery FROM @query;
|
294 |
-
EXECUTE myquery;
|
295 |
-
DROP PREPARE myquery;
|
296 |
-
|
297 |
-
END
|
298 |
-
";
|
299 |
-
|
300 |
-
if (!mysqli_query($cnx, $query)) {
|
301 |
-
throw new Exception("Failed to create stored procedure".$query);
|
302 |
-
}
|
303 |
-
|
304 |
-
|
305 |
-
mysqli_close($cnx);
|
306 |
-
|
307 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
|
4 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
5 |
+
$config = $installer->getConnection()->getConfig();
|
6 |
+
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
7 |
+
if (!$cnx) {
|
8 |
+
throw new Exception('Failed to connect to database.');
|
9 |
+
}
|
10 |
+
|
11 |
+
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
12 |
+
throw new Exception('Failed to select a database.');
|
13 |
+
}
|
14 |
+
|
15 |
+
$installer->startSetup();
|
16 |
+
|
17 |
+
|
18 |
+
$attr_text=array(
|
19 |
+
'reviews' => 'Reviews'
|
20 |
+
);
|
21 |
+
|
22 |
+
foreach($attr_text as $key=>$value){
|
23 |
+
|
24 |
+
$installer->addAttribute('catalog_product', $key,array(
|
25 |
+
'label' => $value,
|
26 |
+
'type' => 'text',
|
27 |
+
'input' => 'textarea',
|
28 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
29 |
+
'frontend' => '',
|
30 |
+
'source' => '',
|
31 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
32 |
+
'visible' => true,
|
33 |
+
'required' => false,
|
34 |
+
'user_defined' => false,
|
35 |
+
'searchable' => false,
|
36 |
+
'filterable' => false,
|
37 |
+
'comparable' => false,
|
38 |
+
'visible_on_front' => true,
|
39 |
+
'is_visible_on_front' => 1,
|
40 |
+
'is_html_allowed_on_front' => 1,
|
41 |
+
'visible_in_advanced_search' => false,
|
42 |
+
'unique' => false
|
43 |
+
));
|
44 |
+
|
45 |
+
$data=array(
|
46 |
+
'is_visible_on_front' => 1,
|
47 |
+
'is_html_allowed_on_front' => 1
|
48 |
+
);
|
49 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
50 |
+
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
51 |
+
$installer->updateAttribute($entityTypeId, $id, $data);
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
$installer->run("
|
59 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(
|
60 |
+
caption,
|
61 |
+
descr,
|
62 |
+
check_code,
|
63 |
+
check_value,
|
64 |
+
check_measure,
|
65 |
+
error_msg, fix_msg
|
66 |
+
)
|
67 |
+
VALUE(
|
68 |
+
'Conflicts with installed plug-ins',
|
69 |
+
'checking conflicts with installed plug-ins and showing how to fix it',
|
70 |
+
'conflictwithinstalledmodules',
|
71 |
+
'Conflicts with installed plug-ins :',
|
72 |
+
'',
|
73 |
+
'Some of installed plug-ins rewrite Sinchimport module config',
|
74 |
+
'You can uninstall them or make inactive in [shop dir]/app/etc/modules '
|
75 |
+
);
|
76 |
+
");
|
77 |
+
|
78 |
+
|
79 |
+
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
80 |
+
|
81 |
+
$query = "
|
82 |
+
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
83 |
+
IN arg_table INT,
|
84 |
+
IN arg_category_id INT,
|
85 |
+
IN arg_image INT,
|
86 |
+
IN arg_category_feature INT,
|
87 |
+
IN arg_least INT,
|
88 |
+
IN arg_greatest INT,
|
89 |
+
IN arg_table_prefix VARCHAR(255)
|
90 |
+
)
|
91 |
+
BEGIN
|
92 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
93 |
+
|
94 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
95 |
+
`entity_id` int(10) unsigned,
|
96 |
+
`category_id` int(10) unsigned,
|
97 |
+
`product_id` int,
|
98 |
+
`sinch_category_id` int,
|
99 |
+
`name` varchar(255),
|
100 |
+
`image` varchar(255),
|
101 |
+
`supplier_id` int,
|
102 |
+
`category_feature_id` int,
|
103 |
+
`feature_id` int,
|
104 |
+
`feature_name` varchar(255),
|
105 |
+
`feature_value` text
|
106 |
+
);
|
107 |
+
|
108 |
+
|
109 |
+
IF arg_image = 1 THEN
|
110 |
+
SET @updquery = CONCAT('
|
111 |
+
|
112 |
+
INSERT INTO `tmp_result` (
|
113 |
+
entity_id,
|
114 |
+
category_id,
|
115 |
+
product_id,
|
116 |
+
sinch_category_id,
|
117 |
+
`name`,
|
118 |
+
`image`,
|
119 |
+
supplier_id,
|
120 |
+
category_feature_id,
|
121 |
+
feature_id,
|
122 |
+
feature_name,
|
123 |
+
feature_value
|
124 |
+
)(
|
125 |
+
SELECT
|
126 |
+
E.entity_id,
|
127 |
+
PCind.category_id,
|
128 |
+
E.entity_id,
|
129 |
+
PCind.category_id as `sinch_category`,
|
130 |
+
PR.`product_name`,
|
131 |
+
PR.main_image_url,
|
132 |
+
PR.sinch_manufacturer_id,
|
133 |
+
CF.category_feature_id,
|
134 |
+
CF.category_feature_id,
|
135 |
+
CF.`feature_name`,
|
136 |
+
RV.`text`
|
137 |
+
FROM ', arg_table_prefix, 'catalog_product_entity E
|
138 |
+
INNER JOIN ', arg_table_prefix, 'catalog_category_product_index PCind
|
139 |
+
ON (E.entity_id = PCind.product_id)
|
140 |
+
INNER JOIN ', arg_table_prefix, 'stINch_categories_mapping scm
|
141 |
+
ON PCind.category_id=scm.shop_entity_id
|
142 |
+
INNER JOIN ',arg_table_prefix, 'stINch_categories_features CF
|
143 |
+
ON (scm.store_category_id=CF.store_category_id)
|
144 |
+
INNER JOIN ',arg_table_prefix, 'stINch_products PR
|
145 |
+
ON (PR.store_product_id = E.store_product_id)
|
146 |
+
INNER JOIN ',arg_table_prefix, 'stINch_product_features PF
|
147 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
148 |
+
INNER JOIN ',arg_table_prefix, 'stINch_restricted_values RV
|
149 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
150 |
+
WHERE
|
151 |
+
scm.shop_entity_id = ', arg_category_id, '
|
152 |
+
AND PR.main_image_url <> \'\'
|
153 |
+
)
|
154 |
+
');
|
155 |
+
ELSE
|
156 |
+
SET @updquery = CONCAT('
|
157 |
+
|
158 |
+
INSERT INTO `tmp_result` (
|
159 |
+
entity_id,
|
160 |
+
category_id,
|
161 |
+
product_id,
|
162 |
+
sinch_category_id,
|
163 |
+
`name`,
|
164 |
+
`image`,
|
165 |
+
supplier_id,
|
166 |
+
category_feature_id,
|
167 |
+
feature_id,
|
168 |
+
feature_name,
|
169 |
+
feature_value
|
170 |
+
)(
|
171 |
+
SELECT
|
172 |
+
E.entity_id,
|
173 |
+
PCind.category_id,
|
174 |
+
E.entity_id,
|
175 |
+
PCind.category_id as `sinch_category`,
|
176 |
+
PR.`product_name`,
|
177 |
+
PR.main_image_url,
|
178 |
+
PR.sinch_manufacturer_id,
|
179 |
+
CF.category_feature_id,
|
180 |
+
CF.category_feature_id,
|
181 |
+
CF.`feature_name`,
|
182 |
+
RV.`text`
|
183 |
+
FROM ', arg_table_prefix ,'catalog_product_entity E
|
184 |
+
INNER JOIN ', arg_table_prefix, 'catalog_category_product_index PCind
|
185 |
+
ON (E.entity_id = PCind.product_id)
|
186 |
+
INNER JOIN ', arg_table_prefix, 'stINch_categories_mapping scm
|
187 |
+
ON PCind.category_id=scm.shop_entity_id
|
188 |
+
INNER JOIN ', arg_table_prefix, 'stINch_categories_features CF
|
189 |
+
ON (scm.store_category_id=CF.store_category_id)
|
190 |
+
INNER JOIN ', arg_table_prefix, 'stINch_products PR
|
191 |
+
ON (PR.store_product_id = E.store_product_id)
|
192 |
+
INNER JOIN ', arg_table_prefix, 'stINch_product_features PF
|
193 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
194 |
+
INNER JOIN ', arg_table_prefix, 'stINch_restricted_values RV
|
195 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
196 |
+
WHERE
|
197 |
+
scm.shop_entity_id = ', arg_category_id, '
|
198 |
+
|
199 |
+
)
|
200 |
+
');
|
201 |
+
END IF;
|
202 |
+
|
203 |
+
PREPARE myquery FROM @updquery;
|
204 |
+
EXECUTE myquery;
|
205 |
+
DROP PREPARE myquery;
|
206 |
+
|
207 |
+
SET @filter_features_count = 0;
|
208 |
+
SET @ifquery = CONCAT('SELECT COUNT(*) INTO @filter_features_count FROM `', arg_table_prefix, 'FilterListOfFeatures`');
|
209 |
+
PREPARE myquery FROM @ifquery;
|
210 |
+
EXECUTE myquery;
|
211 |
+
DROP PREPARE myquery;
|
212 |
+
|
213 |
+
IF (@filter_features_count) > 0 THEN
|
214 |
+
SET @query = CONCAT('
|
215 |
+
INSERT INTO `', arg_table_prefix, 'SinchFilterResult_', arg_table, '` (
|
216 |
+
entity_id,
|
217 |
+
category_id,
|
218 |
+
product_id,
|
219 |
+
sinch_category_id,
|
220 |
+
`name`,
|
221 |
+
`image`,
|
222 |
+
supplier_id,
|
223 |
+
category_feature_id,
|
224 |
+
feature_id,
|
225 |
+
feature_name,
|
226 |
+
feature_value
|
227 |
+
)(
|
228 |
+
SELECT
|
229 |
+
TR.entity_id,
|
230 |
+
TR.category_id,
|
231 |
+
TR.product_id,
|
232 |
+
TR.sinch_category_id,
|
233 |
+
TR.`name`,
|
234 |
+
TR.`image`,
|
235 |
+
TR.supplier_id,
|
236 |
+
TR.category_feature_id,
|
237 |
+
TR.feature_id,
|
238 |
+
TR.feature_name,
|
239 |
+
TR.feature_value
|
240 |
+
FROM `tmp_result` AS TR
|
241 |
+
INNER JOIN `', arg_table_prefix, 'FilterListOfFeatures` AS LF
|
242 |
+
ON (TR.category_feature_id = LF.category_feature_id)
|
243 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
244 |
+
)
|
245 |
+
');
|
246 |
+
|
247 |
+
ELSE
|
248 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
249 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
250 |
+
ELSE
|
251 |
+
IF arg_least IS null THEN
|
252 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
253 |
+
ELSE
|
254 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
255 |
+
END IF;
|
256 |
+
END IF;
|
257 |
+
|
258 |
+
SET @query = CONCAT('
|
259 |
+
INSERT INTO `', arg_table_prefix, 'SinchFilterResult_', arg_table, '` (
|
260 |
+
entity_id,
|
261 |
+
category_id,
|
262 |
+
product_id,
|
263 |
+
sinch_category_id,
|
264 |
+
`name`,
|
265 |
+
`image`,
|
266 |
+
supplier_id,
|
267 |
+
category_feature_id,
|
268 |
+
feature_id,
|
269 |
+
feature_name,
|
270 |
+
feature_value
|
271 |
+
)(
|
272 |
+
SELECT
|
273 |
+
TR.entity_id,
|
274 |
+
TR.category_id,
|
275 |
+
TR.product_id,
|
276 |
+
TR.sinch_category_id,
|
277 |
+
TR.`name`,
|
278 |
+
TR.`image`,
|
279 |
+
TR.supplier_id,
|
280 |
+
TR.category_feature_id,
|
281 |
+
TR.feature_id,
|
282 |
+
TR.feature_name,
|
283 |
+
TR.feature_value
|
284 |
+
FROM `tmp_result` AS TR
|
285 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
286 |
+
@where,
|
287 |
+
'GROUP BY entity_id
|
288 |
+
)
|
289 |
+
');
|
290 |
+
|
291 |
+
END IF;
|
292 |
+
|
293 |
+
PREPARE myquery FROM @query;
|
294 |
+
EXECUTE myquery;
|
295 |
+
DROP PREPARE myquery;
|
296 |
+
|
297 |
+
END
|
298 |
+
";
|
299 |
+
|
300 |
+
if (!mysqli_query($cnx, $query)) {
|
301 |
+
throw new Exception("Failed to create stored procedure".$query);
|
302 |
+
}
|
303 |
+
|
304 |
+
|
305 |
+
mysqli_close($cnx);
|
306 |
+
|
307 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.1-3.0.2.php
CHANGED
@@ -1,108 +1,108 @@
|
|
1 |
-
<?php
|
2 |
-
$installer = $this;
|
3 |
-
|
4 |
-
$installer->startSetup();
|
5 |
-
|
6 |
-
$installer->run("
|
7 |
-
DROP TABLE IF EXISTS ".$installer->getTable('stINch_distributors').";
|
8 |
-
");
|
9 |
-
|
10 |
-
$installer->run("
|
11 |
-
CREATE TABLE ".$installer->getTable('stINch_distributors')."
|
12 |
-
(
|
13 |
-
distributor_id int(11),
|
14 |
-
distributor_name varchar(255),
|
15 |
-
website varchar(255),
|
16 |
-
KEY(distributor_id)
|
17 |
-
);
|
18 |
-
");
|
19 |
-
|
20 |
-
$installer->run("
|
21 |
-
DROP TABLE IF EXISTS ".$installer->getTable('stINch_distributors_stock_and_price').";
|
22 |
-
");
|
23 |
-
|
24 |
-
$installer->run("
|
25 |
-
CREATE TABLE ".$installer->getTable('stINch_distributors_stock_and_price')."
|
26 |
-
(
|
27 |
-
`store_product_id` int(11) DEFAULT NULL,
|
28 |
-
`distributor_id` int(11) DEFAULT NULL,
|
29 |
-
`stock` int(11) DEFAULT NULL,
|
30 |
-
`cost` decimal(15,4) DEFAULT NULL,
|
31 |
-
`distributor_sku` varchar(255) DEFAULT NULL,
|
32 |
-
`distributor_category` varchar(50) DEFAULT NULL,
|
33 |
-
`eta` varchar(50) DEFAULT NULL,
|
34 |
-
UNIQUE KEY `product_distri` (store_product_id, distributor_id)
|
35 |
-
);
|
36 |
-
");
|
37 |
-
|
38 |
-
|
39 |
-
$attr_text=array(
|
40 |
-
'sinch_search_cache' => 'Sinch Search Cache'
|
41 |
-
);
|
42 |
-
|
43 |
-
foreach($attr_text as $key=>$value){
|
44 |
-
|
45 |
-
$installer->addAttribute('catalog_product', $key,array(
|
46 |
-
'label' => $value,
|
47 |
-
'type' => 'text',
|
48 |
-
'input' => 'textarea',
|
49 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
50 |
-
'frontend' => '',
|
51 |
-
'source' => '',
|
52 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
53 |
-
'visible' => false,
|
54 |
-
'required' => false,
|
55 |
-
'user_defined' => false,
|
56 |
-
'searchable' => 1,
|
57 |
-
'filterable' => false,
|
58 |
-
'comparable' => false,
|
59 |
-
'visible_on_front' => true,
|
60 |
-
'is_visible_on_front' => 1,
|
61 |
-
'is_html_allowed_on_front' => 1,
|
62 |
-
'visible_in_advanced_search' => false,
|
63 |
-
'unique' => false
|
64 |
-
));
|
65 |
-
|
66 |
-
$installer->updateAttribute('catalog_product', $key, 'is_searchable', '1');
|
67 |
-
}
|
68 |
-
|
69 |
-
$attr_varchar=array(
|
70 |
-
'pdf_url' => 'PDF Url'
|
71 |
-
);
|
72 |
-
|
73 |
-
foreach($attr_varchar as $key=>$value){
|
74 |
-
|
75 |
-
$installer->addAttribute('catalog_product', $key,array(
|
76 |
-
'label' => $value,
|
77 |
-
'type' => 'varchar',
|
78 |
-
'input' => 'text',
|
79 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
80 |
-
'frontend' => '',
|
81 |
-
'source' => '',
|
82 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
83 |
-
'visible' => true,
|
84 |
-
'required' => false,
|
85 |
-
'user_defined' => false,
|
86 |
-
'searchable' => false,
|
87 |
-
'filterable' => false,
|
88 |
-
'comparable' => false,
|
89 |
-
'visible_on_front' => true,
|
90 |
-
'visible_in_advanced_search' => false,
|
91 |
-
'unique' => false
|
92 |
-
));
|
93 |
-
|
94 |
-
|
95 |
-
$data=array(
|
96 |
-
'is_visible_on_front' => 1,
|
97 |
-
'is_html_allowed_on_front' => 1
|
98 |
-
);
|
99 |
-
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
100 |
-
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
101 |
-
$installer->updateAttribute($entityTypeId, $id, $data);
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
$installer->run("
|
7 |
+
DROP TABLE IF EXISTS ".$installer->getTable('stINch_distributors').";
|
8 |
+
");
|
9 |
+
|
10 |
+
$installer->run("
|
11 |
+
CREATE TABLE ".$installer->getTable('stINch_distributors')."
|
12 |
+
(
|
13 |
+
distributor_id int(11),
|
14 |
+
distributor_name varchar(255),
|
15 |
+
website varchar(255),
|
16 |
+
KEY(distributor_id)
|
17 |
+
);
|
18 |
+
");
|
19 |
+
|
20 |
+
$installer->run("
|
21 |
+
DROP TABLE IF EXISTS ".$installer->getTable('stINch_distributors_stock_and_price').";
|
22 |
+
");
|
23 |
+
|
24 |
+
$installer->run("
|
25 |
+
CREATE TABLE ".$installer->getTable('stINch_distributors_stock_and_price')."
|
26 |
+
(
|
27 |
+
`store_product_id` int(11) DEFAULT NULL,
|
28 |
+
`distributor_id` int(11) DEFAULT NULL,
|
29 |
+
`stock` int(11) DEFAULT NULL,
|
30 |
+
`cost` decimal(15,4) DEFAULT NULL,
|
31 |
+
`distributor_sku` varchar(255) DEFAULT NULL,
|
32 |
+
`distributor_category` varchar(50) DEFAULT NULL,
|
33 |
+
`eta` varchar(50) DEFAULT NULL,
|
34 |
+
UNIQUE KEY `product_distri` (store_product_id, distributor_id)
|
35 |
+
);
|
36 |
+
");
|
37 |
+
|
38 |
+
|
39 |
+
$attr_text=array(
|
40 |
+
'sinch_search_cache' => 'Sinch Search Cache'
|
41 |
+
);
|
42 |
+
|
43 |
+
foreach($attr_text as $key=>$value){
|
44 |
+
|
45 |
+
$installer->addAttribute('catalog_product', $key,array(
|
46 |
+
'label' => $value,
|
47 |
+
'type' => 'text',
|
48 |
+
'input' => 'textarea',
|
49 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
50 |
+
'frontend' => '',
|
51 |
+
'source' => '',
|
52 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
53 |
+
'visible' => false,
|
54 |
+
'required' => false,
|
55 |
+
'user_defined' => false,
|
56 |
+
'searchable' => 1,
|
57 |
+
'filterable' => false,
|
58 |
+
'comparable' => false,
|
59 |
+
'visible_on_front' => true,
|
60 |
+
'is_visible_on_front' => 1,
|
61 |
+
'is_html_allowed_on_front' => 1,
|
62 |
+
'visible_in_advanced_search' => false,
|
63 |
+
'unique' => false
|
64 |
+
));
|
65 |
+
|
66 |
+
$installer->updateAttribute('catalog_product', $key, 'is_searchable', '1');
|
67 |
+
}
|
68 |
+
|
69 |
+
$attr_varchar=array(
|
70 |
+
'pdf_url' => 'PDF Url'
|
71 |
+
);
|
72 |
+
|
73 |
+
foreach($attr_varchar as $key=>$value){
|
74 |
+
|
75 |
+
$installer->addAttribute('catalog_product', $key,array(
|
76 |
+
'label' => $value,
|
77 |
+
'type' => 'varchar',
|
78 |
+
'input' => 'text',
|
79 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
80 |
+
'frontend' => '',
|
81 |
+
'source' => '',
|
82 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
83 |
+
'visible' => true,
|
84 |
+
'required' => false,
|
85 |
+
'user_defined' => false,
|
86 |
+
'searchable' => false,
|
87 |
+
'filterable' => false,
|
88 |
+
'comparable' => false,
|
89 |
+
'visible_on_front' => true,
|
90 |
+
'visible_in_advanced_search' => false,
|
91 |
+
'unique' => false
|
92 |
+
));
|
93 |
+
|
94 |
+
|
95 |
+
$data=array(
|
96 |
+
'is_visible_on_front' => 1,
|
97 |
+
'is_html_allowed_on_front' => 1
|
98 |
+
);
|
99 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
100 |
+
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
101 |
+
$installer->updateAttribute($entityTypeId, $id, $data);
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.2-3.0.3.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$installer = $this;
|
4 |
-
|
5 |
-
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
-
$config = $installer->getConnection()->getConfig();
|
7 |
-
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
-
if (!$cnx) {
|
9 |
-
throw new Exception('Failed to connect to database.');
|
10 |
-
}
|
11 |
-
|
12 |
-
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
-
throw new Exception('Failed to select a database.');
|
14 |
-
}
|
15 |
-
|
16 |
-
$installer->startSetup();
|
17 |
-
|
18 |
-
$installer->run("DROP FUNCTION IF EXISTS ".$installer->getTable('func_calc_price'));
|
19 |
-
|
20 |
-
$query = "
|
21 |
-
CREATE FUNCTION ".$installer->getTable('func_calc_price')." (price decimal(8,2) , marge decimal(10,2), fixed decimal(10,2), final_price decimal(10,2)) RETURNS decimal(8,2)
|
22 |
-
BEGIN
|
23 |
-
IF marge IS NOT NULL THEN
|
24 |
-
RETURN price + price * marge / 100;
|
25 |
-
END IF;
|
26 |
-
IF fixed IS NOT NULL THEN
|
27 |
-
RETURN price + fixed;
|
28 |
-
END IF;
|
29 |
-
IF final_price IS NOT NULL THEN
|
30 |
-
RETURN final_price;
|
31 |
-
END IF;
|
32 |
-
RETURN price;
|
33 |
-
END
|
34 |
-
";
|
35 |
-
|
36 |
-
if (!mysqli_query($cnx, $query)) {
|
37 |
-
throw new Exception("Failed to create stored function");
|
38 |
-
}
|
39 |
-
|
40 |
-
mysqli_close($cnx);
|
41 |
-
|
42 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
+
$config = $installer->getConnection()->getConfig();
|
7 |
+
$cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
|
8 |
+
if (!$cnx) {
|
9 |
+
throw new Exception('Failed to connect to database.');
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!mysqli_select_db($cnx, $config['dbname'])) {
|
13 |
+
throw new Exception('Failed to select a database.');
|
14 |
+
}
|
15 |
+
|
16 |
+
$installer->startSetup();
|
17 |
+
|
18 |
+
$installer->run("DROP FUNCTION IF EXISTS ".$installer->getTable('func_calc_price'));
|
19 |
+
|
20 |
+
$query = "
|
21 |
+
CREATE FUNCTION ".$installer->getTable('func_calc_price')." (price decimal(8,2) , marge decimal(10,2), fixed decimal(10,2), final_price decimal(10,2)) RETURNS decimal(8,2)
|
22 |
+
BEGIN
|
23 |
+
IF marge IS NOT NULL THEN
|
24 |
+
RETURN price + price * marge / 100;
|
25 |
+
END IF;
|
26 |
+
IF fixed IS NOT NULL THEN
|
27 |
+
RETURN price + fixed;
|
28 |
+
END IF;
|
29 |
+
IF final_price IS NOT NULL THEN
|
30 |
+
RETURN final_price;
|
31 |
+
END IF;
|
32 |
+
RETURN price;
|
33 |
+
END
|
34 |
+
";
|
35 |
+
|
36 |
+
if (!mysqli_query($cnx, $query)) {
|
37 |
+
throw new Exception("Failed to create stored function");
|
38 |
+
}
|
39 |
+
|
40 |
+
mysqli_close($cnx);
|
41 |
+
|
42 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.3-3.0.4.php
CHANGED
@@ -1,50 +1,50 @@
|
|
1 |
-
<?php
|
2 |
-
$installer = $this;
|
3 |
-
|
4 |
-
$installer->startSetup();
|
5 |
-
|
6 |
-
|
7 |
-
$attr_varchar=array(
|
8 |
-
'supplier_1' => 'Supplier 1',
|
9 |
-
'supplier_2' => 'Supplier 2',
|
10 |
-
'supplier_3' => 'Supplier 3',
|
11 |
-
'supplier_4' => 'Supplier 4',
|
12 |
-
'supplier_5' => 'Supplier 5'
|
13 |
-
);
|
14 |
-
|
15 |
-
foreach($attr_varchar as $key=>$value){
|
16 |
-
|
17 |
-
$installer->addAttribute('catalog_product', $key,array(
|
18 |
-
'label' => $value,
|
19 |
-
'type' => 'varchar',
|
20 |
-
'input' => 'text',
|
21 |
-
'backend' => 'eav/entity_attribute_backend_array',
|
22 |
-
'frontend' => '',
|
23 |
-
'source' => '',
|
24 |
-
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
25 |
-
'visible' => true,
|
26 |
-
'required' => false,
|
27 |
-
'user_defined' => false,
|
28 |
-
'searchable' => false,
|
29 |
-
'filterable' => false,
|
30 |
-
'comparable' => false,
|
31 |
-
'visible_on_front' => true,
|
32 |
-
'visible_in_advanced_search' => false,
|
33 |
-
'unique' => false
|
34 |
-
));
|
35 |
-
|
36 |
-
|
37 |
-
$data=array(
|
38 |
-
'is_visible_on_front' => 0,
|
39 |
-
'is_html_allowed_on_front' => 1
|
40 |
-
);
|
41 |
-
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
42 |
-
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
43 |
-
$installer->updateAttribute($entityTypeId, $id, $data);
|
44 |
-
}
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
|
7 |
+
$attr_varchar=array(
|
8 |
+
'supplier_1' => 'Supplier 1',
|
9 |
+
'supplier_2' => 'Supplier 2',
|
10 |
+
'supplier_3' => 'Supplier 3',
|
11 |
+
'supplier_4' => 'Supplier 4',
|
12 |
+
'supplier_5' => 'Supplier 5'
|
13 |
+
);
|
14 |
+
|
15 |
+
foreach($attr_varchar as $key=>$value){
|
16 |
+
|
17 |
+
$installer->addAttribute('catalog_product', $key,array(
|
18 |
+
'label' => $value,
|
19 |
+
'type' => 'varchar',
|
20 |
+
'input' => 'text',
|
21 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
22 |
+
'frontend' => '',
|
23 |
+
'source' => '',
|
24 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
25 |
+
'visible' => true,
|
26 |
+
'required' => false,
|
27 |
+
'user_defined' => false,
|
28 |
+
'searchable' => false,
|
29 |
+
'filterable' => false,
|
30 |
+
'comparable' => false,
|
31 |
+
'visible_on_front' => true,
|
32 |
+
'visible_in_advanced_search' => false,
|
33 |
+
'unique' => false
|
34 |
+
));
|
35 |
+
|
36 |
+
|
37 |
+
$data=array(
|
38 |
+
'is_visible_on_front' => 0,
|
39 |
+
'is_html_allowed_on_front' => 1
|
40 |
+
);
|
41 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
42 |
+
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
43 |
+
$installer->updateAttribute($entityTypeId, $id, $data);
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/stock_price_sinch_import_start_ajax.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
$baseDir = dirname(__FILE__);
|
3 |
-
require $baseDir . '/../../../../../app/Mage.php';
|
4 |
-
|
5 |
-
Mage::app();
|
6 |
-
|
7 |
-
$import=Mage::getModel('sinchimport/sinch');
|
8 |
-
|
9 |
-
|
10 |
-
$import->run_stock_price_sinch_import();
|
11 |
-
|
12 |
-
$import->addImportStatus('Stock Price Finish import', 1);
|
13 |
-
|
14 |
-
?>
|
1 |
+
<?php
|
2 |
+
$baseDir = dirname(__FILE__);
|
3 |
+
require $baseDir . '/../../../../../app/Mage.php';
|
4 |
+
|
5 |
+
Mage::app();
|
6 |
+
|
7 |
+
$import=Mage::getModel('sinchimport/sinch');
|
8 |
+
|
9 |
+
|
10 |
+
$import->run_stock_price_sinch_import();
|
11 |
+
|
12 |
+
$import->addImportStatus('Stock Price Finish import', 1);
|
13 |
+
|
14 |
+
?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>stockinthechannel2012</name>
|
4 |
-
<version>2.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3</license>
|
7 |
<channel>community</channel>
|
@@ -9,12 +9,12 @@
|
|
9 |
<summary>Import Plugin for the Stock in the Channel Magento Data Feed</summary>
|
10 |
<description>Import Plugin for the Stock in the Channel Magento Data Feed.
|
11 |
Requires a Magento Formatted Data feed from http://stockinthechannel.com</description>
|
12 |
-
<notes>Version 2.0.
|
13 |
-
*
|
14 |
<authors><author><name>stockinchannel</name><user>stockinchannel</user><email>marketing@stockinthechannel.com</email></author><author><name>Nick Anstee</name><user>nicka101</user><email>nick@stockinthechannel.com</email></author></authors>
|
15 |
-
<date>2015-01-
|
16 |
-
<time>
|
17 |
-
<contents><target name="magelocal"><dir name="Bintime"><dir name="Sinchimport"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Sinchdistributors.php" hash="
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>stockinthechannel2012</name>
|
4 |
+
<version>2.0.8</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3</license>
|
7 |
<channel>community</channel>
|
9 |
<summary>Import Plugin for the Stock in the Channel Magento Data Feed</summary>
|
10 |
<description>Import Plugin for the Stock in the Channel Magento Data Feed.
|
11 |
Requires a Magento Formatted Data feed from http://stockinthechannel.com</description>
|
12 |
+
<notes>Version 2.0.8:
|
13 |
+
* Add Demo site to server list</notes>
|
14 |
<authors><author><name>stockinchannel</name><user>stockinchannel</user><email>marketing@stockinthechannel.com</email></author><author><name>Nick Anstee</name><user>nicka101</user><email>nick@stockinthechannel.com</email></author></authors>
|
15 |
+
<date>2015-01-16</date>
|
16 |
+
<time>15:29:49</time>
|
17 |
+
<contents><target name="magelocal"><dir name="Bintime"><dir name="Sinchimport"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Sinchdistributors.php" hash="20c2452bfbf7206c72b2402e4eaa1541"/></dir></dir></dir><file name="Importenvironment.php" hash="85ac7cf582ad798fc31d85855319d6e1"/><file name="Importhistory.php" hash="9f1bda290333c3015b54ef3802857a3f"/><dir name="Layer"><dir name="Filter"><file name="Feature.php" hash="239d86cde4cf08f5f50183df26e89eea"/></dir><file name="View.php" hash="60e6aeb7f07e6be9e6202395bf76dfad"/></dir><file name="List.php" hash="db883cb9fb90fc16e4e9cb5db2050937"/><dir name="Product"><dir name="View"><file name="Media.php" hash="f82030a12d1d41dfc75647a56b691dcb"/></dir></dir><file name="Startimportbutton.php" hash="b7564c48d52fc777abe1c5e87f63ad02"/><file name="Startstockpriceimportbutton.php" hash="f295d3d570114d0eb71238fb9c51dfa4"/></dir><dir name="Helper"><file name="Data.php" hash="6ba3ed5d098de4d1d90f5ce49bffbed2"/><file name="Getdata.php" hash="b966ec1c48a70956c980627af49d2078"/><file name="Image.php" hash="4507e0741e1bf094ce558ffb908dbae8"/></dir><dir name="Model"><file name="Api.php" hash="9c563069c93b6010597114a32304e44d"/><file name="Category.php" hash="24023d361652a68627a28a20b9229684"/><file name="Image.php" hash="b87da6ed365c3265495afdc2f3b04eb2"/><dir name="Layer"><dir name="Filter"><file name="Feature.php" hash="4ab6866b88f6aa5e59a99808b38dc85b"/><file name="Price.php" hash="93a6b62fec1e11bf6af57dd0cb2f063a"/></dir></dir><file name="Layer.php" hash="2c0131265f18450126d7a0988d6ed284"/><file name="Product.php" hash="de3db0ad9ab43ec060f906a66e7ac2ee"/><dir name="Resource"><dir name="Layer"><dir name="Filter"><file name="Price.php" hash="8d60e0cf4d143dd98f72353ff7f5c0b2"/></dir></dir><dir name="Mysql4"><dir name="Layer"><dir name="Filter"><file name="Feature.php" hash="ea9c35e365239bdcc362ff98369cbd87"/></dir></dir><file name="Setup.php" hash="a46e28853cc29d7ba38a168342f60b59"/></dir></dir><file name="Sinch.php" hash="2e7f6cbed7e7fee4283b0487d82e15a6"/><dir name="System"><dir name="Config"><file name="CatRewrite.php" hash="9e23b203bd4af59065776696794f105a"/><file name="ProdRewrite.php" hash="a93e7bfa552cb18886c06c7404d41e8a"/><file name="ServerList.php" hash="0ec52dc392e19e67a5da1eb7430aecef"/><file name="Subscription.php" hash="2909e8dfe199e768fe763561cca68ac5"/></dir></dir><file name="config.php" hash="239f67e965eb9dbe0ada9af8f2112f13"/></dir><dir name="controllers"><file name="AjaxController.php" hash="388673c76cae1930317331ba66bf34b7"/><file name="IndexController.php" hash="54610343286f65e5ab6c640101194502"/><file name="ProductController.php" hash="f1a19d5b9516fe1896a74adafb005953"/><file name="SplitfeaturesController.php" hash="201702c1b94fdea2bb8f8f09ad96508e"/></dir><dir name="etc"><file name="api.xml" hash="4b9df3ba0ff94824f06a5c14497034cb"/><file name="config.xml" hash="d1aef99f24977f702b6f3f5aaaf1f373"/><file name="system.xml" hash="b725941c89c9695ac9ff6e15e30ffb8e"/></dir><file name="sinch_import_start_ajax.php" hash="3f34acad1b0618d5350d28fd1acf506d"/><dir name="sql"><dir name="sinchimport_setup"><file name="filter_sinch_products_s.sql" hash="a66330a1c2717091c1752ddd89f63960"/><file name="mysql4-install-0.1.0.php" hash="5925ffb8574cb35032b9d2866f4da7be"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="93a43b01c4ad6eb9c9638dc1d31ca777"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="710c4d2873fcbe3061b925072d995d73"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="d2892bb825c7baf2139c136fd96f2f66"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="ab6aa72ff697db247423911437830795"/><file name="mysql4-upgrade-0.1.4-0.1.5.php" hash="f195a8bf9fbcc31eca6d066ff1bb98f5"/><file name="mysql4-upgrade-0.1.5-0.1.6.php" hash="f4ee53d9644c16c80327b40fec432d1d"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="987ed4ca76a263580705ec93e0277120"/><file name="mysql4-upgrade-0.1.7-0.1.8.php" hash="e52bb4ef6f982992fcbfcce710698525"/><file name="mysql4-upgrade-0.1.8-0.1.9.php" hash="de6b560cef7edf7914cc4f135b0678b9"/><file name="mysql4-upgrade-0.1.9-0.2.0.php" hash="33618a810c8b88d28fc1b504eb65c657"/><file name="mysql4-upgrade-0.2.0-0.2.1.php" hash="507b285ba1f3eb98d9fb54a3ae29257c"/><file name="mysql4-upgrade-0.2.1-0.2.2.php" hash="55732b89b294191eaecbe3a5e1c7691e"/><file name="mysql4-upgrade-3.0.0-3.0.1.php" hash="3a7b53cbc0585e04afed64b321771a8a"/><file name="mysql4-upgrade-3.0.1-3.0.2.php" hash="12853ce85af460e0d462fbf3297715c0"/><file name="mysql4-upgrade-3.0.2-3.0.3.php" hash="2c0c1a12c567ecacad6647eeffa4f198"/><file name="mysql4-upgrade-3.0.3-3.0.4.php" hash="9c3612df0a873fa6e59ae9f98c5de2b0"/></dir></dir><file name="stock_price_sinch_import_start_ajax.php" hash="960ba4cfdb5ea3548a17c2365c0fca80"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bintime_Sinchimport.xml" hash="14afd0361958cc31fc57431c4e4c3ba1"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="sinchimport.xml" hash="e60b86828e8d9666724311907451d1ba"/></dir><dir name="template"><dir name="sinchimport"><file name="list.phtml" hash="1312f3b0ded996cb820e9c17a434e716"/><file name="media.phtml" hash="a448fd63753f44c86cc091e4da8b9e99"/><file name="view.phtml" hash="7c21e0b3f31cf3eb7d0e2a6e619f58ef"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sinchimport.xml" hash="86d65ea9bea9c37cfb20f593095995db"/></dir><dir name="template"><dir name="sinchimport"><dir name="sales"><dir name="items"><dir name="column"><file name="name.phtml" hash="7997765254d19e09b30cf1d0090bd4e6"/></dir></dir></dir><file name="sinchdistributors.phtml" hash="d74f3d401b83319c1b42b878afc5ccff"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="sinchimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="sinchimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/></dir></dir></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|