Version Notes
Now has section to check server configuration for suitability of running extension.
Download this release
Release Info
| Developer | stockinchannel |
| Extension | stockinthechannel2012 |
| Version | 1.0.0.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0.0 to 1.0.0.1
- app/code/local/Bintime/Sinchimport/Block/Importenvironment.php +194 -0
- app/code/local/Bintime/Sinchimport/Block/Importhistory.php +1 -1
- app/code/local/Bintime/Sinchimport/Block/List.php +38 -9
- app/code/local/Bintime/Sinchimport/Model/Layer.php +0 -166
- app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Feature.php +14 -9
- app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php +17 -17
- app/code/local/Bintime/Sinchimport/Model/Sinch.php +4145 -3120
- app/code/local/Bintime/Sinchimport/Model/config.php +0 -11
- app/code/local/Bintime/Sinchimport/etc/config.xml +3 -3
- app/code/local/Bintime/Sinchimport/etc/system.xml +23 -2
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-install-0.1.0.php +14 -14
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.1-0.1.2.php +43 -18
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.2-0.1.3.php +14 -14
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.4-0.1.5.php +2 -2
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.5-0.1.6.php +1 -1
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.6-0.1.7.php +225 -114
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.7-0.1.8.php +108 -0
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.8-0.1.9.php +13 -0
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.9-0.2.0.php +126 -0
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.0-0.2.1.php +108 -0
- app/design/frontend/default/default/template/sinchimport/list.phtml +0 -153
- app/design/frontend/default/default/template/sinchimport/media.phtml +0 -89
- app/design/frontend/default/default/template/sinchimport/view.phtml +0 -363
- package.xml +12 -13
app/code/local/Bintime/Sinchimport/Block/Importenvironment.php
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 rowspan=4> $caption </td> </tr>
|
| 44 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 45 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 46 |
+
<tr> <td nowrap> <b>Fix: </b>$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 rowspan=4> $caption </td> </tr>
|
| 59 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 60 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 61 |
+
<tr> <td nowrap> <b>Fix: </b>$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 rowspan=4> $caption </td> </tr>
|
| 73 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 74 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 75 |
+
<tr> <td nowrap> <b>Fix: </b>$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 rowspan=4> $caption </td> </tr>
|
| 87 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 88 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 89 |
+
<tr> <td nowrap> <b>Fix: </b>$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 rowspan=4> $caption </td> </tr>
|
| 101 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 102 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 103 |
+
<tr> <td nowrap> <b>Fix: </b>$fixmsg </td> </tr>
|
| 104 |
+
";
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
// PHP run string
|
| 109 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhprunstring();
|
| 110 |
+
if ($status == 'error') $errors_count++;
|
| 111 |
+
if ($status == 'error') {
|
| 112 |
+
$html .= // $caption: $value $measure
|
| 113 |
+
"
|
| 114 |
+
<tr> <td rowspan=4> $caption </td> </tr>
|
| 115 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 116 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 117 |
+
<tr> <td nowrap> <b>Fix: </b>$fixmsg </td> </tr>
|
| 118 |
+
";
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
// Chmod wget file
|
| 123 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetdatafile();
|
| 124 |
+
if ($status == 'error') $errors_count++;
|
| 125 |
+
if ($status == 'error') {
|
| 126 |
+
$html .= // $caption: $value $measure
|
| 127 |
+
"
|
| 128 |
+
<tr> <td rowspan=4> $caption </td> </tr>
|
| 129 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 130 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 131 |
+
<tr> <td nowrap> <b>Fix: </b>$fixmsg </td> </tr>
|
| 132 |
+
";
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
// Chmod wget cron.php file
|
| 137 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronphpfile();
|
| 138 |
+
if ($status == 'error') $errors_count++;
|
| 139 |
+
if ($status == 'error') {
|
| 140 |
+
$html .= // $caption: $value $measure
|
| 141 |
+
"
|
| 142 |
+
<tr> <td rowspan=4> $caption </td> </tr>
|
| 143 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 144 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 145 |
+
<tr> <td nowrap> <b>Fix: </b>$fixmsg </td> </tr>
|
| 146 |
+
";
|
| 147 |
+
};
|
| 148 |
+
|
| 149 |
+
// Chmod wget cron.sh file
|
| 150 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkChmodwgetcronshfile();
|
| 151 |
+
if ($status == 'error') $errors_count++;
|
| 152 |
+
if ($status == 'error') {
|
| 153 |
+
$html .= // $caption: $value $measure
|
| 154 |
+
"
|
| 155 |
+
<tr> <td rowspan=4> $caption </td> </tr>
|
| 156 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 157 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 158 |
+
<tr> <td nowrap> <b>Fix: </b>$fixmsg </td> </tr>
|
| 159 |
+
";
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
// Mysql stored procedure filter_icecat_products_s
|
| 163 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkProcedure();
|
| 164 |
+
if ($status == 'error') $errors_count++;
|
| 165 |
+
if ($status == 'error') {
|
| 166 |
+
$html .= // $caption: $value $measure
|
| 167 |
+
"
|
| 168 |
+
<tr> <td rowspan=4> $caption </td> </tr>
|
| 169 |
+
<tr> <td nowrap> <b>Necessary: </b>$critical $measure </td> </tr>
|
| 170 |
+
<tr> <td nowrap> <b>Error: </b>$errmsg </td> </tr>
|
| 171 |
+
<tr> <td nowrap> <b>Fix: </b>$fixmsg </td> </tr>
|
| 172 |
+
";
|
| 173 |
+
};
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
$html .= '
|
| 177 |
+
</tbody>
|
| 178 |
+
</table>';
|
| 179 |
+
|
| 180 |
+
$html .= '<div class="comment"><H3>'.("There are $errors_count critical errors." ).'</H3></div>';
|
| 181 |
+
|
| 182 |
+
// all checks
|
| 183 |
+
return $html;
|
| 184 |
+
|
| 185 |
+
} // protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
} // class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
|
app/code/local/Bintime/Sinchimport/Block/Importhistory.php
CHANGED
|
@@ -356,7 +356,7 @@ updateStatusHtml: function(){
|
|
| 356 |
message=this.objectMsg.message.toLowerCase();
|
| 357 |
mess_id='sinchimport_'+message.replace(/\s+/g, '_');
|
| 358 |
if(!document.getElementById(mess_id)){
|
| 359 |
-
|
| 360 |
}
|
| 361 |
else{
|
| 362 |
// alert (mess_id+' - exist');
|
| 356 |
message=this.objectMsg.message.toLowerCase();
|
| 357 |
mess_id='sinchimport_'+message.replace(/\s+/g, '_');
|
| 358 |
if(!document.getElementById(mess_id)){
|
| 359 |
+
alert(mess_id+' - not exist');
|
| 360 |
}
|
| 361 |
else{
|
| 362 |
// alert (mess_id+' - exist');
|
app/code/local/Bintime/Sinchimport/Block/List.php
CHANGED
|
@@ -10,7 +10,7 @@ class Bintime_Sinchimport_Block_List extends Mage_Catalog_Block_Product_Compare_
|
|
| 10 |
$items[] = $_item->getId();
|
| 11 |
}
|
| 12 |
$to_compare=implode(',', $items);
|
| 13 |
-
$tmp_table_sorted = '$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,
|
|
@@ -28,20 +28,49 @@ class Bintime_Sinchimport_Block_List extends Mage_Catalog_Block_Product_Compare_
|
|
| 28 |
|
| 29 |
|
| 30 |
$query = "SELECT p.sinch_product_id, p.store_product_id, p.specifications, pm.entity_id
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
$sinch = $this->tep_db_query($query);
|
| 36 |
while($data = $sinch->fetch(PDO::FETCH_ASSOC)){
|
| 37 |
$this->ins_from_htm($data['sinch_product_id'],$data['store_product_id'],$data['specifications'],$tmp_table_sorted);
|
| 38 |
$sinch_products_array[] = $data['sinch_product_id'];
|
| 39 |
$this->_compareSinchStoreProd[$data['entity_id']]=$data['sinch_product_id'];
|
| 40 |
}
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
$this->goods = array();
|
| 47 |
|
| 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,
|
| 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 |
|
app/code/local/Bintime/Sinchimport/Model/Layer.php
CHANGED
|
@@ -11,10 +11,6 @@ class Bintime_Sinchimport_Model_Layer extends Mage_Catalog_Model_Layer
|
|
| 11 |
{
|
| 12 |
Varien_Profiler::start(__METHOD__);
|
| 13 |
|
| 14 |
-
/* $iceCategories = $this->_getIceCategoryIds();
|
| 15 |
-
if (empty($iceCategories))
|
| 16 |
-
return array();
|
| 17 |
-
*/
|
| 18 |
$category = Mage::registry('current_category');
|
| 19 |
$categoryId = $category->getEntityId();
|
| 20 |
$resource = Mage::getSingleton('core/resource');
|
|
@@ -49,166 +45,4 @@ class Bintime_Sinchimport_Model_Layer extends Mage_Catalog_Model_Layer
|
|
| 49 |
return $result;
|
| 50 |
}
|
| 51 |
|
| 52 |
-
/**
|
| 53 |
-
* Возвращает id icecat-категорий, к которым относятся продукты в текущей категории.
|
| 54 |
-
*
|
| 55 |
-
* @return array
|
| 56 |
-
*/
|
| 57 |
-
protected function _getIceCategoryIds()
|
| 58 |
-
{
|
| 59 |
-
Varien_Profiler::start(__METHOD__);
|
| 60 |
-
$select = clone $this->getProductCollection()->getSelect();
|
| 61 |
-
|
| 62 |
-
$resource = Mage::getSingleton('core/resource');
|
| 63 |
-
$tProducts = $resource->getTableName('icecat_products');
|
| 64 |
-
|
| 65 |
-
$select->join(
|
| 66 |
-
array('_ip' => $tProducts),
|
| 67 |
-
'_ip.mpn = e.vendor_product_id'
|
| 68 |
-
|
| 69 |
-
);
|
| 70 |
-
|
| 71 |
-
$select->reset(Zend_Db_Select::COLUMNS);
|
| 72 |
-
$select->distinct(true);
|
| 73 |
-
$select->columns('_ip.category_id');
|
| 74 |
-
|
| 75 |
-
Varien_Profiler::stop(__METHOD__);
|
| 76 |
-
|
| 77 |
-
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($select);
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
/**
|
| 81 |
-
* Возвращает фичи, по которым следует строить навигацию для данной категории.
|
| 82 |
-
*
|
| 83 |
-
* @return mixed
|
| 84 |
-
*/
|
| 85 |
-
public function getFilterableFeaturesForEdit($categoryId)
|
| 86 |
-
{
|
| 87 |
-
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
| 88 |
-
$iceCategories = $this->_getIceCategoryIdsForEdit($categoryId);
|
| 89 |
-
$iceCategories = implode(',',$iceCategories);
|
| 90 |
-
if (empty($iceCategories))
|
| 91 |
-
return '';
|
| 92 |
-
|
| 93 |
-
$resource = Mage::getSingleton('core/resource');
|
| 94 |
-
$tFeature = $resource->getTableName('icecat_feature');
|
| 95 |
-
$tFeatureDesc = $resource->getTableName('icecat_feature_description');
|
| 96 |
-
$tFeatureEnab = $resource->getTableName('icecat_category_feature_enabled');
|
| 97 |
-
$tCatFeature = $resource->getTableName('icecat_category_feature');
|
| 98 |
-
$tMeasure = $resource->getTableName('icecat_measures_list');
|
| 99 |
-
|
| 100 |
-
$select = "SELECT `_if`.*, `ifd`.*, `icf`.*, `im`.*,IF(ife.name is NULL,ifd.name,ife.name) as name,IF(ife.enabled is NULL,icf.searchable,ife.enabled) as enabled,ife.position,IF(ife.restricted is NULL,icf.restricted_values,ife.restricted) as restricted_values,ife.order_val
|
| 101 |
-
FROM $tFeature AS _if
|
| 102 |
-
INNER JOIN $tFeatureDesc AS ifd
|
| 103 |
-
ON ifd.feature_id = _if.feature_id
|
| 104 |
-
LEFT JOIN $tCatFeature AS icf
|
| 105 |
-
ON icf.feature_id = _if.feature_id
|
| 106 |
-
LEFT JOIN $tFeatureEnab AS ife
|
| 107 |
-
ON ife.feature_id = ifd.feature_id AND ife.category_id = $categoryId
|
| 108 |
-
INNER JOIN $tMeasure AS im
|
| 109 |
-
ON im.measure_id = icf.measure_id
|
| 110 |
-
WHERE ifd.langid = 1
|
| 111 |
-
AND (icf.category_id IN ($iceCategories))
|
| 112 |
-
AND (icf.restricted_values <> '') GROUP BY _if.feature_id;
|
| 113 |
-
";
|
| 114 |
-
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($select);
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
/**
|
| 118 |
-
* Возвращает id icecat-категорий, к которым относятся продукты в текущей категории.
|
| 119 |
-
*
|
| 120 |
-
* @return array
|
| 121 |
-
*/
|
| 122 |
-
protected function _getIceCategoryIdsForEdit($categoryId)
|
| 123 |
-
{
|
| 124 |
-
$select = "
|
| 125 |
-
SELECT DISTINCT `_ip`.`category_id`
|
| 126 |
-
FROM `catalog_product_entity` AS `e`
|
| 127 |
-
INNER JOIN `catalog_category_product_index` AS `cat_index`
|
| 128 |
-
ON cat_index.product_id=e.entity_id
|
| 129 |
-
AND cat_index.store_id='1'
|
| 130 |
-
AND cat_index.visibility IN(2, 4)
|
| 131 |
-
AND cat_index.category_id='".$categoryId."'
|
| 132 |
-
INNER JOIN `catalog_product_index_price` AS `price_index`
|
| 133 |
-
ON price_index.entity_id = e.entity_id AND price_index.website_id = '1'
|
| 134 |
-
AND price_index.customer_group_id = 0
|
| 135 |
-
INNER JOIN `icecat_products` AS `_ip`
|
| 136 |
-
ON _ip.mpn = e.vendor_product_id
|
| 137 |
-
;
|
| 138 |
-
";
|
| 139 |
-
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($select);
|
| 140 |
-
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
public function saveFeatures($categoryId,$features)
|
| 144 |
-
{
|
| 145 |
-
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
| 146 |
-
$features = explode(',',$features);
|
| 147 |
-
$featureId = $features[0];
|
| 148 |
-
$nameFeatures = $features[1];
|
| 149 |
-
$enabled = $features[2];
|
| 150 |
-
$position = $features[3];
|
| 151 |
-
$restricted = $features[4];
|
| 152 |
-
if (!isset($features[5])) {
|
| 153 |
-
$order_val = 1;
|
| 154 |
-
}
|
| 155 |
-
else {
|
| 156 |
-
$order_val = $features[5];
|
| 157 |
-
}
|
| 158 |
-
$connection->query("
|
| 159 |
-
REPLACE INTO icecat_category_feature_enabled (
|
| 160 |
-
feature_id,
|
| 161 |
-
position,
|
| 162 |
-
category_id,
|
| 163 |
-
name,
|
| 164 |
-
restricted,
|
| 165 |
-
order_val,
|
| 166 |
-
enabled
|
| 167 |
-
) VALUE (
|
| 168 |
-
".$featureId.",
|
| 169 |
-
".$position.",
|
| 170 |
-
".$categoryId.",
|
| 171 |
-
'".$nameFeatures."',
|
| 172 |
-
'".$restricted."',
|
| 173 |
-
".$order_val.",
|
| 174 |
-
".$enabled."
|
| 175 |
-
)
|
| 176 |
-
");
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
public function getCount($category_feature_id,$categoryId)
|
| 180 |
-
{
|
| 181 |
-
$select = "
|
| 182 |
-
SELECT idx_".$category_feature_id.".value, COUNT(e.entity_id) AS count
|
| 183 |
-
FROM catalog_product_entity AS e
|
| 184 |
-
INNER JOIN catalog_category_product_index AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id='1'
|
| 185 |
-
AND cat_index.visibility IN(2, 4) AND cat_index.category_id='".$categoryId."'
|
| 186 |
-
INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.website_id = '1'
|
| 187 |
-
AND price_index.customer_group_id = 0
|
| 188 |
-
INNER JOIN icecat_products_feature_".$category_feature_id." AS idx_".$category_feature_id."
|
| 189 |
-
ON idx_".$category_feature_id.".entity_id = e.entity_id GROUP BY idx_".$category_feature_id.".value
|
| 190 |
-
";
|
| 191 |
-
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($select);
|
| 192 |
-
}
|
| 193 |
-
|
| 194 |
-
public function getIntervalCount($category_feature_id,$categoryId)
|
| 195 |
-
{
|
| 196 |
-
$select = "
|
| 197 |
-
SELECT COUNT(e.entity_id) AS count
|
| 198 |
-
FROM catalog_product_entity AS e
|
| 199 |
-
INNER JOIN catalog_category_product_index AS cat_index
|
| 200 |
-
ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(2, 4) AND cat_index.category_id='".$categoryId."'
|
| 201 |
-
INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.website_id = '1'
|
| 202 |
-
AND price_index.customer_group_id = 0
|
| 203 |
-
INNER JOIN icecat_products_feature_".$category_feature_id." AS idx_".$category_feature_id."
|
| 204 |
-
ON idx_".$category_feature_id.".entity_id = e.entity_id;
|
| 205 |
-
";
|
| 206 |
-
|
| 207 |
-
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($select);
|
| 208 |
-
}
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
}
|
| 11 |
{
|
| 12 |
Varien_Profiler::start(__METHOD__);
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
$category = Mage::registry('current_category');
|
| 15 |
$categoryId = $category->getEntityId();
|
| 16 |
$resource = Mage::getSingleton('core/resource');
|
| 45 |
return $result;
|
| 46 |
}
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
}
|
app/code/local/Bintime/Sinchimport/Model/Layer/Filter/Feature.php
CHANGED
|
@@ -239,15 +239,20 @@ class Bintime_Sinchimport_Model_Layer_Filter_Feature extends Mage_Catalog_Model_
|
|
| 239 |
public function getOrderValues($category_feature_id,$categoryId)
|
| 240 |
{
|
| 241 |
$select = "
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchCol($select);
|
| 253 |
}
|
| 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 |
}
|
app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php
CHANGED
|
@@ -97,7 +97,7 @@ class Bintime_Sinchimport_Model_Resource_Mysql4_Layer_Filter_Feature extends Mag
|
|
| 97 |
$params .= $bounds[1] != '-' ? (int)$bounds[1] : 'null';
|
| 98 |
}
|
| 99 |
//$connection->query("CALL `filter_icecat_products_s`($cfid, $catId,0,$cfid, $params)"));
|
| 100 |
-
$result = $connection->raw_query("CALL
|
| 101 |
Varien_Profiler::stop(__METHOD__);
|
| 102 |
return $resultTable;
|
| 103 |
}
|
|
@@ -164,7 +164,7 @@ class Bintime_Sinchimport_Model_Resource_Mysql4_Layer_Filter_Feature extends Mag
|
|
| 164 |
)
|
| 165 |
->group("{$tableAlias}.value");
|
| 166 |
|
| 167 |
-
$tablePattern = 'stINch_products_feature_'.$feature['category_feature_id'];
|
| 168 |
$query = "SHOW TABLES LIKE '$tablePattern'";
|
| 169 |
$featureTables = $connection->fetchCol($query);
|
| 170 |
$presentFeatures = array();
|
|
@@ -346,21 +346,21 @@ class Bintime_Sinchimport_Model_Resource_Mysql4_Layer_Filter_Feature extends Mag
|
|
| 346 |
WHERE category_feature_id = $featureId
|
| 347 |
";*/
|
| 348 |
$query = "
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
$connection->exec($query);
|
| 365 |
}
|
| 366 |
Mage::log(__METHOD__ . " end at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
| 97 |
$params .= $bounds[1] != '-' ? (int)$bounds[1] : 'null';
|
| 98 |
}
|
| 99 |
//$connection->query("CALL `filter_icecat_products_s`($cfid, $catId,0,$cfid, $params)"));
|
| 100 |
+
$result = $connection->raw_query("CALL ".$this->_getTableName('filter_sinch_products_s')."($cfid, $catId,0, $cfid, $params)");
|
| 101 |
Varien_Profiler::stop(__METHOD__);
|
| 102 |
return $resultTable;
|
| 103 |
}
|
| 164 |
)
|
| 165 |
->group("{$tableAlias}.value");
|
| 166 |
|
| 167 |
+
$tablePattern = $this->_getTableName('stINch_products_feature_'.$feature['category_feature_id']);
|
| 168 |
$query = "SHOW TABLES LIKE '$tablePattern'";
|
| 169 |
$featureTables = $connection->fetchCol($query);
|
| 170 |
$presentFeatures = array();
|
| 346 |
WHERE category_feature_id = $featureId
|
| 347 |
";*/
|
| 348 |
$query = "
|
| 349 |
+
REPLACE INTO $tFeature (entity_id,feature_id, product_id, category_feature_id, value, presentation_value)
|
| 350 |
+
SELECT E.entity_id, RV.category_feature_id,E.entity_id, RV.category_feature_id, RV.text , RV.text
|
| 351 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." E
|
| 352 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." PCind
|
| 353 |
+
ON (E.entity_id = PCind.product_id AND PCind.store_id='1' AND PCind.visibility IN(2,4))
|
| 354 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." AS price_index
|
| 355 |
+
ON price_index.entity_id = E.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
|
| 356 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." PR
|
| 357 |
+
ON (PR.store_product_id = E.store_product_id)
|
| 358 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features')." PF
|
| 359 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
| 360 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values')." RV
|
| 361 |
+
ON (PF.restricted_value_id=RV.restricted_value_id AND RV.category_feature_id= $featureId)
|
| 362 |
+
GROUP BY E.entity_id;
|
| 363 |
+
";
|
| 364 |
$connection->exec($query);
|
| 365 |
}
|
| 366 |
Mage::log(__METHOD__ . " end at ". date('d-m-Y H:i:s'), null, 'sinchlayered.log');
|
app/code/local/Bintime/Sinchimport/Model/Sinch.php
CHANGED
|
@@ -1,129 +1,133 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
ini_set('memory_limit','256M');
|
| 4 |
-
$dir = dirname(__FILE__);
|
| 5 |
require_once ($dir.'/config.php');
|
| 6 |
|
| 7 |
class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
| 8 |
-
var
|
| 9 |
-
$connection,
|
| 10 |
-
$varDir,
|
| 11 |
-
$shellDir,
|
| 12 |
-
$files,
|
| 13 |
-
$attributes,
|
| 14 |
-
$db,
|
| 15 |
-
$lang_id,
|
| 16 |
-
$debug_mode=1;
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
private $_root_cat;
|
|
|
|
| 40 |
private $_ignore_category_features = false;
|
| 41 |
private $_ignore_product_features = false;
|
| 42 |
private $_ignore_product_related = false;
|
| 43 |
private $_ignore_restricted_values = false;
|
| 44 |
-
|
| 45 |
public $price_breaks_filter;
|
| 46 |
|
| 47 |
#################################################################################################
|
| 48 |
|
| 49 |
-
|
| 50 |
|
| 51 |
-
$this->import_status_table=
|
| 52 |
-
$this->import_status_statistic_table=
|
| 53 |
$this->import_log_table="stINch_import_log";
|
| 54 |
-
|
| 55 |
-
|
| 56 |
$this->price_breaks_filter=PRICE_BREAKS;
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
*/
|
|
|
|
| 62 |
$this->shellDir = SHELL_DIRECTORY_FOR_INDEXER;
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
// if($dataConf['field_terminated_char']){
|
| 95 |
-
// $this->field_terminated_char=$dataConf['field_terminated_char'];
|
| 96 |
-
// }else{
|
| 97 |
$this->field_terminated_char=DEFAULT_FILE_TERMINATED_CHAR;
|
| 98 |
-
// }
|
| 99 |
-
// $attributeOptions = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('manufacturer')->getFirstItem()->getSource()->getAllOptions(false);
|
| 100 |
-
// echo "<pre>"; print_r($attributeOptions); echo "</pre>";
|
| 101 |
-
|
| 102 |
|
| 103 |
#################################################################################################
|
| 104 |
function cron_start_import(){
|
| 105 |
$this->_LOG("Start import from cron");
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
|
| 116 |
$this->_LOG("Finish import from cron");
|
| 117 |
-
|
| 118 |
}
|
| 119 |
################################################################################################
|
| 120 |
function cron_start_full_import(){
|
| 121 |
-
|
| 122 |
-
|
|
|
|
| 123 |
################################################################################################
|
| 124 |
function cron_start_stock_price_import(){
|
| 125 |
-
|
| 126 |
-
|
|
|
|
| 127 |
#################################################################################################
|
| 128 |
function is_imort_not_run(){
|
| 129 |
$q="SELECT IS_FREE_LOCK('sinchimport') as getlock";
|
|
@@ -133,18 +137,20 @@ $debug_mode=1;
|
|
| 133 |
}
|
| 134 |
#################################################################################################
|
| 135 |
function check_store_procedure_exist(){
|
| 136 |
-
$
|
|
|
|
| 137 |
$quer=$this->db_do($q);
|
| 138 |
-
$
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
}
|
| 144 |
-
|
|
|
|
| 145 |
#################################################################################################
|
| 146 |
function check_db_privileges(){
|
| 147 |
-
$q='
|
| 148 |
$quer=$this->db_do($q);
|
| 149 |
while($row=mysql_fetch_array($quer)){
|
| 150 |
if($row['Privilege']=='File' && $row['Context']=='File access on server'){
|
|
@@ -155,7 +161,7 @@ $debug_mode=1;
|
|
| 155 |
}
|
| 156 |
#################################################################################################
|
| 157 |
function check_local_infile(){
|
| 158 |
-
$q='
|
| 159 |
$quer=$this->db_do($q);
|
| 160 |
$row=mysql_fetch_array($quer);
|
| 161 |
if($row['Variable_name']=='local_infile' && $row['Value']=="ON"){
|
|
@@ -166,14 +172,16 @@ $debug_mode=1;
|
|
| 166 |
}
|
| 167 |
#################################################################################################
|
| 168 |
function is_full_import_have_been_run(){
|
| 169 |
-
|
|
|
|
|
|
|
| 170 |
$quer=$this->db_do($q);
|
| 171 |
$row=mysql_fetch_array($quer);
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
}
|
| 178 |
#################################################################################################
|
| 179 |
function run_sinch_import(){
|
|
@@ -188,8 +196,8 @@ $debug_mode=1;
|
|
| 188 |
$store_proc=$this->check_store_procedure_exist();
|
| 189 |
|
| 190 |
if(!$store_proc){
|
| 191 |
-
$this->_LOG('store prcedure "filter_sinch_products_s" is absent. import stoped.');
|
| 192 |
-
$this->set_import_error_reporting_message('Stored procedure "filter_sinch_products_s" is absent. Import stopped.');
|
| 193 |
exit;
|
| 194 |
}
|
| 195 |
|
|
@@ -198,7 +206,7 @@ $debug_mode=1;
|
|
| 198 |
if(!$file_privileg){
|
| 199 |
$this->_LOG("Loaddata option not set - please check the documentation on how to fix this. You dan't have privileges for LOAD DATA.");
|
| 200 |
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
| 201 |
-
|
| 202 |
}
|
| 203 |
$local_infile=$this->check_local_infile();
|
| 204 |
if(!$local_infile){
|
|
@@ -208,99 +216,98 @@ $debug_mode=1;
|
|
| 208 |
}
|
| 209 |
|
| 210 |
if($this->is_imort_not_run()){
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
}catch (Exception $e) {
|
| 302 |
$this->set_import_error_reporting_message($e);
|
| 303 |
-
|
| 304 |
}
|
| 305 |
else{
|
| 306 |
Mage::log("Sinchimport already run", null, $this->_logFile);
|
|
@@ -315,16 +322,16 @@ $debug_mode=1;
|
|
| 315 |
|
| 316 |
$this->InitImportStatuses('PRICE STOCK');
|
| 317 |
if($safe_mode_set ){
|
| 318 |
-
$this->_LOG('safe_mode is enable. import stoped.');
|
| 319 |
$this->set_import_error_reporting_message('Safe_mode is enabled. Please check the documentation on how to fix this. Import stopped.');
|
| 320 |
exit;
|
| 321 |
}
|
| 322 |
$store_proc=$this->check_store_procedure_exist();
|
| 323 |
|
| 324 |
if(!$store_proc){
|
| 325 |
-
$this->_LOG('store prcedure "filter_sinch_products_s" is absent. import stoped.');
|
| 326 |
-
$this->set_import_error_reporting_message('Stored procedure "filter_sinch_products_s" is absent. Import stopped.');
|
| 327 |
-
exit;
|
| 328 |
}
|
| 329 |
|
| 330 |
$file_privileg=$this->check_db_privileges();
|
|
@@ -332,7 +339,7 @@ $debug_mode=1;
|
|
| 332 |
if(!$file_privileg){
|
| 333 |
$this->_LOG("Loaddata option not set - please check the documentation on how to fix this. You dan't have privileges for LOAD DATA.");
|
| 334 |
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
| 335 |
-
|
| 336 |
}
|
| 337 |
$local_infile=$this->check_local_infile();
|
| 338 |
if(!$local_infile){
|
|
@@ -342,2153 +349,2485 @@ $debug_mode=1;
|
|
| 342 |
}
|
| 343 |
|
| 344 |
if($this->is_imort_not_run() && $this->is_full_import_have_been_run()){
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
//exit;
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
|
|
|
| 379 |
$this->set_import_error_reporting_message($e);
|
| 380 |
-
|
| 381 |
}
|
| 382 |
else{
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
}
|
| 391 |
|
| 392 |
-
}
|
| 393 |
#################################################################################################
|
| 394 |
|
| 395 |
|
| 396 |
-
|
| 397 |
|
| 398 |
-
|
| 399 |
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
| 400 |
$login=$dataConf['login'];
|
| 401 |
$passw=$dataConf['password'];
|
| 402 |
//return;//stepan tes//stepan tes//stepan testtt
|
| 403 |
if(!$login || !$passw){
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
}
|
| 409 |
$file_url_and_dir=$this->repl_ph(FILE_URL_AND_DIR, array('login' => $login,
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
preg_match("/ftp:\/\/(.*?):(.*?)@(.*?)(\/.*)/i", $file_url_and_dir, $match);
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
}
|
| 424 |
}
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
}
|
| 429 |
-
|
| 430 |
-
$this->_LOG("wget Can't copy ".$file.", will use old one");
|
| 431 |
-
echo "copy Can't copy ".$file_url_and_dir.$file." to ".$this->varDir.$file.", will use old one<br>";
|
| 432 |
-
}
|
| 433 |
-
}
|
| 434 |
-
else{
|
| 435 |
-
if(!copy($file_url_and_dir.$file, $this->varDir.$file)){
|
| 436 |
-
$this->_LOG("copy Can't copy ".$file.", will use old one");
|
| 437 |
-
echo "copy Can't copy ".$file_url_and_dir.$file." to ".$this->varDir.$file." will use old one<br>";
|
| 438 |
-
}
|
| 439 |
-
}
|
| 440 |
exec("chmod a+rw ".$this->varDir.$file);
|
| 441 |
if(!filesize($this->varDir.$file)){
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
}
|
| 464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
)");
|
| 494 |
-
|
| 495 |
-
$res=$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."' INTO TABLE categories_temp FIELDS TERMINATED BY '".$this->field_terminated_char."' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\r\n\" IGNORE 1 LINES ");
|
| 496 |
$inf=mysql_info();
|
| 497 |
-
$table =
|
| 498 |
if(!$this->check_loaded_data($parse_file, $table)){
|
| 499 |
$this->set_import_error_reporting_message('The Stock In The Channel data files do not appear to be in the correct format. Check file'.$parse_file. "(LOAD DATA ... ".$inf.")");
|
| 500 |
exit;
|
| 501 |
}
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
$this->_root_cat=$root_cat;
|
| 516 |
-
|
| 517 |
-
|
|
|
|
|
|
|
|
|
|
| 518 |
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
$this->mapSinchCategories();
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
}else{
|
| 567 |
-
echo "Insert ignore category_entity \n";
|
| 568 |
-
$q="insert ignore into ".TABLE_CATEGORY_ENTITY." (
|
| 569 |
-
entity_type_id,
|
| 570 |
-
attribute_set_id,
|
| 571 |
-
created_at,
|
| 572 |
-
updated_at,
|
| 573 |
-
level,
|
| 574 |
-
children_count,
|
| 575 |
-
entity_id,
|
| 576 |
-
position,
|
| 577 |
-
parent_id,
|
| 578 |
-
store_category_id,
|
| 579 |
-
parent_store_category_id
|
| 580 |
-
)(select
|
| 581 |
-
".$this->_categoryEntityTypeId.",
|
| 582 |
-
".$this->_categoryDefault_attribute_set_id.",
|
| 583 |
-
now(),
|
| 584 |
-
now(),
|
| 585 |
-
c.level,
|
| 586 |
-
c.children_count,
|
| 587 |
-
scm.shop_entity_id,
|
| 588 |
-
c.order_number,
|
| 589 |
-
scm.shop_parent_id,
|
| 590 |
-
c.store_category_id,
|
| 591 |
-
c.parent_store_category_id
|
| 592 |
-
from categories_temp c left join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id )
|
| 593 |
-
";
|
| 594 |
-
}
|
| 595 |
-
$this->db_do($q);
|
| 596 |
|
| 597 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 598 |
|
| 599 |
-
|
| 600 |
|
| 601 |
-
$q="select entity_id, parent_id from ".TABLE_CATEGORY_ENTITY." order by parent_id";
|
| 602 |
-
$quer=$this->db_do($q);
|
| 603 |
-
while($row=mysql_fetch_array($quer)){
|
| 604 |
-
$this->db_do("update ".TABLE_CATEGORY_ENTITY." set path='".$this->culc_path($row['parent_id'], $row['entity_id'])."' where entity_id=".$row['entity_id']);
|
| 605 |
-
}
|
| 606 |
|
| 607 |
-
if(UPDATE_CATEGORY_DATA){
|
| 608 |
-
|
| 609 |
-
echo "Update category_data \n";
|
| 610 |
-
$q="insert into ".TABLE_CATEGORY_ENTITY_VARCHAR." (
|
| 611 |
-
entity_type_id,
|
| 612 |
-
attribute_id,
|
| 613 |
-
store_id,
|
| 614 |
-
entity_id,
|
| 615 |
-
value
|
| 616 |
-
)(select
|
| 617 |
-
".$this->_categoryEntityTypeId.",
|
| 618 |
-
".$this->_getCategoryAttributeId('name').",
|
| 619 |
-
0,
|
| 620 |
-
scm.shop_entity_id,
|
| 621 |
-
c.category_name
|
| 622 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 623 |
-
ON DUPLICATE KEY UPDATE
|
| 624 |
-
value=c.category_name
|
| 625 |
-
|
| 626 |
-
";
|
| 627 |
-
$this->db_do($q);
|
| 628 |
-
|
| 629 |
-
$q="insert into ".TABLE_CATEGORY_ENTITY_VARCHAR." (
|
| 630 |
-
entity_type_id,
|
| 631 |
-
attribute_id,
|
| 632 |
-
store_id,
|
| 633 |
-
entity_id,
|
| 634 |
-
value
|
| 635 |
-
)(select
|
| 636 |
-
".$this->_categoryEntityTypeId.",
|
| 637 |
-
".$this->_getCategoryAttributeId('name').",
|
| 638 |
-
1,
|
| 639 |
-
scm.shop_entity_id,
|
| 640 |
-
c.category_name
|
| 641 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 642 |
-
ON DUPLICATE KEY UPDATE
|
| 643 |
-
value=c.category_name
|
| 644 |
-
";
|
| 645 |
-
$this->db_do($q);
|
| 646 |
-
|
| 647 |
-
$q="insert into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 648 |
-
entity_type_id,
|
| 649 |
-
attribute_id,
|
| 650 |
-
store_id,
|
| 651 |
-
entity_id,
|
| 652 |
-
value
|
| 653 |
-
)(select
|
| 654 |
-
".$this->_categoryEntityTypeId.",
|
| 655 |
-
".$this->attributes['is_active'].",
|
| 656 |
-
0,
|
| 657 |
-
scm.shop_entity_id,
|
| 658 |
-
1
|
| 659 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 660 |
-
ON DUPLICATE KEY UPDATE
|
| 661 |
-
value=1
|
| 662 |
-
";
|
| 663 |
-
$this->db_do($q);
|
| 664 |
-
|
| 665 |
-
$q="insert into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 666 |
-
entity_type_id,
|
| 667 |
-
attribute_id,
|
| 668 |
-
store_id,
|
| 669 |
-
entity_id,
|
| 670 |
-
value
|
| 671 |
-
)(select
|
| 672 |
-
".$this->_categoryEntityTypeId.",
|
| 673 |
-
".$this->attributes['is_active'].",
|
| 674 |
-
1,
|
| 675 |
-
scm.shop_entity_id,
|
| 676 |
-
1
|
| 677 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 678 |
-
ON DUPLICATE KEY UPDATE
|
| 679 |
-
value=1
|
| 680 |
-
";
|
| 681 |
-
$this->db_do($q);
|
| 682 |
-
|
| 683 |
-
$q="insert into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 684 |
-
entity_type_id,
|
| 685 |
-
attribute_id,
|
| 686 |
-
store_id,
|
| 687 |
-
entity_id,
|
| 688 |
-
value
|
| 689 |
-
)(select
|
| 690 |
-
".$this->_categoryEntityTypeId.",
|
| 691 |
-
".$this->attributes['include_in_menu'].",
|
| 692 |
-
0,
|
| 693 |
-
scm.shop_entity_id,
|
| 694 |
-
1
|
| 695 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 696 |
-
ON DUPLICATE KEY UPDATE
|
| 697 |
-
value=1
|
| 698 |
-
";
|
| 699 |
-
$this->db_do($q);
|
| 700 |
-
|
| 701 |
-
$q="insert into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 702 |
-
entity_type_id,
|
| 703 |
-
attribute_id,
|
| 704 |
-
store_id,
|
| 705 |
-
entity_id,
|
| 706 |
-
value
|
| 707 |
-
)(select
|
| 708 |
-
".$this->_categoryEntityTypeId.",
|
| 709 |
-
".$this->_getCategoryAttributeId('is_anchor').",
|
| 710 |
-
1,
|
| 711 |
-
scm.shop_entity_id,
|
| 712 |
-
1
|
| 713 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 714 |
-
ON DUPLICATE KEY UPDATE
|
| 715 |
-
value=1
|
| 716 |
-
";
|
| 717 |
-
$this->db_do($q);
|
| 718 |
-
|
| 719 |
-
$q="insert into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 720 |
-
entity_type_id,
|
| 721 |
-
attribute_id,
|
| 722 |
-
store_id,
|
| 723 |
-
entity_id,
|
| 724 |
-
value
|
| 725 |
-
)(select
|
| 726 |
-
".$this->_categoryEntityTypeId.",
|
| 727 |
-
".$this->_getCategoryAttributeId('is_anchor').",
|
| 728 |
-
0,
|
| 729 |
-
scm.shop_entity_id,
|
| 730 |
-
1
|
| 731 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 732 |
-
ON DUPLICATE KEY UPDATE
|
| 733 |
-
value=1
|
| 734 |
-
";
|
| 735 |
-
$this->db_do($q);
|
| 736 |
-
|
| 737 |
-
$q="insert into ".TABLE_CATEGORY_ENTITY_VARCHAR." (
|
| 738 |
-
entity_type_id,
|
| 739 |
-
attribute_id,
|
| 740 |
-
store_id,
|
| 741 |
-
entity_id,
|
| 742 |
-
value
|
| 743 |
-
)(select
|
| 744 |
-
".$this->_categoryEntityTypeId.",
|
| 745 |
-
".$this->_getCategoryAttributeId('image').",
|
| 746 |
-
0,
|
| 747 |
-
scm.shop_entity_id,
|
| 748 |
-
c.categories_image
|
| 749 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 750 |
-
ON DUPLICATE KEY UPDATE
|
| 751 |
-
value=c.categories_image
|
| 752 |
-
";
|
| 753 |
-
$this->db_do($q);
|
| 754 |
-
}else{
|
| 755 |
-
echo "Insert ignore category_data \n";
|
| 756 |
-
$q="insert IGNORE into ".TABLE_CATEGORY_ENTITY_VARCHAR." (
|
| 757 |
-
entity_type_id,
|
| 758 |
-
attribute_id,
|
| 759 |
-
store_id,
|
| 760 |
-
entity_id,
|
| 761 |
-
value
|
| 762 |
-
)(select
|
| 763 |
-
".$this->_categoryEntityTypeId.",
|
| 764 |
-
".$this->_getCategoryAttributeId('name').",
|
| 765 |
-
0,
|
| 766 |
-
scm.shop_entity_id,
|
| 767 |
-
c.category_name
|
| 768 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 769 |
-
|
| 770 |
-
";
|
| 771 |
-
$this->db_do($q);
|
| 772 |
-
|
| 773 |
-
/* $q="insert IGNORE into ".TABLE_CATEGORY_ENTITY_VARCHAR." (
|
| 774 |
-
entity_type_id,
|
| 775 |
-
attribute_id,
|
| 776 |
-
store_id,
|
| 777 |
-
entity_id,
|
| 778 |
-
value
|
| 779 |
-
)(select
|
| 780 |
-
".$this->_categoryEntityTypeId.",
|
| 781 |
-
".$this->_getCategoryAttributeId('name').",
|
| 782 |
-
1,
|
| 783 |
-
scm.shop_entity_id,
|
| 784 |
-
c.category_name
|
| 785 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 786 |
-
";
|
| 787 |
-
$this->db_do($q);
|
| 788 |
-
*/
|
| 789 |
-
$q="insert IGNORE into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 790 |
-
entity_type_id,
|
| 791 |
-
attribute_id,
|
| 792 |
-
store_id,
|
| 793 |
-
entity_id,
|
| 794 |
-
value
|
| 795 |
-
)(select
|
| 796 |
-
".$this->_categoryEntityTypeId.",
|
| 797 |
-
".$this->attributes['is_active'].",
|
| 798 |
-
0,
|
| 799 |
-
scm.shop_entity_id,
|
| 800 |
-
1
|
| 801 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 802 |
-
";
|
| 803 |
-
$this->db_do($q);
|
| 804 |
-
/*
|
| 805 |
-
$q="insert IGNORE into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 806 |
-
entity_type_id,
|
| 807 |
-
attribute_id,
|
| 808 |
-
store_id,
|
| 809 |
-
entity_id,
|
| 810 |
-
value
|
| 811 |
-
)(select
|
| 812 |
-
".$this->_categoryEntityTypeId.",
|
| 813 |
-
".$this->attributes['is_active'].",
|
| 814 |
-
1,
|
| 815 |
-
scm.shop_entity_id,
|
| 816 |
-
1
|
| 817 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 818 |
-
";
|
| 819 |
-
$this->db_do($q);
|
| 820 |
-
*/
|
| 821 |
-
$q="insert IGNORE into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 822 |
-
entity_type_id,
|
| 823 |
-
attribute_id,
|
| 824 |
-
store_id,
|
| 825 |
-
entity_id,
|
| 826 |
-
value
|
| 827 |
-
)(select
|
| 828 |
-
".$this->_categoryEntityTypeId.",
|
| 829 |
-
".$this->attributes['include_in_menu'].",
|
| 830 |
-
0,
|
| 831 |
-
scm.shop_entity_id,
|
| 832 |
-
1
|
| 833 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 834 |
-
";
|
| 835 |
-
$this->db_do($q);
|
| 836 |
-
/*
|
| 837 |
-
$q="insert IGNORE into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 838 |
-
entity_type_id,
|
| 839 |
-
attribute_id,
|
| 840 |
-
store_id,
|
| 841 |
-
entity_id,
|
| 842 |
-
value
|
| 843 |
-
)(select
|
| 844 |
-
".$this->_categoryEntityTypeId.",
|
| 845 |
-
".$this->_getCategoryAttributeId('is_anchor').",
|
| 846 |
-
1,
|
| 847 |
-
scm.shop_entity_id,
|
| 848 |
-
1
|
| 849 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 850 |
-
";
|
| 851 |
-
$this->db_do($q);
|
| 852 |
-
*/
|
| 853 |
-
$q="insert IGNORE into ".TABLE_CATEGORY_ENTITY_INT." (
|
| 854 |
-
entity_type_id,
|
| 855 |
-
attribute_id,
|
| 856 |
-
store_id,
|
| 857 |
-
entity_id,
|
| 858 |
-
value
|
| 859 |
-
)(select
|
| 860 |
-
".$this->_categoryEntityTypeId.",
|
| 861 |
-
".$this->_getCategoryAttributeId('is_anchor').",
|
| 862 |
-
0,
|
| 863 |
-
scm.shop_entity_id,
|
| 864 |
-
1
|
| 865 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 866 |
-
";
|
| 867 |
-
$this->db_do($q);
|
| 868 |
-
|
| 869 |
-
$q="insert IGNORE into ".TABLE_CATEGORY_ENTITY_VARCHAR." (
|
| 870 |
-
entity_type_id,
|
| 871 |
-
attribute_id,
|
| 872 |
-
store_id,
|
| 873 |
-
entity_id,
|
| 874 |
-
value
|
| 875 |
-
)(select
|
| 876 |
-
".$this->_categoryEntityTypeId.",
|
| 877 |
-
".$this->_getCategoryAttributeId('image').",
|
| 878 |
-
0,
|
| 879 |
-
scm.shop_entity_id,
|
| 880 |
-
c.categories_image
|
| 881 |
-
from ".TABLE_SINCH_CAT." c join stINch_categories_mapping scm on c.store_category_id=scm.store_category_id)
|
| 882 |
-
";
|
| 883 |
-
$this->db_do($q);
|
| 884 |
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
|
|
|
|
| 896 |
|
| 897 |
-
|
| 898 |
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 913 |
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
}
|
| 917 |
-
$this->db_do("DROP TABLE IF EXISTS stINch_categories_features");
|
| 918 |
-
$this->db_do("RENAME TABLE categories_features_temp TO stINch_categories_features");
|
| 919 |
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 926 |
|
| 927 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 928 |
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
| 934 |
-
|
| 935 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 936 |
|
| 937 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 938 |
|
| 939 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 940 |
|
| 941 |
-
|
| 942 |
-
|
| 943 |
-
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
|
| 948 |
-
|
| 949 |
-
|
| 950 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 951 |
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 956 |
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 962 |
}
|
|
|
|
|
|
|
| 963 |
|
| 964 |
#################################################################################################
|
| 965 |
|
| 966 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 967 |
|
| 968 |
-
|
| 969 |
-
if(filesize($parse_file)){
|
| 970 |
-
$this->_LOG("Start parse ".FILE_EANCODES);
|
| 971 |
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 978 |
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
|
|
|
|
|
|
| 983 |
|
| 984 |
-
|
| 985 |
-
|
| 986 |
-
|
| 987 |
-
|
| 988 |
-
|
|
|
|
|
|
|
| 989 |
}
|
|
|
|
|
|
|
| 990 |
|
| 991 |
#################################################################################################
|
| 992 |
|
| 993 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 994 |
|
| 995 |
-
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
manufacturer_name varchar(255),
|
| 1002 |
-
manufacturers_image varchar(255),
|
| 1003 |
-
shop_option_id int(11),
|
| 1004 |
-
key(sinch_manufacturer_id),
|
| 1005 |
-
key(shop_option_id),
|
| 1006 |
-
key(manufacturer_name)
|
| 1007 |
-
)");
|
| 1008 |
|
| 1009 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1010 |
|
| 1011 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1012 |
|
| 1013 |
-
|
| 1014 |
-
$this->db_do("insert ignore into manufacturers (manufacturers_id, manufacturers_name, manufacturers_image)(select sinch_manufacturer_id, manufacturer_name, manufacturers_image from manufacturers_temp)");
|
| 1015 |
|
| 1016 |
-
|
| 1017 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1018 |
$this->db_do($q);
|
| 1019 |
|
| 1020 |
-
$q="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1021 |
$this->db_do($q);
|
| 1022 |
|
| 1023 |
-
$q="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1024 |
$quer=$this->db_do($q);
|
| 1025 |
|
| 1026 |
while($row=mysql_fetch_array($quer)){
|
| 1027 |
-
$q0="
|
|
|
|
|
|
|
| 1028 |
$quer0=$this->db_do($q0);
|
| 1029 |
|
| 1030 |
-
$q2="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1031 |
$quer2=$this->db_do($q2);
|
| 1032 |
-
// $option['attribute_id'] = $this->attributes['manufacturer'];
|
| 1033 |
-
// $option['value'][$row['sinch_manufacturer_id']][0] = $row['manufacturer_name'];
|
| 1034 |
|
| 1035 |
}
|
| 1036 |
|
| 1037 |
-
$q="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1038 |
$this->db_do($q);
|
| 1039 |
-
|
| 1040 |
-
|
| 1041 |
-
|
| 1042 |
-
|
| 1043 |
-
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
$this->_LOG(' ');
|
| 1047 |
}
|
|
|
|
|
|
|
| 1048 |
|
| 1049 |
#################################################################################################
|
| 1050 |
|
| 1051 |
-
|
| 1052 |
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
-
|
| 1064 |
-
|
|
|
|
| 1065 |
if(!$this->_ignore_product_features){
|
| 1066 |
-
|
| 1067 |
-
|
| 1068 |
-
|
| 1069 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1070 |
|
| 1071 |
-
|
| 1072 |
-
|
| 1073 |
-
|
| 1074 |
-
}
|
| 1075 |
-
$this->_LOG(" ");
|
| 1076 |
}
|
|
|
|
|
|
|
| 1077 |
|
| 1078 |
#################################################################################################
|
| 1079 |
|
| 1080 |
-
|
| 1081 |
-
|
| 1082 |
-
$parse_file=$this->varDir.FILE_PRODUCTS;
|
| 1083 |
-
if(filesize($parse_file)){
|
| 1084 |
-
$this->_LOG("Start parse ".FILE_PRODUCTS);
|
| 1085 |
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
while (!feof($file_handle_from)) {
|
| 1090 |
-
$line = fgets($file_handle_from);
|
| 1091 |
-
$line = $this->valid_utf($line);
|
| 1092 |
-
fwrite($file_handle_to, $line);
|
| 1093 |
-
}
|
| 1094 |
-
fclose($file_handle_from);
|
| 1095 |
-
fclose($file_handle_to);
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
// $prod_file_str = file_get_contents($parse_file);
|
| 1099 |
-
$this->db_do("DROP TABLE IF EXISTS products_temp");
|
| 1100 |
-
$this->db_do("CREATE TABLE products_temp(
|
| 1101 |
-
store_category_product_id int(11),
|
| 1102 |
-
store_product_id int(11),
|
| 1103 |
-
sinch_product_id int(11),
|
| 1104 |
-
product_sku varchar(255),
|
| 1105 |
-
product_name varchar(255),
|
| 1106 |
-
sinch_manufacturer_id int(11),
|
| 1107 |
-
store_category_id int(11),
|
| 1108 |
-
main_image_url varchar(255),
|
| 1109 |
-
thumb_image_url varchar(255),
|
| 1110 |
-
specifications text,
|
| 1111 |
-
description text,
|
| 1112 |
-
search_cache text,
|
| 1113 |
-
spec_characte_u_count int(11),
|
| 1114 |
-
description_type varchar(50),
|
| 1115 |
-
medium_image_url varchar(255),
|
| 1116 |
-
products_date_added datetime default NULL,
|
| 1117 |
-
products_last_modified datetime default NULL,
|
| 1118 |
-
availability_id_in_stock int(11) default '1',
|
| 1119 |
-
availability_id_out_of_stock int(11) default '2',
|
| 1120 |
-
products_locate varchar(30) default NULL,
|
| 1121 |
-
products_ordered int(11) NOT NULL default '0',
|
| 1122 |
-
products_url varchar(255) default NULL,
|
| 1123 |
-
products_viewed int(5) default '0',
|
| 1124 |
-
products_seo_url varchar(100) NOT NULL,
|
| 1125 |
-
manufacturer_name varchar(255) default NULL,
|
| 1126 |
-
key(store_category_product_id),
|
| 1127 |
-
key(store_product_id),
|
| 1128 |
-
key(sinch_manufacturer_id),
|
| 1129 |
-
key(store_category_id)
|
| 1130 |
-
)DEFAULT CHARSET=utf8");
|
| 1131 |
-
|
| 1132 |
-
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file.".conv' INTO TABLE products_temp FIELDS TERMINATED BY '".$this->field_terminated_char."' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\r\n\" IGNORE 1 LINES ");
|
| 1133 |
-
$this->db_do("ALTER TABLE products_temp convert to CHARACTER SET \"latin1\"");
|
| 1134 |
-
|
| 1135 |
-
$this->db_do("update products_temp set products_date_added=now(), products_last_modified=now()");
|
| 1136 |
-
|
| 1137 |
-
$this->db_do("update products_temp p join stINch_manufacturers m on p.sinch_manufacturer_id=m.sinch_manufacturer_id set p.manufacturer_name=m.manufacturer_name");
|
| 1138 |
|
| 1139 |
-
|
| 1140 |
-
|
| 1141 |
-
|
| 1142 |
-
|
|
|
|
|
|
|
|
|
|
| 1143 |
}
|
| 1144 |
-
|
| 1145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1146 |
|
| 1147 |
-
|
| 1148 |
-
|
| 1149 |
|
|
|
|
|
|
|
| 1150 |
|
| 1151 |
-
|
| 1152 |
-
|
| 1153 |
-
|
| 1154 |
-
|
| 1155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1156 |
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
|
| 1160 |
$this->mapSinchProducts();
|
| 1161 |
-
$this->replaceMagentoProducts();
|
| 1162 |
-
$this->mapSinchProducts();
|
| 1163 |
$this->addManufacturer_attribute();
|
| 1164 |
-
|
| 1165 |
-
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
-
|
| 1169 |
-
|
| 1170 |
-
$this->_LOG(" ");
|
| 1171 |
}
|
|
|
|
|
|
|
| 1172 |
|
| 1173 |
#################################################################################################
|
| 1174 |
|
| 1175 |
-
|
| 1176 |
-
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
if(!$this->_ignore_product_related){
|
| 1193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1194 |
}
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
| 1200 |
-
|
| 1201 |
-
|
| 1202 |
-
$this->_LOG(" ");
|
| 1203 |
}
|
|
|
|
|
|
|
| 1204 |
|
| 1205 |
#################################################################################################
|
| 1206 |
|
| 1207 |
-
|
| 1208 |
-
|
| 1209 |
-
|
| 1210 |
-
|
| 1211 |
-
|
| 1212 |
-
|
| 1213 |
-
|
| 1214 |
-
|
| 1215 |
-
|
| 1216 |
-
|
| 1217 |
-
|
| 1218 |
-
|
| 1219 |
-
|
| 1220 |
-
|
| 1221 |
-
|
| 1222 |
-
|
| 1223 |
-
|
| 1224 |
-
|
| 1225 |
-
|
| 1226 |
-
|
| 1227 |
-
|
| 1228 |
-
|
| 1229 |
-
|
| 1230 |
-
|
| 1231 |
-
|
| 1232 |
-
|
| 1233 |
if(!$this->_ignore_restricted_values){
|
| 1234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1235 |
}
|
| 1236 |
-
|
| 1237 |
-
|
| 1238 |
-
|
|
|
|
|
|
|
| 1239 |
|
| 1240 |
-
|
| 1241 |
-
|
| 1242 |
-
|
| 1243 |
-
}
|
| 1244 |
-
$this->_LOG(" ");
|
| 1245 |
}
|
|
|
|
|
|
|
| 1246 |
|
| 1247 |
#################################################################################################
|
| 1248 |
|
| 1249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1250 |
|
| 1251 |
-
|
| 1252 |
-
if(filesize($parse_file)){
|
| 1253 |
-
$this->_LOG("Start parse ".FILE_RELATED_PRODUCTS);
|
| 1254 |
-
$this->db_do("DROP TABLE IF EXISTS stock_and_prices_temp");
|
| 1255 |
-
$this->db_do("CREATE TABLE stock_and_prices_temp(
|
| 1256 |
-
store_product_id int(11),
|
| 1257 |
-
stock int(11),
|
| 1258 |
-
price decimal(15,4),
|
| 1259 |
-
cost decimal(15,4),
|
| 1260 |
-
distributor_id int(11),
|
| 1261 |
-
key(store_product_id),
|
| 1262 |
-
key(distributor_id)
|
| 1263 |
-
)");
|
| 1264 |
|
| 1265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1266 |
|
| 1267 |
-
|
| 1268 |
-
$this->replaceMagentoProductsStockPrice();
|
| 1269 |
|
| 1270 |
-
|
| 1271 |
-
|
| 1272 |
-
|
| 1273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1274 |
|
| 1275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1276 |
|
| 1277 |
-
|
| 1278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1279 |
|
| 1280 |
-
|
| 1281 |
-
|
| 1282 |
-
|
| 1283 |
-
|
| 1284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1285 |
}
|
| 1286 |
|
| 1287 |
-
#################################################################################################
|
| 1288 |
-
|
| 1289 |
-
function ParseProductsPicturesGallery(){
|
| 1290 |
|
| 1291 |
-
|
| 1292 |
-
|
| 1293 |
-
|
| 1294 |
-
|
| 1295 |
-
$this->db_do("CREATE TABLE products_pictures_gallery_temp(
|
| 1296 |
-
sinch_product_id int(11),
|
| 1297 |
-
image_url varchar(255),
|
| 1298 |
-
thumb_image_url varchar(255),
|
| 1299 |
-
store_product_id int(11),
|
| 1300 |
-
key(sinch_product_id),
|
| 1301 |
-
key(store_product_id)
|
| 1302 |
-
)");
|
| 1303 |
|
| 1304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1305 |
|
| 1306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1307 |
|
| 1308 |
-
|
| 1309 |
-
$this->db_do("RENAME TABLE products_pictures_gallery_temp TO stINch_products_pictures_gallery");
|
| 1310 |
|
| 1311 |
-
|
| 1312 |
-
|
| 1313 |
-
|
| 1314 |
-
|
| 1315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1317 |
}
|
| 1318 |
-
#################################################################################################
|
| 1319 |
-
public function mapSinchCategories(){
|
| 1320 |
-
$this->db_do("DROP TABLE IF EXISTS stINch_categories_mapping_temp");
|
| 1321 |
-
$this->db_do("CREATE TABLE stINch_categories_mapping_temp(
|
| 1322 |
-
shop_entity_id int(11) unsigned NOT NULL,
|
| 1323 |
-
shop_entity_type_id int(11),
|
| 1324 |
-
shop_attribute_set_id int(11),
|
| 1325 |
-
shop_parent_id int(11),
|
| 1326 |
-
shop_store_category_id int(11),
|
| 1327 |
-
shop_parent_store_category_id int(11),
|
| 1328 |
-
store_category_id int(11),
|
| 1329 |
-
parent_store_category_id int(11),
|
| 1330 |
-
category_name varchar(255),
|
| 1331 |
-
order_number int(11),
|
| 1332 |
-
products_within_this_category int(11),
|
| 1333 |
-
key shop_entity_id (shop_entity_id),
|
| 1334 |
-
key shop_parent_id (shop_parent_id),
|
| 1335 |
-
key store_category_id (store_category_id),
|
| 1336 |
-
key parent_store_category_id (parent_store_category_id),
|
| 1337 |
-
unique key(shop_entity_id)
|
| 1338 |
-
)
|
| 1339 |
-
");
|
| 1340 |
-
$this->db_do("CREATE TABLE IF NOT EXISTS stINch_categories_mapping like stINch_categories_mapping_temp");
|
| 1341 |
-
$result = $this->db_do("
|
| 1342 |
-
INSERT ignore INTO stINch_categories_mapping_temp (
|
| 1343 |
-
shop_entity_id,
|
| 1344 |
-
shop_entity_type_id,
|
| 1345 |
-
shop_attribute_set_id,
|
| 1346 |
-
shop_parent_id,
|
| 1347 |
-
shop_store_category_id,
|
| 1348 |
-
shop_parent_store_category_id
|
| 1349 |
-
)(select
|
| 1350 |
-
entity_id,
|
| 1351 |
-
entity_type_id,
|
| 1352 |
-
attribute_set_id,
|
| 1353 |
-
parent_id,
|
| 1354 |
-
store_category_id,
|
| 1355 |
-
parent_store_category_id
|
| 1356 |
-
from catalog_category_entity
|
| 1357 |
-
)
|
| 1358 |
-
|
| 1359 |
-
");
|
| 1360 |
-
|
| 1361 |
-
$q="update stINch_categories_mapping_temp cmt join categories_temp c on cmt.shop_store_category_id=c.store_category_id set cmt.store_category_id=c.store_category_id, cmt.parent_store_category_id=c.parent_store_category_id, cmt.category_name=c.category_name, cmt.order_number=c.order_number, cmt.products_within_this_category=c.products_within_this_category";
|
| 1362 |
-
$this->db_do($q);
|
| 1363 |
-
|
| 1364 |
-
$q="update stINch_categories_mapping_temp cmt join catalog_category_entity cce on cmt.parent_store_category_id=cce.store_category_id set cmt.shop_parent_id=cce.entity_id";
|
| 1365 |
-
$this->db_do($q);
|
| 1366 |
-
|
| 1367 |
-
$q="update stINch_categories_mapping_temp cmt join categories_temp c on cmt.shop_store_category_id=c.store_category_id set shop_parent_id=".$this->_root_cat." where shop_parent_id=0";
|
| 1368 |
-
$this->db_do($q);
|
| 1369 |
-
|
| 1370 |
-
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
| 1371 |
-
$im_type = $dataConf['replace_category'];
|
| 1372 |
-
if((UPDATE_CATEGORY_DATA && $im_type=="MERGE") || ($im_type=="REWRITE")){
|
| 1373 |
-
$q="update stINch_categories_mapping_temp cmt join catalog_category_entity cce on cmt.shop_entity_id=cce.entity_id set cce.parent_id=cmt.shop_parent_id";
|
| 1374 |
-
$this->db_do($q);
|
| 1375 |
-
}
|
| 1376 |
-
|
| 1377 |
-
|
| 1378 |
-
$this->db_do("DROP TABLE IF EXISTS stINch_categories_mapping");
|
| 1379 |
-
$this->db_do("RENAME TABLE stINch_categories_mapping_temp TO stINch_categories_mapping");
|
| 1380 |
-
}
|
| 1381 |
-
|
| 1382 |
-
#################################################################################################
|
| 1383 |
-
public function mapSinchProducts(){
|
| 1384 |
-
$this->db_do("DROP TABLE IF EXISTS stINch_products_mapping_temp");
|
| 1385 |
-
$this->db_do("CREATE TABLE stINch_products_mapping_temp(
|
| 1386 |
-
entity_id int(11) unsigned NOT NULL,
|
| 1387 |
-
manufacturer_option_id int(11),
|
| 1388 |
-
manufacturer_name varchar(255),
|
| 1389 |
-
shop_store_product_id int(11),
|
| 1390 |
-
shop_sinch_product_id int(11),
|
| 1391 |
-
sku varchar(64) default NULL,
|
| 1392 |
-
store_category_product_id int(11),
|
| 1393 |
-
store_product_id int(11),
|
| 1394 |
-
sinch_product_id int(11),
|
| 1395 |
-
product_sku varchar(255),
|
| 1396 |
-
sinch_manufacturer_id int(11),
|
| 1397 |
-
sinch_manufacturer_name varchar(255),
|
| 1398 |
-
key entity_id (entity_id),
|
| 1399 |
-
key manufacturer_option_id (manufacturer_option_id),
|
| 1400 |
-
key manufacturer_name (manufacturer_name),
|
| 1401 |
-
key store_product_id (store_product_id),
|
| 1402 |
-
key sinch_product_id (sinch_product_id),
|
| 1403 |
-
key sku (sku),
|
| 1404 |
-
unique key(entity_id)
|
| 1405 |
-
)
|
| 1406 |
-
");
|
| 1407 |
-
$this->db_do("CREATE TABLE IF NOT EXISTS stINch_products_mapping like stINch_products_mapping_temp");
|
| 1408 |
-
$result = $this->db_do("
|
| 1409 |
-
INSERT ignore INTO stINch_products_mapping_temp (
|
| 1410 |
-
entity_id,
|
| 1411 |
-
sku,
|
| 1412 |
-
shop_store_product_id,
|
| 1413 |
-
shop_sinch_product_id
|
| 1414 |
-
)(select
|
| 1415 |
-
entity_id,
|
| 1416 |
-
sku,
|
| 1417 |
-
store_product_id,
|
| 1418 |
-
sinch_product_id
|
| 1419 |
-
from catalog_product_entity
|
| 1420 |
-
)
|
| 1421 |
-
|
| 1422 |
-
");
|
| 1423 |
-
|
| 1424 |
-
$this->addManufacturers(1);
|
| 1425 |
-
|
| 1426 |
-
$q="update stINch_products_mapping_temp pmt join catalog_product_index_eav cpie on pmt.entity_id=cpie.entity_id join eav_attribute_option_value aov on cpie.value=aov.option_id set manufacturer_option_id=cpie.value, manufacturer_name=aov.value where cpie.attribute_id=".$this->attributes['manufacturer'];
|
| 1427 |
-
$this->db_do($q);
|
| 1428 |
-
|
| 1429 |
-
$q="update stINch_products_mapping_temp pmt join products_temp p on pmt.sku=p.product_sku set pmt.store_category_product_id=p.store_category_product_id, pmt.store_product_id=p.store_product_id, pmt.sinch_product_id=p.sinch_product_id, pmt.product_sku=p.product_sku, pmt.sinch_manufacturer_id=p.sinch_manufacturer_id, pmt.sinch_manufacturer_name=p.manufacturer_name";
|
| 1430 |
-
$this->db_do($q);
|
| 1431 |
-
|
| 1432 |
-
$q="update catalog_product_entity cpe join stINch_products_mapping_temp pmt on cpe.entity_id=pmt.entity_id set cpe.store_product_id=pmt.store_product_id, cpe.sinch_product_id=pmt.sinch_product_id where cpe.sinch_product_id is null and pmt.sinch_product_id is not null and cpe.store_product_id is null and pmt.store_product_id is not null";
|
| 1433 |
-
$this->db_do($q);
|
| 1434 |
|
| 1435 |
-
$this->db_do("DROP TABLE IF EXISTS stINch_products_mapping");
|
| 1436 |
-
$this->db_do("RENAME TABLE stINch_products_mapping_temp TO stINch_products_mapping");
|
| 1437 |
-
}
|
| 1438 |
-
public function addProductsWebsite (){
|
| 1439 |
-
$this->db_do(" DROP TABLE IF EXISTS products_website_temp");
|
| 1440 |
-
// TEMPORARY
|
| 1441 |
-
$this->db_do("
|
| 1442 |
-
CREATE TABLE `products_website_temp` (
|
| 1443 |
-
`id` int(10) unsigned NOT NULL auto_increment,
|
| 1444 |
-
store_product_id int(11),
|
| 1445 |
-
sinch_product_id int(11),
|
| 1446 |
-
`website` int(11) default NULL,
|
| 1447 |
-
`website_id` int(11) default NULL,
|
| 1448 |
-
PRIMARY KEY (`id`),
|
| 1449 |
-
KEY store_product_id (`store_product_id`)
|
| 1450 |
-
)
|
| 1451 |
-
");
|
| 1452 |
-
$result = $this->db_do("SELECT website_id, store_id as website FROM core_store where code!='admin'"); // where code!='admin' was adder for editing Featured products;
|
| 1453 |
-
while ($row = mysql_fetch_assoc($result)) {
|
| 1454 |
-
$sql = "INSERT INTO products_website_temp
|
| 1455 |
-
(store_product_id, sinch_product_id, website, website_id)
|
| 1456 |
-
(SELECT distinct
|
| 1457 |
-
store_product_id,
|
| 1458 |
-
sinch_product_id,
|
| 1459 |
-
{$row['website']},
|
| 1460 |
-
{$row['website_id']}
|
| 1461 |
-
FROM products_temp)";
|
| 1462 |
-
$result2 = $this->db_do($sql);
|
| 1463 |
-
}
|
| 1464 |
|
|
|
|
| 1465 |
|
| 1466 |
-
}
|
| 1467 |
#################################################################################################
|
| 1468 |
-
|
| 1469 |
-
|
| 1470 |
-
|
| 1471 |
-
|
| 1472 |
-
|
| 1473 |
-
|
| 1474 |
-
|
| 1475 |
-
|
| 1476 |
-
|
| 1477 |
-
|
| 1478 |
-
|
| 1479 |
-
|
| 1480 |
-
|
| 1481 |
-
|
| 1482 |
-
|
| 1483 |
-
|
| 1484 |
-
|
| 1485 |
-
|
| 1486 |
-
|
| 1487 |
-
|
| 1488 |
-
|
| 1489 |
-
|
| 1490 |
-
|
| 1491 |
-
|
| 1492 |
-
|
| 1493 |
-
|
| 1494 |
-
|
| 1495 |
-
|
| 1496 |
-
|
| 1497 |
-
|
| 1498 |
-
|
| 1499 |
-
|
| 1500 |
-
|
| 1501 |
-
|
| 1502 |
-
|
| 1503 |
-
|
| 1504 |
-
|
| 1505 |
-
|
| 1506 |
-
|
| 1507 |
-
|
| 1508 |
-
|
| 1509 |
-
|
| 1510 |
-
|
| 1511 |
-
|
| 1512 |
-
|
| 1513 |
-
|
| 1514 |
-
|
| 1515 |
-
|
| 1516 |
-
|
| 1517 |
-
|
| 1518 |
-
|
| 1519 |
-
|
| 1520 |
-
|
| 1521 |
-
|
| 1522 |
-
|
| 1523 |
-
|
| 1524 |
-
|
| 1525 |
-
|
| 1526 |
-
|
| 1527 |
-
|
| 1528 |
-
|
| 1529 |
-
|
| 1530 |
-
|
| 1531 |
-
|
| 1532 |
-
|
| 1533 |
-
|
| 1534 |
-
|
| 1535 |
-
|
| 1536 |
-
|
| 1537 |
-
|
| 1538 |
-
|
| 1539 |
-
|
| 1540 |
-
|
| 1541 |
-
|
| 1542 |
-
|
| 1543 |
-
|
| 1544 |
-
|
| 1545 |
-
|
| 1546 |
-
|
| 1547 |
-
|
| 1548 |
-
|
| 1549 |
-
|
| 1550 |
-
|
| 1551 |
-
|
| 1552 |
-
|
| 1553 |
-
|
| 1554 |
-
|
| 1555 |
-
|
| 1556 |
-
|
| 1557 |
-
|
| 1558 |
-
|
| 1559 |
-
|
| 1560 |
-
|
| 1561 |
-
|
| 1562 |
-
|
| 1563 |
-
|
| 1564 |
-
|
| 1565 |
-
|
| 1566 |
-
|
| 1567 |
-
|
| 1568 |
-
|
| 1569 |
-
"
|
| 1570 |
-
|
| 1571 |
-
|
| 1572 |
-
|
| 1573 |
-
|
| 1574 |
-
|
| 1575 |
-
|
| 1576 |
-
|
| 1577 |
-
|
| 1578 |
-
|
| 1579 |
-
|
| 1580 |
-
|
| 1581 |
-
|
| 1582 |
-
|
| 1583 |
-
|
| 1584 |
-
|
| 1585 |
-
|
| 1586 |
-
|
| 1587 |
-
|
| 1588 |
-
|
| 1589 |
-
|
| 1590 |
-
|
| 1591 |
-
|
| 1592 |
-
`store_product_id` int(10) NOT NULL default '0',
|
| 1593 |
-
`store_category_id` int(10) NOT NULL default '0',
|
| 1594 |
-
`new_category_id` int(10) NOT NULL default '0',
|
| 1595 |
UNIQUE KEY `UNQ_CATEGORY_PRODUCT` (`category_id`,`product_id`),
|
| 1596 |
KEY `CATALOG_CATEGORY_PRODUCT_CATEGORY` (`category_id`),
|
| 1597 |
KEY `CATALOG_CATEGORY_PRODUCT_PRODUCT` (`product_id`),
|
| 1598 |
KEY `CATALOG_NEW_CATEGORY_PRODUCT_CATEGORY` (`new_category_id`)
|
| 1599 |
)
|
| 1600 |
|
| 1601 |
-
");
|
| 1602 |
-
|
| 1603 |
-
$result = $this->db_do("
|
| 1604 |
-
INSERT INTO catalog_category_product_for_delete_temp (
|
| 1605 |
-
category_id,
|
| 1606 |
-
product_id,
|
| 1607 |
-
store_product_id
|
| 1608 |
-
)(
|
| 1609 |
-
SELECT
|
| 1610 |
-
ccp.category_id,
|
| 1611 |
-
ccp.product_id,
|
| 1612 |
-
cpe.store_product_id
|
| 1613 |
-
FROM catalog_category_product ccp join catalog_product_entity cpe on ccp.product_id=cpe.entity_id)
|
| 1614 |
-
");
|
| 1615 |
-
|
| 1616 |
-
$result = $this->db_do("
|
| 1617 |
-
update catalog_category_product_for_delete_temp ccpfd join products_temp p on ccpfd.store_product_id=p.store_product_id set ccpfd.store_category_id=p.store_category_id where ccpfd.store_product_id!=0
|
| 1618 |
-
");
|
| 1619 |
-
|
| 1620 |
-
$result = $this->db_do("
|
| 1621 |
-
update catalog_category_product_for_delete_temp ccpfd join stINch_categories_mapping scm on ccpfd.store_category_id=scm.store_category_id set ccpfd.new_category_id=scm.shop_entity_id where ccpfd.store_category_id!=0
|
| 1622 |
-
");
|
| 1623 |
-
|
| 1624 |
-
$result = $this->db_do("delete from catalog_category_product_for_delete_temp where category_id=new_category_id");
|
| 1625 |
-
|
| 1626 |
-
$result = $this->db_do("
|
| 1627 |
-
delete ccp from catalog_category_product ccp join catalog_category_product_for_delete_temp ccpfd on ccp.product_id=ccpfd.product_id and ccp.category_id=ccpfd.category_id
|
| 1628 |
-
");
|
| 1629 |
-
|
| 1630 |
-
$result = $this->db_do("
|
| 1631 |
-
INSERT INTO catalog_category_product (
|
| 1632 |
-
category_id,
|
| 1633 |
-
product_id
|
| 1634 |
-
)(
|
| 1635 |
-
SELECT scm.shop_entity_id, cpe.entity_id from catalog_product_entity cpe join products_temp p on cpe.store_product_id=p.store_product_id join stINch_categories_mapping scm on p.store_category_id=scm.store_category_id)
|
| 1636 |
-
ON DUPLICATE KEY UPDATE
|
| 1637 |
-
product_id = cpe.entity_id
|
| 1638 |
-
");
|
| 1639 |
-
|
| 1640 |
-
//Indexing products and categories in the shop
|
| 1641 |
-
$result = $this->db_do("DELETE ccpi from catalog_category_product_index ccpi LEFT JOIN catalog_product_entity cpe on ccpi.product_id=cpe.entity_id where cpe.entity_id is null");
|
| 1642 |
-
|
| 1643 |
-
$result = $this->db_do("
|
| 1644 |
-
INSERT INTO catalog_category_product_index (
|
| 1645 |
-
category_id,
|
| 1646 |
-
product_id,
|
| 1647 |
-
position,
|
| 1648 |
-
is_parent,
|
| 1649 |
-
store_id,
|
| 1650 |
-
visibility
|
| 1651 |
-
)(
|
| 1652 |
-
SELECT
|
| 1653 |
-
a.category_id,
|
| 1654 |
-
a.product_id,
|
| 1655 |
-
a.position,
|
| 1656 |
-
1,
|
| 1657 |
-
b.store_id,
|
| 1658 |
-
4
|
| 1659 |
-
FROM catalog_category_product a
|
| 1660 |
-
INNER JOIN core_store b)
|
| 1661 |
-
ON DUPLICATE KEY UPDATE
|
| 1662 |
-
visibility = 4
|
| 1663 |
-
");
|
| 1664 |
-
$result = $this->db_do("
|
| 1665 |
-
INSERT ignore INTO catalog_category_product_index (
|
| 1666 |
-
category_id,
|
| 1667 |
-
product_id,
|
| 1668 |
-
position,
|
| 1669 |
-
is_parent,
|
| 1670 |
-
store_id,
|
| 1671 |
-
visibility
|
| 1672 |
-
)(
|
| 1673 |
-
SELECT
|
| 1674 |
-
2,
|
| 1675 |
-
a.product_id,
|
| 1676 |
-
a.position,
|
| 1677 |
-
1,
|
| 1678 |
-
b.store_id,
|
| 1679 |
-
4
|
| 1680 |
-
FROM catalog_category_product a
|
| 1681 |
-
INNER JOIN core_store b)
|
| 1682 |
-
ON DUPLICATE KEY UPDATE
|
| 1683 |
-
visibility = 4
|
| 1684 |
-
|
| 1685 |
-
");
|
| 1686 |
-
|
| 1687 |
-
|
| 1688 |
-
|
| 1689 |
-
//Set product name for specific web sites
|
| 1690 |
-
$result = $this->db_do("DELETE cpev from catalog_product_entity_varchar cpev LEFT JOIN catalog_product_entity cpe on cpev.entity_id=cpe.entity_id where cpe.entity_id is null");
|
| 1691 |
-
$result = $this->db_do("
|
| 1692 |
-
INSERT INTO catalog_product_entity_varchar (
|
| 1693 |
-
entity_type_id,
|
| 1694 |
-
attribute_id,
|
| 1695 |
-
store_id,
|
| 1696 |
-
entity_id,
|
| 1697 |
-
value
|
| 1698 |
-
)(
|
| 1699 |
-
SELECT
|
| 1700 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1701 |
-
" . $this->_getProductAttributeId('name'). ",
|
| 1702 |
-
w.website,
|
| 1703 |
-
a.entity_id,
|
| 1704 |
-
b.product_name
|
| 1705 |
-
FROM catalog_product_entity a
|
| 1706 |
-
INNER JOIN products_temp b
|
| 1707 |
-
ON a.store_product_id= b.store_product_id
|
| 1708 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id)
|
| 1709 |
-
ON DUPLICATE KEY UPDATE
|
| 1710 |
-
value = b.product_name
|
| 1711 |
-
");
|
| 1712 |
-
// product name for all web sites
|
| 1713 |
-
$result = $this->db_do("
|
| 1714 |
-
INSERT INTO catalog_product_entity_varchar (
|
| 1715 |
-
entity_type_id,
|
| 1716 |
-
attribute_id,
|
| 1717 |
-
store_id,
|
| 1718 |
-
entity_id,
|
| 1719 |
-
value
|
| 1720 |
-
)(
|
| 1721 |
-
SELECT
|
| 1722 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1723 |
-
" . $this->_getProductAttributeId('name'). ",
|
| 1724 |
-
0,
|
| 1725 |
-
a.entity_id,
|
| 1726 |
-
b.product_name
|
| 1727 |
-
FROM catalog_product_entity a
|
| 1728 |
-
INNER JOIN products_temp b
|
| 1729 |
-
ON a.store_product_id = b.store_product_id)
|
| 1730 |
-
ON DUPLICATE KEY UPDATE
|
| 1731 |
-
value = b.product_name
|
| 1732 |
-
");
|
| 1733 |
-
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
| 1734 |
-
|
| 1735 |
-
$this->addDescriptions();
|
| 1736 |
-
$this->addShortDescriptions();
|
| 1737 |
-
$this->addEAN();
|
| 1738 |
-
$this->addSpecification();
|
| 1739 |
-
$this->addManufacturers();
|
| 1740 |
-
|
| 1741 |
-
//Enabling product index.
|
| 1742 |
-
$result = $this->db_do("DELETE cpei from catalog_product_enabled_index cpei LEFT JOIN catalog_product_entity cpe on cpei.product_id=cpe.entity_id where cpe.entity_id is null");
|
| 1743 |
-
$result = $this->db_do("
|
| 1744 |
-
INSERT INTO catalog_product_enabled_index (
|
| 1745 |
-
product_id,
|
| 1746 |
-
store_id,
|
| 1747 |
-
visibility
|
| 1748 |
-
)(
|
| 1749 |
-
SELECT
|
| 1750 |
-
a.entity_id,
|
| 1751 |
-
w.website,
|
| 1752 |
-
4
|
| 1753 |
-
FROM catalog_product_entity a
|
| 1754 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id
|
| 1755 |
-
)
|
| 1756 |
-
ON DUPLICATE KEY UPDATE
|
| 1757 |
-
visibility = 4
|
| 1758 |
-
");
|
| 1759 |
-
$result = $this->db_do("
|
| 1760 |
-
INSERT INTO catalog_product_enabled_index (
|
| 1761 |
-
product_id,
|
| 1762 |
-
store_id,
|
| 1763 |
-
visibility
|
| 1764 |
-
)(
|
| 1765 |
-
SELECT
|
| 1766 |
-
a.entity_id,
|
| 1767 |
-
0,
|
| 1768 |
-
4
|
| 1769 |
-
FROM catalog_product_entity a
|
| 1770 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id
|
| 1771 |
-
)
|
| 1772 |
-
ON DUPLICATE KEY UPDATE
|
| 1773 |
-
visibility = 4
|
| 1774 |
-
");
|
| 1775 |
-
|
| 1776 |
-
|
| 1777 |
-
$result = $this->db_do("
|
| 1778 |
-
INSERT INTO catalog_product_entity_int (
|
| 1779 |
-
entity_type_id,
|
| 1780 |
-
attribute_id,
|
| 1781 |
-
store_id,
|
| 1782 |
-
entity_id,
|
| 1783 |
-
value
|
| 1784 |
-
)(
|
| 1785 |
-
SELECT
|
| 1786 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1787 |
-
" . $this->_getProductAttributeId('visibility'). ",
|
| 1788 |
-
w.website,
|
| 1789 |
-
a.entity_id,
|
| 1790 |
-
4
|
| 1791 |
-
FROM catalog_product_entity a
|
| 1792 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id)
|
| 1793 |
-
ON DUPLICATE KEY UPDATE
|
| 1794 |
-
value = 4
|
| 1795 |
-
");
|
| 1796 |
-
|
| 1797 |
-
$result = $this->db_do("
|
| 1798 |
-
INSERT INTO catalog_product_entity_int (
|
| 1799 |
-
entity_type_id,
|
| 1800 |
-
attribute_id,
|
| 1801 |
-
store_id,
|
| 1802 |
-
entity_id,
|
| 1803 |
-
value
|
| 1804 |
-
)(
|
| 1805 |
-
SELECT
|
| 1806 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1807 |
-
" . $this->_getProductAttributeId('visibility'). ",
|
| 1808 |
-
0,
|
| 1809 |
-
a.entity_id,
|
| 1810 |
-
4
|
| 1811 |
-
FROM catalog_product_entity a
|
| 1812 |
-
)
|
| 1813 |
-
ON DUPLICATE KEY UPDATE
|
| 1814 |
-
value = 4
|
| 1815 |
-
");
|
| 1816 |
-
|
| 1817 |
-
// $result = $this->db_do(" truncate catalog_product_website");
|
| 1818 |
-
$result = $this->db_do("DELETE cpw from catalog_product_website cpw LEFT JOIN catalog_product_entity cpe on cpw.product_id=cpe.entity_id where cpe.entity_id is null");
|
| 1819 |
-
$result = $this->db_do("
|
| 1820 |
-
INSERT INTO catalog_product_website (
|
| 1821 |
-
product_id,
|
| 1822 |
-
website_id
|
| 1823 |
-
)(
|
| 1824 |
-
SELECT a.entity_id, w.website_id
|
| 1825 |
-
FROM catalog_product_entity a
|
| 1826 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id)
|
| 1827 |
-
ON DUPLICATE KEY UPDATE
|
| 1828 |
-
product_id=a.entity_id,
|
| 1829 |
-
website_id=w.website_id
|
| 1830 |
-
");
|
| 1831 |
-
|
| 1832 |
-
// temporary disabled mart@bintime.com
|
| 1833 |
-
//$result = $this->db_do("
|
| 1834 |
-
// UPDATE catalog_category_entity_int a
|
| 1835 |
-
// SET a.value = 0
|
| 1836 |
-
// WHERE a.attribute_id = 32
|
| 1837 |
-
//");
|
| 1838 |
-
|
| 1839 |
-
|
| 1840 |
-
//Adding tax class "Taxable Goods"
|
| 1841 |
-
$result = $this->db_do("
|
| 1842 |
-
INSERT INTO catalog_product_entity_int (
|
| 1843 |
-
entity_type_id,
|
| 1844 |
-
attribute_id,
|
| 1845 |
-
store_id,
|
| 1846 |
-
entity_id,
|
| 1847 |
-
value
|
| 1848 |
-
)(
|
| 1849 |
-
SELECT
|
| 1850 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1851 |
-
" . $this->_getProductAttributeId('tax_class_id'). ",
|
| 1852 |
-
w.website,
|
| 1853 |
-
a.entity_id,
|
| 1854 |
-
2
|
| 1855 |
-
FROM catalog_product_entity a
|
| 1856 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id)
|
| 1857 |
-
ON DUPLICATE KEY UPDATE
|
| 1858 |
-
value = 2
|
| 1859 |
-
");
|
| 1860 |
-
$result = $this->db_do("
|
| 1861 |
-
INSERT INTO catalog_product_entity_int (
|
| 1862 |
-
entity_type_id,
|
| 1863 |
-
attribute_id,
|
| 1864 |
-
store_id,
|
| 1865 |
-
entity_id,
|
| 1866 |
-
value
|
| 1867 |
-
)(
|
| 1868 |
-
SELECT
|
| 1869 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1870 |
-
" . $this->_getProductAttributeId('tax_class_id'). ",
|
| 1871 |
-
0,
|
| 1872 |
-
a.entity_id,
|
| 1873 |
-
2
|
| 1874 |
-
FROM catalog_product_entity a)
|
| 1875 |
-
ON DUPLICATE KEY UPDATE
|
| 1876 |
-
value = 2
|
| 1877 |
-
");
|
| 1878 |
-
|
| 1879 |
-
//Add weight value
|
| 1880 |
-
/* $result = $this->db_do("
|
| 1881 |
-
INSERT INTO catalog_product_entity_decimal (
|
| 1882 |
-
entity_type_id,
|
| 1883 |
-
attribute_id,
|
| 1884 |
-
store_id,
|
| 1885 |
-
entity_id,
|
| 1886 |
-
value
|
| 1887 |
-
)
|
| 1888 |
-
SELECT 4, 65, 0, entity_id, b.weight
|
| 1889 |
-
FROM catalog_product_entity a
|
| 1890 |
-
INNER JOIN import_distributor_offer b
|
| 1891 |
-
ON a.distributor_product_id = b.distributor_product_code
|
| 1892 |
-
AND a.distributor_id = b.distributor_id
|
| 1893 |
-
");
|
| 1894 |
-
*/
|
| 1895 |
-
// Load url Image
|
| 1896 |
-
$result = $this->db_do("
|
| 1897 |
-
INSERT INTO catalog_product_entity_varchar (
|
| 1898 |
-
entity_type_id,
|
| 1899 |
-
attribute_id,
|
| 1900 |
-
store_id,
|
| 1901 |
-
entity_id,
|
| 1902 |
-
value
|
| 1903 |
-
)
|
| 1904 |
-
SELECT
|
| 1905 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1906 |
-
" . $this->_getProductAttributeId('image'). ",
|
| 1907 |
-
w.store_id,
|
| 1908 |
-
a.entity_id,
|
| 1909 |
-
b.main_image_url
|
| 1910 |
-
FROM catalog_product_entity a
|
| 1911 |
-
INNER JOIN core_store w
|
| 1912 |
-
INNER JOIN products_temp b
|
| 1913 |
-
ON a.store_product_id = b.store_product_id
|
| 1914 |
-
ON DUPLICATE KEY UPDATE
|
| 1915 |
-
value = b.main_image_url
|
| 1916 |
-
");
|
| 1917 |
-
|
| 1918 |
-
|
| 1919 |
-
// image for specific web sites
|
| 1920 |
-
$result = $this->db_do("
|
| 1921 |
-
INSERT INTO catalog_product_entity_varchar (
|
| 1922 |
-
entity_type_id,
|
| 1923 |
-
attribute_id,
|
| 1924 |
-
store_id,
|
| 1925 |
-
entity_id,
|
| 1926 |
-
value
|
| 1927 |
-
)
|
| 1928 |
-
SELECT
|
| 1929 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1930 |
-
" . $this->_getProductAttributeId('image'). ",
|
| 1931 |
-
0,
|
| 1932 |
-
a.entity_id,
|
| 1933 |
-
b.main_image_url
|
| 1934 |
-
FROM catalog_product_entity a
|
| 1935 |
-
INNER JOIN products_temp b
|
| 1936 |
-
ON a.store_product_id = b.store_product_id
|
| 1937 |
-
ON DUPLICATE KEY UPDATE
|
| 1938 |
-
value = b.main_image_url
|
| 1939 |
-
|
| 1940 |
-
|
| 1941 |
-
");
|
| 1942 |
-
|
| 1943 |
-
|
| 1944 |
-
// small_image for specific web sites
|
| 1945 |
-
$result = $this->db_do("
|
| 1946 |
-
INSERT INTO catalog_product_entity_varchar (
|
| 1947 |
-
entity_type_id,
|
| 1948 |
-
attribute_id,
|
| 1949 |
-
store_id,
|
| 1950 |
-
entity_id,
|
| 1951 |
-
value
|
| 1952 |
-
)
|
| 1953 |
-
SELECT
|
| 1954 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1955 |
-
" . $this->_getProductAttributeId('small_image'). ",
|
| 1956 |
-
w.store_id,
|
| 1957 |
-
a.entity_id,
|
| 1958 |
-
b.medium_image_url
|
| 1959 |
-
FROM catalog_product_entity a
|
| 1960 |
-
INNER JOIN core_store w
|
| 1961 |
-
INNER JOIN products_temp b
|
| 1962 |
-
ON a.store_product_id = b.store_product_id
|
| 1963 |
-
ON DUPLICATE KEY UPDATE
|
| 1964 |
-
value = b.medium_image_url
|
| 1965 |
-
");
|
| 1966 |
-
|
| 1967 |
-
|
| 1968 |
-
// small_image for all web sites
|
| 1969 |
-
$result = $this->db_do("
|
| 1970 |
-
INSERT INTO catalog_product_entity_varchar (
|
| 1971 |
-
entity_type_id,
|
| 1972 |
-
attribute_id,
|
| 1973 |
-
store_id,
|
| 1974 |
-
entity_id,
|
| 1975 |
-
value
|
| 1976 |
-
)
|
| 1977 |
-
SELECT
|
| 1978 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 1979 |
-
" . $this->_getProductAttributeId('small_image'). ",
|
| 1980 |
-
0,
|
| 1981 |
-
a.entity_id,
|
| 1982 |
-
b.medium_image_url
|
| 1983 |
-
FROM catalog_product_entity a
|
| 1984 |
-
INNER JOIN core_store w
|
| 1985 |
-
INNER JOIN products_temp b
|
| 1986 |
-
ON a.store_product_id = b.store_product_id
|
| 1987 |
-
ON DUPLICATE KEY UPDATE
|
| 1988 |
-
value = b.medium_image_url
|
| 1989 |
-
");
|
| 1990 |
-
|
| 1991 |
-
|
| 1992 |
-
// thumbnail for specific web site
|
| 1993 |
-
$result = $this->db_do("
|
| 1994 |
-
INSERT INTO catalog_product_entity_varchar (
|
| 1995 |
-
entity_type_id,
|
| 1996 |
-
attribute_id,
|
| 1997 |
-
store_id,
|
| 1998 |
-
entity_id,
|
| 1999 |
-
value
|
| 2000 |
-
)
|
| 2001 |
-
SELECT
|
| 2002 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 2003 |
-
" . $this->_getProductAttributeId('thumbnail'). ",
|
| 2004 |
-
w.store_id,
|
| 2005 |
-
a.entity_id,
|
| 2006 |
-
b.thumb_image_url
|
| 2007 |
-
FROM catalog_product_entity a
|
| 2008 |
-
INNER JOIN core_store w
|
| 2009 |
-
INNER JOIN products_temp b
|
| 2010 |
-
ON a.store_product_id = b.store_product_id
|
| 2011 |
-
ON DUPLICATE KEY UPDATE
|
| 2012 |
-
value = b.thumb_image_url
|
| 2013 |
");
|
| 2014 |
|
| 2015 |
-
|
| 2016 |
-
|
| 2017 |
-
|
| 2018 |
-
|
| 2019 |
-
|
| 2020 |
-
|
| 2021 |
-
|
| 2022 |
-
|
| 2023 |
-
|
| 2024 |
-
|
| 2025 |
-
|
| 2026 |
-
|
| 2027 |
-
|
| 2028 |
-
|
| 2029 |
-
|
| 2030 |
-
|
| 2031 |
-
|
| 2032 |
-
|
| 2033 |
-
|
| 2034 |
-
|
| 2035 |
-
|
| 2036 |
-
|
| 2037 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2038 |
");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2039 |
|
| 2040 |
-
|
| 2041 |
-
//Refresh fulltext search
|
| 2042 |
-
//d.value
|
| 2043 |
-
//$this->db_do('TRUNCATE catalogsearch_fulltext');
|
| 2044 |
-
$result = $this->db_do("DROP TABLE IF EXISTS catalogsearch_fulltext_tmp");
|
| 2045 |
-
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS catalogsearch_fulltext_tmp LIKE catalogsearch_fulltext");
|
| 2046 |
-
|
| 2047 |
-
$result = $this->db_do("
|
| 2048 |
-
INSERT INTO catalogsearch_fulltext_tmp (product_id, store_id, data_index)
|
| 2049 |
-
SELECT
|
| 2050 |
-
a.entity_id,
|
| 2051 |
-
w.website_id,
|
| 2052 |
-
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
| 2053 |
-
FROM catalog_product_entity a
|
| 2054 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id
|
| 2055 |
-
LEFT JOIN catalog_category_product b ON a.entity_id = b.product_id
|
| 2056 |
-
LEFT JOIN catalog_category_entity_varchar c ON b.category_id = c.entity_id AND c.attribute_id =
|
| 2057 |
-
" . $this->_getCategoryAttributeId('name'). "
|
| 2058 |
-
LEFT JOIN catalog_product_entity_varchar e ON a.entity_id = e.entity_id AND e.attribute_id =
|
| 2059 |
-
" . $this->_getProductAttributeId('name'). "
|
| 2060 |
-
LEFT JOIN catalog_product_website j ON a.entity_id = j.product_id
|
| 2061 |
-
LEFT JOIN products_temp f ON a.entity_id = f.store_product_id
|
| 2062 |
-
ON DUPLICATE KEY UPDATE
|
| 2063 |
-
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
| 2064 |
");
|
| 2065 |
-
$result = $this->db_do("
|
| 2066 |
-
INSERT INTO catalogsearch_fulltext_tmp (product_id, store_id, data_index)
|
| 2067 |
-
SELECT
|
| 2068 |
-
a.entity_id,
|
| 2069 |
-
w.website_id,
|
| 2070 |
-
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
| 2071 |
-
FROM catalog_product_entity a
|
| 2072 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id
|
| 2073 |
-
LEFT JOIN catalog_category_product b ON a.entity_id = b.product_id
|
| 2074 |
-
LEFT JOIN catalog_category_entity_varchar c ON b.category_id = c.entity_id AND c.attribute_id =
|
| 2075 |
-
" . $this->_getCategoryAttributeId('name'). "
|
| 2076 |
-
LEFT JOIN catalog_product_entity_varchar e ON a.entity_id = e.entity_id AND e.attribute_id =
|
| 2077 |
-
" . $this->_getProductAttributeId('name'). "
|
| 2078 |
-
LEFT JOIN products_temp f ON a.entity_id = f.store_product_id
|
| 2079 |
-
ON DUPLICATE KEY UPDATE
|
| 2080 |
-
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
| 2081 |
-
");
|
| 2082 |
|
| 2083 |
-
$result = $this->db_do("DELETE cf from catalogsearch_fulltext cf LEFT JOIN catalog_product_entity cpe on cf.product_id=cpe.entity_id where cpe.entity_id is null");
|
| 2084 |
-
|
| 2085 |
-
$result = $this->db_do("
|
| 2086 |
-
INSERT INTO catalogsearch_fulltext (product_id, store_id, data_index)
|
| 2087 |
-
SELECT
|
| 2088 |
-
a.product_id,
|
| 2089 |
-
a.store_id,
|
| 2090 |
-
a.data_index
|
| 2091 |
-
FROM catalogsearch_fulltext_tmp a
|
| 2092 |
-
WHERE product_id = a.product_id
|
| 2093 |
-
ON DUPLICATE KEY UPDATE
|
| 2094 |
-
data_index = a.data_index
|
| 2095 |
-
");
|
| 2096 |
|
| 2097 |
-
|
| 2098 |
-
|
| 2099 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2100 |
|
| 2101 |
-
$this->addRelatedProducts();
|
| 2102 |
-
}
|
| 2103 |
#################################################################################################
|
| 2104 |
-
|
| 2105 |
// product description for all web sites
|
| 2106 |
-
|
| 2107 |
-
|
| 2108 |
-
|
| 2109 |
-
|
| 2110 |
-
|
| 2111 |
-
|
| 2112 |
-
|
| 2113 |
-
|
| 2114 |
-
|
| 2115 |
-
|
| 2116 |
-
|
| 2117 |
-
|
| 2118 |
-
|
| 2119 |
-
|
| 2120 |
-
|
| 2121 |
-
|
| 2122 |
-
|
| 2123 |
-
|
| 2124 |
-
|
| 2125 |
-
|
| 2126 |
-
|
| 2127 |
-
|
| 2128 |
-
|
| 2129 |
-
|
| 2130 |
-
|
| 2131 |
-
|
| 2132 |
-
|
| 2133 |
-
|
| 2134 |
-
|
| 2135 |
-
|
| 2136 |
-
|
| 2137 |
-
|
| 2138 |
-
|
| 2139 |
-
|
| 2140 |
-
|
| 2141 |
-
|
| 2142 |
-
|
| 2143 |
-
|
| 2144 |
-
|
| 2145 |
-
|
| 2146 |
-
|
| 2147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2148 |
|
| 2149 |
-
");
|
| 2150 |
|
|
|
|
| 2151 |
|
| 2152 |
-
}
|
| 2153 |
#################################################################################################
|
| 2154 |
-
|
| 2155 |
// product short description for all web sites
|
| 2156 |
-
|
| 2157 |
-
|
| 2158 |
-
|
| 2159 |
-
|
| 2160 |
-
|
| 2161 |
-
|
| 2162 |
-
|
| 2163 |
-
|
| 2164 |
-
|
| 2165 |
-
|
| 2166 |
-
|
| 2167 |
-
|
| 2168 |
-
|
| 2169 |
-
|
| 2170 |
-
|
| 2171 |
-
|
| 2172 |
-
|
| 2173 |
-
|
| 2174 |
-
|
| 2175 |
-
|
| 2176 |
-
|
| 2177 |
-
|
| 2178 |
-
|
| 2179 |
-
|
| 2180 |
-
|
| 2181 |
-
|
| 2182 |
-
|
| 2183 |
-
|
| 2184 |
-
|
| 2185 |
-
|
| 2186 |
-
|
| 2187 |
-
|
| 2188 |
-
|
| 2189 |
-
|
| 2190 |
-
|
| 2191 |
-
|
| 2192 |
-
|
| 2193 |
-
|
| 2194 |
-
|
| 2195 |
-
|
| 2196 |
-
|
| 2197 |
-
|
| 2198 |
-
|
| 2199 |
-
|
| 2200 |
-
|
| 2201 |
|
| 2202 |
-
|
| 2203 |
|
| 2204 |
#################################################################################################
|
| 2205 |
-
|
| 2206 |
//gather EAN codes for each product
|
| 2207 |
-
|
| 2208 |
-
|
| 2209 |
-
|
| 2210 |
sinch_product_id int(11),
|
| 2211 |
store_product_id int(11),
|
| 2212 |
EANs text,
|
| 2213 |
KEY `sinch_product_id` (`sinch_product_id`),
|
| 2214 |
KEY `store_product_id` (`store_product_id`)
|
| 2215 |
-
|
| 2216 |
");
|
| 2217 |
-
|
| 2218 |
-
|
| 2219 |
-
|
| 2220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2221 |
// product EANs for all web sites
|
| 2222 |
-
|
| 2223 |
-
|
| 2224 |
-
|
| 2225 |
-
|
| 2226 |
-
|
| 2227 |
-
|
| 2228 |
-
|
| 2229 |
-
|
| 2230 |
-
|
| 2231 |
-
|
| 2232 |
-
|
| 2233 |
-
|
| 2234 |
-
|
| 2235 |
-
|
| 2236 |
-
|
| 2237 |
-
|
| 2238 |
-
|
| 2239 |
-
|
| 2240 |
-
|
| 2241 |
-
|
|
|
|
|
|
|
| 2242 |
");
|
| 2243 |
|
| 2244 |
-
|
| 2245 |
-
|
| 2246 |
-
|
| 2247 |
-
|
| 2248 |
-
|
| 2249 |
-
|
| 2250 |
-
|
| 2251 |
-
|
| 2252 |
-
|
| 2253 |
-
|
| 2254 |
-
|
| 2255 |
-
|
| 2256 |
-
|
| 2257 |
-
|
| 2258 |
-
|
| 2259 |
-
|
| 2260 |
-
|
| 2261 |
-
|
| 2262 |
-
|
| 2263 |
-
|
| 2264 |
-
|
| 2265 |
-
|
| 2266 |
-
|
|
|
|
|
|
|
|
|
|
| 2267 |
|
| 2268 |
-
}
|
| 2269 |
################################################################################################
|
| 2270 |
-
|
| 2271 |
// product specification for all web sites
|
| 2272 |
-
|
| 2273 |
-
|
| 2274 |
-
|
| 2275 |
-
|
| 2276 |
-
|
| 2277 |
-
|
| 2278 |
-
|
| 2279 |
-
|
| 2280 |
-
|
| 2281 |
-
|
| 2282 |
-
|
| 2283 |
-
|
| 2284 |
-
|
| 2285 |
-
|
| 2286 |
-
|
| 2287 |
-
|
| 2288 |
-
|
| 2289 |
-
|
| 2290 |
-
|
| 2291 |
-
|
|
|
|
|
|
|
| 2292 |
");
|
| 2293 |
-
|
| 2294 |
-
|
| 2295 |
-
|
| 2296 |
-
|
| 2297 |
-
|
| 2298 |
-
|
| 2299 |
-
|
| 2300 |
-
|
| 2301 |
-
|
| 2302 |
-
|
| 2303 |
-
|
| 2304 |
-
|
| 2305 |
-
|
| 2306 |
-
|
| 2307 |
-
|
| 2308 |
-
|
| 2309 |
-
|
| 2310 |
-
|
| 2311 |
-
|
| 2312 |
-
|
|
|
|
|
|
|
| 2313 |
|
| 2314 |
|
| 2315 |
-
|
| 2316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2317 |
|
| 2318 |
-
}
|
| 2319 |
-
private function addManufacturer_attribute(){
|
| 2320 |
-
$result = $this->db_do("
|
| 2321 |
-
INSERT INTO catalog_product_entity_int (
|
| 2322 |
-
entity_type_id,
|
| 2323 |
-
attribute_id,
|
| 2324 |
-
store_id,
|
| 2325 |
-
entity_id,
|
| 2326 |
-
value
|
| 2327 |
-
)(
|
| 2328 |
-
SELECT
|
| 2329 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 2330 |
-
" . $this->_getProductAttributeId('manufacturer'). ",
|
| 2331 |
-
0,
|
| 2332 |
-
a.entity_id,
|
| 2333 |
-
pm.manufacturer_option_id
|
| 2334 |
-
FROM catalog_product_entity a
|
| 2335 |
-
INNER JOIN stINch_products_mapping pm
|
| 2336 |
-
ON a.entity_id = pm.entity_id)
|
| 2337 |
-
ON DUPLICATE KEY UPDATE
|
| 2338 |
-
value = pm.manufacturer_option_id
|
| 2339 |
-
");
|
| 2340 |
|
|
|
|
| 2341 |
|
| 2342 |
-
}
|
| 2343 |
#################################################################################################
|
| 2344 |
-
|
| 2345 |
-
|
| 2346 |
-
|
| 2347 |
-
$result = $this->db_do("
|
| 2348 |
-
DELETE FROM catalog_product_index_eav WHERE attribute_id = ".$this->_getProductAttributeId('manufacturer')//." AND store_id = ".$websiteId
|
| 2349 |
-
);
|
| 2350 |
-
|
| 2351 |
-
}
|
| 2352 |
-
$this->addManufacturer_attribute();
|
| 2353 |
-
// todo: doesn't seems to work properly, should be inserted per visibility
|
| 2354 |
-
// done, test now
|
| 2355 |
-
|
| 2356 |
-
$result = $this->db_do("
|
| 2357 |
-
INSERT INTO catalog_product_index_eav(
|
| 2358 |
-
entity_id,
|
| 2359 |
-
attribute_id,
|
| 2360 |
-
store_id,
|
| 2361 |
-
value
|
| 2362 |
-
)(
|
| 2363 |
-
SELECT
|
| 2364 |
-
a.entity_id,
|
| 2365 |
-
" . $this->_getProductAttributeId('manufacturer'). ",
|
| 2366 |
-
w.website,
|
| 2367 |
-
mn.shop_option_id
|
| 2368 |
-
FROM catalog_product_entity a
|
| 2369 |
-
INNER JOIN products_temp b
|
| 2370 |
-
ON a.store_product_id = b.store_product_id
|
| 2371 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id
|
| 2372 |
-
INNER JOIN stINch_manufacturers mn on b.sinch_manufacturer_id=mn.sinch_manufacturer_id
|
| 2373 |
-
where mn.shop_option_id is not null
|
| 2374 |
-
)
|
| 2375 |
-
ON DUPLICATE KEY UPDATE
|
| 2376 |
-
value = mn.shop_option_id
|
| 2377 |
-
");
|
| 2378 |
-
|
| 2379 |
$result = $this->db_do("
|
| 2380 |
-
|
| 2381 |
-
|
| 2382 |
-
|
| 2383 |
-
|
| 2384 |
-
|
| 2385 |
-
|
| 2386 |
-
|
| 2387 |
-
|
| 2388 |
-
|
| 2389 |
-
|
| 2390 |
-
|
| 2391 |
-
|
| 2392 |
-
|
| 2393 |
-
|
| 2394 |
-
|
| 2395 |
-
|
| 2396 |
-
|
| 2397 |
-
|
| 2398 |
-
|
| 2399 |
-
|
| 2400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2401 |
|
| 2402 |
|
|
|
|
| 2403 |
|
| 2404 |
-
}
|
| 2405 |
#################################################################################################
|
| 2406 |
-
|
| 2407 |
-
|
| 2408 |
-
|
| 2409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2410 |
|
| 2411 |
-
$result = $this->db_do("SELECT link_type_id,code FROM catalog_product_link_type;");
|
| 2412 |
-
$link_type=array();
|
| 2413 |
-
while ($row = mysql_fetch_array($result)) {
|
| 2414 |
-
$link_type[$row['code']]=$row['link_type_id'];
|
| 2415 |
-
}
|
| 2416 |
-
|
| 2417 |
-
$result = $this->db_do("
|
| 2418 |
-
INSERT INTO catalog_product_link(
|
| 2419 |
-
product_id,
|
| 2420 |
-
linked_product_id,
|
| 2421 |
-
link_type_id
|
| 2422 |
-
)(
|
| 2423 |
-
SELECT
|
| 2424 |
-
entity_id,
|
| 2425 |
-
related_entity_id,
|
| 2426 |
-
".$link_type['relation']."
|
| 2427 |
-
FROM stINch_related_products
|
| 2428 |
-
WHERE store_product_id is not null and store_related_product_id is not null
|
| 2429 |
-
)
|
| 2430 |
-
ON DUPLICATE KEY UPDATE
|
| 2431 |
-
product_id = entity_id,
|
| 2432 |
-
linked_product_id = related_entity_id
|
| 2433 |
-
");
|
| 2434 |
-
$this->db_do("DROP TABLE IF EXISTS catalog_product_link_attribute_int_tmp");
|
| 2435 |
-
|
| 2436 |
-
$this->db_do("create temporary table catalog_product_link_attribute_int_tmp (
|
| 2437 |
-
`value_id` int(11) default NULL,
|
| 2438 |
-
`product_link_attribute_id` smallint(6) unsigned default NULL,
|
| 2439 |
-
`link_id` int(11) unsigned default NULL,
|
| 2440 |
-
`value` int(11) NOT NULL default '0',
|
| 2441 |
-
KEY `FK_INT_PRODUCT_LINK_ATTRIBUTE` (`product_link_attribute_id`),
|
| 2442 |
-
KEY `FK_INT_PRODUCT_LINK` (`link_id`)
|
| 2443 |
-
)
|
| 2444 |
-
");
|
| 2445 |
-
|
| 2446 |
-
$result = $this->db_do("
|
| 2447 |
-
INSERT INTO catalog_product_link_attribute_int_tmp(
|
| 2448 |
-
product_link_attribute_id,
|
| 2449 |
-
link_id,
|
| 2450 |
-
value
|
| 2451 |
-
)(
|
| 2452 |
-
SELECT
|
| 2453 |
-
2,
|
| 2454 |
-
cpl.link_id,
|
| 2455 |
-
0
|
| 2456 |
-
FROM catalog_product_link cpl
|
| 2457 |
-
)
|
| 2458 |
-
");
|
| 2459 |
-
|
| 2460 |
-
$result = $this->db_do(" UPDATE catalog_product_link_attribute_int_tmp ct join catalog_product_link_attribute_int c on ct.link_id=c.link_id set ct.value_id=c.value_id where c.product_link_attribute_id=2
|
| 2461 |
-
");
|
| 2462 |
-
// $result = $this->db_do(" UPDATE catalog_product_link_attribute_int_tmp ct join catalog_product_link_attribute_int c on ct.link_id=c.link_id and ct.product_link_attribute_id=c.product_link_attribute_id set ct.value_id=c.value_id
|
| 2463 |
-
// ");
|
| 2464 |
-
|
| 2465 |
-
|
| 2466 |
$result = $this->db_do("
|
| 2467 |
-
|
| 2468 |
-
|
| 2469 |
-
|
| 2470 |
-
|
| 2471 |
-
|
| 2472 |
-
|
| 2473 |
-
|
| 2474 |
-
|
| 2475 |
-
|
| 2476 |
-
|
| 2477 |
-
|
| 2478 |
-
|
| 2479 |
-
|
| 2480 |
-
|
| 2481 |
-
|
| 2482 |
|
| 2483 |
-
|
| 2484 |
|
| 2485 |
-
/* $q="select distinct store_product_id from stINch_related_products";
|
| 2486 |
-
|
| 2487 |
-
|
| 2488 |
-
|
| 2489 |
-
|
| 2490 |
-
|
| 2491 |
-
|
| 2492 |
|
| 2493 |
###//get related product data (product id's and positions)
|
| 2494 |
###$relatedData = array();
|
|
@@ -2501,613 +2840,681 @@ v*/
|
|
| 2501 |
###$product->setRelatedLinkData($relatedData);
|
| 2502 |
###$product->save();
|
| 2503 |
###
|
| 2504 |
-
|
| 2505 |
-
|
| 2506 |
-
|
| 2507 |
-
|
| 2508 |
-
|
| 2509 |
-
|
| 2510 |
-
|
| 2511 |
-
|
| 2512 |
|
| 2513 |
}
|
| 2514 |
-
*/
|
| 2515 |
-
|
| 2516 |
#################################################################################################
|
| 2517 |
-
|
| 2518 |
-
|
| 2519 |
-
|
| 2520 |
-
|
| 2521 |
-
|
| 2522 |
-
|
| 2523 |
-
|
| 2524 |
-
|
| 2525 |
-
|
| 2526 |
-
|
| 2527 |
-
|
| 2528 |
-
|
| 2529 |
-
|
| 2530 |
-
|
| 2531 |
-
|
| 2532 |
-
|
| 2533 |
-
|
| 2534 |
-
|
| 2535 |
-
|
| 2536 |
-
|
| 2537 |
-
|
| 2538 |
-
|
| 2539 |
-
|
| 2540 |
-
|
| 2541 |
-
|
| 2542 |
-
|
| 2543 |
-
|
| 2544 |
-
|
| 2545 |
-
|
| 2546 |
-
|
| 2547 |
-
|
| 2548 |
-
|
| 2549 |
-
|
| 2550 |
-
|
| 2551 |
-
|
| 2552 |
-
|
| 2553 |
-
|
| 2554 |
-
|
| 2555 |
-
|
| 2556 |
-
|
| 2557 |
-
|
| 2558 |
-
|
| 2559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2560 |
|
| 2561 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2562 |
");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2563 |
|
| 2564 |
-
|
| 2565 |
-
|
| 2566 |
-
|
| 2567 |
-
|
| 2568 |
-
|
| 2569 |
-
|
| 2570 |
-
|
| 2571 |
-
|
| 2572 |
-
|
| 2573 |
-
|
| 2574 |
-
|
| 2575 |
-
|
| 2576 |
-
|
| 2577 |
-
|
| 2578 |
-
|
| 2579 |
-
|
| 2580 |
-
|
| 2581 |
-
|
| 2582 |
-
|
| 2583 |
-
|
| 2584 |
-
|
| 2585 |
-
|
| 2586 |
-
|
| 2587 |
-
|
| 2588 |
-
|
| 2589 |
-
|
| 2590 |
-
|
| 2591 |
-
|
| 2592 |
-
|
| 2593 |
-
|
| 2594 |
-
|
| 2595 |
-
|
| 2596 |
-
|
|
|
|
|
|
|
| 2597 |
|
| 2598 |
|
| 2599 |
-
$result = $this->db_do("
|
| 2600 |
-
DELETE FROM cataloginventory_stock_status
|
| 2601 |
-
");
|
| 2602 |
-
$result = $this->db_do("
|
| 2603 |
-
INSERT INTO cataloginventory_stock_status (
|
| 2604 |
-
product_id,
|
| 2605 |
-
website_id,
|
| 2606 |
-
stock_id,
|
| 2607 |
-
qty,
|
| 2608 |
-
stock_status
|
| 2609 |
-
)(
|
| 2610 |
-
SELECT
|
| 2611 |
-
a.product_id,
|
| 2612 |
-
w.website_id,
|
| 2613 |
-
1,
|
| 2614 |
-
a.qty,
|
| 2615 |
-
IF(qty > 0, 1, 0)
|
| 2616 |
-
FROM cataloginventory_stock_item a
|
| 2617 |
-
INNER JOIN catalog_product_entity b
|
| 2618 |
-
on a.product_id=b.entity_id
|
| 2619 |
-
INNER JOIN products_website_temp w
|
| 2620 |
-
on b.store_product_id=w.store_product_id
|
| 2621 |
-
)
|
| 2622 |
-
ON DUPLICATE KEY UPDATE
|
| 2623 |
-
qty=a.qty,
|
| 2624 |
-
stock_status = IF(a.qty > 0, 1, 0)
|
| 2625 |
|
| 2626 |
-
|
| 2627 |
|
| 2628 |
-
|
| 2629 |
-
//$result = $this->db_do("truncate catalog_product_entity_decimal");
|
| 2630 |
-
$result = $this->db_do("DELETE cped from catalog_product_entity_decimal cped LEFT JOIN catalog_product_entity cpe on cped.entity_id=cpe.entity_id where cpe.entity_id is null");
|
| 2631 |
-
$result = $this->db_do("
|
| 2632 |
-
INSERT INTO catalog_product_entity_decimal (
|
| 2633 |
-
entity_type_id,
|
| 2634 |
-
attribute_id,
|
| 2635 |
-
store_id,
|
| 2636 |
-
entity_id,
|
| 2637 |
-
value
|
| 2638 |
-
)(
|
| 2639 |
-
SELECT
|
| 2640 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 2641 |
-
" . $this->_getProductAttributeId('price'). ",
|
| 2642 |
-
w.website_id,
|
| 2643 |
-
a.entity_id,
|
| 2644 |
-
b.price
|
| 2645 |
-
FROM catalog_product_entity a
|
| 2646 |
-
INNER JOIN stock_and_prices_temp b on a.store_product_id=b.store_product_id
|
| 2647 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id)
|
| 2648 |
-
ON DUPLICATE KEY UPDATE
|
| 2649 |
-
value = b.price
|
| 2650 |
|
| 2651 |
-
|
| 2652 |
-
|
| 2653 |
-
|
| 2654 |
-
|
| 2655 |
-
|
| 2656 |
-
|
| 2657 |
-
entity_id,
|
| 2658 |
-
value
|
| 2659 |
-
)(
|
| 2660 |
-
SELECT
|
| 2661 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 2662 |
-
" . $this->_getProductAttributeId('price'). ",
|
| 2663 |
-
0,
|
| 2664 |
-
a.entity_id,
|
| 2665 |
-
b.price
|
| 2666 |
-
FROM catalog_product_entity a
|
| 2667 |
-
INNER JOIN stock_and_prices_temp b on a.store_product_id=b.store_product_id)
|
| 2668 |
-
ON DUPLICATE KEY UPDATE
|
| 2669 |
-
value = b.price
|
| 2670 |
-
");
|
| 2671 |
-
//Add cost
|
| 2672 |
-
// $result = $this->db_do("truncate catalog_product_entity_decimal");
|
| 2673 |
-
$result = $this->db_do("
|
| 2674 |
-
INSERT INTO catalog_product_entity_decimal (
|
| 2675 |
-
entity_type_id,
|
| 2676 |
-
attribute_id,
|
| 2677 |
-
store_id,
|
| 2678 |
-
entity_id,
|
| 2679 |
-
value
|
| 2680 |
-
)(
|
| 2681 |
-
SELECT
|
| 2682 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 2683 |
-
" . $this->_getProductAttributeId('cost'). ",
|
| 2684 |
-
w.website_id,
|
| 2685 |
-
a.entity_id,
|
| 2686 |
-
b.cost
|
| 2687 |
-
FROM catalog_product_entity a
|
| 2688 |
-
INNER JOIN stock_and_prices_temp b on a.store_product_id=b.store_product_id
|
| 2689 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id)
|
| 2690 |
-
ON DUPLICATE KEY UPDATE
|
| 2691 |
-
value = b.cost
|
| 2692 |
-
");
|
| 2693 |
-
$result = $this->db_do("
|
| 2694 |
-
INSERT INTO catalog_product_entity_decimal (
|
| 2695 |
-
entity_type_id,
|
| 2696 |
-
attribute_id,
|
| 2697 |
-
store_id,
|
| 2698 |
-
entity_id,
|
| 2699 |
-
value
|
| 2700 |
-
)(
|
| 2701 |
-
SELECT
|
| 2702 |
-
" . $this->_getProductEntityTypeId(). ",
|
| 2703 |
-
" . $this->_getProductAttributeId('cost'). ",
|
| 2704 |
-
0,
|
| 2705 |
-
a.entity_id,
|
| 2706 |
-
b.cost
|
| 2707 |
-
FROM catalog_product_entity a
|
| 2708 |
-
INNER JOIN stock_and_prices_temp b on a.store_product_id=b.store_product_id)
|
| 2709 |
-
ON DUPLICATE KEY UPDATE
|
| 2710 |
-
value = b.cost
|
| 2711 |
-
");
|
| 2712 |
|
|
|
|
|
|
|
|
|
|
| 2713 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2714 |
|
| 2715 |
-
|
| 2716 |
-
|
| 2717 |
-
|
| 2718 |
-
|
| 2719 |
-
");
|
| 2720 |
|
| 2721 |
-
|
| 2722 |
-
|
| 2723 |
-
|
| 2724 |
-
|
| 2725 |
-
|
| 2726 |
-
|
| 2727 |
-
|
| 2728 |
-
|
| 2729 |
-
|
| 2730 |
-
|
| 2731 |
-
|
| 2732 |
-
|
| 2733 |
-
|
| 2734 |
-
|
| 2735 |
-
|
| 2736 |
-
|
| 2737 |
-
|
| 2738 |
-
|
| 2739 |
-
|
| 2740 |
-
|
| 2741 |
-
|
| 2742 |
-
|
| 2743 |
-
|
| 2744 |
-
|
| 2745 |
-
|
| 2746 |
-
|
| 2747 |
-
|
| 2748 |
-
|
| 2749 |
-
|
| 2750 |
-
|
| 2751 |
-
|
| 2752 |
-
|
| 2753 |
-
|
| 2754 |
-
|
| 2755 |
-
|
| 2756 |
-
|
| 2757 |
-
|
| 2758 |
-
|
| 2759 |
-
INNER JOIN stock_and_prices_temp b on a.store_product_id=b.store_product_id
|
| 2760 |
-
INNER JOIN products_website_temp w on a.store_product_id=w.store_product_id
|
| 2761 |
-
)
|
| 2762 |
-
ON DUPLICATE KEY UPDATE
|
| 2763 |
-
tax_class_id = 2,
|
| 2764 |
-
price = b.price,
|
| 2765 |
-
final_price = b.price,
|
| 2766 |
-
min_price = b.price,
|
| 2767 |
-
max_price = b.price
|
| 2768 |
-
");
|
| 2769 |
-
}
|
| 2770 |
-
}
|
| 2771 |
-
|
| 2772 |
-
|
| 2773 |
-
|
| 2774 |
-
#################################################################################################
|
| 2775 |
-
|
| 2776 |
-
function getProductDescription($entity_id){
|
| 2777 |
-
|
| 2778 |
-
$this->loadProductParams($entity_id);
|
| 2779 |
-
$this->loadProductStarfeatures($entity_id);
|
| 2780 |
-
$this->loadGalleryPhotos($entity_id);
|
| 2781 |
-
Varien_Profiler::start('Bintime FILE RELATED');
|
| 2782 |
-
$this->loadRelatedProducts($entity_id);
|
| 2783 |
-
Varien_Profiler::stop('Bintime FILE RELATED');
|
| 2784 |
-
|
| 2785 |
-
return true;
|
| 2786 |
-
}
|
| 2787 |
-
#################################################################################################
|
| 2788 |
-
|
| 2789 |
-
public function getProductName(){
|
| 2790 |
-
return $this->productName;
|
| 2791 |
-
}
|
| 2792 |
-
#################################################################################################
|
| 2793 |
-
|
| 2794 |
-
public function getProductDescriptionList(){
|
| 2795 |
-
return $this->productDescriptionList;
|
| 2796 |
-
}
|
| 2797 |
-
#################################################################################################
|
| 2798 |
-
|
| 2799 |
-
public function getProductSpecifications(){
|
| 2800 |
-
return $this->specifications;
|
| 2801 |
-
}
|
| 2802 |
-
#################################################################################################
|
| 2803 |
-
|
| 2804 |
-
public function getShortProductDescription(){
|
| 2805 |
-
return $this->productDescription;
|
| 2806 |
-
}
|
| 2807 |
-
#################################################################################################
|
| 2808 |
-
|
| 2809 |
-
public function getFullProductDescription(){
|
| 2810 |
-
return $this->fullProductDescription;
|
| 2811 |
-
}
|
| 2812 |
-
#################################################################################################
|
| 2813 |
-
|
| 2814 |
-
public function getLowPicUrl(){
|
| 2815 |
-
return $this->highPicUrl;
|
| 2816 |
-
}
|
| 2817 |
-
#################################################################################################
|
| 2818 |
-
|
| 2819 |
-
public function getRelatedProducts(){
|
| 2820 |
-
return $this->relatedProducts;
|
| 2821 |
-
}
|
| 2822 |
-
#################################################################################################
|
| 2823 |
-
|
| 2824 |
-
public function getVendor(){
|
| 2825 |
-
return $this->vendor;
|
| 2826 |
-
}
|
| 2827 |
-
#################################################################################################
|
| 2828 |
-
|
| 2829 |
-
public function getMPN(){
|
| 2830 |
-
return $this->productId;
|
| 2831 |
-
}
|
| 2832 |
-
#################################################################################################
|
| 2833 |
-
|
| 2834 |
-
public function getEAN(){
|
| 2835 |
-
return $this->EAN;
|
| 2836 |
-
}
|
| 2837 |
################################################################################################
|
| 2838 |
|
| 2839 |
-
|
| 2840 |
-
|
| 2841 |
-
|
| 2842 |
-
|
| 2843 |
-
#################################################################################################
|
| 2844 |
-
|
| 2845 |
-
|
| 2846 |
-
|
| 2847 |
-
|
| 2848 |
-
// echo "AAAAAAA"; exit;
|
| 2849 |
-
|
| 2850 |
-
|
| 2851 |
-
|
| 2852 |
-
|
| 2853 |
-
|
| 2854 |
-
|
| 2855 |
-
|
| 2856 |
-
|
| 2857 |
-
|
| 2858 |
-
|
| 2859 |
-
|
| 2860 |
-
|
| 2861 |
-
|
| 2862 |
-
|
| 2863 |
-
|
| 2864 |
-
|
| 2865 |
-
|
| 2866 |
-
|
| 2867 |
-
|
| 2868 |
-
|
| 2869 |
-
|
| 2870 |
-
|
| 2871 |
-
|
| 2872 |
-
|
| 2873 |
-
|
| 2874 |
-
|
| 2875 |
-
|
| 2876 |
-
|
| 2877 |
-
|
| 2878 |
-
|
| 2879 |
-
|
| 2880 |
-
|
| 2881 |
-
|
| 2882 |
-
|
| 2883 |
-
|
| 2884 |
-
|
| 2885 |
-
|
| 2886 |
-
|
| 2887 |
-
|
| 2888 |
-
|
| 2889 |
-
|
| 2890 |
-
|
| 2891 |
-
|
| 2892 |
-
|
| 2893 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2894 |
while ($features = mysql_fetch_array($product_info_features)) {
|
| 2895 |
-
|
| 2896 |
}
|
| 2897 |
|
| 2898 |
-
|
| 2899 |
-
|
| 2900 |
-
|
| 2901 |
#################################################################################################
|
| 2902 |
|
| 2903 |
-
|
| 2904 |
-
|
| 2905 |
-
|
| 2906 |
-
|
| 2907 |
-
|
| 2908 |
-
|
| 2909 |
-
|
| 2910 |
-
|
| 2911 |
-
|
| 2912 |
-
|
| 2913 |
-
|
| 2914 |
-
|
| 2915 |
-
|
| 2916 |
-
|
| 2917 |
-
|
| 2918 |
-
|
| 2919 |
-
|
| 2920 |
-
|
| 2921 |
-
|
| 2922 |
-
|
| 2923 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2924 |
}
|
|
|
|
| 2925 |
#################################################################################################
|
| 2926 |
-
|
| 2927 |
-
|
| 2928 |
-
|
| 2929 |
-
|
| 2930 |
-
|
| 2931 |
-
|
| 2932 |
-
|
| 2933 |
-
|
| 2934 |
-
|
| 2935 |
-
|
| 2936 |
-
|
| 2937 |
-
|
| 2938 |
-
|
| 2939 |
-
|
| 2940 |
-
|
| 2941 |
-
|
| 2942 |
-
|
| 2943 |
-
|
| 2944 |
-
|
| 2945 |
-
|
| 2946 |
-
|
| 2947 |
-
while($photo=mysql_fetch_array($res)){
|
| 2948 |
-
$picHeight = (int)500;//$photo["PicHeight"];
|
| 2949 |
-
$picWidth = (int)500;//$photo["PicWidth"];
|
| 2950 |
-
$thumbUrl = (string)$photo["ThumbPic"];
|
| 2951 |
-
$picUrl = (string)$photo["Pic"];
|
| 2952 |
-
|
| 2953 |
-
array_push($this->galleryPhotos, array(
|
| 2954 |
-
'height' => $picHeight,
|
| 2955 |
-
'width' => $picWidth,
|
| 2956 |
-
'thumb' => $thumbUrl,
|
| 2957 |
-
'pic' => $picUrl
|
| 2958 |
-
));
|
| 2959 |
-
}
|
| 2960 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2961 |
#################################################################################################
|
| 2962 |
-
|
| 2963 |
-
|
| 2964 |
-
|
| 2965 |
-
|
| 2966 |
-
|
| 2967 |
-
|
| 2968 |
-
|
| 2969 |
-
|
| 2970 |
-
|
| 2971 |
-
|
| 2972 |
-
|
| 2973 |
-
|
| 2974 |
-
|
| 2975 |
-
|
| 2976 |
-
|
| 2977 |
-
|
| 2978 |
-
|
| 2979 |
-
|
| 2980 |
-
|
| 2981 |
-
|
| 2982 |
-
|
| 2983 |
-
|
| 2984 |
-
|
| 2985 |
-
|
| 2986 |
-
|
| 2987 |
-
|
| 2988 |
-
|
| 2989 |
-
|
| 2990 |
-
|
| 2991 |
-
|
| 2992 |
-
|
| 2993 |
-
|
| 2994 |
-
|
| 2995 |
-
|
| 2996 |
-
|
| 2997 |
-
|
| 2998 |
-
|
| 2999 |
-
|
| 3000 |
-
|
| 3001 |
-
|
| 3002 |
-
|
| 3003 |
-
|
| 3004 |
-
|
| 3005 |
-
|
| 3006 |
-
|
| 3007 |
-
|
| 3008 |
-
|
| 3009 |
-
|
| 3010 |
-
|
| 3011 |
-
|
| 3012 |
-
|
| 3013 |
-
|
| 3014 |
-
|
| 3015 |
-
|
| 3016 |
-
|
| 3017 |
-
|
| 3018 |
-
|
| 3019 |
-
|
| 3020 |
-
|
| 3021 |
-
|
| 3022 |
-
|
| 3023 |
-
|
| 3024 |
-
|
| 3025 |
-
|
| 3026 |
-
|
| 3027 |
-
|
| 3028 |
-
|
| 3029 |
-
|
| 3030 |
-
|
| 3031 |
-
|
| 3032 |
-
|
| 3033 |
-
|
| 3034 |
-
|
| 3035 |
-
|
| 3036 |
-
|
| 3037 |
-
|
| 3038 |
-
|
| 3039 |
-
|
| 3040 |
-
|
| 3041 |
-
|
| 3042 |
-
|
| 3043 |
-
|
| 3044 |
-
|
| 3045 |
-
|
| 3046 |
-
|
| 3047 |
-
|
| 3048 |
-
|
| 3049 |
-
|
| 3050 |
-
|
| 3051 |
-
|
| 3052 |
-
|
| 3053 |
-
|
| 3054 |
-
|
| 3055 |
-
|
| 3056 |
-
|
| 3057 |
-
|
| 3058 |
-
|
| 3059 |
-
|
| 3060 |
-
|
| 3061 |
-
|
| 3062 |
-
|
| 3063 |
-
|
| 3064 |
-
|
| 3065 |
-
|
| 3066 |
-
|
| 3067 |
-
|
| 3068 |
-
|
| 3069 |
-
|
| 3070 |
-
|
| 3071 |
-
|
| 3072 |
-
|
| 3073 |
-
|
| 3074 |
-
|
| 3075 |
-
|
| 3076 |
-
|
| 3077 |
-
|
| 3078 |
-
|
| 3079 |
-
|
| 3080 |
-
|
| 3081 |
-
|
| 3082 |
-
|
| 3083 |
-
|
| 3084 |
-
|
| 3085 |
-
|
| 3086 |
-
|
| 3087 |
-
|
| 3088 |
-
|
| 3089 |
-
|
| 3090 |
-
|
| 3091 |
-
|
| 3092 |
-
|
| 3093 |
-
|
| 3094 |
-
|
| 3095 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3096 |
#################################################################################################
|
| 3097 |
|
| 3098 |
private function db_do($query) {
|
| 3099 |
-
|
| 3100 |
-
// $this->_LOG("Query: " . $query);
|
| 3101 |
Mage::log("Query: " . $query, null, $this->_logFile);
|
| 3102 |
-
|
| 3103 |
-
// $result = $this->this->db_do($query);//
|
| 3104 |
-
// $query=mysql_real_escape_string($query);
|
| 3105 |
-
|
| 3106 |
-
|
| 3107 |
-
|
| 3108 |
-
|
| 3109 |
-
|
| 3110 |
-
|
| 3111 |
|
| 3112 |
return $result;
|
| 3113 |
}
|
|
@@ -3124,217 +3531,237 @@ v*/
|
|
| 3124 |
}
|
| 3125 |
##################################################################################################
|
| 3126 |
function check_loaded_data($file, $table){
|
| 3127 |
-
|
| 3128 |
-
|
| 3129 |
-
|
| 3130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3131 |
return true;
|
| 3132 |
}else{
|
| 3133 |
return false;
|
| 3134 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3135 |
}
|
| 3136 |
-
|
| 3137 |
-
|
| 3138 |
-
|
| 3139 |
-
|
| 3140 |
-
|
| 3141 |
-
|
| 3142 |
-
|
| 3143 |
-
|
| 3144 |
-
|
| 3145 |
-
|
| 3146 |
-
|
| 3147 |
-
|
| 3148 |
-
$string = preg_replace("/".chr(226).chr(128).chr(153)."/",'′',$string);
|
| 3149 |
-
$string = preg_replace("/°/",'°',$string);
|
| 3150 |
-
$string = preg_replace("/±/",'±',$string);
|
| 3151 |
-
$string = preg_replace("/µ/",'µ',$string);
|
| 3152 |
-
$string = preg_replace("/²/",'²',$string);
|
| 3153 |
-
$string = preg_replace("/³/",'³',$string);
|
| 3154 |
-
$string = preg_replace('/\xe2\x80\x93/','-',$string);
|
| 3155 |
-
$string = preg_replace('/\xe2\x80\x99/','\'',$string);
|
| 3156 |
-
$string = preg_replace('/\xe2\x80\x9c/',' ',$string);
|
| 3157 |
-
$string = preg_replace('/\xe2\x80\x9d/',' ',$string);
|
| 3158 |
-
|
| 3159 |
-
return utf8_decode($string);
|
| 3160 |
-
|
| 3161 |
-
// return $string;
|
| 3162 |
-
}
|
| 3163 |
-
|
| 3164 |
-
#################################################################################################
|
| 3165 |
-
function dropHTMLentities($entity_type_id, $attribute_id){
|
| 3166 |
-
// product name for all web sites
|
| 3167 |
-
$result = $this->db_do("
|
| 3168 |
-
SELECT value, entity_id from catalog_product_entity_varchar where entity_type_id=".$entity_type_id."
|
| 3169 |
-
and attribute_id=".$attribute_id
|
| 3170 |
-
);
|
| 3171 |
-
while($row=mysql_fetch_array($result)){
|
| 3172 |
-
$value=$this->valid_char($row['value']);
|
| 3173 |
-
if($value!='' and $value!=$row['value']){
|
| 3174 |
-
$this->db_do("UPDATE catalog_product_entity_varchar set value='".mysql_real_escape_string($value)."' where entity_id=".$row['entity_id']." and entity_type_id=".$entity_type_id." and attribute_id=".$attribute_id);
|
| 3175 |
-
}
|
| 3176 |
-
|
| 3177 |
-
}
|
| 3178 |
-
}
|
| 3179 |
-
|
| 3180 |
-
#################################################################################################
|
| 3181 |
-
|
| 3182 |
-
function valid_char($string){
|
| 3183 |
-
$string = preg_replace('/™/', ' ',$string);
|
| 3184 |
-
$string = preg_replace('/®/', ' ',$string);
|
| 3185 |
-
$string = preg_replace('/≈/', ' ',$string);
|
| 3186 |
-
$string = preg_replace('/"/', ' ',$string);
|
| 3187 |
-
$string = preg_replace('/′/', ' ',$string);
|
| 3188 |
-
$string = preg_replace('/°/', ' ',$string);
|
| 3189 |
-
$string = preg_replace('/±/', ' ',$string);
|
| 3190 |
-
$string = preg_replace('/µ/', ' ',$string);
|
| 3191 |
-
$string = preg_replace('/²/', ' ',$string);
|
| 3192 |
-
$string = preg_replace('/³/', ' ',$string);
|
| 3193 |
-
// $string = preg_replace('/\xe2\x80\x93/','-',$string);
|
| 3194 |
-
// $string = preg_replace('/\xe2\x80\x99/','\'',$string);
|
| 3195 |
-
// $string = preg_replace('/\xe2\x80\x9c/',' ',$string);
|
| 3196 |
-
// $string = preg_replace('/\xe2\x80\x9d/',' ',$string);
|
| 3197 |
-
|
| 3198 |
-
// return utf8_decode($string);
|
| 3199 |
-
|
| 3200 |
-
return $string;
|
| 3201 |
-
}
|
| 3202 |
-
|
| 3203 |
-
#################################################################################################
|
| 3204 |
-
|
| 3205 |
-
function _LOG($log){
|
| 3206 |
-
|
| 3207 |
-
if($log){
|
| 3208 |
-
// $q="insert into ".$this->import_log_table." (message_date, message) values(now(), '".$log."')";
|
| 3209 |
-
// $this->db_do($q);
|
| 3210 |
-
Mage::log($log, null, $this->_logFile);
|
| 3211 |
-
// list($usec, $sec) = explode(" ", microtime());
|
| 3212 |
-
// $time = ((float)$usec + (float)$sec);
|
| 3213 |
-
/* $time = date("D M j G:i:s T Y");
|
| 3214 |
-
|
| 3215 |
-
if($_SERVER['REMOTE_ADDR']){
|
| 3216 |
-
$log = "[".getmypid()."] "."[".$_SERVER['REMOTE_ADDR']."] "."[".$time."] ".$log."\n";
|
| 3217 |
-
error_log($log,3,LOG_FILE);
|
| 3218 |
-
}else{
|
| 3219 |
-
$log = "[".getmypid()."] "."[".$time."] ".$log."\n";
|
| 3220 |
-
error_log($log,3,LOG_FILE . ".cli");
|
| 3221 |
-
*/
|
| 3222 |
-
}
|
| 3223 |
-
}
|
| 3224 |
-
|
| 3225 |
-
#################################################################################################
|
| 3226 |
-
|
| 3227 |
-
function wget(){
|
| 3228 |
-
|
| 3229 |
-
$got = func_num_args();
|
| 3230 |
-
$url = $file = $flag = false;
|
| 3231 |
-
|
| 3232 |
-
if($got<1){
|
| 3233 |
-
return false;
|
| 3234 |
-
}elseif($got == 1){
|
| 3235 |
-
$url = func_get_arg(0);
|
| 3236 |
-
}elseif($got == 2){
|
| 3237 |
-
$url = func_get_arg(0);
|
| 3238 |
-
$file= func_get_arg(1);
|
| 3239 |
-
}elseif($got == 3){
|
| 3240 |
-
$url = func_get_arg(0);
|
| 3241 |
-
$file= func_get_arg(1);
|
| 3242 |
-
$flag= func_get_arg(2);
|
| 3243 |
-
}
|
| 3244 |
-
|
| 3245 |
-
if($flag == 'copy'){
|
| 3246 |
-
if(copy($url,$file)){
|
| 3247 |
-
return true;
|
| 3248 |
-
}else{
|
| 3249 |
-
return false;
|
| 3250 |
-
}
|
| 3251 |
-
}elseif($flag == 'system'){
|
| 3252 |
-
exec("wget -O$file $url");
|
| 3253 |
-
return true;
|
| 3254 |
-
}else{
|
| 3255 |
-
$c=curl_init($url);
|
| 3256 |
-
curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
|
| 3257 |
-
curl_setopt($c,CURLOPT_FOLLOWLOCATION,1);
|
| 3258 |
-
curl_setopt($c,CURLOPT_HEADER,array("Accept-Encoding: gzip"));
|
| 3259 |
-
if(!$file){
|
| 3260 |
-
$page = curl_exec($c);
|
| 3261 |
-
curl_close($c);
|
| 3262 |
-
return $page;
|
| 3263 |
-
}else{
|
| 3264 |
-
$FH = fopen($file,"wb");// or echo"Can't open for writing ".$file;
|
| 3265 |
-
fwrite($FH,curl_exec($c));
|
| 3266 |
-
fclose($FH);
|
| 3267 |
-
curl_close($c);
|
| 3268 |
-
return true;
|
| 3269 |
-
}
|
| 3270 |
-
}
|
| 3271 |
-
}
|
| 3272 |
-
#################################################################################################
|
| 3273 |
-
/**
|
| 3274 |
-
* Create the import directory Hierarchy
|
| 3275 |
-
* @return false if directory already exists
|
| 3276 |
-
*/
|
| 3277 |
-
public function createTemporaryImportDerictory(){
|
| 3278 |
-
$dirArray = explode('/', $this->varDir);
|
| 3279 |
-
end($dirArray);
|
| 3280 |
-
// $this->_LOG('before :'.$this->varDir);
|
| 3281 |
-
if (prev($dirArray)=='bintime'){
|
| 3282 |
-
return false;
|
| 3283 |
-
}
|
| 3284 |
|
| 3285 |
|
| 3286 |
-
|
| 3287 |
-
|
| 3288 |
-
|
| 3289 |
-
}
|
| 3290 |
-
// $this->_LOG('after :'.$this->varDir);
|
| 3291 |
}
|
|
|
|
|
|
|
| 3292 |
#################################################################################################
|
| 3293 |
|
| 3294 |
-
|
| 3295 |
|
| 3296 |
-
$q="
|
|
|
|
|
|
|
| 3297 |
$quer=$this->db_do($q);
|
| 3298 |
$count=0;
|
| 3299 |
while ($row=mysql_fetch_array($quer)){
|
| 3300 |
-
|
| 3301 |
-
|
| 3302 |
}
|
| 3303 |
return ($count);
|
| 3304 |
-
|
| 3305 |
#################################################################################################
|
| 3306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3307 |
|
| 3308 |
-
|
| 3309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3310 |
|
| 3311 |
-
|
| 3312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3313 |
|
| 3314 |
-
|
| 3315 |
-
$this->db_do($q);
|
| 3316 |
-
|
| 3317 |
-
}
|
| 3318 |
#################################################################################################
|
| 3319 |
|
| 3320 |
-
|
| 3321 |
-
/* $q="select path from ".TABLE_CATEGORY_ENTITY." where entity_id=".$parent_id;
|
| 3322 |
-
$quer=$this->db_do($q);
|
| 3323 |
-
$row=mysql_fetch_array($quer);
|
| 3324 |
-
if($row['path']){
|
| 3325 |
-
return($row['path'].'/'.$ent_id);
|
| 3326 |
-
}else{
|
| 3327 |
-
return($ent_id);
|
| 3328 |
-
}
|
| 3329 |
-
*/
|
| 3330 |
$path='';
|
| 3331 |
$cat_id=$parent_id;
|
| 3332 |
-
$q="
|
|
|
|
|
|
|
|
|
|
| 3333 |
$quer=$this->db_do($q);
|
| 3334 |
$row=mysql_fetch_array($quer);
|
| 3335 |
while($row['parent_id']){
|
| 3336 |
$path=$row['parent_id'].'/'.$path;
|
| 3337 |
-
$q="
|
|
|
|
|
|
|
|
|
|
| 3338 |
$quer=$this->db_do($q);
|
| 3339 |
$row=mysql_fetch_array($quer);
|
| 3340 |
|
|
@@ -3349,236 +3776,834 @@ v*/
|
|
| 3349 |
return($ent_id);
|
| 3350 |
}
|
| 3351 |
|
| 3352 |
-
|
| 3353 |
#################################################################################################
|
| 3354 |
|
| 3355 |
-
|
| 3356 |
-
|
| 3357 |
-
|
| 3358 |
-
|
| 3359 |
-
|
|
|
|
|
|
|
| 3360 |
while ($row['parent_store_category_id']!=0){
|
| 3361 |
-
|
| 3362 |
-
|
| 3363 |
-
|
| 3364 |
-
|
| 3365 |
-
|
| 3366 |
-
|
| 3367 |
-
|
|
|
|
|
|
|
| 3368 |
}
|
| 3369 |
|
| 3370 |
-
|
| 3371 |
-
|
| 3372 |
#################################################################################################
|
| 3373 |
|
| 3374 |
-
|
| 3375 |
-
|
| 3376 |
-
|
| 3377 |
-
|
| 3378 |
-
|
| 3379 |
-
|
| 3380 |
-
|
| 3381 |
-
|
| 3382 |
-
|
| 3383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3384 |
|
| 3385 |
-
|
| 3386 |
-
|
| 3387 |
-
|
| 3388 |
-
|
|
|
|
|
|
|
| 3389 |
|
| 3390 |
-
|
| 3391 |
#################################################################################################
|
| 3392 |
-
|
| 3393 |
-
|
| 3394 |
-
|
| 3395 |
-
|
| 3396 |
-
|
| 3397 |
-
|
| 3398 |
-
|
| 3399 |
-
|
| 3400 |
-
|
| 3401 |
-
|
| 3402 |
-
|
| 3403 |
-
|
| 3404 |
-
|
| 3405 |
-
$
|
| 3406 |
-
$
|
| 3407 |
-
$
|
| 3408 |
-
|
| 3409 |
-
|
| 3410 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3411 |
}
|
|
|
|
| 3412 |
}
|
| 3413 |
-
return $StatusHistory_arr;
|
| 3414 |
-
}
|
| 3415 |
#################################################################################################
|
| 3416 |
-
|
| 3417 |
-
|
| 3418 |
-
|
| 3419 |
-
|
| 3420 |
-
|
|
|
|
|
|
|
|
|
|
| 3421 |
#################################################################################################
|
| 3422 |
-
|
| 3423 |
-
|
| 3424 |
-
|
| 3425 |
-
|
| 3426 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3427 |
|
| 3428 |
#################################################################################################
|
| 3429 |
-
|
| 3430 |
-
|
| 3431 |
-
|
| 3432 |
-
|
| 3433 |
-
|
| 3434 |
-
|
| 3435 |
-
|
| 3436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3437 |
#################################################################################################
|
| 3438 |
|
| 3439 |
-
function
|
| 3440 |
-
|
| 3441 |
-
|
| 3442 |
-
|
| 3443 |
-
|
| 3444 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3445 |
}
|
| 3446 |
-
|
| 3447 |
-
|
| 3448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3449 |
}
|
| 3450 |
-
return $messages;
|
| 3451 |
-
}
|
| 3452 |
-
#################################################################################################
|
| 3453 |
-
|
| 3454 |
-
private function _getEntityTypeId($code) {
|
| 3455 |
-
$sql = "
|
| 3456 |
-
SELECT entity_type_id
|
| 3457 |
-
FROM eav_entity_type
|
| 3458 |
-
WHERE entity_type_code = '".$code."'
|
| 3459 |
-
LIMIT 1
|
| 3460 |
-
";
|
| 3461 |
-
$result = $this->db_do($sql);
|
| 3462 |
-
if ($row = mysql_fetch_assoc($result)) {
|
| 3463 |
-
return $row['entity_type_id'];
|
| 3464 |
-
}
|
| 3465 |
-
return false;
|
| 3466 |
-
}
|
| 3467 |
-
#################################################################################################
|
| 3468 |
-
|
| 3469 |
-
private function _getProductEntityTypeId(){
|
| 3470 |
-
if (!$this->_productEntityTypeId) {
|
| 3471 |
-
$this->_productEntityTypeId = $this->_getEntityTypeId('catalog_product');
|
| 3472 |
-
}
|
| 3473 |
-
return $this->_productEntityTypeId;
|
| 3474 |
-
}
|
| 3475 |
#################################################################################
|
| 3476 |
|
| 3477 |
-
|
| 3478 |
-
|
| 3479 |
-
|
| 3480 |
-
|
| 3481 |
-
|
| 3482 |
-
|
| 3483 |
-
|
| 3484 |
-
|
| 3485 |
-
|
| 3486 |
-
|
| 3487 |
|
| 3488 |
$this->defaultAttributeSetId = $row['default_attribute_set_id'];
|
| 3489 |
-
|
| 3490 |
-
|
| 3491 |
-
|
| 3492 |
-
|
| 3493 |
-
#################################################################################################
|
| 3494 |
-
|
| 3495 |
-
|
| 3496 |
-
|
| 3497 |
-
|
| 3498 |
-
|
| 3499 |
-
|
| 3500 |
-
|
| 3501 |
-
|
| 3502 |
-
|
| 3503 |
-
|
| 3504 |
-
|
| 3505 |
-
|
| 3506 |
-
|
| 3507 |
-
|
| 3508 |
-
|
| 3509 |
-
|
| 3510 |
-
|
| 3511 |
##################################################################################################
|
| 3512 |
|
| 3513 |
-
|
| 3514 |
-
|
| 3515 |
if ($typeCode=='catalog_product') {
|
| 3516 |
-
|
| 3517 |
}
|
| 3518 |
else {
|
| 3519 |
-
|
| 3520 |
-
}
|
| 3521 |
-
|
| 3522 |
-
|
| 3523 |
-
|
| 3524 |
-
|
| 3525 |
-
|
| 3526 |
-
|
| 3527 |
-
|
| 3528 |
-
|
| 3529 |
-
|
| 3530 |
-
|
| 3531 |
-
|
| 3532 |
-
|
| 3533 |
-
|
| 3534 |
-
|
| 3535 |
##################################################################################################
|
| 3536 |
|
| 3537 |
-
|
| 3538 |
-
|
| 3539 |
-
|
| 3540 |
-
|
| 3541 |
-
|
| 3542 |
-
|
| 3543 |
-
|
| 3544 |
-
|
| 3545 |
-
|
| 3546 |
-
|
| 3547 |
-
|
| 3548 |
##################################################################################################
|
| 3549 |
|
| 3550 |
-
|
| 3551 |
-
|
| 3552 |
-
|
| 3553 |
##################################################################################################
|
| 3554 |
|
| 3555 |
-
|
| 3556 |
-
|
| 3557 |
-
|
| 3558 |
##################################################################################################
|
| 3559 |
-
|
| 3560 |
-
|
| 3561 |
-
|
| 3562 |
-
|
| 3563 |
-
|
| 3564 |
-
|
| 3565 |
-
|
| 3566 |
-
|
| 3567 |
-
|
| 3568 |
-
|
| 3569 |
-
|
| 3570 |
-
|
| 3571 |
-
|
| 3572 |
-
|
| 3573 |
-
|
| 3574 |
-
|
| 3575 |
-
|
| 3576 |
-
|
| 3577 |
-
|
| 3578 |
-
|
| 3579 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3580 |
##################################################################################################
|
| 3581 |
|
| 3582 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3583 |
|
| 3584 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
ini_set('memory_limit','256M');
|
| 4 |
+
$dir = Mage::getBaseDir('code')."/local/Bintime/Sinchimport/Model";//dirname(__FILE__);
|
| 5 |
require_once ($dir.'/config.php');
|
| 6 |
|
| 7 |
class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
| 8 |
+
var
|
| 9 |
+
$connection,
|
| 10 |
+
$varDir,
|
| 11 |
+
$shellDir,
|
| 12 |
+
$files,
|
| 13 |
+
$attributes,
|
| 14 |
+
$db,
|
| 15 |
+
$lang_id,
|
| 16 |
+
$debug_mode=1;
|
| 17 |
+
private $productDescriptionList = array();
|
| 18 |
+
private $specifications;
|
| 19 |
+
private $productDescription;
|
| 20 |
+
private $fullProductDescription;
|
| 21 |
+
private $lowPicUrl;
|
| 22 |
+
private $highPicUrl;
|
| 23 |
+
private $errorMessage;
|
| 24 |
+
private $galleryPhotos = array();
|
| 25 |
+
private $productName;
|
| 26 |
+
private $relatedProducts = array();
|
| 27 |
+
private $errorSystemMessage; //depricated
|
| 28 |
+
private $sinchProductId;
|
| 29 |
+
private $_productEntityTypeId = 0;
|
| 30 |
+
private $defaultAttributeSetId = 0;
|
| 31 |
+
private $field_terminated_char;
|
| 32 |
+
private $import_status_table;
|
| 33 |
+
private $import_status_statistic_table;
|
| 34 |
+
private $current_import_status_statistic_id;
|
| 35 |
+
private $import_log_table;
|
| 36 |
+
private $_attributeId;
|
| 37 |
+
private $_categoryEntityTypeId;
|
| 38 |
+
private $_categoryDefault_attribute_set_id;
|
| 39 |
private $_root_cat;
|
| 40 |
+
private $import_run_type = 'MANUAL';
|
| 41 |
private $_ignore_category_features = false;
|
| 42 |
private $_ignore_product_features = false;
|
| 43 |
private $_ignore_product_related = false;
|
| 44 |
private $_ignore_restricted_values = false;
|
| 45 |
+
public $php_run_string;
|
| 46 |
public $price_breaks_filter;
|
| 47 |
|
| 48 |
#################################################################################################
|
| 49 |
|
| 50 |
+
function __construct(){
|
| 51 |
|
| 52 |
+
$this->import_status_table=Mage::getSingleton('core/resource')->getTableName('stINch_import_status');
|
| 53 |
+
$this->import_status_statistic_table=Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic');
|
| 54 |
$this->import_log_table="stINch_import_log";
|
| 55 |
+
|
| 56 |
+
$this->php_run_string=PHP_RUN_STRING;
|
| 57 |
$this->price_breaks_filter=PRICE_BREAKS;
|
| 58 |
+
/*$this->db_connect();
|
| 59 |
+
$res = $this->db_do("select languages_id from languages where code='".LANG_CODE."'");
|
| 60 |
+
$row = mysql_fetch_assoc($res);
|
| 61 |
+
$this->lang_id = $row['languages_id'];
|
| 62 |
+
*/
|
| 63 |
+
$this->varDir = TEMPORARY_DIRECTORY_FOR_STORING_FILES;
|
| 64 |
$this->shellDir = SHELL_DIRECTORY_FOR_INDEXER;
|
| 65 |
+
$this->connection=$this->db_connect();
|
| 66 |
+
$this->createTemporaryImportDerictory();
|
| 67 |
+
$this->_logFile="Sinch.log";
|
| 68 |
+
$this->_LOG("constructor");
|
| 69 |
+
$this->files=array(
|
| 70 |
+
FILE_CATEGORIES,
|
| 71 |
+
FILE_CATEGORIES_FEATURES,
|
| 72 |
+
FILE_DISTRIBUTORS,
|
| 73 |
+
FILE_EANCODES,
|
| 74 |
+
FILE_MANUFACTURERS,
|
| 75 |
+
FILE_PRODUCT_FEATURES,
|
| 76 |
+
FILE_PRODUCTS,
|
| 77 |
+
FILE_RELATED_PRODUCTS,
|
| 78 |
+
FILE_RESTRICTED_VALUES,
|
| 79 |
+
FILE_STOCK_AND_PRICES,
|
| 80 |
+
FILE_PRODUCTS_PICTURES_GALLERY
|
| 81 |
+
);
|
| 82 |
+
$this->attributes['manufacturer']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('manufacturer')->getFirstItem()->getId();
|
| 83 |
+
$this->attributes['name']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('name')->getFirstItem()->getId();
|
| 84 |
+
$this->attributes['is_active']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('is_active')->getFirstItem()->getId();
|
| 85 |
+
$this->attributes['include_in_menu']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('include_in_menu')->getFirstItem()->getId();
|
| 86 |
+
$this->attributes['url_key']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('url_key')->getFirstItem()->getId();
|
| 87 |
+
$this->attributes['display_mode']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('display_mode')->getFirstItem()->getId();
|
| 88 |
+
$this->attributes['status']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('status')->getFirstItem()->getId();
|
| 89 |
+
$this->attributes['visibility']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('visibility')->getFirstItem()->getId();
|
| 90 |
+
$this->attributes['price']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('price')->getFirstItem()->getId();
|
| 91 |
+
$this->attributes['cost']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('cost')->getFirstItem()->getId();
|
| 92 |
+
$this->attributes['weight']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('weight')->getFirstItem()->getId();
|
| 93 |
+
$this->attributes['tax_class_id']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('tax_class_id')->getFirstItem()->getId();
|
| 94 |
+
|
| 95 |
+
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
| 96 |
+
// if($dataConf['field_terminated_char']){
|
| 97 |
+
// $this->field_terminated_char=$dataConf['field_terminated_char'];
|
| 98 |
+
// }else{
|
| 99 |
$this->field_terminated_char=DEFAULT_FILE_TERMINATED_CHAR;
|
| 100 |
+
// }
|
| 101 |
+
// $attributeOptions = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('manufacturer')->getFirstItem()->getSource()->getAllOptions(false);
|
| 102 |
+
// echo "<pre>"; print_r($attributeOptions); echo "</pre>";
|
| 103 |
+
}
|
| 104 |
|
| 105 |
#################################################################################################
|
| 106 |
function cron_start_import(){
|
| 107 |
$this->_LOG("Start import from cron");
|
| 108 |
+
$start_hr=Mage::getStoreConfig('sinchimport_root/sinch_cron/sinch_cron_time');
|
| 109 |
+
$now_hr=date('H');
|
| 110 |
+
$this->_LOG("Now $now_hr hr, scheduler time is $start_hr hr");
|
| 111 |
|
| 112 |
+
if($start_hr==$now_hr){
|
| 113 |
+
$this->run_sinch_import();
|
| 114 |
+
}else{
|
| 115 |
+
$this->_LOG(" it's NOT time for SINCH ");
|
| 116 |
+
}
|
| 117 |
|
| 118 |
$this->_LOG("Finish import from cron");
|
| 119 |
+
|
| 120 |
}
|
| 121 |
################################################################################################
|
| 122 |
function cron_start_full_import(){
|
| 123 |
+
$this->import_run_type='CRON';
|
| 124 |
+
$this->run_sinch_import();
|
| 125 |
+
}
|
| 126 |
################################################################################################
|
| 127 |
function cron_start_stock_price_import(){
|
| 128 |
+
$this->import_run_type='CRON';
|
| 129 |
+
$this->run_stock_price_sinch_import();
|
| 130 |
+
}
|
| 131 |
#################################################################################################
|
| 132 |
function is_imort_not_run(){
|
| 133 |
$q="SELECT IS_FREE_LOCK('sinchimport') as getlock";
|
| 137 |
}
|
| 138 |
#################################################################################################
|
| 139 |
function check_store_procedure_exist(){
|
| 140 |
+
$dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
|
| 141 |
+
$q='SHOW PROCEDURE STATUS LIKE "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'"';
|
| 142 |
$quer=$this->db_do($q);
|
| 143 |
+
$result=false;
|
| 144 |
+
While($row=mysql_fetch_array($quer)){
|
| 145 |
+
if(($row['Name']==Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s')) && ($row['Db']==$dbConf->dbname)){
|
| 146 |
+
$result = true;
|
| 147 |
+
}
|
| 148 |
}
|
| 149 |
+
return $result;
|
| 150 |
+
}
|
| 151 |
#################################################################################################
|
| 152 |
function check_db_privileges(){
|
| 153 |
+
$q='SHOW PRIVILEGES';
|
| 154 |
$quer=$this->db_do($q);
|
| 155 |
while($row=mysql_fetch_array($quer)){
|
| 156 |
if($row['Privilege']=='File' && $row['Context']=='File access on server'){
|
| 161 |
}
|
| 162 |
#################################################################################################
|
| 163 |
function check_local_infile(){
|
| 164 |
+
$q='SHOW VARIABLES LIKE "local_infile"';
|
| 165 |
$quer=$this->db_do($q);
|
| 166 |
$row=mysql_fetch_array($quer);
|
| 167 |
if($row['Variable_name']=='local_infile' && $row['Value']=="ON"){
|
| 172 |
}
|
| 173 |
#################################################################################################
|
| 174 |
function is_full_import_have_been_run(){
|
| 175 |
+
$q="SELECT COUNT(*) AS cnt
|
| 176 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic')."
|
| 177 |
+
WHERE import_type='FULL' AND global_status_import='Successful'";
|
| 178 |
$quer=$this->db_do($q);
|
| 179 |
$row=mysql_fetch_array($quer);
|
| 180 |
+
if($row['cnt']>0){
|
| 181 |
+
return true;
|
| 182 |
+
}else{
|
| 183 |
+
return false;
|
| 184 |
+
}
|
| 185 |
}
|
| 186 |
#################################################################################################
|
| 187 |
function run_sinch_import(){
|
| 196 |
$store_proc=$this->check_store_procedure_exist();
|
| 197 |
|
| 198 |
if(!$store_proc){
|
| 199 |
+
$this->_LOG('store prcedure "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'" is absent in this database. import stoped.');
|
| 200 |
+
$this->set_import_error_reporting_message('Stored procedure "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'" is absent in this database. Import stopped.');
|
| 201 |
exit;
|
| 202 |
}
|
| 203 |
|
| 206 |
if(!$file_privileg){
|
| 207 |
$this->_LOG("Loaddata option not set - please check the documentation on how to fix this. You dan't have privileges for LOAD DATA.");
|
| 208 |
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
| 209 |
+
exit;
|
| 210 |
}
|
| 211 |
$local_infile=$this->check_local_infile();
|
| 212 |
if(!$local_infile){
|
| 216 |
}
|
| 217 |
|
| 218 |
if($this->is_imort_not_run()){
|
| 219 |
+
try{
|
| 220 |
+
//$this->InitImportStatuses();
|
| 221 |
+
$q="SELECT GET_LOCK('sinchimport', 30)";
|
| 222 |
+
$quer=$this->db_do($q);
|
| 223 |
+
$import=$this;
|
| 224 |
+
$import->addImportStatus('Start Import');
|
| 225 |
+
echo "Upload Files <br>";
|
| 226 |
+
$import->UploadFiles();
|
| 227 |
+
$import->addImportStatus('Upload Files');
|
| 228 |
+
|
| 229 |
+
echo "Parse Categories <br>";
|
| 230 |
+
$import->ParseCategories();
|
| 231 |
+
$import->addImportStatus('Parse Categories');
|
| 232 |
+
|
| 233 |
+
echo "Parse Category Features <br>";
|
| 234 |
+
$import->ParseCategoryFeatures();
|
| 235 |
+
$import->addImportStatus('Parse Category Features');
|
| 236 |
+
|
| 237 |
+
echo "Parse Distributors <br>";
|
| 238 |
+
$import->ParseDistributors();
|
| 239 |
+
$import->addImportStatus('Parse Distributors');
|
| 240 |
+
|
| 241 |
+
echo "Parse EAN Codes <br>";
|
| 242 |
+
$import->ParseEANCodes();
|
| 243 |
+
$import->addImportStatus('Parse EAN Codes');
|
| 244 |
+
|
| 245 |
+
echo "Parse Manufacturers <br>";
|
| 246 |
+
$import->ParseManufacturers();
|
| 247 |
+
$import->addImportStatus('Parse Manufacturers');
|
| 248 |
+
|
| 249 |
+
echo "Parse Related Products <br>";
|
| 250 |
+
$import->ParseRelatedProducts();
|
| 251 |
+
$import->addImportStatus('Parse Related Products');
|
| 252 |
+
|
| 253 |
+
echo "Parse Product Features <br>";
|
| 254 |
+
$import->ParseProductFeatures();
|
| 255 |
+
$import->addImportStatus('Parse Product Features');
|
| 256 |
+
|
| 257 |
+
echo "Parse Products <br>";
|
| 258 |
+
$import->ParseProducts();
|
| 259 |
+
$import->addImportStatus('Parse Products');
|
| 260 |
+
|
| 261 |
+
echo "Parse Pictures Gallery";
|
| 262 |
+
$import->ParseProductsPicturesGallery();
|
| 263 |
+
$import->addImportStatus('Parse Pictures Gallery');
|
| 264 |
+
|
| 265 |
+
echo "Parse Restricted Values <br>";
|
| 266 |
+
$import->ParseRestrictedValues();
|
| 267 |
+
$import->addImportStatus('Parse Restricted Values');
|
| 268 |
+
|
| 269 |
+
echo "Parse Stock And Prices <br>";
|
| 270 |
+
$import->ParseStockAndPrices();
|
| 271 |
+
$import->addImportStatus('Parse Stock And Prices');
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
Mage::log("Finish Sinch import", null, $this->_logFile);
|
| 275 |
+
echo "Finish Sinch import<br>";
|
| 276 |
+
|
| 277 |
+
Mage::log("Start cleanin Sinch cache<br>", null, $this->_logFile);
|
| 278 |
+
echo "Start cleanin Sinch cache<br>";
|
| 279 |
+
Mage::app()->getCacheInstance()->cleanType('block_html');
|
| 280 |
+
/*
|
| 281 |
+
$indexProcess = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
|
| 282 |
+
if ($indexProcess) {
|
| 283 |
+
$indexProcess->reindexAll();
|
| 284 |
+
}
|
| 285 |
+
*/
|
| 286 |
+
|
| 287 |
+
Mage::log("Start indexing Sinch features for filters", null, $this->_logFile);
|
| 288 |
+
echo "Start indexing Sinch features for filters<br>";
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
$resource = Mage::getResourceModel('sinchimport/layer_filter_feature');
|
| 292 |
+
$resource->splitProductsFeature(null);
|
| 293 |
+
|
| 294 |
+
Mage::log("Finish indexing Sinch features for filters", null, $this->_logFile);
|
| 295 |
+
$import->addImportStatus('Generate category filters');
|
| 296 |
+
echo "Finish indexing Sinch features for filters<br>";
|
| 297 |
+
|
| 298 |
+
Mage::log("Start indexing data", null, $this->_logFile);
|
| 299 |
+
echo "Start indexing data";
|
| 300 |
+
$import->_cleanCateoryProductFlatTable();
|
| 301 |
+
$import->runIndexer();
|
| 302 |
+
Mage::log("Finish indexing data", null, $this->_logFile);
|
| 303 |
+
$import->addImportStatus('Indexing data', 1);
|
| 304 |
+
echo "Finish indexing data";
|
| 305 |
+
|
| 306 |
+
$q="SELECT RELEASE_LOCK('sinchimport')";
|
| 307 |
+
$quer=$this->db_do($q);
|
| 308 |
+
}catch (Exception $e) {
|
|
|
|
| 309 |
$this->set_import_error_reporting_message($e);
|
| 310 |
+
}
|
| 311 |
}
|
| 312 |
else{
|
| 313 |
Mage::log("Sinchimport already run", null, $this->_logFile);
|
| 322 |
|
| 323 |
$this->InitImportStatuses('PRICE STOCK');
|
| 324 |
if($safe_mode_set ){
|
| 325 |
+
$this->_LOG('safe_mode is enable. import stoped.');
|
| 326 |
$this->set_import_error_reporting_message('Safe_mode is enabled. Please check the documentation on how to fix this. Import stopped.');
|
| 327 |
exit;
|
| 328 |
}
|
| 329 |
$store_proc=$this->check_store_procedure_exist();
|
| 330 |
|
| 331 |
if(!$store_proc){
|
| 332 |
+
$this->_LOG('store prcedure "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'" is absent in this database. import stoped.');
|
| 333 |
+
$this->set_import_error_reporting_message('Stored procedure "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'" is absent in this database. Import stopped.');
|
| 334 |
+
exit;
|
| 335 |
}
|
| 336 |
|
| 337 |
$file_privileg=$this->check_db_privileges();
|
| 339 |
if(!$file_privileg){
|
| 340 |
$this->_LOG("Loaddata option not set - please check the documentation on how to fix this. You dan't have privileges for LOAD DATA.");
|
| 341 |
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
| 342 |
+
exit;
|
| 343 |
}
|
| 344 |
$local_infile=$this->check_local_infile();
|
| 345 |
if(!$local_infile){
|
| 349 |
}
|
| 350 |
|
| 351 |
if($this->is_imort_not_run() && $this->is_full_import_have_been_run()){
|
| 352 |
+
try{
|
| 353 |
+
//$this->InitImportStatuses();
|
| 354 |
+
$q="SELECT GET_LOCK('sinchimport', 30)";
|
| 355 |
+
$quer=$this->db_do($q);
|
| 356 |
+
$import=$this;
|
| 357 |
+
$import->addImportStatus('Stock Price Start Import');
|
| 358 |
+
echo "Upload Files <br>";
|
| 359 |
+
$this->files=array(
|
| 360 |
+
FILE_STOCK_AND_PRICES
|
| 361 |
+
);
|
| 362 |
+
|
| 363 |
+
$import->UploadFiles();
|
| 364 |
+
$import->addImportStatus('Stock Price Upload Files');
|
| 365 |
+
|
| 366 |
+
echo "Parse Stock And Prices <br>";
|
| 367 |
+
//exit;
|
| 368 |
+
$import->ParseStockAndPrices();
|
| 369 |
+
$import->addImportStatus('Stock Price Parse Products');
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
Mage::log("Finish Stock & Price Sinch import", null, $this->_logFile);
|
| 373 |
+
echo "Finish Stock & Price Sinch import<br>";
|
| 374 |
+
|
| 375 |
+
Mage::log("Start indexing Stock & Price", null, $this->_logFile);
|
| 376 |
+
echo "Start indexing Stock & Price<br>";
|
| 377 |
+
$import->_cleanCateoryProductFlatTable();
|
| 378 |
+
$import->runStockPriceIndexer();
|
| 379 |
+
Mage::log("Finish indexing Stock & Price", null, $this->_logFile);
|
| 380 |
+
$import->addImportStatus('Stock Price Indexing data');
|
| 381 |
+
$import->addImportStatus('Stock Price Finish import', 1);
|
| 382 |
+
echo "Finish indexing Stock & Price<br>";
|
| 383 |
+
|
| 384 |
+
$q="SELECT RELEASE_LOCK('sinchimport')";
|
| 385 |
+
$quer=$this->db_do($q);
|
| 386 |
+
}catch (Exception $e) {
|
| 387 |
$this->set_import_error_reporting_message($e);
|
| 388 |
+
}
|
| 389 |
}
|
| 390 |
else{
|
| 391 |
+
if(!$this->is_imort_not_run()){
|
| 392 |
+
Mage::log("Sinchimport already run", null, $this->_logFile);
|
| 393 |
+
echo "Sinchimport already run<br>";
|
| 394 |
+
}else{
|
| 395 |
+
Mage::log("Full import have never finished with success", null, $this->_logFile);
|
| 396 |
+
echo "Full import have never finished with success<br>";
|
| 397 |
+
}
|
| 398 |
}
|
| 399 |
|
| 400 |
+
}
|
| 401 |
#################################################################################################
|
| 402 |
|
| 403 |
|
| 404 |
+
function UploadFiles(){
|
| 405 |
|
| 406 |
+
$this->_LOG("Start upload files");
|
| 407 |
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
| 408 |
$login=$dataConf['login'];
|
| 409 |
$passw=$dataConf['password'];
|
| 410 |
//return;//stepan tes//stepan tes//stepan testtt
|
| 411 |
if(!$login || !$passw){
|
| 412 |
+
$this->_LOG('ftp login or password dosent defined');
|
| 413 |
+
$this->set_import_error_reporting_message('FTP login or password has not been defined. Import stopped.');
|
| 414 |
+
exit;
|
| 415 |
+
|
| 416 |
}
|
| 417 |
$file_url_and_dir=$this->repl_ph(FILE_URL_AND_DIR, array('login' => $login,
|
| 418 |
+
'password'=> $passw
|
| 419 |
+
)
|
| 420 |
+
);
|
| 421 |
+
foreach ($this->files as $file) {
|
| 422 |
+
$this->_LOG("Copy ".$file_url_and_dir.$file." to ".$this->varDir.$file);
|
| 423 |
+
if(strstr($file_url_and_dir, 'ftp://')){
|
| 424 |
preg_match("/ftp:\/\/(.*?):(.*?)@(.*?)(\/.*)/i", $file_url_and_dir, $match);
|
| 425 |
+
//var_dump($match);
|
| 426 |
+
if($conn = ftp_connect($match[3])){
|
| 427 |
+
if(!ftp_login($conn, $login, $passw))
|
| 428 |
+
{
|
| 429 |
+
$this->set_import_error_reporting_message('Incorrect username or password for the Stock In The Channel server. Import stopped.');
|
| 430 |
+
exit;
|
|
|
|
| 431 |
}
|
| 432 |
+
}
|
| 433 |
+
else{
|
| 434 |
+
$this->set_import_error_reporting_message('FTP connection failed. Unable to connect to the Stock In The Channel server');
|
| 435 |
+
exit;
|
| 436 |
+
}
|
| 437 |
+
if (!$this->wget ($file_url_and_dir.$file, $this->varDir.$file, 'system')){
|
| 438 |
+
$this->_LOG("wget Can't copy ".$file.", will use old one");
|
| 439 |
+
echo "copy Can't copy ".$file_url_and_dir.$file." to ".$this->varDir.$file.", will use old one<br>";
|
| 440 |
+
}
|
| 441 |
+
}
|
| 442 |
+
else{
|
| 443 |
+
if(!copy($file_url_and_dir.$file, $this->varDir.$file)){
|
| 444 |
+
$this->_LOG("copy Can't copy ".$file.", will use old one");
|
| 445 |
+
echo "copy Can't copy ".$file_url_and_dir.$file." to ".$this->varDir.$file." will use old one<br>";
|
| 446 |
}
|
| 447 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
exec("chmod a+rw ".$this->varDir.$file);
|
| 449 |
if(!filesize($this->varDir.$file)){
|
| 450 |
+
if($file!=FILE_CATEGORIES_FEATURES && $file!=FILE_PRODUCT_FEATURES && $file!=FILE_RELATED_PRODUCTS && $file!=FILE_RESTRICTED_VALUES){
|
| 451 |
+
$this->_LOG("Can't copy ".$file_url_and_dir.$file.". file $this->varDir.$file is emty");
|
| 452 |
+
$this->set_import_error_reporting_message("Can't copy ".$file_url_and_dir.$file.". file ".$this->varDir.$file." is emty");
|
| 453 |
+
$this->addImportStatus('Sinch import stoped. Impot file(s) empty', 1);
|
| 454 |
+
|
| 455 |
+
exit;
|
| 456 |
+
}else{
|
| 457 |
+
if($file==FILE_CATEGORIES_FEATURES){
|
| 458 |
+
$this->_LOG("Can't copy ".FILE_CATEGORIES_FEATURES." file ignored" );
|
| 459 |
+
$this->_ignore_category_features=true;
|
| 460 |
+
}elseif($file==FILE_PRODUCT_FEATURES){
|
| 461 |
+
$this->_LOG("Can't copy ".FILE_PRODUCT_FEATURES." file ignored" );
|
| 462 |
+
$this->_ignore_product_features=true;
|
| 463 |
+
}elseif($file==FILE_RELATED_PRODUCTS){
|
| 464 |
+
$this->_LOG("Can't copy ".FILE_RELATED_PRODUCTS." file ignored" );
|
| 465 |
+
$this->_ignore_product_related=true;
|
| 466 |
+
}elseif($file==FILE_RESTRICTED_VALUES){
|
| 467 |
+
$this->_LOG("Can't copy ".FILE_RESTRICTED_VALUES." file ignored" );
|
| 468 |
+
$this->_ignore_restricted_values=true;
|
| 469 |
+
}
|
| 470 |
+
}
|
| 471 |
+
}
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
$this->_LOG("Finish upload files");
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
#################################################################################################
|
| 478 |
+
|
| 479 |
+
function ParseCategories(){
|
| 480 |
|
| 481 |
+
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
| 482 |
+
$im_type = $dataConf['replace_category'];
|
| 483 |
+
$parse_file=$this->varDir.FILE_CATEGORIES;
|
| 484 |
+
if(filesize($parse_file)){
|
| 485 |
+
$this->_LOG("Start parse ".FILE_CATEGORIES);
|
| 486 |
+
$this->_getCategoryEntityTypeIdAndDefault_attribute_set_id();
|
| 487 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('categories_temp'));
|
| 488 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." (
|
| 489 |
+
store_category_id int(11),
|
| 490 |
+
parent_store_category_id int(11),
|
| 491 |
+
category_name varchar(50),
|
| 492 |
+
order_number int(11),
|
| 493 |
+
is_hidden boolean,
|
| 494 |
+
products_within_this_category int(11),
|
| 495 |
+
products_within_sub_categories int(11),
|
| 496 |
+
categories_image varchar(255),
|
| 497 |
+
children_count int(11) NOT NULL default 0,
|
| 498 |
+
level int(10) NOT NULL default 0,
|
| 499 |
+
KEY(store_category_id),
|
| 500 |
+
KEY(parent_store_category_id)
|
| 501 |
+
)
|
| 502 |
+
");
|
| 503 |
+
|
| 504 |
+
$res=$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 505 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
|
| 506 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."' OPTIONALLY ENCLOSED BY '\"'
|
| 507 |
+
LINES TERMINATED BY \"\r\n\" IGNORE 1 LINES ");
|
|
|
|
|
|
|
|
|
|
| 508 |
$inf=mysql_info();
|
| 509 |
+
$table =Mage::getSingleton('core/resource')->getTableName('categories_temp');
|
| 510 |
if(!$this->check_loaded_data($parse_file, $table)){
|
| 511 |
$this->set_import_error_reporting_message('The Stock In The Channel data files do not appear to be in the correct format. Check file'.$parse_file. "(LOAD DATA ... ".$inf.")");
|
| 512 |
exit;
|
| 513 |
}
|
| 514 |
+
if($im_type=="REWRITE"){
|
| 515 |
+
$root_cat=2;
|
| 516 |
+
$this->db_do('SET foreign_key_checks=0');
|
| 517 |
+
|
| 518 |
+
$this->db_do("TRUNCATE ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity'));
|
| 519 |
+
$this->db_do("INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
| 520 |
+
(entity_id,
|
| 521 |
+
entity_type_id,
|
| 522 |
+
attribute_set_id,
|
| 523 |
+
parent_id,
|
| 524 |
+
created_at,
|
| 525 |
+
updated_at,
|
| 526 |
+
path,
|
| 527 |
+
position,
|
| 528 |
+
level,
|
| 529 |
+
children_count,
|
| 530 |
+
store_category_id,
|
| 531 |
+
parent_store_category_id
|
| 532 |
+
)
|
| 533 |
+
VALUES
|
| 534 |
+
(1,".$this->_categoryEntityTypeId.",".$this->_categoryDefault_attribute_set_id.",0,'0000-00-00 00:00:00',now(),'1',0,0,1,null,null),
|
| 535 |
+
(2,".$this->_categoryEntityTypeId.",".$this->_categoryDefault_attribute_set_id.",1,now(),now(),'1/2',1,1,0,null,null)
|
| 536 |
+
");
|
| 537 |
+
|
| 538 |
+
$this->db_do("TRUNCATE ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar'));
|
| 539 |
+
$this->db_do("INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')."
|
| 540 |
+
(value_id,
|
| 541 |
+
entity_type_id,
|
| 542 |
+
attribute_id,
|
| 543 |
+
store_id,
|
| 544 |
+
entity_id,
|
| 545 |
+
value
|
| 546 |
+
)
|
| 547 |
+
VALUES
|
| 548 |
+
(1,".$this->_categoryEntityTypeId.",".$this->_getCategoryAttributeId('name').",0,1,'Root Catalog'),
|
| 549 |
+
(2,".$this->_categoryEntityTypeId.",".$this->_getCategoryAttributeId('name').",1,1,'Root Catalog'),
|
| 550 |
+
(3,".$this->_categoryEntityTypeId.",".$this->attributes['url_key'].",0,1,'root-catalog'),
|
| 551 |
+
(4,".$this->_categoryEntityTypeId.",".$this->_getCategoryAttributeId('name').",0,2,'Default Category'),
|
| 552 |
+
(5,".$this->_categoryEntityTypeId.",".$this->_getCategoryAttributeId('name').",1,2,'Default Category'),
|
| 553 |
+
(6,".$this->_categoryEntityTypeId.",".$this->attributes['display_mode'].",1,2,'PRODUCTS'),
|
| 554 |
+
(7,".$this->_categoryEntityTypeId.",".$this->attributes['url_key'].",0,2,'default-category')");
|
| 555 |
+
|
| 556 |
+
$this->db_do("TRUNCATE ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int'));
|
| 557 |
+
$this->db_do("INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')."
|
| 558 |
+
(value_id,
|
| 559 |
+
entity_type_id,
|
| 560 |
+
attribute_id,
|
| 561 |
+
store_id,
|
| 562 |
+
entity_id,
|
| 563 |
+
value
|
| 564 |
+
)
|
| 565 |
+
VALUES
|
| 566 |
+
(1,".$this->_categoryEntityTypeId.",".$this->attributes['is_active'].",0,2,1),
|
| 567 |
+
(2,".$this->_categoryEntityTypeId.",".$this->attributes['is_active'].",1,2,1),
|
| 568 |
+
(3,".$this->_categoryEntityTypeId.",".$this->attributes['include_in_menu'].",0,1,1),
|
| 569 |
+
(4,".$this->_categoryEntityTypeId.",".$this->attributes['include_in_menu'].",0,2,1)");
|
| 570 |
+
|
| 571 |
+
}else{
|
| 572 |
+
$root_cat=$this->_getShopRootCategoryId();
|
| 573 |
+
}
|
| 574 |
$this->_root_cat=$root_cat;
|
| 575 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
|
| 576 |
+
SET parent_store_category_id='".$root_cat."'
|
| 577 |
+
WHERE parent_store_category_id=0";
|
| 578 |
+
$this->db_do($q);
|
| 579 |
+
$this->_LOG("root cat : ".$this->_root_cat);
|
| 580 |
|
| 581 |
+
$q="SELECT store_category_id
|
| 582 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp');
|
| 583 |
+
$quer=$this->db_do($q);
|
| 584 |
+
while($row=mysql_fetch_array($quer)){
|
| 585 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
|
| 586 |
+
SET children_count=".$this->count_children($row['store_category_id']).",
|
| 587 |
+
level=".$this->get_category_level($row['store_category_id'])."
|
| 588 |
+
WHERE store_category_id=".$row['store_category_id']);
|
| 589 |
+
}
|
| 590 |
$this->mapSinchCategories();
|
| 591 |
+
if(UPDATE_CATEGORY_DATA){
|
| 592 |
+
echo "Update category_entity \n";
|
| 593 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." (
|
| 594 |
+
entity_type_id,
|
| 595 |
+
attribute_set_id,
|
| 596 |
+
created_at,
|
| 597 |
+
updated_at,
|
| 598 |
+
level,
|
| 599 |
+
children_count,
|
| 600 |
+
entity_id,
|
| 601 |
+
position,
|
| 602 |
+
parent_id,
|
| 603 |
+
store_category_id,
|
| 604 |
+
parent_store_category_id
|
| 605 |
+
)(SELECT
|
| 606 |
+
".$this->_categoryEntityTypeId.",
|
| 607 |
+
".$this->_categoryDefault_attribute_set_id.",
|
| 608 |
+
now(),
|
| 609 |
+
now(),
|
| 610 |
+
c.level,
|
| 611 |
+
c.children_count,
|
| 612 |
+
scm.shop_entity_id,
|
| 613 |
+
c.order_number,
|
| 614 |
+
scm.shop_parent_id,
|
| 615 |
+
c.store_category_id,
|
| 616 |
+
c.parent_store_category_id
|
| 617 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 618 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 619 |
+
ON c.store_category_id=scm.store_category_id
|
| 620 |
+
)
|
| 621 |
+
ON DUPLICATE KEY UPDATE
|
| 622 |
+
updated_at=now(),
|
| 623 |
+
store_category_id=c.store_category_id,
|
| 624 |
+
level=c.level,
|
| 625 |
+
children_count=c.children_count,
|
| 626 |
+
position=c.order_number,
|
| 627 |
+
parent_store_category_id=c.parent_store_category_id";
|
| 628 |
+
//level=c.level,
|
| 629 |
+
//children_count=c.children_count
|
| 630 |
+
//position=c.order_number,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
|
| 632 |
+
}else{
|
| 633 |
+
echo "Insert ignore category_entity \n";
|
| 634 |
+
$q="INSERT IGNORE INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." (
|
| 635 |
+
entity_type_id,
|
| 636 |
+
attribute_set_id,
|
| 637 |
+
created_at,
|
| 638 |
+
updated_at,
|
| 639 |
+
level,
|
| 640 |
+
children_count,
|
| 641 |
+
entity_id,
|
| 642 |
+
position,
|
| 643 |
+
parent_id,
|
| 644 |
+
store_category_id,
|
| 645 |
+
parent_store_category_id
|
| 646 |
+
)(SELECT
|
| 647 |
+
".$this->_categoryEntityTypeId.",
|
| 648 |
+
".$this->_categoryDefault_attribute_set_id.",
|
| 649 |
+
now(),
|
| 650 |
+
now(),
|
| 651 |
+
c.level,
|
| 652 |
+
c.children_count,
|
| 653 |
+
scm.shop_entity_id,
|
| 654 |
+
c.order_number,
|
| 655 |
+
scm.shop_parent_id,
|
| 656 |
+
c.store_category_id,
|
| 657 |
+
c.parent_store_category_id
|
| 658 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 659 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 660 |
+
ON c.store_category_id=scm.store_category_id
|
| 661 |
+
)";
|
| 662 |
+
}
|
| 663 |
+
$this->db_do($q);
|
| 664 |
|
| 665 |
+
$this->mapSinchCategories();
|
| 666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 668 |
|
| 669 |
+
$q="SELECT
|
| 670 |
+
entity_id,
|
| 671 |
+
parent_id
|
| 672 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
| 673 |
+
ORDER BY parent_id"
|
| 674 |
+
;
|
| 675 |
+
$quer=$this->db_do($q);
|
| 676 |
+
while($row=mysql_fetch_array($quer)){
|
| 677 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
| 678 |
+
SET path='".$this->culc_path($row['parent_id'], $row['entity_id'])."'
|
| 679 |
+
WHERE entity_id=".$row['entity_id']);
|
| 680 |
+
}
|
| 681 |
|
| 682 |
+
if(UPDATE_CATEGORY_DATA){
|
| 683 |
|
| 684 |
+
echo "Update category_data \n";
|
| 685 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." (
|
| 686 |
+
entity_type_id,
|
| 687 |
+
attribute_id,
|
| 688 |
+
store_id,
|
| 689 |
+
entity_id,
|
| 690 |
+
value
|
| 691 |
+
)(SELECT
|
| 692 |
+
".$this->_categoryEntityTypeId.",
|
| 693 |
+
".$this->_getCategoryAttributeId('name').",
|
| 694 |
+
0,
|
| 695 |
+
scm.shop_entity_id,
|
| 696 |
+
c.category_name
|
| 697 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 698 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 699 |
+
ON c.store_category_id=scm.store_category_id
|
| 700 |
+
)
|
| 701 |
+
ON DUPLICATE KEY UPDATE
|
| 702 |
+
value=c.category_name
|
| 703 |
|
| 704 |
+
";
|
| 705 |
+
$this->db_do($q);
|
|
|
|
|
|
|
|
|
|
| 706 |
|
| 707 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." (
|
| 708 |
+
entity_type_id,
|
| 709 |
+
attribute_id,
|
| 710 |
+
store_id,
|
| 711 |
+
entity_id,
|
| 712 |
+
value
|
| 713 |
+
)(SELECT
|
| 714 |
+
".$this->_categoryEntityTypeId.",
|
| 715 |
+
".$this->_getCategoryAttributeId('name').",
|
| 716 |
+
1,
|
| 717 |
+
scm.shop_entity_id,
|
| 718 |
+
c.category_name
|
| 719 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 720 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 721 |
+
ON c.store_category_id=scm.store_category_id
|
| 722 |
+
)
|
| 723 |
+
ON DUPLICATE KEY UPDATE
|
| 724 |
+
value=c.category_name
|
| 725 |
+
";
|
| 726 |
+
$this->db_do($q);
|
| 727 |
+
|
| 728 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." (
|
| 729 |
+
entity_type_id,
|
| 730 |
+
attribute_id,
|
| 731 |
+
store_id,
|
| 732 |
+
entity_id,
|
| 733 |
+
value
|
| 734 |
+
)(SELECT
|
| 735 |
+
".$this->_categoryEntityTypeId.",
|
| 736 |
+
".$this->attributes['is_active'].",
|
| 737 |
+
0,
|
| 738 |
+
scm.shop_entity_id,
|
| 739 |
+
1
|
| 740 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 741 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 742 |
+
ON c.store_category_id=scm.store_category_id
|
| 743 |
+
)
|
| 744 |
+
ON DUPLICATE KEY UPDATE
|
| 745 |
+
value=1
|
| 746 |
+
";
|
| 747 |
+
$this->db_do($q);
|
| 748 |
|
| 749 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')." (
|
| 750 |
+
entity_type_id,
|
| 751 |
+
attribute_id,
|
| 752 |
+
store_id,
|
| 753 |
+
entity_id,
|
| 754 |
+
value
|
| 755 |
+
)(SELECT
|
| 756 |
+
".$this->_categoryEntityTypeId.",
|
| 757 |
+
".$this->attributes['is_active'].",
|
| 758 |
+
1,
|
| 759 |
+
scm.shop_entity_id,
|
| 760 |
+
1
|
| 761 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 762 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 763 |
+
ON c.store_category_id=scm.store_category_id
|
| 764 |
+
)
|
| 765 |
+
ON DUPLICATE KEY UPDATE
|
| 766 |
+
value=1
|
| 767 |
+
";
|
| 768 |
+
$this->db_do($q);
|
| 769 |
|
| 770 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')." (
|
| 771 |
+
entity_type_id,
|
| 772 |
+
attribute_id,
|
| 773 |
+
store_id,
|
| 774 |
+
entity_id,
|
| 775 |
+
value
|
| 776 |
+
)(SELECT
|
| 777 |
+
".$this->_categoryEntityTypeId.",
|
| 778 |
+
".$this->attributes['include_in_menu'].",
|
| 779 |
+
0,
|
| 780 |
+
scm.shop_entity_id,
|
| 781 |
+
1
|
| 782 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 783 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 784 |
+
ON c.store_category_id=scm.store_category_id
|
| 785 |
+
)
|
| 786 |
+
ON DUPLICATE KEY UPDATE
|
| 787 |
+
value=1
|
| 788 |
+
";
|
| 789 |
+
$this->db_do($q);
|
| 790 |
|
| 791 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')." (
|
| 792 |
+
entity_type_id,
|
| 793 |
+
attribute_id,
|
| 794 |
+
store_id,
|
| 795 |
+
entity_id,
|
| 796 |
+
value
|
| 797 |
+
)(SELECT
|
| 798 |
+
".$this->_categoryEntityTypeId.",
|
| 799 |
+
".$this->_getCategoryAttributeId('is_anchor').",
|
| 800 |
+
1,
|
| 801 |
+
scm.shop_entity_id,
|
| 802 |
+
1
|
| 803 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 804 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 805 |
+
ON c.store_category_id=scm.store_category_id
|
| 806 |
+
)
|
| 807 |
+
ON DUPLICATE KEY UPDATE
|
| 808 |
+
value=1
|
| 809 |
+
";
|
| 810 |
+
$this->db_do($q);
|
| 811 |
+
|
| 812 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')." (
|
| 813 |
+
entity_type_id,
|
| 814 |
+
attribute_id,
|
| 815 |
+
store_id,
|
| 816 |
+
entity_id,
|
| 817 |
+
value
|
| 818 |
+
)(SELECT
|
| 819 |
+
".$this->_categoryEntityTypeId.",
|
| 820 |
+
".$this->_getCategoryAttributeId('is_anchor').",
|
| 821 |
+
0,
|
| 822 |
+
scm.shop_entity_id,
|
| 823 |
+
1
|
| 824 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 825 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 826 |
+
ON c.store_category_id=scm.store_category_id
|
| 827 |
+
)
|
| 828 |
+
ON DUPLICATE KEY UPDATE
|
| 829 |
+
value=1
|
| 830 |
+
";
|
| 831 |
+
$this->db_do($q);
|
| 832 |
+
|
| 833 |
+
$q="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." (
|
| 834 |
+
entity_type_id,
|
| 835 |
+
attribute_id,
|
| 836 |
+
store_id,
|
| 837 |
+
entity_id,
|
| 838 |
+
value
|
| 839 |
+
)(SELECT
|
| 840 |
+
".$this->_categoryEntityTypeId.",
|
| 841 |
+
".$this->_getCategoryAttributeId('image').",
|
| 842 |
+
0,
|
| 843 |
+
scm.shop_entity_id,
|
| 844 |
+
c.categories_image
|
| 845 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 846 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 847 |
+
ON c.store_category_id=scm.store_category_id
|
| 848 |
+
)
|
| 849 |
+
ON DUPLICATE KEY UPDATE
|
| 850 |
+
value=c.categories_image
|
| 851 |
+
";
|
| 852 |
+
$this->db_do($q);
|
| 853 |
+
}else{
|
| 854 |
+
echo "Insert ignore category_data \n";
|
| 855 |
+
$q="INSERT IGNORE INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." (
|
| 856 |
+
entity_type_id,
|
| 857 |
+
attribute_id,
|
| 858 |
+
store_id,
|
| 859 |
+
entity_id,
|
| 860 |
+
value
|
| 861 |
+
)(SELECT
|
| 862 |
+
".$this->_categoryEntityTypeId.",
|
| 863 |
+
".$this->_getCategoryAttributeId('name').",
|
| 864 |
+
0,
|
| 865 |
+
scm.shop_entity_id,
|
| 866 |
+
c.category_name
|
| 867 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 868 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 869 |
+
ON c.store_category_id=scm.store_category_id
|
| 870 |
+
)
|
| 871 |
+
";
|
| 872 |
+
$this->db_do($q);
|
| 873 |
|
| 874 |
+
$q="INSERT IGNORE INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')." (
|
| 875 |
+
entity_type_id,
|
| 876 |
+
attribute_id,
|
| 877 |
+
store_id,
|
| 878 |
+
entity_id,
|
| 879 |
+
value
|
| 880 |
+
)(SELECT
|
| 881 |
+
".$this->_categoryEntityTypeId.",
|
| 882 |
+
".$this->attributes['is_active'].",
|
| 883 |
+
0,
|
| 884 |
+
scm.shop_entity_id,
|
| 885 |
+
1
|
| 886 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 887 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 888 |
+
ON c.store_category_id=scm.store_category_id
|
| 889 |
+
)
|
| 890 |
+
";
|
| 891 |
+
$this->db_do($q);
|
| 892 |
+
|
| 893 |
+
$q="INSERT IGNORE INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')." (
|
| 894 |
+
entity_type_id,
|
| 895 |
+
attribute_id,
|
| 896 |
+
store_id,
|
| 897 |
+
entity_id,
|
| 898 |
+
value
|
| 899 |
+
)(SELECT
|
| 900 |
+
".$this->_categoryEntityTypeId.",
|
| 901 |
+
".$this->attributes['include_in_menu'].",
|
| 902 |
+
0,
|
| 903 |
+
scm.shop_entity_id,
|
| 904 |
+
1
|
| 905 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 906 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 907 |
+
ON c.store_category_id=scm.store_category_id
|
| 908 |
+
)
|
| 909 |
+
";
|
| 910 |
+
$this->db_do($q);
|
| 911 |
|
| 912 |
+
$q="INSERT IGNORE INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')." (
|
| 913 |
+
entity_type_id,
|
| 914 |
+
attribute_id,
|
| 915 |
+
store_id,
|
| 916 |
+
entity_id,
|
| 917 |
+
value
|
| 918 |
+
)(SELECT
|
| 919 |
+
".$this->_categoryEntityTypeId.",
|
| 920 |
+
".$this->_getCategoryAttributeId('is_anchor').",
|
| 921 |
+
0,
|
| 922 |
+
scm.shop_entity_id,
|
| 923 |
+
1
|
| 924 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 925 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 926 |
+
ON c.store_category_id=scm.store_category_id
|
| 927 |
+
)
|
| 928 |
+
";
|
| 929 |
+
$this->db_do($q);
|
| 930 |
|
| 931 |
+
$q="INSERT IGNORE INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." (
|
| 932 |
+
entity_type_id,
|
| 933 |
+
attribute_id,
|
| 934 |
+
store_id,
|
| 935 |
+
entity_id,
|
| 936 |
+
value
|
| 937 |
+
)(SELECT
|
| 938 |
+
".$this->_categoryEntityTypeId.",
|
| 939 |
+
".$this->_getCategoryAttributeId('image').",
|
| 940 |
+
0,
|
| 941 |
+
scm.shop_entity_id,
|
| 942 |
+
c.categories_image
|
| 943 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 944 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 945 |
+
ON c.store_category_id=scm.store_category_id
|
| 946 |
+
)
|
| 947 |
+
";
|
| 948 |
+
$this->db_do($q);
|
| 949 |
|
| 950 |
+
}
|
| 951 |
+
$this->delete_old_sinch_categories_from_shop();
|
| 952 |
+
|
| 953 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_categories'));
|
| 954 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
|
| 955 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_categories')
|
| 956 |
+
);
|
| 957 |
+
$this->_LOG("Finish parse ".FILE_CATEGORIES);
|
| 958 |
+
}else{
|
| 959 |
+
$this->_LOG("Wrong file ".$parse_file);
|
| 960 |
}
|
| 961 |
+
$this->_LOG(' ');
|
| 962 |
+
}
|
| 963 |
|
| 964 |
#################################################################################################
|
| 965 |
|
| 966 |
+
function ParseCategoryFeatures(){
|
| 967 |
+
|
| 968 |
+
$parse_file=$this->varDir.FILE_CATEGORIES_FEATURES;
|
| 969 |
+
if(filesize($parse_file) || $this->_ignore_category_features){
|
| 970 |
+
$this->_LOG("Start parse ".FILE_CATEGORIES_FEATURES);
|
| 971 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('categories_features_temp'));
|
| 972 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('categories_features_temp')." (
|
| 973 |
+
category_feature_id int(11),
|
| 974 |
+
store_category_id int(11),
|
| 975 |
+
feature_name varchar(50),
|
| 976 |
+
display_order_number int(11),
|
| 977 |
+
KEY(store_category_id),
|
| 978 |
+
KEY(category_feature_id)
|
| 979 |
+
)
|
| 980 |
+
");
|
| 981 |
+
|
| 982 |
+
if(!$this->_ignore_category_features){
|
| 983 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 984 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('categories_features_temp')."
|
| 985 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 986 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 987 |
+
LINES TERMINATED BY \"\r\n\"
|
| 988 |
+
IGNORE 1 LINES ");
|
| 989 |
+
}
|
| 990 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features'));
|
| 991 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('categories_features_temp')."
|
| 992 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features'));
|
| 993 |
+
|
| 994 |
+
$this->_LOG("Finish parse ".FILE_CATEGORIES_FEATURES);
|
| 995 |
+
}else{
|
| 996 |
+
$this->_LOG("Wrong file ".$parse_file);
|
| 997 |
+
}
|
| 998 |
+
$this->_LOG(' ');
|
| 999 |
+
}
|
| 1000 |
|
| 1001 |
+
#################################################################################################
|
|
|
|
|
|
|
| 1002 |
|
| 1003 |
+
function ParseDistributors(){
|
| 1004 |
+
|
| 1005 |
+
$parse_file=$this->varDir.FILE_DISTRIBUTORS;
|
| 1006 |
+
if(filesize($parse_file)){
|
| 1007 |
+
$this->_LOG("Start parse ".FILE_DISTRIBUTORS);
|
| 1008 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('distributors_temp'));
|
| 1009 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('distributors_temp')."(
|
| 1010 |
+
distributor_id int(11),
|
| 1011 |
+
distributor_name varchar(255),
|
| 1012 |
+
website varchar(255),
|
| 1013 |
+
KEY(distributor_id)
|
| 1014 |
+
)
|
| 1015 |
+
");
|
| 1016 |
|
| 1017 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 1018 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('distributors_temp')."
|
| 1019 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1020 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1021 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1022 |
+
IGNORE 1 LINES ");
|
| 1023 |
|
| 1024 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_distributors'));
|
| 1025 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('distributors_temp')."
|
| 1026 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_distributors'));
|
| 1027 |
+
|
| 1028 |
+
$this->_LOG("Finish parse ".FILE_DISTRIBUTORS);
|
| 1029 |
+
}else{
|
| 1030 |
+
$this->_LOG("Wrong file ".$parse_file);
|
| 1031 |
}
|
| 1032 |
+
$this->_LOG(' ');
|
| 1033 |
+
}
|
| 1034 |
|
| 1035 |
#################################################################################################
|
| 1036 |
|
| 1037 |
+
function ParseEANCodes(){
|
| 1038 |
+
|
| 1039 |
+
$parse_file=$this->varDir.FILE_EANCODES;
|
| 1040 |
+
if(filesize($parse_file)){
|
| 1041 |
+
$this->_LOG("Start parse ".FILE_EANCODES);
|
| 1042 |
|
| 1043 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('ean_codes_temp'));
|
| 1044 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('ean_codes_temp')."(
|
| 1045 |
+
product_id int(11),
|
| 1046 |
+
ean_code varchar(255),
|
| 1047 |
+
KEY(product_id)
|
| 1048 |
+
)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1049 |
|
| 1050 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 1051 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('ean_codes_temp')."
|
| 1052 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1053 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1054 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1055 |
+
IGNORE 1 LINES ");
|
| 1056 |
|
| 1057 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_ean_codes'));
|
| 1058 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('ean_codes_temp')."
|
| 1059 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_ean_codes'));
|
| 1060 |
+
|
| 1061 |
+
$this->_LOG("Finish parse ".FILE_EANCODES);
|
| 1062 |
+
}else{
|
| 1063 |
+
$this->_LOG("Wrong file ".$parse_file);
|
| 1064 |
+
}
|
| 1065 |
+
$this->_LOG(' ');
|
| 1066 |
+
}
|
| 1067 |
|
| 1068 |
+
#################################################################################################
|
|
|
|
| 1069 |
|
| 1070 |
+
function ParseManufacturers(){
|
| 1071 |
+
|
| 1072 |
+
$parse_file=$this->varDir.FILE_MANUFACTURERS;
|
| 1073 |
+
if(filesize($parse_file)){
|
| 1074 |
+
$this->_LOG("Start parse ".FILE_MANUFACTURERS);
|
| 1075 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('manufacturers_temp'));
|
| 1076 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('manufacturers_temp')."(
|
| 1077 |
+
sinch_manufacturer_id int(11),
|
| 1078 |
+
manufacturer_name varchar(255),
|
| 1079 |
+
manufacturers_image varchar(255),
|
| 1080 |
+
shop_option_id int(11),
|
| 1081 |
+
KEY(sinch_manufacturer_id),
|
| 1082 |
+
KEY(shop_option_id),
|
| 1083 |
+
KEY(manufacturer_name)
|
| 1084 |
+
)");
|
| 1085 |
+
|
| 1086 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 1087 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('manufacturers_temp')."
|
| 1088 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1089 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1090 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1091 |
+
IGNORE 1 LINES ");
|
| 1092 |
+
|
| 1093 |
+
$q="DELETE aov
|
| 1094 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')." ao
|
| 1095 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')." aov
|
| 1096 |
+
ON ao.option_id=aov.option_id left
|
| 1097 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('manufacturers_temp')." mt
|
| 1098 |
+
ON aov.value=mt.manufacturer_name
|
| 1099 |
+
WHERE
|
| 1100 |
+
ao.attribute_id=".$this->attributes['manufacturer']." AND
|
| 1101 |
+
mt.manufacturer_name is null";
|
| 1102 |
$this->db_do($q);
|
| 1103 |
|
| 1104 |
+
$q="DELETE ao
|
| 1105 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')." ao
|
| 1106 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')." aov
|
| 1107 |
+
ON ao.option_id=aov.option_id
|
| 1108 |
+
WHERE
|
| 1109 |
+
attribute_id=".$this->attributes['manufacturer']." AND
|
| 1110 |
+
aov.option_id is null";
|
| 1111 |
$this->db_do($q);
|
| 1112 |
|
| 1113 |
+
$q="SELECT
|
| 1114 |
+
m.sinch_manufacturer_id,
|
| 1115 |
+
m.manufacturer_name,
|
| 1116 |
+
m.manufacturers_image
|
| 1117 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('manufacturers_temp')." m
|
| 1118 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')." aov
|
| 1119 |
+
ON m.manufacturer_name=aov.value
|
| 1120 |
+
WHERE aov.value IS NULL";
|
| 1121 |
$quer=$this->db_do($q);
|
| 1122 |
|
| 1123 |
while($row=mysql_fetch_array($quer)){
|
| 1124 |
+
$q0="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
|
| 1125 |
+
(attribute_id)
|
| 1126 |
+
VALUES(".$this->attributes['manufacturer'].")";
|
| 1127 |
$quer0=$this->db_do($q0);
|
| 1128 |
|
| 1129 |
+
$q2="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')."(
|
| 1130 |
+
option_id,
|
| 1131 |
+
value
|
| 1132 |
+
)(
|
| 1133 |
+
SELECT
|
| 1134 |
+
max(option_id) as option_id,
|
| 1135 |
+
"."'".mysql_real_escape_string($row['manufacturer_name'])."'
|
| 1136 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
|
| 1137 |
+
WHERE attribute_id=".$this->attributes['manufacturer']."
|
| 1138 |
+
)
|
| 1139 |
+
";
|
| 1140 |
$quer2=$this->db_do($q2);
|
| 1141 |
+
// $option['attribute_id'] = $this->attributes['manufacturer'];
|
| 1142 |
+
// $option['value'][$row['sinch_manufacturer_id']][0] = $row['manufacturer_name'];
|
| 1143 |
|
| 1144 |
}
|
| 1145 |
|
| 1146 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('manufacturers_temp')." mt
|
| 1147 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')." aov
|
| 1148 |
+
ON mt.manufacturer_name=aov.value
|
| 1149 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')." ao
|
| 1150 |
+
ON ao.option_id=aov.option_id
|
| 1151 |
+
SET mt.shop_option_id=aov.option_id
|
| 1152 |
+
WHERE ao.attribute_id=".$this->attributes['manufacturer'];
|
| 1153 |
$this->db_do($q);
|
| 1154 |
+
|
| 1155 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers'));
|
| 1156 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('manufacturers_temp')."
|
| 1157 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers'));
|
| 1158 |
+
$this->_LOG("Finish parse ".FILE_MANUFACTURERS);
|
| 1159 |
+
}else{
|
| 1160 |
+
$this->_LOG("Wrong file ".$parse_file);
|
|
|
|
| 1161 |
}
|
| 1162 |
+
$this->_LOG(' ');
|
| 1163 |
+
}
|
| 1164 |
|
| 1165 |
#################################################################################################
|
| 1166 |
|
| 1167 |
+
function ParseProductFeatures(){
|
| 1168 |
|
| 1169 |
+
$parse_file=$this->varDir.FILE_PRODUCT_FEATURES;
|
| 1170 |
+
if(filesize($parse_file) || $this->_ignore_product_features){
|
| 1171 |
+
$this->_LOG("Start parse ".FILE_PRODUCT_FEATURES);
|
| 1172 |
|
| 1173 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('product_features_temp'));
|
| 1174 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('product_features_temp')."(
|
| 1175 |
+
product_feature_id int(11),
|
| 1176 |
+
sinch_product_id int(11),
|
| 1177 |
+
restricted_value_id int(11),
|
| 1178 |
+
KEY(sinch_product_id),
|
| 1179 |
+
KEY(restricted_value_id)
|
| 1180 |
+
)
|
| 1181 |
+
");
|
| 1182 |
if(!$this->_ignore_product_features){
|
| 1183 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 1184 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('product_features_temp')."
|
| 1185 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1186 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1187 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1188 |
+
IGNORE 1 LINES ");
|
| 1189 |
+
}
|
| 1190 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features'));
|
| 1191 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('product_features_temp')."
|
| 1192 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features'));
|
| 1193 |
|
| 1194 |
+
$this->_LOG("Finish parse ".FILE_PRODUCT_FEATURES);
|
| 1195 |
+
}else{
|
| 1196 |
+
$this->_LOG("Wrong file ".$parse_file);
|
|
|
|
|
|
|
| 1197 |
}
|
| 1198 |
+
$this->_LOG(" ");
|
| 1199 |
+
}
|
| 1200 |
|
| 1201 |
#################################################################################################
|
| 1202 |
|
| 1203 |
+
function ParseProducts(){
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1204 |
|
| 1205 |
+
$parse_file=$this->varDir.FILE_PRODUCTS;
|
| 1206 |
+
if(filesize($parse_file)){
|
| 1207 |
+
$this->_LOG("Start parse ".FILE_PRODUCTS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1208 |
|
| 1209 |
+
$file_handle_from = fopen($parse_file, "r");
|
| 1210 |
+
unlink($parse_file.".conv");
|
| 1211 |
+
$file_handle_to = fopen($parse_file.".conv", "w");
|
| 1212 |
+
while (!feof($file_handle_from)) {
|
| 1213 |
+
$line = fgets($file_handle_from);
|
| 1214 |
+
$line = $this->valid_utf($line);
|
| 1215 |
+
fwrite($file_handle_to, $line);
|
| 1216 |
}
|
| 1217 |
+
fclose($file_handle_from);
|
| 1218 |
+
fclose($file_handle_to);
|
| 1219 |
+
|
| 1220 |
+
|
| 1221 |
+
// $prod_file_str = file_get_contents($parse_file);
|
| 1222 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
|
| 1223 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."(
|
| 1224 |
+
store_category_product_id int(11),
|
| 1225 |
+
store_product_id int(11),
|
| 1226 |
+
sinch_product_id int(11),
|
| 1227 |
+
product_sku varchar(255),
|
| 1228 |
+
product_name varchar(255),
|
| 1229 |
+
sinch_manufacturer_id int(11),
|
| 1230 |
+
store_category_id int(11),
|
| 1231 |
+
main_image_url varchar(255),
|
| 1232 |
+
thumb_image_url varchar(255),
|
| 1233 |
+
specifications text,
|
| 1234 |
+
description text,
|
| 1235 |
+
search_cache text,
|
| 1236 |
+
spec_characte_u_count int(11),
|
| 1237 |
+
description_type varchar(50),
|
| 1238 |
+
medium_image_url varchar(255),
|
| 1239 |
+
products_date_added datetime default NULL,
|
| 1240 |
+
products_last_modified datetime default NULL,
|
| 1241 |
+
availability_id_in_stock int(11) default '1',
|
| 1242 |
+
availability_id_out_of_stock int(11) default '2',
|
| 1243 |
+
products_locate varchar(30) default NULL,
|
| 1244 |
+
products_ordered int(11) NOT NULL default '0',
|
| 1245 |
+
products_url varchar(255) default NULL,
|
| 1246 |
+
products_viewed int(5) default '0',
|
| 1247 |
+
products_seo_url varchar(100) NOT NULL,
|
| 1248 |
+
manufacturer_name varchar(255) default NULL,
|
| 1249 |
+
KEY(store_category_product_id),
|
| 1250 |
+
KEY(store_product_id),
|
| 1251 |
+
KEY(sinch_manufacturer_id),
|
| 1252 |
+
KEY(store_category_id)
|
| 1253 |
+
)DEFAULT CHARSET=utf8
|
| 1254 |
+
");
|
| 1255 |
+
|
| 1256 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file.".conv'
|
| 1257 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
| 1258 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1259 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1260 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1261 |
+
IGNORE 1 LINES ");
|
| 1262 |
|
| 1263 |
+
$this->db_do("ALTER TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
| 1264 |
+
CONVERT TO CHARACTER SET \"latin1\"");
|
| 1265 |
|
| 1266 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
| 1267 |
+
SET products_date_added=now(), products_last_modified=now()");
|
| 1268 |
|
| 1269 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
| 1270 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')." m
|
| 1271 |
+
ON p.sinch_manufacturer_id=m.sinch_manufacturer_id
|
| 1272 |
+
SET p.manufacturer_name=m.manufacturer_name");
|
| 1273 |
+
|
| 1274 |
+
if($this->current_import_status_statistic_id){
|
| 1275 |
+
$res = $this->db_do("SELECT COUNT(*) AS cnt
|
| 1276 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
|
| 1277 |
+
$row = mysql_fetch_assoc($res);
|
| 1278 |
+
$this->db_do("UPDATE ".$this->import_status_statistic_table."
|
| 1279 |
+
SET number_of_products=".$row['cnt']."
|
| 1280 |
+
WHERE id=".$this->current_import_status_statistic_id);
|
| 1281 |
+
}
|
| 1282 |
|
| 1283 |
+
$this->addProductsWebsite();
|
| 1284 |
+
$this->mapSinchProducts();
|
| 1285 |
+
$this->replaceMagentoProducts();
|
| 1286 |
$this->mapSinchProducts();
|
|
|
|
|
|
|
| 1287 |
$this->addManufacturer_attribute();
|
| 1288 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_products'));
|
| 1289 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
| 1290 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_products'));
|
| 1291 |
+
$this->_LOG("Finish parse ".FILE_PRODUCTS);
|
| 1292 |
+
}else{
|
| 1293 |
+
$this->_LOG("Wrong file ".$parse_file);
|
|
|
|
| 1294 |
}
|
| 1295 |
+
$this->_LOG(" ");
|
| 1296 |
+
}
|
| 1297 |
|
| 1298 |
#################################################################################################
|
| 1299 |
|
| 1300 |
+
function ParseRelatedProducts(){
|
| 1301 |
+
|
| 1302 |
+
$parse_file=$this->varDir.FILE_RELATED_PRODUCTS;
|
| 1303 |
+
if(filesize($parse_file) || $this->_ignore_product_related){
|
| 1304 |
+
$this->_LOG("Start parse ".FILE_RELATED_PRODUCTS);
|
| 1305 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('related_products_temp'));
|
| 1306 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('related_products_temp')."(
|
| 1307 |
+
sinch_product_id int(11),
|
| 1308 |
+
related_sinch_product_id int(11),
|
| 1309 |
+
store_product_id int(11) default null,
|
| 1310 |
+
store_related_product_id int(11) default null,
|
| 1311 |
+
entity_id int(11),
|
| 1312 |
+
related_entity_id int(11),
|
| 1313 |
+
KEY(sinch_product_id),
|
| 1314 |
+
KEY(related_sinch_product_id),
|
| 1315 |
+
KEY(store_product_id)
|
| 1316 |
+
)DEFAULT CHARSET=utf8");
|
| 1317 |
if(!$this->_ignore_product_related){
|
| 1318 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 1319 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('related_products_temp')."
|
| 1320 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1321 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1322 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1323 |
+
IGNORE 1 LINES ");
|
| 1324 |
}
|
| 1325 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_related_products'));
|
| 1326 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('related_products_temp')."
|
| 1327 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_related_products'));
|
| 1328 |
+
|
| 1329 |
+
$this->_LOG("Finish parse ".FILE_RELATED_PRODUCTS);
|
| 1330 |
+
}else{
|
| 1331 |
+
$this->_LOG("Wrong file ".$parse_file);
|
|
|
|
| 1332 |
}
|
| 1333 |
+
$this->_LOG(" ");
|
| 1334 |
+
}
|
| 1335 |
|
| 1336 |
#################################################################################################
|
| 1337 |
|
| 1338 |
+
function ParseRestrictedValues(){
|
| 1339 |
+
|
| 1340 |
+
$parse_file=$this->varDir.FILE_RESTRICTED_VALUES;
|
| 1341 |
+
if(filesize($parse_file) || $this->_ignore_restricted_values){
|
| 1342 |
+
$this->_LOG("Start parse ".FILE_RESTRICTED_VALUES);
|
| 1343 |
+
$file_handle_from = fopen($parse_file, "r");
|
| 1344 |
+
unlink($parse_file.".conv");
|
| 1345 |
+
$file_handle_to = fopen($parse_file.".conv", "w");
|
| 1346 |
+
while (!feof($file_handle_from)) {
|
| 1347 |
+
$line = fgets($file_handle_from);
|
| 1348 |
+
$line = $this->valid_utf($line);
|
| 1349 |
+
fwrite($file_handle_to, $line);
|
| 1350 |
+
}
|
| 1351 |
+
fclose($file_handle_from);
|
| 1352 |
+
fclose($file_handle_to);
|
| 1353 |
+
|
| 1354 |
+
|
| 1355 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp'));
|
| 1356 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')." (
|
| 1357 |
+
restricted_value_id int(11),
|
| 1358 |
+
category_feature_id int(11),
|
| 1359 |
+
text text,
|
| 1360 |
+
display_order_number int(11),
|
| 1361 |
+
KEY(restricted_value_id),
|
| 1362 |
+
KEY(category_feature_id)
|
| 1363 |
+
)");
|
| 1364 |
if(!$this->_ignore_restricted_values){
|
| 1365 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file.".conv'
|
| 1366 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')."
|
| 1367 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1368 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1369 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1370 |
+
IGNORE 1 LINES ");
|
| 1371 |
}
|
| 1372 |
+
$this->db_do("ALTER TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')."
|
| 1373 |
+
CONVERT TO CHARACTER SET \"latin1\"");
|
| 1374 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values'));
|
| 1375 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')."
|
| 1376 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values'));
|
| 1377 |
|
| 1378 |
+
$this->_LOG("Finish parse ".FILE_RESTRICTED_VALUES);
|
| 1379 |
+
}else{
|
| 1380 |
+
$this->_LOG("Wrong file ".$parse_file);
|
|
|
|
|
|
|
| 1381 |
}
|
| 1382 |
+
$this->_LOG(" ");
|
| 1383 |
+
}
|
| 1384 |
|
| 1385 |
#################################################################################################
|
| 1386 |
|
| 1387 |
+
function ParseStockAndPrices(){
|
| 1388 |
+
|
| 1389 |
+
$parse_file=$this->varDir.FILE_STOCK_AND_PRICES;
|
| 1390 |
+
if(filesize($parse_file)){
|
| 1391 |
+
$this->_LOG("Start parse ".FILE_RELATED_PRODUCTS);
|
| 1392 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp'));
|
| 1393 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." (
|
| 1394 |
+
store_product_id int(11),
|
| 1395 |
+
stock int(11),
|
| 1396 |
+
price decimal(15,4),
|
| 1397 |
+
cost decimal(15,4),
|
| 1398 |
+
distributor_id int(11),
|
| 1399 |
+
KEY(store_product_id),
|
| 1400 |
+
KEY(distributor_id)
|
| 1401 |
+
)");
|
| 1402 |
+
|
| 1403 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 1404 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')."
|
| 1405 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1406 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1407 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1408 |
+
IGNORE 1 LINES ");
|
| 1409 |
+
|
| 1410 |
+
$this->replaceMagentoProductsStockPrice();
|
| 1411 |
+
|
| 1412 |
+
$res = $this->db_do("SELECT count(*) as cnt
|
| 1413 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 1414 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
|
| 1415 |
+
ON a.store_product_id=b.store_product_id");
|
| 1416 |
+
$row = mysql_fetch_assoc($res);
|
| 1417 |
+
$this->db_do("UPDATE ".$this->import_status_statistic_table."
|
| 1418 |
+
SET number_of_products=".$row['cnt']."
|
| 1419 |
+
WHERE id=".$this->current_import_status_statistic_id);
|
| 1420 |
+
|
| 1421 |
+
$this->addWeight();
|
| 1422 |
+
|
| 1423 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_stock_and_prices'));
|
| 1424 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')."
|
| 1425 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_stock_and_prices'));
|
| 1426 |
+
|
| 1427 |
+
$this->_LOG("Finish parse".FILE_RELATED_PRODUCTS);
|
| 1428 |
+
}else{
|
| 1429 |
+
$this->_LOG("Wrong file".$parse_file);
|
| 1430 |
+
}
|
| 1431 |
+
$this->_LOG(" ");
|
| 1432 |
+
}
|
| 1433 |
|
| 1434 |
+
#################################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1435 |
|
| 1436 |
+
function ParseProductsPicturesGallery(){
|
| 1437 |
+
|
| 1438 |
+
$parse_file=$this->varDir.FILE_PRODUCTS_PICTURES_GALLERY;
|
| 1439 |
+
if(filesize($parse_file)){
|
| 1440 |
+
$this->_LOG("Start parse ".FILE_PRODUCTS_PICTURES_GALLERY);
|
| 1441 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp'));
|
| 1442 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp')." (
|
| 1443 |
+
sinch_product_id int(11),
|
| 1444 |
+
image_url varchar(255),
|
| 1445 |
+
thumb_image_url varchar(255),
|
| 1446 |
+
store_product_id int(11),
|
| 1447 |
+
key(sinch_product_id),
|
| 1448 |
+
key(store_product_id)
|
| 1449 |
+
)");
|
| 1450 |
+
|
| 1451 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
| 1452 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp')."
|
| 1453 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
| 1454 |
+
OPTIONALLY ENCLOSED BY '\"'
|
| 1455 |
+
LINES TERMINATED BY \"\r\n\"
|
| 1456 |
+
IGNORE 1 LINES ");
|
| 1457 |
+
|
| 1458 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp')." ppgt
|
| 1459 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." sp
|
| 1460 |
+
ON ppgt.sinch_product_id=sp.sinch_product_id
|
| 1461 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1462 |
+
ON sp.store_product_id=cpe.store_product_id
|
| 1463 |
+
SET ppgt.store_product_id=sp.store_product_id");
|
| 1464 |
+
|
| 1465 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery'));
|
| 1466 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('products_pictures_gallery_temp')."
|
| 1467 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery'));
|
| 1468 |
+
|
| 1469 |
+
$this->_LOG("Finish parse".FILE_PRODUCTS_PICTURES_GALLERY);
|
| 1470 |
+
}else{
|
| 1471 |
+
$this->_LOG("Wrong file".$parse_file);
|
| 1472 |
+
}
|
| 1473 |
+
$this->_LOG(" ");
|
| 1474 |
|
| 1475 |
+
}
|
|
|
|
| 1476 |
|
| 1477 |
+
#################################################################################################
|
| 1478 |
+
public function mapSinchCategories(){
|
| 1479 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp'));
|
| 1480 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')." (
|
| 1481 |
+
shop_entity_id int(11) unsigned NOT NULL,
|
| 1482 |
+
shop_entity_type_id int(11),
|
| 1483 |
+
shop_attribute_set_id int(11),
|
| 1484 |
+
shop_parent_id int(11),
|
| 1485 |
+
shop_store_category_id int(11),
|
| 1486 |
+
shop_parent_store_category_id int(11),
|
| 1487 |
+
store_category_id int(11),
|
| 1488 |
+
parent_store_category_id int(11),
|
| 1489 |
+
category_name varchar(255),
|
| 1490 |
+
order_number int(11),
|
| 1491 |
+
products_within_this_category int(11),
|
| 1492 |
+
KEY shop_entity_id (shop_entity_id),
|
| 1493 |
+
KEY shop_parent_id (shop_parent_id),
|
| 1494 |
+
KEY store_category_id (store_category_id),
|
| 1495 |
+
KEY parent_store_category_id (parent_store_category_id),
|
| 1496 |
+
UNIQUE KEY(shop_entity_id)
|
| 1497 |
+
)
|
| 1498 |
+
");
|
| 1499 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')."
|
| 1500 |
+
LIKE ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')
|
| 1501 |
+
);
|
| 1502 |
+
$result = $this->db_do("INSERT IGNORE INTO ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')." (
|
| 1503 |
+
shop_entity_id,
|
| 1504 |
+
shop_entity_type_id,
|
| 1505 |
+
shop_attribute_set_id,
|
| 1506 |
+
shop_parent_id,
|
| 1507 |
+
shop_store_category_id,
|
| 1508 |
+
shop_parent_store_category_id
|
| 1509 |
+
)(SELECT
|
| 1510 |
+
entity_id,
|
| 1511 |
+
entity_type_id,
|
| 1512 |
+
attribute_set_id,
|
| 1513 |
+
parent_id,
|
| 1514 |
+
store_category_id,
|
| 1515 |
+
parent_store_category_id
|
| 1516 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
| 1517 |
+
)
|
| 1518 |
+
");
|
| 1519 |
+
|
| 1520 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')." cmt
|
| 1521 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 1522 |
+
ON cmt.shop_store_category_id=c.store_category_id
|
| 1523 |
+
SET
|
| 1524 |
+
cmt.store_category_id=c.store_category_id,
|
| 1525 |
+
cmt.parent_store_category_id=c.parent_store_category_id,
|
| 1526 |
+
cmt.category_name=c.category_name,
|
| 1527 |
+
cmt.order_number=c.order_number,
|
| 1528 |
+
cmt.products_within_this_category=c.products_within_this_category";
|
| 1529 |
+
$this->db_do($q);
|
| 1530 |
|
| 1531 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')." cmt
|
| 1532 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." cce
|
| 1533 |
+
ON cmt.parent_store_category_id=cce.store_category_id
|
| 1534 |
+
SET cmt.shop_parent_id=cce.entity_id";
|
| 1535 |
+
$this->db_do($q);
|
| 1536 |
|
| 1537 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')." cmt
|
| 1538 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('categories_temp')." c
|
| 1539 |
+
ON cmt.shop_store_category_id=c.store_category_id
|
| 1540 |
+
SET shop_parent_id=".$this->_root_cat."
|
| 1541 |
+
WHERE shop_parent_id=0";
|
| 1542 |
+
$this->db_do($q);
|
| 1543 |
|
| 1544 |
+
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
| 1545 |
+
$im_type = $dataConf['replace_category'];
|
| 1546 |
+
// added for mapping new sinch categories in merge && !UPDATE_CATEGORY_DATA mode
|
| 1547 |
+
if((UPDATE_CATEGORY_DATA && $im_type=="MERGE") || ($im_type=="REWRITE")){
|
| 1548 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')." cmt
|
| 1549 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." cce
|
| 1550 |
+
ON cmt.shop_entity_id=cce.entity_id
|
| 1551 |
+
SET cce.parent_id=cmt.shop_parent_id";
|
| 1552 |
+
$this->db_do($q);
|
| 1553 |
+
}else{
|
| 1554 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')." cmt
|
| 1555 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." cce
|
| 1556 |
+
ON cmt.shop_entity_id=cce.entity_id
|
| 1557 |
+
SET cce.parent_id=cmt.shop_parent_id
|
| 1558 |
+
WHERE cce.parent_id=0 AND cce.store_category_id is not null
|
| 1559 |
+
";
|
| 1560 |
+
$this->db_do($q);
|
| 1561 |
+
|
| 1562 |
}
|
| 1563 |
|
|
|
|
|
|
|
|
|
|
| 1564 |
|
| 1565 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping'));
|
| 1566 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp')."
|
| 1567 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping'));
|
| 1568 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1569 |
|
| 1570 |
+
#################################################################################################
|
| 1571 |
+
public function mapSinchProducts(){
|
| 1572 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp'));
|
| 1573 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp')." (
|
| 1574 |
+
entity_id int(11) unsigned NOT NULL,
|
| 1575 |
+
manufacturer_option_id int(11),
|
| 1576 |
+
manufacturer_name varchar(255),
|
| 1577 |
+
shop_store_product_id int(11),
|
| 1578 |
+
shop_sinch_product_id int(11),
|
| 1579 |
+
sku varchar(64) default NULL,
|
| 1580 |
+
store_category_product_id int(11),
|
| 1581 |
+
store_product_id int(11),
|
| 1582 |
+
sinch_product_id int(11),
|
| 1583 |
+
product_sku varchar(255),
|
| 1584 |
+
sinch_manufacturer_id int(11),
|
| 1585 |
+
sinch_manufacturer_name varchar(255),
|
| 1586 |
+
KEY entity_id (entity_id),
|
| 1587 |
+
KEY manufacturer_option_id (manufacturer_option_id),
|
| 1588 |
+
KEY manufacturer_name (manufacturer_name),
|
| 1589 |
+
KEY store_product_id (store_product_id),
|
| 1590 |
+
KEY sinch_product_id (sinch_product_id),
|
| 1591 |
+
KEY sku (sku),
|
| 1592 |
+
UNIQUE KEY(entity_id)
|
| 1593 |
+
)
|
| 1594 |
+
");
|
| 1595 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')."
|
| 1596 |
+
LIKE ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp'));
|
| 1597 |
+
$result = $this->db_do("
|
| 1598 |
+
INSERT ignore INTO ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp')." (
|
| 1599 |
+
entity_id,
|
| 1600 |
+
sku,
|
| 1601 |
+
shop_store_product_id,
|
| 1602 |
+
shop_sinch_product_id
|
| 1603 |
+
)(SELECT
|
| 1604 |
+
entity_id,
|
| 1605 |
+
sku,
|
| 1606 |
+
store_product_id,
|
| 1607 |
+
sinch_product_id
|
| 1608 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')."
|
| 1609 |
+
)
|
| 1610 |
+
");
|
| 1611 |
+
|
| 1612 |
+
$this->addManufacturers(1);
|
| 1613 |
+
|
| 1614 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp')." pmt
|
| 1615 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_eav')." cpie
|
| 1616 |
+
ON pmt.entity_id=cpie.entity_id
|
| 1617 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option_value')." aov
|
| 1618 |
+
ON cpie.value=aov.option_id
|
| 1619 |
+
SET
|
| 1620 |
+
manufacturer_option_id=cpie.value,
|
| 1621 |
+
manufacturer_name=aov.value
|
| 1622 |
+
WHERE cpie.attribute_id=".$this->attributes['manufacturer'];
|
| 1623 |
+
$this->db_do($q);
|
| 1624 |
|
| 1625 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp')." pmt
|
| 1626 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
| 1627 |
+
ON pmt.sku=p.product_sku
|
| 1628 |
+
SET
|
| 1629 |
+
pmt.store_category_product_id=p.store_category_product_id,
|
| 1630 |
+
pmt.store_product_id=p.store_product_id,
|
| 1631 |
+
pmt.sinch_product_id=p.sinch_product_id,
|
| 1632 |
+
pmt.product_sku=p.product_sku,
|
| 1633 |
+
pmt.sinch_manufacturer_id=p.sinch_manufacturer_id,
|
| 1634 |
+
pmt.sinch_manufacturer_name=p.manufacturer_name";
|
| 1635 |
|
| 1636 |
+
$this->db_do($q);
|
|
|
|
| 1637 |
|
| 1638 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1639 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp')." pmt
|
| 1640 |
+
ON cpe.entity_id=pmt.entity_id
|
| 1641 |
+
SET cpe.store_product_id=pmt.store_product_id,
|
| 1642 |
+
cpe.sinch_product_id=pmt.sinch_product_id
|
| 1643 |
+
WHERE
|
| 1644 |
+
cpe.sinch_product_id IS NULL
|
| 1645 |
+
AND pmt.sinch_product_id IS NOT NULL
|
| 1646 |
+
AND cpe.store_product_id IS NULL
|
| 1647 |
+
AND pmt.store_product_id IS NOT NULL";
|
| 1648 |
+
$this->db_do($q);
|
| 1649 |
|
| 1650 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping'));
|
| 1651 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp')."
|
| 1652 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping'));
|
| 1653 |
+
}
|
| 1654 |
+
#################################################################################################
|
| 1655 |
+
public function addProductsWebsite (){
|
| 1656 |
+
$this->db_do(" DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('products_website_temp'));
|
| 1657 |
+
// TEMPORARY
|
| 1658 |
+
$this->db_do("
|
| 1659 |
+
CREATE TABLE `".Mage::getSingleton('core/resource')->getTableName('products_website_temp')."` (
|
| 1660 |
+
`id` int(10) unsigned NOT NULL auto_increment,
|
| 1661 |
+
store_product_id int(11),
|
| 1662 |
+
sinch_product_id int(11),
|
| 1663 |
+
`website` int(11) default NULL,
|
| 1664 |
+
`website_id` int(11) default NULL,
|
| 1665 |
+
PRIMARY KEY (`id`),
|
| 1666 |
+
KEY store_product_id (`store_product_id`)
|
| 1667 |
+
)
|
| 1668 |
+
");
|
| 1669 |
+
$result = $this->db_do("SELECT
|
| 1670 |
+
website_id,
|
| 1671 |
+
store_id as website
|
| 1672 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('core_store')."
|
| 1673 |
+
WHERE code!='admin'
|
| 1674 |
+
"); // where code!='admin' was adder for editing Featured products;
|
| 1675 |
+
while ($row = mysql_fetch_assoc($result)) {
|
| 1676 |
+
$sql = "INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." (
|
| 1677 |
+
store_product_id,
|
| 1678 |
+
sinch_product_id,
|
| 1679 |
+
website,
|
| 1680 |
+
website_id
|
| 1681 |
+
)(
|
| 1682 |
+
SELECT
|
| 1683 |
+
distinct
|
| 1684 |
+
store_product_id,
|
| 1685 |
+
sinch_product_id,
|
| 1686 |
+
{$row['website']},
|
| 1687 |
+
{$row['website_id']}
|
| 1688 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
| 1689 |
+
)";
|
| 1690 |
+
$result2 = $this->db_do($sql);
|
| 1691 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1692 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1693 |
|
| 1694 |
+
}
|
| 1695 |
|
|
|
|
| 1696 |
#################################################################################################
|
| 1697 |
+
public function replaceMagentoProducts() {
|
| 1698 |
+
|
| 1699 |
+
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
| 1700 |
+
|
| 1701 |
+
$result = $this->db_do("DELETE cpe
|
| 1702 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1703 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')." pm
|
| 1704 |
+
ON cpe.entity_id=pm.entity_id
|
| 1705 |
+
WHERE pm.shop_store_product_id IS NOT NULL
|
| 1706 |
+
AND pm.store_product_id IS NULL
|
| 1707 |
+
");
|
| 1708 |
+
|
| 1709 |
+
//Inserting new products and updating old others.
|
| 1710 |
+
$this->_getProductDefaulAttributeSetId();
|
| 1711 |
+
$result = $this->db_do("
|
| 1712 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." (
|
| 1713 |
+
entity_id,
|
| 1714 |
+
entity_type_id,
|
| 1715 |
+
attribute_set_id,
|
| 1716 |
+
type_id,
|
| 1717 |
+
sku,
|
| 1718 |
+
updated_at,
|
| 1719 |
+
has_options,
|
| 1720 |
+
store_product_id,
|
| 1721 |
+
sinch_product_id
|
| 1722 |
+
)(SELECT
|
| 1723 |
+
pm.entity_id,
|
| 1724 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 1725 |
+
$this->defaultAttributeSetId,
|
| 1726 |
+
'simple',
|
| 1727 |
+
a.product_sku,
|
| 1728 |
+
NOW(),
|
| 1729 |
+
0,
|
| 1730 |
+
a.store_product_id,
|
| 1731 |
+
a.sinch_product_id
|
| 1732 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('products_temp')." a
|
| 1733 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')." pm
|
| 1734 |
+
ON a.store_product_id=pm.store_product_id
|
| 1735 |
+
AND a.sinch_product_id=pm.sinch_product_id
|
| 1736 |
+
)
|
| 1737 |
+
ON DUPLICATE KEY UPDATE
|
| 1738 |
+
sku= a.product_sku,
|
| 1739 |
+
store_product_id=a.store_product_id,
|
| 1740 |
+
sinch_product_id=a.sinch_product_id
|
| 1741 |
+
");
|
| 1742 |
+
// store_product_id=a.store_product_id,
|
| 1743 |
+
// sinch_product_id=a.sinch_product_id
|
| 1744 |
+
|
| 1745 |
+
//Set enabled
|
| 1746 |
+
$result = $this->db_do("DELETE cpei
|
| 1747 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." cpei
|
| 1748 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1749 |
+
ON cpei.entity_id=cpe.entity_id
|
| 1750 |
+
WHERE cpe.entity_id IS NULL");
|
| 1751 |
+
|
| 1752 |
+
$result = $this->db_do("
|
| 1753 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." (
|
| 1754 |
+
entity_type_id,
|
| 1755 |
+
attribute_id,
|
| 1756 |
+
store_id,
|
| 1757 |
+
entity_id,
|
| 1758 |
+
value
|
| 1759 |
+
)(
|
| 1760 |
+
SELECT
|
| 1761 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 1762 |
+
". $this->_getProductAttributeId('status').",
|
| 1763 |
+
w.website,
|
| 1764 |
+
a.entity_id,
|
| 1765 |
+
1
|
| 1766 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 1767 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 1768 |
+
ON a.store_product_id=w.store_product_id
|
| 1769 |
+
)
|
| 1770 |
+
ON DUPLICATE KEY UPDATE
|
| 1771 |
+
value=1
|
| 1772 |
+
");
|
| 1773 |
+
// set status = 1 for all stores
|
| 1774 |
+
$result = $this->db_do("
|
| 1775 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." (
|
| 1776 |
+
entity_type_id,
|
| 1777 |
+
attribute_id,
|
| 1778 |
+
store_id,
|
| 1779 |
+
entity_id,
|
| 1780 |
+
value
|
| 1781 |
+
)(SELECT
|
| 1782 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 1783 |
+
".$this->_getProductAttributeId('status').",
|
| 1784 |
+
0,
|
| 1785 |
+
a.entity_id,
|
| 1786 |
+
1
|
| 1787 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 1788 |
+
)
|
| 1789 |
+
ON DUPLICATE KEY UPDATE
|
| 1790 |
+
value=1
|
| 1791 |
+
");
|
| 1792 |
+
|
| 1793 |
+
//Unifying products with categories.
|
| 1794 |
+
$result = $this->db_do("DELETE ccp
|
| 1795 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." ccp
|
| 1796 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1797 |
+
ON ccp.product_id=cpe.entity_id
|
| 1798 |
+
WHERE cpe.entity_id IS NULL");
|
| 1799 |
+
|
| 1800 |
+
$result = $this->db_do("UPDATE IGNORE ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." ccp
|
| 1801 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." cce
|
| 1802 |
+
ON ccp.category_id=cce.entity_id
|
| 1803 |
+
SET ccp.category_id=".$this->_root_cat."
|
| 1804 |
+
WHERE cce.entity_id IS NULL");
|
| 1805 |
+
|
| 1806 |
+
$result = $this->db_do("DELETE ccp FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." ccp
|
| 1807 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." cce
|
| 1808 |
+
ON ccp.category_id=cce.entity_id
|
| 1809 |
+
WHERE cce.entity_id IS NULL");
|
| 1810 |
+
|
| 1811 |
+
|
| 1812 |
+
$this->db_do(" DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')."_for_delete_temp");
|
| 1813 |
+
// TEMPORARY
|
| 1814 |
+
$this->db_do("
|
| 1815 |
+
CREATE TABLE `".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')."_for_delete_temp` (
|
| 1816 |
+
`category_id` int(10) unsigned NOT NULL default '0',
|
| 1817 |
+
`product_id` int(10) unsigned NOT NULL default '0',
|
| 1818 |
+
`store_product_id` int(10) NOT NULL default '0',
|
| 1819 |
+
`store_category_id` int(10) NOT NULL default '0',
|
| 1820 |
+
`new_category_id` int(10) NOT NULL default '0',
|
|
|
|
|
|
|
|
|
|
| 1821 |
UNIQUE KEY `UNQ_CATEGORY_PRODUCT` (`category_id`,`product_id`),
|
| 1822 |
KEY `CATALOG_CATEGORY_PRODUCT_CATEGORY` (`category_id`),
|
| 1823 |
KEY `CATALOG_CATEGORY_PRODUCT_PRODUCT` (`product_id`),
|
| 1824 |
KEY `CATALOG_NEW_CATEGORY_PRODUCT_CATEGORY` (`new_category_id`)
|
| 1825 |
)
|
| 1826 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1827 |
");
|
| 1828 |
|
| 1829 |
+
$result = $this->db_do("
|
| 1830 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')."_for_delete_temp (
|
| 1831 |
+
category_id,
|
| 1832 |
+
product_id,
|
| 1833 |
+
store_product_id
|
| 1834 |
+
)(SELECT
|
| 1835 |
+
ccp.category_id,
|
| 1836 |
+
ccp.product_id,
|
| 1837 |
+
cpe.store_product_id
|
| 1838 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." ccp
|
| 1839 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1840 |
+
ON ccp.product_id=cpe.entity_id
|
| 1841 |
+
WHERE store_product_id is not null
|
| 1842 |
+
)
|
| 1843 |
+
");
|
| 1844 |
+
|
| 1845 |
+
$result = $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')."_for_delete_temp ccpfd
|
| 1846 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
| 1847 |
+
ON ccpfd.store_product_id=p.store_product_id
|
| 1848 |
+
SET ccpfd.store_category_id=p.store_category_id
|
| 1849 |
+
WHERE ccpfd.store_product_id!=0
|
| 1850 |
+
");
|
| 1851 |
+
|
| 1852 |
+
$result = $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')."_for_delete_temp ccpfd
|
| 1853 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 1854 |
+
ON ccpfd.store_category_id=scm.store_category_id
|
| 1855 |
+
SET ccpfd.new_category_id=scm.shop_entity_id
|
| 1856 |
+
WHERE ccpfd.store_category_id!=0
|
| 1857 |
+
");
|
| 1858 |
+
|
| 1859 |
+
$result = $this->db_do("DELETE FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')."_for_delete_temp
|
| 1860 |
+
WHERE category_id=new_category_id");
|
| 1861 |
+
|
| 1862 |
+
$result = $this->db_do("
|
| 1863 |
+
DELETE ccp
|
| 1864 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." ccp
|
| 1865 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')."_for_delete_temp ccpfd
|
| 1866 |
+
ON ccp.product_id=ccpfd.product_id
|
| 1867 |
+
AND ccp.category_id=ccpfd.category_id
|
| 1868 |
+
");
|
| 1869 |
+
|
| 1870 |
+
$result = $this->db_do("
|
| 1871 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." (
|
| 1872 |
+
category_id,
|
| 1873 |
+
product_id
|
| 1874 |
+
)(SELECT
|
| 1875 |
+
scm.shop_entity_id,
|
| 1876 |
+
cpe.entity_id
|
| 1877 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1878 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
| 1879 |
+
ON cpe.store_product_id=p.store_product_id
|
| 1880 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 1881 |
+
ON p.store_category_id=scm.store_category_id
|
| 1882 |
+
)
|
| 1883 |
+
ON DUPLICATE KEY UPDATE
|
| 1884 |
+
product_id = cpe.entity_id
|
| 1885 |
+
");
|
| 1886 |
+
|
| 1887 |
+
//Indexing products and categories in the shop
|
| 1888 |
+
$result = $this->db_do("DELETE ccpi
|
| 1889 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." ccpi
|
| 1890 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1891 |
+
ON ccpi.product_id=cpe.entity_id
|
| 1892 |
+
WHERE cpe.entity_id IS NULL");
|
| 1893 |
+
|
| 1894 |
+
$result = $this->db_do("
|
| 1895 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." (
|
| 1896 |
+
category_id,
|
| 1897 |
+
product_id,
|
| 1898 |
+
position,
|
| 1899 |
+
is_parent,
|
| 1900 |
+
store_id,
|
| 1901 |
+
visibility
|
| 1902 |
+
)(
|
| 1903 |
+
SELECT
|
| 1904 |
+
a.category_id,
|
| 1905 |
+
a.product_id,
|
| 1906 |
+
a.position,
|
| 1907 |
+
1,
|
| 1908 |
+
b.store_id,
|
| 1909 |
+
4
|
| 1910 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." a
|
| 1911 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." b
|
| 1912 |
+
)
|
| 1913 |
+
ON DUPLICATE KEY UPDATE
|
| 1914 |
+
visibility = 4
|
| 1915 |
+
");
|
| 1916 |
+
|
| 1917 |
+
$result = $this->db_do("
|
| 1918 |
+
INSERT ignore INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." (
|
| 1919 |
+
category_id,
|
| 1920 |
+
product_id,
|
| 1921 |
+
position,
|
| 1922 |
+
is_parent,
|
| 1923 |
+
store_id,
|
| 1924 |
+
visibility
|
| 1925 |
+
)(
|
| 1926 |
+
SELECT
|
| 1927 |
+
".$this->_root_cat.",
|
| 1928 |
+
a.product_id,
|
| 1929 |
+
a.position,
|
| 1930 |
+
1,
|
| 1931 |
+
b.store_id,
|
| 1932 |
+
4
|
| 1933 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." a
|
| 1934 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." b
|
| 1935 |
+
)
|
| 1936 |
+
ON DUPLICATE KEY UPDATE
|
| 1937 |
+
visibility = 4
|
| 1938 |
+
");
|
| 1939 |
+
|
| 1940 |
+
//Set product name for specific web sites
|
| 1941 |
+
$result = $this->db_do("DELETE cpev
|
| 1942 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." cpev
|
| 1943 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 1944 |
+
ON cpev.entity_id=cpe.entity_id
|
| 1945 |
+
WHERE cpe.entity_id IS NULL");
|
| 1946 |
+
$result = $this->db_do("
|
| 1947 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 1948 |
+
entity_type_id,
|
| 1949 |
+
attribute_id,
|
| 1950 |
+
store_id,
|
| 1951 |
+
entity_id,
|
| 1952 |
+
value
|
| 1953 |
+
)(SELECT
|
| 1954 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 1955 |
+
" . $this->_getProductAttributeId('name'). ",
|
| 1956 |
+
w.website,
|
| 1957 |
+
a.entity_id,
|
| 1958 |
+
b.product_name
|
| 1959 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 1960 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 1961 |
+
ON a.store_product_id= b.store_product_id
|
| 1962 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 1963 |
+
ON a.store_product_id=w.store_product_id
|
| 1964 |
+
)
|
| 1965 |
+
ON DUPLICATE KEY UPDATE
|
| 1966 |
+
value = b.product_name
|
| 1967 |
+
");
|
| 1968 |
+
|
| 1969 |
+
// product name for all web sites
|
| 1970 |
+
$result = $this->db_do("
|
| 1971 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 1972 |
+
entity_type_id,
|
| 1973 |
+
attribute_id,
|
| 1974 |
+
store_id,
|
| 1975 |
+
entity_id,
|
| 1976 |
+
value
|
| 1977 |
+
)(
|
| 1978 |
+
SELECT
|
| 1979 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 1980 |
+
" . $this->_getProductAttributeId('name'). ",
|
| 1981 |
+
0,
|
| 1982 |
+
a.entity_id,
|
| 1983 |
+
b.product_name
|
| 1984 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 1985 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 1986 |
+
ON a.store_product_id = b.store_product_id
|
| 1987 |
+
)
|
| 1988 |
+
ON DUPLICATE KEY UPDATE
|
| 1989 |
+
value = b.product_name
|
| 1990 |
+
");
|
| 1991 |
+
|
| 1992 |
+
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
| 1993 |
+
$this->addDescriptions();
|
| 1994 |
+
$this->addShortDescriptions();
|
| 1995 |
+
$this->addEAN();
|
| 1996 |
+
$this->addSpecification();
|
| 1997 |
+
$this->addManufacturers();
|
| 1998 |
+
|
| 1999 |
+
//Enabling product index.
|
| 2000 |
+
$result = $this->db_do("DELETE cpei
|
| 2001 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index')." cpei
|
| 2002 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 2003 |
+
ON cpei.product_id=cpe.entity_id
|
| 2004 |
+
WHERE cpe.entity_id IS NULL");
|
| 2005 |
+
|
| 2006 |
+
$result = $this->db_do("
|
| 2007 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index')." (
|
| 2008 |
+
product_id,
|
| 2009 |
+
store_id,
|
| 2010 |
+
visibility
|
| 2011 |
+
)(
|
| 2012 |
+
SELECT
|
| 2013 |
+
a.entity_id,
|
| 2014 |
+
w.website,
|
| 2015 |
+
4
|
| 2016 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2017 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2018 |
+
ON a.store_product_id=w.store_product_id
|
| 2019 |
+
)
|
| 2020 |
+
ON DUPLICATE KEY UPDATE
|
| 2021 |
+
visibility = 4
|
| 2022 |
+
");
|
| 2023 |
+
$result = $this->db_do("
|
| 2024 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index')." (
|
| 2025 |
+
product_id,
|
| 2026 |
+
store_id,
|
| 2027 |
+
visibility
|
| 2028 |
+
)(
|
| 2029 |
+
SELECT
|
| 2030 |
+
a.entity_id,
|
| 2031 |
+
0,
|
| 2032 |
+
4
|
| 2033 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2034 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2035 |
+
ON a.store_product_id=w.store_product_id
|
| 2036 |
+
)
|
| 2037 |
+
ON DUPLICATE KEY UPDATE
|
| 2038 |
+
visibility = 4
|
| 2039 |
+
");
|
| 2040 |
+
|
| 2041 |
+
|
| 2042 |
+
$result = $this->db_do("
|
| 2043 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." (
|
| 2044 |
+
entity_type_id,
|
| 2045 |
+
attribute_id,
|
| 2046 |
+
store_id,
|
| 2047 |
+
entity_id,
|
| 2048 |
+
value
|
| 2049 |
+
)(
|
| 2050 |
+
SELECT
|
| 2051 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2052 |
+
" . $this->_getProductAttributeId('visibility'). ",
|
| 2053 |
+
w.website,
|
| 2054 |
+
a.entity_id,
|
| 2055 |
+
4
|
| 2056 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2057 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2058 |
+
ON a.store_product_id=w.store_product_id
|
| 2059 |
+
)
|
| 2060 |
+
ON DUPLICATE KEY UPDATE
|
| 2061 |
+
value = 4
|
| 2062 |
+
");
|
| 2063 |
+
|
| 2064 |
+
$result = $this->db_do("
|
| 2065 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." (
|
| 2066 |
+
entity_type_id,
|
| 2067 |
+
attribute_id,
|
| 2068 |
+
store_id,
|
| 2069 |
+
entity_id,
|
| 2070 |
+
value
|
| 2071 |
+
)(
|
| 2072 |
+
SELECT
|
| 2073 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2074 |
+
" . $this->_getProductAttributeId('visibility'). ",
|
| 2075 |
+
0,
|
| 2076 |
+
a.entity_id,
|
| 2077 |
+
4
|
| 2078 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2079 |
+
)
|
| 2080 |
+
ON DUPLICATE KEY UPDATE
|
| 2081 |
+
value = 4
|
| 2082 |
+
");
|
| 2083 |
+
|
| 2084 |
+
$result = $this->db_do("DELETE cpw
|
| 2085 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_website')." cpw
|
| 2086 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 2087 |
+
ON cpw.product_id=cpe.entity_id
|
| 2088 |
+
WHERE cpe.entity_id IS NULL");
|
| 2089 |
+
|
| 2090 |
+
$result = $this->db_do("
|
| 2091 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_website')." (
|
| 2092 |
+
product_id,
|
| 2093 |
+
website_id
|
| 2094 |
+
)(
|
| 2095 |
+
SELECT a.entity_id, w.website_id
|
| 2096 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2097 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2098 |
+
ON a.store_product_id=w.store_product_id
|
| 2099 |
+
)
|
| 2100 |
+
ON DUPLICATE KEY UPDATE
|
| 2101 |
+
product_id=a.entity_id,
|
| 2102 |
+
website_id=w.website_id
|
| 2103 |
+
");
|
| 2104 |
+
|
| 2105 |
+
// temporary disabled mart@bintime.com
|
| 2106 |
+
//$result = $this->db_do("
|
| 2107 |
+
// UPDATE catalog_category_entity_int a
|
| 2108 |
+
// SET a.value = 0
|
| 2109 |
+
// WHERE a.attribute_id = 32
|
| 2110 |
+
//");
|
| 2111 |
+
|
| 2112 |
+
|
| 2113 |
+
//Adding tax class "Taxable Goods"
|
| 2114 |
+
$result = $this->db_do("
|
| 2115 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." (
|
| 2116 |
+
entity_type_id,
|
| 2117 |
+
attribute_id,
|
| 2118 |
+
store_id,
|
| 2119 |
+
entity_id,
|
| 2120 |
+
value
|
| 2121 |
+
)(
|
| 2122 |
+
SELECT
|
| 2123 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2124 |
+
" . $this->_getProductAttributeId('tax_class_id'). ",
|
| 2125 |
+
w.website,
|
| 2126 |
+
a.entity_id,
|
| 2127 |
+
2
|
| 2128 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2129 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2130 |
+
ON a.store_product_id=w.store_product_id
|
| 2131 |
+
)
|
| 2132 |
+
ON DUPLICATE KEY UPDATE
|
| 2133 |
+
value = 2
|
| 2134 |
");
|
| 2135 |
+
$result = $this->db_do("
|
| 2136 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." (
|
| 2137 |
+
entity_type_id,
|
| 2138 |
+
attribute_id,
|
| 2139 |
+
store_id,
|
| 2140 |
+
entity_id,
|
| 2141 |
+
value
|
| 2142 |
+
)(
|
| 2143 |
+
SELECT
|
| 2144 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2145 |
+
" . $this->_getProductAttributeId('tax_class_id'). ",
|
| 2146 |
+
0,
|
| 2147 |
+
a.entity_id,
|
| 2148 |
+
2
|
| 2149 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2150 |
+
)
|
| 2151 |
+
ON DUPLICATE KEY UPDATE
|
| 2152 |
+
value = 2
|
| 2153 |
+
");
|
| 2154 |
+
|
| 2155 |
+
// Load url Image
|
| 2156 |
+
$result = $this->db_do("
|
| 2157 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2158 |
+
entity_type_id,
|
| 2159 |
+
attribute_id,
|
| 2160 |
+
store_id,
|
| 2161 |
+
entity_id,
|
| 2162 |
+
value
|
| 2163 |
+
)(
|
| 2164 |
+
SELECT
|
| 2165 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2166 |
+
" . $this->_getProductAttributeId('image'). ",
|
| 2167 |
+
w.store_id,
|
| 2168 |
+
a.entity_id,
|
| 2169 |
+
b.main_image_url
|
| 2170 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2171 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." w
|
| 2172 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2173 |
+
ON a.store_product_id = b.store_product_id
|
| 2174 |
+
)
|
| 2175 |
+
ON DUPLICATE KEY UPDATE
|
| 2176 |
+
value = b.main_image_url
|
| 2177 |
+
");
|
| 2178 |
+
|
| 2179 |
+
|
| 2180 |
+
// image for specific web sites
|
| 2181 |
+
$result = $this->db_do("
|
| 2182 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2183 |
+
entity_type_id,
|
| 2184 |
+
attribute_id,
|
| 2185 |
+
store_id,
|
| 2186 |
+
entity_id,
|
| 2187 |
+
value
|
| 2188 |
+
)(
|
| 2189 |
+
SELECT
|
| 2190 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2191 |
+
" . $this->_getProductAttributeId('image'). ",
|
| 2192 |
+
0,
|
| 2193 |
+
a.entity_id,
|
| 2194 |
+
b.main_image_url
|
| 2195 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2196 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2197 |
+
ON a.store_product_id = b.store_product_id
|
| 2198 |
+
)
|
| 2199 |
+
ON DUPLICATE KEY UPDATE
|
| 2200 |
+
value = b.main_image_url
|
| 2201 |
+
");
|
| 2202 |
+
|
| 2203 |
+
|
| 2204 |
+
// small_image for specific web sites
|
| 2205 |
+
$result = $this->db_do("
|
| 2206 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2207 |
+
entity_type_id,
|
| 2208 |
+
attribute_id,
|
| 2209 |
+
store_id,
|
| 2210 |
+
entity_id,
|
| 2211 |
+
value
|
| 2212 |
+
)(
|
| 2213 |
+
SELECT
|
| 2214 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2215 |
+
" . $this->_getProductAttributeId('small_image'). ",
|
| 2216 |
+
w.store_id,
|
| 2217 |
+
a.entity_id,
|
| 2218 |
+
b.medium_image_url
|
| 2219 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2220 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." w
|
| 2221 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2222 |
+
ON a.store_product_id = b.store_product_id
|
| 2223 |
+
)
|
| 2224 |
+
ON DUPLICATE KEY UPDATE
|
| 2225 |
+
value = b.medium_image_url
|
| 2226 |
+
");
|
| 2227 |
+
|
| 2228 |
+
|
| 2229 |
+
// small_image for all web sites
|
| 2230 |
+
$result = $this->db_do("
|
| 2231 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2232 |
+
entity_type_id,
|
| 2233 |
+
attribute_id,
|
| 2234 |
+
store_id,
|
| 2235 |
+
entity_id,
|
| 2236 |
+
value
|
| 2237 |
+
)(
|
| 2238 |
+
SELECT
|
| 2239 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2240 |
+
" . $this->_getProductAttributeId('small_image'). ",
|
| 2241 |
+
0,
|
| 2242 |
+
a.entity_id,
|
| 2243 |
+
b.medium_image_url
|
| 2244 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2245 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." w
|
| 2246 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2247 |
+
ON a.store_product_id = b.store_product_id
|
| 2248 |
+
)
|
| 2249 |
+
ON DUPLICATE KEY UPDATE
|
| 2250 |
+
value = b.medium_image_url
|
| 2251 |
+
");
|
| 2252 |
+
|
| 2253 |
+
|
| 2254 |
+
// thumbnail for specific web site
|
| 2255 |
+
$result = $this->db_do("
|
| 2256 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2257 |
+
entity_type_id,
|
| 2258 |
+
attribute_id,
|
| 2259 |
+
store_id,
|
| 2260 |
+
entity_id,
|
| 2261 |
+
value
|
| 2262 |
+
)(
|
| 2263 |
+
SELECT
|
| 2264 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2265 |
+
" . $this->_getProductAttributeId('thumbnail'). ",
|
| 2266 |
+
w.store_id,
|
| 2267 |
+
a.entity_id,
|
| 2268 |
+
b.thumb_image_url
|
| 2269 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2270 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." w
|
| 2271 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2272 |
+
ON a.store_product_id = b.store_product_id
|
| 2273 |
+
)
|
| 2274 |
+
ON DUPLICATE KEY UPDATE
|
| 2275 |
+
value = b.thumb_image_url
|
| 2276 |
+
");
|
| 2277 |
+
|
| 2278 |
+
|
| 2279 |
+
// thumbnail for all web sites
|
| 2280 |
+
$result = $this->db_do("
|
| 2281 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2282 |
+
entity_type_id,
|
| 2283 |
+
attribute_id,
|
| 2284 |
+
store_id,
|
| 2285 |
+
entity_id,
|
| 2286 |
+
value
|
| 2287 |
+
)(
|
| 2288 |
+
SELECT
|
| 2289 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2290 |
+
" . $this->_getProductAttributeId('thumbnail'). ",
|
| 2291 |
+
0,
|
| 2292 |
+
a.entity_id,
|
| 2293 |
+
b.thumb_image_url
|
| 2294 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2295 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." w
|
| 2296 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2297 |
+
ON a.store_product_id = b.store_product_id
|
| 2298 |
+
)
|
| 2299 |
+
ON DUPLICATE KEY UPDATE
|
| 2300 |
+
value = b.thumb_image_url
|
| 2301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2302 |
");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2304 |
|
| 2305 |
+
//Refresh fulltext search
|
| 2306 |
+
$result = $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp");
|
| 2307 |
+
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS
|
| 2308 |
+
".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp
|
| 2309 |
+
LIKE ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext'));
|
| 2310 |
+
|
| 2311 |
+
$result = $this->db_do("
|
| 2312 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp (
|
| 2313 |
+
product_id,
|
| 2314 |
+
store_id,
|
| 2315 |
+
data_index
|
| 2316 |
+
)(
|
| 2317 |
+
SELECT
|
| 2318 |
+
a.entity_id,
|
| 2319 |
+
w.website_id,
|
| 2320 |
+
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
| 2321 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2322 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2323 |
+
ON a.store_product_id=w.store_product_id
|
| 2324 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." b
|
| 2325 |
+
ON a.entity_id = b.product_id
|
| 2326 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." c
|
| 2327 |
+
ON b.category_id = c.entity_id
|
| 2328 |
+
AND c.attribute_id = " . $this->_getCategoryAttributeId('name'). "
|
| 2329 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." e
|
| 2330 |
+
ON a.entity_id = e.entity_id
|
| 2331 |
+
AND e.attribute_id = " . $this->_getProductAttributeId('name'). "
|
| 2332 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_website')." j
|
| 2333 |
+
ON a.entity_id = j.product_id
|
| 2334 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." f
|
| 2335 |
+
ON a.entity_id = f.store_product_id
|
| 2336 |
+
)
|
| 2337 |
+
ON DUPLICATE KEY UPDATE
|
| 2338 |
+
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
| 2339 |
+
");
|
| 2340 |
+
|
| 2341 |
+
$result = $this->db_do("
|
| 2342 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp (
|
| 2343 |
+
product_id,
|
| 2344 |
+
store_id,
|
| 2345 |
+
data_index
|
| 2346 |
+
)(
|
| 2347 |
+
SELECT
|
| 2348 |
+
a.entity_id,
|
| 2349 |
+
w.website_id,
|
| 2350 |
+
CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
| 2351 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2352 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2353 |
+
ON a.store_product_id=w.store_product_id
|
| 2354 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." b
|
| 2355 |
+
ON a.entity_id = b.product_id
|
| 2356 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." c
|
| 2357 |
+
ON b.category_id = c.entity_id
|
| 2358 |
+
AND c.attribute_id = " . $this->_getCategoryAttributeId('name'). "
|
| 2359 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." e
|
| 2360 |
+
ON a.entity_id = e.entity_id
|
| 2361 |
+
AND e.attribute_id = " . $this->_getProductAttributeId('name'). "
|
| 2362 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." f
|
| 2363 |
+
ON a.entity_id = f.store_product_id
|
| 2364 |
+
)
|
| 2365 |
+
ON DUPLICATE KEY UPDATE
|
| 2366 |
+
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
| 2367 |
+
");
|
| 2368 |
+
|
| 2369 |
+
$result = $this->db_do("DELETE cf
|
| 2370 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')." cf
|
| 2371 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 2372 |
+
ON cf.product_id=cpe.entity_id
|
| 2373 |
+
WHERE cpe.entity_id is null");
|
| 2374 |
+
|
| 2375 |
+
$result = $this->db_do("
|
| 2376 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')." (
|
| 2377 |
+
product_id,
|
| 2378 |
+
store_id,
|
| 2379 |
+
data_index
|
| 2380 |
+
)(
|
| 2381 |
+
SELECT
|
| 2382 |
+
a.product_id,
|
| 2383 |
+
a.store_id,
|
| 2384 |
+
a.data_index
|
| 2385 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp a
|
| 2386 |
+
WHERE product_id = a.product_id
|
| 2387 |
+
)
|
| 2388 |
+
ON DUPLICATE KEY UPDATE
|
| 2389 |
+
data_index = a.data_index
|
| 2390 |
+
");
|
| 2391 |
+
|
| 2392 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_query')." SET is_processed = 0");
|
| 2393 |
+
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
| 2394 |
+
//TODO add something else
|
| 2395 |
+
|
| 2396 |
+
$this->addRelatedProducts();
|
| 2397 |
+
}
|
| 2398 |
|
|
|
|
|
|
|
| 2399 |
#################################################################################################
|
| 2400 |
+
function addDescriptions(){
|
| 2401 |
// product description for all web sites
|
| 2402 |
+
$result = $this->db_do("
|
| 2403 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')." (
|
| 2404 |
+
entity_type_id,
|
| 2405 |
+
attribute_id,
|
| 2406 |
+
store_id,
|
| 2407 |
+
entity_id,
|
| 2408 |
+
value
|
| 2409 |
+
)(
|
| 2410 |
+
SELECT
|
| 2411 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2412 |
+
" . $this->_getProductAttributeId('description'). ",
|
| 2413 |
+
w.website,
|
| 2414 |
+
a.entity_id,
|
| 2415 |
+
b.description
|
| 2416 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2417 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2418 |
+
ON a.store_product_id = b.store_product_id
|
| 2419 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2420 |
+
ON a.store_product_id=w.store_product_id
|
| 2421 |
+
)
|
| 2422 |
+
ON DUPLICATE KEY UPDATE
|
| 2423 |
+
value = b.description
|
| 2424 |
+
");
|
| 2425 |
+
|
| 2426 |
+
// product description for all web sites
|
| 2427 |
+
$result = $this->db_do("
|
| 2428 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')." (
|
| 2429 |
+
entity_type_id,
|
| 2430 |
+
attribute_id,
|
| 2431 |
+
store_id,
|
| 2432 |
+
entity_id,
|
| 2433 |
+
value
|
| 2434 |
+
)(
|
| 2435 |
+
SELECT
|
| 2436 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2437 |
+
" . $this->_getProductAttributeId('description'). ",
|
| 2438 |
+
0,
|
| 2439 |
+
a.entity_id,
|
| 2440 |
+
b.description
|
| 2441 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2442 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2443 |
+
ON a.store_product_id = b.store_product_id
|
| 2444 |
+
)
|
| 2445 |
+
ON DUPLICATE KEY UPDATE
|
| 2446 |
+
value = b.description
|
| 2447 |
+
");
|
| 2448 |
|
|
|
|
| 2449 |
|
| 2450 |
+
}
|
| 2451 |
|
|
|
|
| 2452 |
#################################################################################################
|
| 2453 |
+
function addShortDescriptions(){
|
| 2454 |
// product short description for all web sites
|
| 2455 |
+
$result = $this->db_do("
|
| 2456 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2457 |
+
entity_type_id,
|
| 2458 |
+
attribute_id,
|
| 2459 |
+
store_id,
|
| 2460 |
+
entity_id,
|
| 2461 |
+
value
|
| 2462 |
+
)(
|
| 2463 |
+
SELECT
|
| 2464 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2465 |
+
" . $this->_getProductAttributeId('short_description'). ",
|
| 2466 |
+
w.website,
|
| 2467 |
+
a.entity_id,
|
| 2468 |
+
' '
|
| 2469 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2470 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2471 |
+
ON a.store_product_id = b.store_product_id
|
| 2472 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2473 |
+
ON a.store_product_id=w.store_product_id
|
| 2474 |
+
)
|
| 2475 |
+
ON DUPLICATE KEY UPDATE
|
| 2476 |
+
value = ' '
|
| 2477 |
+
");
|
| 2478 |
+
// product short description for all web sites
|
| 2479 |
+
$result = $this->db_do("
|
| 2480 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2481 |
+
entity_type_id,
|
| 2482 |
+
attribute_id,
|
| 2483 |
+
store_id,
|
| 2484 |
+
entity_id,
|
| 2485 |
+
value
|
| 2486 |
+
)(
|
| 2487 |
+
SELECT
|
| 2488 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2489 |
+
" . $this->_getProductAttributeId('short_description'). ",
|
| 2490 |
+
0,
|
| 2491 |
+
a.entity_id,
|
| 2492 |
+
' '
|
| 2493 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2494 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2495 |
+
ON a.store_product_id = b.store_product_id
|
| 2496 |
+
)
|
| 2497 |
+
ON DUPLICATE KEY UPDATE
|
| 2498 |
+
value = ' '
|
| 2499 |
+
");
|
| 2500 |
|
| 2501 |
+
}
|
| 2502 |
|
| 2503 |
#################################################################################################
|
| 2504 |
+
function addEAN(){
|
| 2505 |
//gather EAN codes for each product
|
| 2506 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('EANs_temp'));
|
| 2507 |
+
$this->db_do("
|
| 2508 |
+
CREATE TEMPORARY TABLE ".Mage::getSingleton('core/resource')->getTableName('EANs_temp')." (
|
| 2509 |
sinch_product_id int(11),
|
| 2510 |
store_product_id int(11),
|
| 2511 |
EANs text,
|
| 2512 |
KEY `sinch_product_id` (`sinch_product_id`),
|
| 2513 |
KEY `store_product_id` (`store_product_id`)
|
| 2514 |
+
)
|
| 2515 |
");
|
| 2516 |
+
$this->db_do("
|
| 2517 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('EANs_temp')." (
|
| 2518 |
+
sinch_product_id,
|
| 2519 |
+
EANs
|
| 2520 |
+
)(SELECT
|
| 2521 |
+
sec.product_id,
|
| 2522 |
+
GROUP_CONCAT(DISTINCT ean_code ORDER BY ean_code DESC SEPARATOR ', ') AS eans
|
| 2523 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_ean_codes')." sec
|
| 2524 |
+
GROUP BY sec.product_id
|
| 2525 |
+
)
|
| 2526 |
+
");
|
| 2527 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('EANs_temp')." e
|
| 2528 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
| 2529 |
+
ON e.sinch_product_id=p.sinch_product_id
|
| 2530 |
+
SET e.store_product_id=p.store_product_id");
|
| 2531 |
// product EANs for all web sites
|
| 2532 |
+
$result = $this->db_do("
|
| 2533 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2534 |
+
entity_type_id,
|
| 2535 |
+
attribute_id,
|
| 2536 |
+
store_id,
|
| 2537 |
+
entity_id,
|
| 2538 |
+
value
|
| 2539 |
+
)(
|
| 2540 |
+
SELECT
|
| 2541 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2542 |
+
" . $this->_getProductAttributeId('ean'). ",
|
| 2543 |
+
w.website,
|
| 2544 |
+
a.entity_id,
|
| 2545 |
+
e.EANs
|
| 2546 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2547 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('EANs_temp')." e
|
| 2548 |
+
ON a.store_product_id = e.store_product_id
|
| 2549 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2550 |
+
ON a.store_product_id=w.store_product_id
|
| 2551 |
+
)
|
| 2552 |
+
ON DUPLICATE KEY UPDATE
|
| 2553 |
+
value = e.EANs
|
| 2554 |
");
|
| 2555 |
|
| 2556 |
+
// product EANs for all web sites
|
| 2557 |
+
$result = $this->db_do("
|
| 2558 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 2559 |
+
entity_type_id,
|
| 2560 |
+
attribute_id,
|
| 2561 |
+
store_id,
|
| 2562 |
+
entity_id,
|
| 2563 |
+
value
|
| 2564 |
+
)(
|
| 2565 |
+
SELECT
|
| 2566 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2567 |
+
" . $this->_getProductAttributeId('ean'). ",
|
| 2568 |
+
0,
|
| 2569 |
+
a.entity_id,
|
| 2570 |
+
e.EANs
|
| 2571 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2572 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('EANs_temp')." e
|
| 2573 |
+
ON a.store_product_id = e.store_product_id
|
| 2574 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2575 |
+
ON a.store_product_id=w.store_product_id
|
| 2576 |
+
)
|
| 2577 |
+
ON DUPLICATE KEY UPDATE
|
| 2578 |
+
value = e.EANs
|
| 2579 |
+
");
|
| 2580 |
+
|
| 2581 |
+
}
|
| 2582 |
|
|
|
|
| 2583 |
################################################################################################
|
| 2584 |
+
function addSpecification(){
|
| 2585 |
// product specification for all web sites
|
| 2586 |
+
$result = $this->db_do("
|
| 2587 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')." (
|
| 2588 |
+
entity_type_id,
|
| 2589 |
+
attribute_id,
|
| 2590 |
+
store_id,
|
| 2591 |
+
entity_id,
|
| 2592 |
+
value
|
| 2593 |
+
)(
|
| 2594 |
+
SELECT
|
| 2595 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2596 |
+
" . $this->_getProductAttributeId('specification'). ",
|
| 2597 |
+
w.website,
|
| 2598 |
+
a.entity_id,
|
| 2599 |
+
b.specifications
|
| 2600 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2601 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2602 |
+
ON a.store_product_id = b.store_product_id
|
| 2603 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2604 |
+
ON a.store_product_id=w.store_product_id
|
| 2605 |
+
)
|
| 2606 |
+
ON DUPLICATE KEY UPDATE
|
| 2607 |
+
value = b.specifications
|
| 2608 |
");
|
| 2609 |
+
// product specification for all web sites
|
| 2610 |
+
$result = $this->db_do("
|
| 2611 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')." (
|
| 2612 |
+
entity_type_id,
|
| 2613 |
+
attribute_id,
|
| 2614 |
+
store_id,
|
| 2615 |
+
entity_id,
|
| 2616 |
+
value
|
| 2617 |
+
)(
|
| 2618 |
+
SELECT
|
| 2619 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2620 |
+
" . $this->_getProductAttributeId('specification'). ",
|
| 2621 |
+
0,
|
| 2622 |
+
a.entity_id,
|
| 2623 |
+
b.specifications
|
| 2624 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2625 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2626 |
+
ON a.store_product_id = b.store_product_id
|
| 2627 |
+
)
|
| 2628 |
+
ON DUPLICATE KEY UPDATE
|
| 2629 |
+
value = b.specifications
|
| 2630 |
+
");
|
| 2631 |
|
| 2632 |
|
| 2633 |
+
}
|
| 2634 |
|
| 2635 |
+
private function addManufacturer_attribute(){
|
| 2636 |
+
$result = $this->db_do("
|
| 2637 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." (
|
| 2638 |
+
entity_type_id,
|
| 2639 |
+
attribute_id,
|
| 2640 |
+
store_id,
|
| 2641 |
+
entity_id,
|
| 2642 |
+
value
|
| 2643 |
+
)(
|
| 2644 |
+
SELECT
|
| 2645 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2646 |
+
" . $this->_getProductAttributeId('manufacturer'). ",
|
| 2647 |
+
0,
|
| 2648 |
+
a.entity_id,
|
| 2649 |
+
pm.manufacturer_option_id
|
| 2650 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2651 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')." pm
|
| 2652 |
+
ON a.entity_id = pm.entity_id
|
| 2653 |
+
)
|
| 2654 |
+
ON DUPLICATE KEY UPDATE
|
| 2655 |
+
value = pm.manufacturer_option_id
|
| 2656 |
+
");
|
| 2657 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2658 |
|
| 2659 |
+
}
|
| 2660 |
|
|
|
|
| 2661 |
#################################################################################################
|
| 2662 |
+
function addManufacturers($delete_eav=null){
|
| 2663 |
+
// this cleanup is not needed due to foreign keys
|
| 2664 |
+
if(!$delete_eav){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2665 |
$result = $this->db_do("
|
| 2666 |
+
DELETE FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_eav')."
|
| 2667 |
+
WHERE attribute_id = ".$this->_getProductAttributeId('manufacturer')//." AND store_id = ".$websiteId
|
| 2668 |
+
);
|
| 2669 |
+
}
|
| 2670 |
+
$this->addManufacturer_attribute();
|
| 2671 |
+
// todo: doesn't seems to work properly, should be inserted per visibility
|
| 2672 |
+
// done, test now
|
| 2673 |
+
|
| 2674 |
+
$result = $this->db_do("
|
| 2675 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_eav')." (
|
| 2676 |
+
entity_id,
|
| 2677 |
+
attribute_id,
|
| 2678 |
+
store_id,
|
| 2679 |
+
value
|
| 2680 |
+
)(
|
| 2681 |
+
SELECT
|
| 2682 |
+
a.entity_id,
|
| 2683 |
+
" . $this->_getProductAttributeId('manufacturer'). ",
|
| 2684 |
+
w.website,
|
| 2685 |
+
mn.shop_option_id
|
| 2686 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2687 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2688 |
+
ON a.store_product_id = b.store_product_id
|
| 2689 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2690 |
+
ON a.store_product_id=w.store_product_id
|
| 2691 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')." mn
|
| 2692 |
+
ON b.sinch_manufacturer_id=mn.sinch_manufacturer_id
|
| 2693 |
+
WHERE mn.shop_option_id IS NOT NULL
|
| 2694 |
+
)
|
| 2695 |
+
ON DUPLICATE KEY UPDATE
|
| 2696 |
+
value = mn.shop_option_id
|
| 2697 |
+
");
|
| 2698 |
+
|
| 2699 |
+
$result = $this->db_do("
|
| 2700 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_eav')." (
|
| 2701 |
+
entity_id,
|
| 2702 |
+
attribute_id,
|
| 2703 |
+
store_id,
|
| 2704 |
+
value
|
| 2705 |
+
)(
|
| 2706 |
+
SELECT
|
| 2707 |
+
a.entity_id,
|
| 2708 |
+
" . $this->_getProductAttributeId('manufacturer'). ",
|
| 2709 |
+
0,
|
| 2710 |
+
mn.shop_option_id
|
| 2711 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2712 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
| 2713 |
+
ON a.store_product_id = b.store_product_id
|
| 2714 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2715 |
+
ON a.store_product_id=w.store_product_id
|
| 2716 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')." mn
|
| 2717 |
+
ON b.sinch_manufacturer_id=mn.sinch_manufacturer_id
|
| 2718 |
+
WHERE mn.shop_option_id IS NOT NULL
|
| 2719 |
+
)
|
| 2720 |
+
ON DUPLICATE KEY UPDATE
|
| 2721 |
+
value = mn.shop_option_id
|
| 2722 |
+
");
|
| 2723 |
|
| 2724 |
|
| 2725 |
+
}
|
| 2726 |
|
|
|
|
| 2727 |
#################################################################################################
|
| 2728 |
+
function addRelatedProducts(){
|
| 2729 |
+
|
| 2730 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_related_products')." rpt
|
| 2731 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
| 2732 |
+
ON rpt.sinch_product_id=p.sinch_product_id
|
| 2733 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 2734 |
+
ON p.store_product_id=cpe.store_product_id
|
| 2735 |
+
SET rpt.store_product_id=p.store_product_id, rpt.entity_id=cpe.entity_id");
|
| 2736 |
+
|
| 2737 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('stINch_related_products')." rpt
|
| 2738 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
| 2739 |
+
ON rpt.related_sinch_product_id=p.sinch_product_id
|
| 2740 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 2741 |
+
ON p.store_product_id=cpe.store_product_id
|
| 2742 |
+
SET rpt.store_related_product_id=p.store_product_id, rpt.related_entity_id=cpe.entity_id");
|
| 2743 |
+
|
| 2744 |
+
$result = $this->db_do("SELECT
|
| 2745 |
+
link_type_id,
|
| 2746 |
+
code
|
| 2747 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_type')
|
| 2748 |
+
);
|
| 2749 |
+
$link_type=array();
|
| 2750 |
+
while ($row = mysql_fetch_array($result)) {
|
| 2751 |
+
$link_type[$row['code']]=$row['link_type_id'];
|
| 2752 |
+
}
|
| 2753 |
+
|
| 2754 |
+
$result = $this->db_do("
|
| 2755 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link')." (
|
| 2756 |
+
product_id,
|
| 2757 |
+
linked_product_id,
|
| 2758 |
+
link_type_id
|
| 2759 |
+
)(
|
| 2760 |
+
SELECT
|
| 2761 |
+
entity_id,
|
| 2762 |
+
related_entity_id,
|
| 2763 |
+
".$link_type['relation']."
|
| 2764 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_related_products')."
|
| 2765 |
+
WHERE store_product_id IS NOT NULL
|
| 2766 |
+
AND store_related_product_id IS NOT NULL
|
| 2767 |
+
)
|
| 2768 |
+
ON DUPLICATE KEY UPDATE
|
| 2769 |
+
product_id = entity_id,
|
| 2770 |
+
linked_product_id = related_entity_id
|
| 2771 |
+
");
|
| 2772 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int')."_tmp");
|
| 2773 |
+
|
| 2774 |
+
$this->db_do("CREATE TEMPORARY TABLE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int')."_tmp (
|
| 2775 |
+
`value_id` int(11) default NULL,
|
| 2776 |
+
`product_link_attribute_id` smallint(6) unsigned default NULL,
|
| 2777 |
+
`link_id` int(11) unsigned default NULL,
|
| 2778 |
+
`value` int(11) NOT NULL default '0',
|
| 2779 |
+
KEY `FK_INT_PRODUCT_LINK_ATTRIBUTE` (`product_link_attribute_id`),
|
| 2780 |
+
KEY `FK_INT_PRODUCT_LINK` (`link_id`)
|
| 2781 |
+
)
|
| 2782 |
+
");
|
| 2783 |
+
|
| 2784 |
+
$result = $this->db_do("
|
| 2785 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int')."_tmp(
|
| 2786 |
+
product_link_attribute_id,
|
| 2787 |
+
link_id,
|
| 2788 |
+
value
|
| 2789 |
+
)(
|
| 2790 |
+
SELECT
|
| 2791 |
+
2,
|
| 2792 |
+
cpl.link_id,
|
| 2793 |
+
0
|
| 2794 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link')." cpl
|
| 2795 |
+
)
|
| 2796 |
+
");
|
| 2797 |
+
|
| 2798 |
+
$result = $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int')."_tmp ct
|
| 2799 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int')." c
|
| 2800 |
+
ON ct.link_id=c.link_id
|
| 2801 |
+
SET ct.value_id=c.value_id
|
| 2802 |
+
WHERE c.product_link_attribute_id=2
|
| 2803 |
+
");
|
| 2804 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2805 |
$result = $this->db_do("
|
| 2806 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int')." (
|
| 2807 |
+
value_id,
|
| 2808 |
+
product_link_attribute_id,
|
| 2809 |
+
link_id,
|
| 2810 |
+
value
|
| 2811 |
+
)(
|
| 2812 |
+
SELECT
|
| 2813 |
+
value_id,
|
| 2814 |
+
product_link_attribute_id,
|
| 2815 |
+
link_id,
|
| 2816 |
+
value
|
| 2817 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_attribute_int')."_tmp ct
|
| 2818 |
+
)
|
| 2819 |
+
ON DUPLICATE KEY UPDATE
|
| 2820 |
+
link_id=ct.link_id
|
| 2821 |
|
| 2822 |
+
");
|
| 2823 |
|
| 2824 |
+
/* $q="select distinct store_product_id from stINch_related_products";
|
| 2825 |
+
$quer=$this->db_do($q);
|
| 2826 |
+
$prod = Mage::getModel('catalog/product');
|
| 2827 |
+
while ($row = mysql_fetch_assoc($quer)) {
|
| 2828 |
+
$q1="select distinct store_related_product_id store_product_id from stINch_related_products where store_product_id=".$row['store_product_id'].;
|
| 2829 |
+
$quer1=$this->db_do($q1);
|
| 2830 |
+
$prod->load($row['store_product_id']);
|
| 2831 |
|
| 2832 |
###//get related product data (product id's and positions)
|
| 2833 |
###$relatedData = array();
|
| 2840 |
###$product->setRelatedLinkData($relatedData);
|
| 2841 |
###$product->save();
|
| 2842 |
###
|
| 2843 |
+
$i=1;
|
| 2844 |
+
while ($row1 = mysql_fetch_assoc($quer1)) {
|
| 2845 |
+
$param[$row1['store_related_product_id']]['position']=$i++;
|
| 2846 |
+
|
| 2847 |
+
}
|
| 2848 |
+
$prod->setRelatedLinkData($param);
|
| 2849 |
+
//here ... some other product operations and in the end
|
| 2850 |
+
$prod->save();
|
| 2851 |
|
| 2852 |
}
|
| 2853 |
+
*/
|
| 2854 |
+
}
|
| 2855 |
#################################################################################################
|
| 2856 |
+
function addWeight(){
|
| 2857 |
+
// product short description for all web sites
|
| 2858 |
+
$result = $this->db_do("
|
| 2859 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
| 2860 |
+
entity_type_id,
|
| 2861 |
+
attribute_id,
|
| 2862 |
+
store_id,
|
| 2863 |
+
entity_id,
|
| 2864 |
+
value
|
| 2865 |
+
)(
|
| 2866 |
+
SELECT
|
| 2867 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2868 |
+
" . $this->_getProductAttributeId('weight'). ",
|
| 2869 |
+
w.website,
|
| 2870 |
+
a.entity_id,
|
| 2871 |
+
0
|
| 2872 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2873 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." b
|
| 2874 |
+
ON a.store_product_id = b.store_product_id
|
| 2875 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2876 |
+
ON a.store_product_id=w.store_product_id
|
| 2877 |
+
)
|
| 2878 |
+
ON DUPLICATE KEY UPDATE
|
| 2879 |
+
value = 0
|
| 2880 |
+
");
|
| 2881 |
+
// product short description for all web sites
|
| 2882 |
+
$result = $this->db_do("
|
| 2883 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
| 2884 |
+
entity_type_id,
|
| 2885 |
+
attribute_id,
|
| 2886 |
+
store_id,
|
| 2887 |
+
entity_id,
|
| 2888 |
+
value
|
| 2889 |
+
)(
|
| 2890 |
+
SELECT
|
| 2891 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2892 |
+
" . $this->_getProductAttributeId('weight'). ",
|
| 2893 |
+
0,
|
| 2894 |
+
a.entity_id,
|
| 2895 |
+
0
|
| 2896 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2897 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." b
|
| 2898 |
+
ON a.store_product_id = b.store_product_id
|
| 2899 |
+
)
|
| 2900 |
+
ON DUPLICATE KEY UPDATE
|
| 2901 |
+
value = 0
|
| 2902 |
+
|
| 2903 |
+
|
| 2904 |
+
");
|
| 2905 |
|
| 2906 |
|
| 2907 |
+
}
|
| 2908 |
+
#################################################################################################
|
| 2909 |
+
function replaceMagentoProductsStockPrice(){
|
| 2910 |
+
//Add stock
|
| 2911 |
+
$connection = Mage::getModel('core/resource')->getConnection('core_write');
|
| 2912 |
+
$result = $this->db_do("DELETE csi
|
| 2913 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')." csi
|
| 2914 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 2915 |
+
ON csi.product_id=cpe.entity_id
|
| 2916 |
+
WHERE cpe.entity_id is null");
|
| 2917 |
+
//set all sinch products stock=0 before upgrade (nedds for dayly stock&price import)
|
| 2918 |
+
|
| 2919 |
+
$result = $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 2920 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')." csi
|
| 2921 |
+
ON cpe.entity_id=csi.product_id
|
| 2922 |
+
SET
|
| 2923 |
+
csi.qty=0,
|
| 2924 |
+
csi.is_in_stock=0
|
| 2925 |
+
WHERE cpe.store_product_id IS NOT NULL");
|
| 2926 |
+
|
| 2927 |
+
$result = $this->db_do("
|
| 2928 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')." (
|
| 2929 |
+
product_id,
|
| 2930 |
+
stock_id,
|
| 2931 |
+
qty,
|
| 2932 |
+
is_in_stock,
|
| 2933 |
+
manage_stock
|
| 2934 |
+
)(
|
| 2935 |
+
SELECT
|
| 2936 |
+
a.entity_id,
|
| 2937 |
+
1,
|
| 2938 |
+
b.stock,
|
| 2939 |
+
IF(b.stock > 0, 1, 0),
|
| 2940 |
+
1
|
| 2941 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 2942 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
|
| 2943 |
+
ON a.store_product_id=b.store_product_id
|
| 2944 |
+
)
|
| 2945 |
+
ON DUPLICATE KEY UPDATE
|
| 2946 |
+
qty=b.stock,
|
| 2947 |
+
is_in_stock = IF(b.stock > 0, 1, 0),
|
| 2948 |
+
manage_stock = 1
|
| 2949 |
+
");
|
| 2950 |
+
|
| 2951 |
+
|
| 2952 |
+
$result = $this->db_do("DELETE FROM ".Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_status'));
|
| 2953 |
+
|
| 2954 |
+
$result = $this->db_do("
|
| 2955 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_status')." (
|
| 2956 |
+
product_id,
|
| 2957 |
+
website_id,
|
| 2958 |
+
stock_id,
|
| 2959 |
+
qty,
|
| 2960 |
+
stock_status
|
| 2961 |
+
)(
|
| 2962 |
+
SELECT
|
| 2963 |
+
a.product_id,
|
| 2964 |
+
w.website_id,
|
| 2965 |
+
1,
|
| 2966 |
+
a.qty,
|
| 2967 |
+
IF(qty > 0, 1, 0)
|
| 2968 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')." a
|
| 2969 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." b
|
| 2970 |
+
ON a.product_id=b.entity_id
|
| 2971 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 2972 |
+
ON b.store_product_id=w.store_product_id
|
| 2973 |
+
)
|
| 2974 |
+
ON DUPLICATE KEY UPDATE
|
| 2975 |
+
qty=a.qty,
|
| 2976 |
+
stock_status = IF(a.qty > 0, 1, 0)
|
| 2977 |
+
");
|
| 2978 |
+
|
| 2979 |
+
//Add prices
|
| 2980 |
+
//$result = $this->db_do("truncate catalog_product_entity_decimal");
|
| 2981 |
+
$result = $this->db_do("DELETE cped
|
| 2982 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." cped
|
| 2983 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 2984 |
+
ON cped.entity_id=cpe.entity_id
|
| 2985 |
+
WHERE cpe.entity_id IS NULL");
|
| 2986 |
+
|
| 2987 |
+
$result = $this->db_do("
|
| 2988 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
| 2989 |
+
entity_type_id,
|
| 2990 |
+
attribute_id,
|
| 2991 |
+
store_id,
|
| 2992 |
+
entity_id,
|
| 2993 |
+
value
|
| 2994 |
+
)(
|
| 2995 |
+
SELECT
|
| 2996 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 2997 |
+
" . $this->_getProductAttributeId('price'). ",
|
| 2998 |
+
w.website_id,
|
| 2999 |
+
a.entity_id,
|
| 3000 |
+
b.price
|
| 3001 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3002 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
|
| 3003 |
+
ON a.store_product_id=b.store_product_id
|
| 3004 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 3005 |
+
ON a.store_product_id=w.store_product_id
|
| 3006 |
+
)
|
| 3007 |
+
ON DUPLICATE KEY UPDATE
|
| 3008 |
+
value = b.price
|
| 3009 |
+
");
|
| 3010 |
+
|
| 3011 |
+
$result = $this->db_do("
|
| 3012 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
| 3013 |
+
entity_type_id,
|
| 3014 |
+
attribute_id,
|
| 3015 |
+
store_id,
|
| 3016 |
+
entity_id,
|
| 3017 |
+
value
|
| 3018 |
+
)(
|
| 3019 |
+
SELECT
|
| 3020 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 3021 |
+
" . $this->_getProductAttributeId('price'). ",
|
| 3022 |
+
0,
|
| 3023 |
+
a.entity_id,
|
| 3024 |
+
b.price
|
| 3025 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3026 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
|
| 3027 |
+
ON a.store_product_id=b.store_product_id
|
| 3028 |
+
)
|
| 3029 |
+
ON DUPLICATE KEY UPDATE
|
| 3030 |
+
value = b.price
|
| 3031 |
");
|
| 3032 |
+
//Add cost
|
| 3033 |
+
// $result = $this->db_do("truncate catalog_product_entity_decimal");
|
| 3034 |
+
$result = $this->db_do("
|
| 3035 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
| 3036 |
+
entity_type_id,
|
| 3037 |
+
attribute_id,
|
| 3038 |
+
store_id,
|
| 3039 |
+
entity_id,
|
| 3040 |
+
value
|
| 3041 |
+
)(
|
| 3042 |
+
SELECT
|
| 3043 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 3044 |
+
" . $this->_getProductAttributeId('cost'). ",
|
| 3045 |
+
w.website_id,
|
| 3046 |
+
a.entity_id,
|
| 3047 |
+
b.cost
|
| 3048 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3049 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
|
| 3050 |
+
ON a.store_product_id=b.store_product_id
|
| 3051 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 3052 |
+
ON a.store_product_id=w.store_product_id
|
| 3053 |
+
)
|
| 3054 |
+
ON DUPLICATE KEY UPDATE
|
| 3055 |
+
value = b.cost
|
| 3056 |
+
");
|
| 3057 |
+
|
| 3058 |
+
$result = $this->db_do("
|
| 3059 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
| 3060 |
+
entity_type_id,
|
| 3061 |
+
attribute_id,
|
| 3062 |
+
store_id,
|
| 3063 |
+
entity_id,
|
| 3064 |
+
value
|
| 3065 |
+
)(
|
| 3066 |
+
SELECT
|
| 3067 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 3068 |
+
" . $this->_getProductAttributeId('cost'). ",
|
| 3069 |
+
0,
|
| 3070 |
+
a.entity_id,
|
| 3071 |
+
b.cost
|
| 3072 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3073 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
|
| 3074 |
+
ON a.store_product_id=b.store_product_id
|
| 3075 |
+
)
|
| 3076 |
+
ON DUPLICATE KEY UPDATE
|
| 3077 |
+
value = b.cost
|
| 3078 |
+
");
|
| 3079 |
+
|
| 3080 |
+
//make products enable in FO
|
| 3081 |
+
// $result = $this->db_do(" truncate catalog_product_index_price");
|
| 3082 |
+
$result = $this->db_do("DELETE cpip
|
| 3083 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." cpip
|
| 3084 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
| 3085 |
+
ON cpip.entity_id=cpe.entity_id
|
| 3086 |
+
WHERE cpe.entity_id IS NULL");
|
| 3087 |
+
|
| 3088 |
+
$q="SELECT customer_group_id FROM ".Mage::getSingleton('core/resource')->getTableName('customer_group');
|
| 3089 |
+
$quer=$this->db_do($q);
|
| 3090 |
|
| 3091 |
+
while ($row = mysql_fetch_assoc($quer)) {
|
| 3092 |
+
$result = $this->db_do("
|
| 3093 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." (
|
| 3094 |
+
entity_id,
|
| 3095 |
+
customer_group_id,
|
| 3096 |
+
website_id,
|
| 3097 |
+
tax_class_id,
|
| 3098 |
+
price,
|
| 3099 |
+
final_price,
|
| 3100 |
+
min_price,
|
| 3101 |
+
max_price
|
| 3102 |
+
)(SELECT
|
| 3103 |
+
a.entity_id,
|
| 3104 |
+
".$row['customer_group_id'].",
|
| 3105 |
+
w.website_id,
|
| 3106 |
+
2,
|
| 3107 |
+
b.price ,
|
| 3108 |
+
b.price ,
|
| 3109 |
+
b.price ,
|
| 3110 |
+
b.price
|
| 3111 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3112 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
|
| 3113 |
+
ON a.store_product_id=b.store_product_id
|
| 3114 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
| 3115 |
+
ON a.store_product_id=w.store_product_id
|
| 3116 |
+
)
|
| 3117 |
+
ON DUPLICATE KEY UPDATE
|
| 3118 |
+
tax_class_id = 2,
|
| 3119 |
+
price = b.price,
|
| 3120 |
+
final_price = b.price,
|
| 3121 |
+
min_price = b.price,
|
| 3122 |
+
max_price = b.price
|
| 3123 |
+
");
|
| 3124 |
+
}
|
| 3125 |
+
}
|
| 3126 |
|
| 3127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3128 |
|
| 3129 |
+
#################################################################################################
|
| 3130 |
|
| 3131 |
+
function getProductDescription($entity_id){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3132 |
|
| 3133 |
+
$this->loadProductParams($entity_id);
|
| 3134 |
+
$this->loadProductStarfeatures($entity_id);
|
| 3135 |
+
$this->loadGalleryPhotos($entity_id);
|
| 3136 |
+
Varien_Profiler::start('Bintime FILE RELATED');
|
| 3137 |
+
$this->loadRelatedProducts($entity_id);
|
| 3138 |
+
Varien_Profiler::stop('Bintime FILE RELATED');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3139 |
|
| 3140 |
+
return true;
|
| 3141 |
+
}
|
| 3142 |
+
#################################################################################################
|
| 3143 |
|
| 3144 |
+
public function getProductName(){
|
| 3145 |
+
return $this->productName;
|
| 3146 |
+
}
|
| 3147 |
+
#################################################################################################
|
| 3148 |
|
| 3149 |
+
public function getProductDescriptionList(){
|
| 3150 |
+
return $this->productDescriptionList;
|
| 3151 |
+
}
|
| 3152 |
+
#################################################################################################
|
|
|
|
| 3153 |
|
| 3154 |
+
public function getProductSpecifications(){
|
| 3155 |
+
return $this->specifications;
|
| 3156 |
+
}
|
| 3157 |
+
#################################################################################################
|
| 3158 |
+
|
| 3159 |
+
public function getShortProductDescription(){
|
| 3160 |
+
return $this->productDescription;
|
| 3161 |
+
}
|
| 3162 |
+
#################################################################################################
|
| 3163 |
+
|
| 3164 |
+
public function getFullProductDescription(){
|
| 3165 |
+
return $this->fullProductDescription;
|
| 3166 |
+
}
|
| 3167 |
+
#################################################################################################
|
| 3168 |
+
|
| 3169 |
+
public function getLowPicUrl(){
|
| 3170 |
+
return $this->highPicUrl;
|
| 3171 |
+
}
|
| 3172 |
+
#################################################################################################
|
| 3173 |
+
|
| 3174 |
+
public function getRelatedProducts(){
|
| 3175 |
+
return $this->relatedProducts;
|
| 3176 |
+
}
|
| 3177 |
+
#################################################################################################
|
| 3178 |
+
|
| 3179 |
+
public function getVendor(){
|
| 3180 |
+
return $this->vendor;
|
| 3181 |
+
}
|
| 3182 |
+
#################################################################################################
|
| 3183 |
+
|
| 3184 |
+
public function getMPN(){
|
| 3185 |
+
return $this->productId;
|
| 3186 |
+
}
|
| 3187 |
+
#################################################################################################
|
| 3188 |
+
|
| 3189 |
+
public function getEAN(){
|
| 3190 |
+
return $this->EAN;
|
| 3191 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3192 |
################################################################################################
|
| 3193 |
|
| 3194 |
+
public function getGalleryPhotos(){
|
| 3195 |
+
return $this->galleryPhotos;
|
| 3196 |
+
}
|
| 3197 |
+
|
| 3198 |
+
#################################################################################################
|
| 3199 |
+
|
| 3200 |
+
private function loadProductParams($entity_id){
|
| 3201 |
+
$store_product_id=$this->getStoreProductIdByEntity($entity_id);
|
| 3202 |
+
if(!$store_product_id){
|
| 3203 |
+
// echo "AAAAAAA"; exit;
|
| 3204 |
+
return;
|
| 3205 |
+
}
|
| 3206 |
+
$q="SELECT
|
| 3207 |
+
sinch_product_id,
|
| 3208 |
+
product_sku,
|
| 3209 |
+
product_name,
|
| 3210 |
+
sinch_manufacturer_id,
|
| 3211 |
+
store_category_id,
|
| 3212 |
+
main_image_url,
|
| 3213 |
+
thumb_image_url,
|
| 3214 |
+
medium_image_url,
|
| 3215 |
+
specifications,
|
| 3216 |
+
description,
|
| 3217 |
+
specifications
|
| 3218 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products')."
|
| 3219 |
+
WHERE store_product_id =".$store_product_id;
|
| 3220 |
+
$quer=$this->db_do($q);
|
| 3221 |
+
$product=mysql_fetch_array($quer);
|
| 3222 |
+
|
| 3223 |
+
$this->productDescription = (string) substr($product['description'],50,0);
|
| 3224 |
+
$this->fullProductDescription = (string)$product['description'];
|
| 3225 |
+
$this->lowPicUrl = (string)$product["medium_image_url"];//thumb_image_url"];
|
| 3226 |
+
$this->highPicUrl = (string)$product["main_image_url"];
|
| 3227 |
+
$this->productName = (string)$product["product_name"];
|
| 3228 |
+
$this->productId = (string)$product['product_sku'];
|
| 3229 |
+
$this->specifications = (string)$product['specifications'];
|
| 3230 |
+
$this->sinchProductId = (string)$product['sinch_product_id'];
|
| 3231 |
+
if($product['sinch_manufacturer_id']){
|
| 3232 |
+
$q="SELECT manufacturer_name
|
| 3233 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')."
|
| 3234 |
+
WHERE sinch_manufacturer_id=".$product['sinch_manufacturer_id'];
|
| 3235 |
+
$quer=$this->db_do($q);
|
| 3236 |
+
$manufacturer=mysql_fetch_array($quer);
|
| 3237 |
+
$this->vendor = (string)$manufacturer['manufacturer_name'];
|
| 3238 |
+
}
|
| 3239 |
+
$q="SELECT DISTINCT ean_code
|
| 3240 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_ean_codes')." sec
|
| 3241 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." sp
|
| 3242 |
+
ON sec.product_id=sp.sinch_product_id
|
| 3243 |
+
WHERE sp.store_product_id=".$store_product_id;
|
| 3244 |
+
$quer=$this->db_do($q);
|
| 3245 |
+
while ($row=mysql_fetch_array($quer)){
|
| 3246 |
+
$EANarr[]=$row['ean_code'];
|
| 3247 |
+
}
|
| 3248 |
+
// $prodEAN = $productTag->EANCode;
|
| 3249 |
+
$EANstr='';
|
| 3250 |
+
/* $EANarr=null;
|
| 3251 |
+
foreach($prodEAN as $ellEAN){
|
| 3252 |
+
$EANarr[]=$ellEAN['EAN'];
|
| 3253 |
+
}
|
| 3254 |
+
*/
|
| 3255 |
+
$EANstr=implode(", ",$EANarr);
|
| 3256 |
+
$this->EAN = (string)$EANstr;//$productTag->EANCode['EAN'];
|
| 3257 |
+
}
|
| 3258 |
+
#################################################################################################
|
| 3259 |
+
|
| 3260 |
+
private function loadProductStarfeatures($entity_id){
|
| 3261 |
+
$descriptionArray=array();
|
| 3262 |
+
$product_info_features = $this->db_do("
|
| 3263 |
+
SELECT c.feature_name AS name, b.text AS value
|
| 3264 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_product_features')." a
|
| 3265 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values')." b
|
| 3266 |
+
ON a.restricted_value_id = b.restricted_value_id
|
| 3267 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features')." c
|
| 3268 |
+
ON b.category_feature_id = c.category_feature_id
|
| 3269 |
+
WHERE a.sinch_product_id = '" .$this->sinchProductId . "'" );
|
| 3270 |
while ($features = mysql_fetch_array($product_info_features)) {
|
| 3271 |
+
$descriptionArray[$features['name']] = $features['value'];
|
| 3272 |
}
|
| 3273 |
|
| 3274 |
+
|
| 3275 |
+
$this->productDescriptionList = $descriptionArray;
|
| 3276 |
+
}
|
| 3277 |
#################################################################################################
|
| 3278 |
|
| 3279 |
+
private function loadRelatedProducts($entity_id){
|
| 3280 |
+
$this->sinchProductId;
|
| 3281 |
+
if(!$this->sinchProductId){
|
| 3282 |
+
return;
|
| 3283 |
+
}
|
| 3284 |
+
$q="SELECT
|
| 3285 |
+
st_prod.sinch_product_id,
|
| 3286 |
+
st_prod.product_sku,
|
| 3287 |
+
st_prod.product_name,
|
| 3288 |
+
st_prod.sinch_manufacturer_id,
|
| 3289 |
+
st_prod.store_category_id,
|
| 3290 |
+
st_prod.main_image_url,
|
| 3291 |
+
st_prod.thumb_image_url,
|
| 3292 |
+
st_prod.medium_image_url,
|
| 3293 |
+
st_prod.specifications,
|
| 3294 |
+
st_prod.description,
|
| 3295 |
+
st_prod.specifications,
|
| 3296 |
+
st_manuf.manufacturer_name,
|
| 3297 |
+
st_manuf.manufacturers_image
|
| 3298 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_related_products')." st_rel_prod
|
| 3299 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." st_prod
|
| 3300 |
+
ON st_rel_prod.related_sinch_product_id=st_prod.sinch_product_id
|
| 3301 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')." st_manuf
|
| 3302 |
+
ON st_prod.sinch_manufacturer_id=st_manuf.sinch_manufacturer_id
|
| 3303 |
+
WHERE st_rel_prod.sinch_product_id=".$this->sinchProductId;
|
| 3304 |
+
|
| 3305 |
+
// echo $q;
|
| 3306 |
+
$quer=$this->db_do($q);
|
| 3307 |
+
while($row=mysql_fetch_array($quer)){
|
| 3308 |
+
|
| 3309 |
+
$productArray = array();
|
| 3310 |
+
$productArray['name'] = (string)$row['product_name'];
|
| 3311 |
+
$productArray['thumb'] = (string)$row['thumb_image_url'];
|
| 3312 |
+
$mpn = (string)$row['product_sku'];
|
| 3313 |
+
$productSupplierId = (int)$row['sinch_manufacturer_id'];
|
| 3314 |
+
$productArray['supplier_thumb'] = (string)($row['manufacturers_image']);
|
| 3315 |
+
$productArray['supplier_name'] = (string)$row['manufacturer_name'];
|
| 3316 |
+
|
| 3317 |
+
$this->relatedProducts[$mpn] = $productArray;
|
| 3318 |
}
|
| 3319 |
+
}
|
| 3320 |
#################################################################################################
|
| 3321 |
+
/**
|
| 3322 |
+
* load Gallery array from XML
|
| 3323 |
+
*/
|
| 3324 |
+
public function loadGalleryPhotos($entity_id){
|
| 3325 |
+
/*$galleryPhotos = $this->simpleDoc->Product->ProductGallery->ProductPicture;
|
| 3326 |
+
if (!count($galleryPhotos)){
|
| 3327 |
+
return false;
|
| 3328 |
+
}
|
| 3329 |
+
*/
|
| 3330 |
+
$store_product_id=$this->getStoreProductIdByEntity($entity_id);
|
| 3331 |
+
if(!$store_product_id){
|
| 3332 |
+
return;
|
| 3333 |
+
}
|
| 3334 |
+
$q=$this->db_do("SELECT COUNT(*) AS cnt
|
| 3335 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery')."
|
| 3336 |
+
WHERE store_product_id=".$store_product_id);
|
| 3337 |
+
|
| 3338 |
+
$res=mysql_fetch_array($q);
|
| 3339 |
+
if(!$res || !$res['cnt']){
|
| 3340 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3341 |
}
|
| 3342 |
+
$q="SELECT
|
| 3343 |
+
image_url as Pic,
|
| 3344 |
+
thumb_image_url as ThumbPic
|
| 3345 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery')."
|
| 3346 |
+
WHERE store_product_id=".$store_product_id;
|
| 3347 |
+
|
| 3348 |
+
$res=$this->db_do($q);
|
| 3349 |
+
|
| 3350 |
+
while($photo=mysql_fetch_array($res)){
|
| 3351 |
+
$picHeight = (int)500;//$photo["PicHeight"];
|
| 3352 |
+
$picWidth = (int)500;//$photo["PicWidth"];
|
| 3353 |
+
$thumbUrl = (string)$photo["ThumbPic"];
|
| 3354 |
+
$picUrl = (string)$photo["Pic"];
|
| 3355 |
+
|
| 3356 |
+
array_push($this->galleryPhotos, array(
|
| 3357 |
+
'height' => $picHeight,
|
| 3358 |
+
'width' => $picWidth,
|
| 3359 |
+
'thumb' => $thumbUrl,
|
| 3360 |
+
'pic' => $picUrl
|
| 3361 |
+
));
|
| 3362 |
+
}
|
| 3363 |
+
}
|
| 3364 |
#################################################################################################
|
| 3365 |
+
public function reloadProductImage($entity_id){
|
| 3366 |
+
$result = $this->db_do("
|
| 3367 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 3368 |
+
entity_type_id,
|
| 3369 |
+
attribute_id,
|
| 3370 |
+
store_id,
|
| 3371 |
+
entity_id,
|
| 3372 |
+
value
|
| 3373 |
+
)(
|
| 3374 |
+
SELECT
|
| 3375 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 3376 |
+
" . $this->_getProductAttributeId('image'). ",
|
| 3377 |
+
w.store_id,
|
| 3378 |
+
a.entity_id,
|
| 3379 |
+
b.main_image_url
|
| 3380 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3381 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." w
|
| 3382 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." b
|
| 3383 |
+
ON a.store_product_id = b.store_product_id
|
| 3384 |
+
WHERE a.entity_id=$entity_id
|
| 3385 |
+
)
|
| 3386 |
+
ON DUPLICATE KEY UPDATE
|
| 3387 |
+
value = b.main_image_url
|
| 3388 |
+
");
|
| 3389 |
+
|
| 3390 |
+
|
| 3391 |
+
// image for specific web sites
|
| 3392 |
+
$result = $this->db_do("
|
| 3393 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 3394 |
+
entity_type_id,
|
| 3395 |
+
attribute_id,
|
| 3396 |
+
store_id,
|
| 3397 |
+
entity_id,
|
| 3398 |
+
value
|
| 3399 |
+
)(
|
| 3400 |
+
SELECT
|
| 3401 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 3402 |
+
" . $this->_getProductAttributeId('image'). ",
|
| 3403 |
+
0,
|
| 3404 |
+
a.entity_id,
|
| 3405 |
+
b.main_image_url
|
| 3406 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3407 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." b
|
| 3408 |
+
ON a.store_product_id = b.store_product_id
|
| 3409 |
+
WHERE a.entity_id=$entity_id
|
| 3410 |
+
)
|
| 3411 |
+
ON DUPLICATE KEY UPDATE
|
| 3412 |
+
value = b.main_image_url
|
| 3413 |
+
");
|
| 3414 |
+
|
| 3415 |
+
|
| 3416 |
+
// small_image for specific web sites
|
| 3417 |
+
$result = $this->db_do("
|
| 3418 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 3419 |
+
entity_type_id,
|
| 3420 |
+
attribute_id,
|
| 3421 |
+
store_id,
|
| 3422 |
+
entity_id,
|
| 3423 |
+
value
|
| 3424 |
+
)(
|
| 3425 |
+
SELECT
|
| 3426 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 3427 |
+
" . $this->_getProductAttributeId('small_image'). ",
|
| 3428 |
+
w.store_id,
|
| 3429 |
+
a.entity_id,
|
| 3430 |
+
b.main_image_url
|
| 3431 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3432 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." w
|
| 3433 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." b
|
| 3434 |
+
ON a.store_product_id = b.store_product_id
|
| 3435 |
+
WHERE a.entity_id=$entity_id
|
| 3436 |
+
)
|
| 3437 |
+
ON DUPLICATE KEY UPDATE
|
| 3438 |
+
value = b.main_image_url
|
| 3439 |
+
");
|
| 3440 |
+
|
| 3441 |
+
|
| 3442 |
+
// small_image for all web sites
|
| 3443 |
+
$result = $this->db_do("
|
| 3444 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
| 3445 |
+
entity_type_id,
|
| 3446 |
+
attribute_id,
|
| 3447 |
+
store_id,
|
| 3448 |
+
entity_id,
|
| 3449 |
+
value
|
| 3450 |
+
)(
|
| 3451 |
+
SELECT
|
| 3452 |
+
" . $this->_getProductEntityTypeId(). ",
|
| 3453 |
+
" . $this->_getProductAttributeId('small_image'). ",
|
| 3454 |
+
0,
|
| 3455 |
+
a.entity_id,
|
| 3456 |
+
b.main_image_url
|
| 3457 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
| 3458 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('core_store')." w
|
| 3459 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products')." b
|
| 3460 |
+
ON a.store_product_id = b.store_product_id
|
| 3461 |
+
WHERE a.entity_id=$entity_id
|
| 3462 |
+
)
|
| 3463 |
+
ON DUPLICATE KEY UPDATE
|
| 3464 |
+
value = b.main_image_url
|
| 3465 |
+
");
|
| 3466 |
+
}
|
| 3467 |
+
#################################################################################################
|
| 3468 |
+
public function runIndexer(){
|
| 3469 |
+
exec(PHP_RUN_STRING.' '.$this->shellDir.'indexer.php reindexall');
|
| 3470 |
+
}
|
| 3471 |
+
#################################################################################################
|
| 3472 |
+
public function runStockPriceIndexer(){
|
| 3473 |
+
exec(PHP_RUN_STRING.' '.$this->shellDir.'indexer.php --reindex catalog_product_price,cataloginventory_stock');
|
| 3474 |
+
}
|
| 3475 |
+
#################################################################################################
|
| 3476 |
+
private function getStoreProductIdByEntity($entity_id){
|
| 3477 |
+
$q=$this->db_do("SELECT store_product_id
|
| 3478 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')."
|
| 3479 |
+
WHERE entity_id=".$entity_id);
|
| 3480 |
+
$res=mysql_fetch_array($q);
|
| 3481 |
+
// echo $entity_id."AAAA".$res['store_product_id']; exit;
|
| 3482 |
+
return ($res['store_product_id']);
|
| 3483 |
+
}
|
| 3484 |
+
#################################################################################################
|
| 3485 |
+
|
| 3486 |
+
private function db_connect() {
|
| 3487 |
+
|
| 3488 |
+
// $connection = Mage::getModel('core/resource')->getConnection('core_write');
|
| 3489 |
+
$dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
|
| 3490 |
+
|
| 3491 |
+
if ($this->db = mysql_connect($dbConf->host, $dbConf->username, $dbConf->password, true, 128)) {
|
| 3492 |
+
if(mysql_select_db($dbConf->dbname)){
|
| 3493 |
+
$this->_LOG("Connected..");
|
| 3494 |
+
}else{
|
| 3495 |
+
die("Can't select the database: " . mysql_error());
|
| 3496 |
+
}
|
| 3497 |
+
}else{
|
| 3498 |
+
die("Could not connect: " . mysql_error());
|
| 3499 |
+
|
| 3500 |
+
}
|
| 3501 |
+
|
| 3502 |
+
}
|
| 3503 |
#################################################################################################
|
| 3504 |
|
| 3505 |
private function db_do($query) {
|
| 3506 |
+
if($this->debug_mode){
|
| 3507 |
+
// $this->_LOG("Query: " . $query);
|
| 3508 |
Mage::log("Query: " . $query, null, $this->_logFile);
|
| 3509 |
+
}
|
| 3510 |
+
// $result = $this->this->db_do($query);//
|
| 3511 |
+
// $query=mysql_real_escape_string($query);
|
| 3512 |
+
$result = mysql_query($query) or die("Query failed: " . mysql_error());
|
| 3513 |
+
if (!$result) {
|
| 3514 |
+
throw new Exception("Invalid query: $sql\n" . mysql_error());
|
| 3515 |
+
} else {
|
| 3516 |
+
return $result;
|
| 3517 |
+
}
|
| 3518 |
|
| 3519 |
return $result;
|
| 3520 |
}
|
| 3531 |
}
|
| 3532 |
##################################################################################################
|
| 3533 |
function check_loaded_data($file, $table){
|
| 3534 |
+
$cnt_strings_in_file=$this->file_strings_count($file);
|
| 3535 |
+
$cnt_rows_int_table=$this->table_rows_count($table);
|
| 3536 |
+
$persent_cnt_strings_in_file=$cnt_strings_in_file / 10;
|
| 3537 |
+
if($cnt_rows_int_table > $persent_cnt_strings_in_file){
|
| 3538 |
+
return true;
|
| 3539 |
+
}else{
|
| 3540 |
+
return false;
|
| 3541 |
+
}
|
| 3542 |
+
}
|
| 3543 |
+
##################################################################################################
|
| 3544 |
+
|
| 3545 |
+
|
| 3546 |
+
function valid_utf($string,$new_line = true){
|
| 3547 |
+
/* if($new_line == true){
|
| 3548 |
+
$string = preg_replace('/\\\n/',"\n",$string);
|
| 3549 |
+
}
|
| 3550 |
+
*/
|
| 3551 |
+
$string = preg_replace('/™/','™',$string);
|
| 3552 |
+
$string = preg_replace("/®/",'®',$string);
|
| 3553 |
+
$string = preg_replace("/≈/",'≈',$string);
|
| 3554 |
+
$string = preg_replace("/".chr(226).chr(128).chr(157)."/",'"',$string);
|
| 3555 |
+
$string = preg_replace("/".chr(226).chr(128).chr(153)."/",'′',$string);
|
| 3556 |
+
$string = preg_replace("/°/",'°',$string);
|
| 3557 |
+
$string = preg_replace("/±/",'±',$string);
|
| 3558 |
+
$string = preg_replace("/µ/",'µ',$string);
|
| 3559 |
+
$string = preg_replace("/²/",'²',$string);
|
| 3560 |
+
$string = preg_replace("/³/",'³',$string);
|
| 3561 |
+
$string = preg_replace('/\xe2\x80\x93/','-',$string);
|
| 3562 |
+
$string = preg_replace('/\xe2\x80\x99/','\'',$string);
|
| 3563 |
+
$string = preg_replace('/\xe2\x80\x9c/',' ',$string);
|
| 3564 |
+
$string = preg_replace('/\xe2\x80\x9d/',' ',$string);
|
| 3565 |
+
|
| 3566 |
+
return utf8_decode($string);
|
| 3567 |
+
|
| 3568 |
+
// return $string;
|
| 3569 |
+
}
|
| 3570 |
+
|
| 3571 |
+
#################################################################################################
|
| 3572 |
+
function dropHTMLentities($entity_type_id, $attribute_id){
|
| 3573 |
+
// product name for all web sites
|
| 3574 |
+
$result = $this->db_do("
|
| 3575 |
+
SELECT value, entity_id
|
| 3576 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')."
|
| 3577 |
+
WHERE entity_type_id=".$entity_type_id."
|
| 3578 |
+
AND attribute_id=".$attribute_id
|
| 3579 |
+
);
|
| 3580 |
+
while($row=mysql_fetch_array($result)){
|
| 3581 |
+
$value=$this->valid_char($row['value']);
|
| 3582 |
+
if($value!='' and $value!=$row['value']){
|
| 3583 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')."
|
| 3584 |
+
SET value='".mysql_real_escape_string($value)."'
|
| 3585 |
+
WHERE entity_id=".$row['entity_id']."
|
| 3586 |
+
AND entity_type_id=".$entity_type_id."
|
| 3587 |
+
AND attribute_id=".$attribute_id);
|
| 3588 |
+
}
|
| 3589 |
+
|
| 3590 |
+
}
|
| 3591 |
+
}
|
| 3592 |
+
|
| 3593 |
+
#################################################################################################
|
| 3594 |
+
|
| 3595 |
+
function valid_char($string){
|
| 3596 |
+
$string = preg_replace('/™/', ' ',$string);
|
| 3597 |
+
$string = preg_replace('/®/', ' ',$string);
|
| 3598 |
+
$string = preg_replace('/≈/', ' ',$string);
|
| 3599 |
+
$string = preg_replace('/"/', ' ',$string);
|
| 3600 |
+
$string = preg_replace('/′/', ' ',$string);
|
| 3601 |
+
$string = preg_replace('/°/', ' ',$string);
|
| 3602 |
+
$string = preg_replace('/±/', ' ',$string);
|
| 3603 |
+
$string = preg_replace('/µ/', ' ',$string);
|
| 3604 |
+
$string = preg_replace('/²/', ' ',$string);
|
| 3605 |
+
$string = preg_replace('/³/', ' ',$string);
|
| 3606 |
+
// $string = preg_replace('/\xe2\x80\x93/','-',$string);
|
| 3607 |
+
// $string = preg_replace('/\xe2\x80\x99/','\'',$string);
|
| 3608 |
+
// $string = preg_replace('/\xe2\x80\x9c/',' ',$string);
|
| 3609 |
+
// $string = preg_replace('/\xe2\x80\x9d/',' ',$string);
|
| 3610 |
+
|
| 3611 |
+
// return utf8_decode($string);
|
| 3612 |
+
|
| 3613 |
+
return $string;
|
| 3614 |
+
}
|
| 3615 |
+
|
| 3616 |
+
#################################################################################################
|
| 3617 |
+
|
| 3618 |
+
function _LOG($log){
|
| 3619 |
+
|
| 3620 |
+
if($log){
|
| 3621 |
+
// $q="insert into ".$this->import_log_table." (message_date, message) values(now(), '".$log."')";
|
| 3622 |
+
// $this->db_do($q);
|
| 3623 |
+
Mage::log($log, null, $this->_logFile);
|
| 3624 |
+
// list($usec, $sec) = explode(" ", microtime());
|
| 3625 |
+
// $time = ((float)$usec + (float)$sec);
|
| 3626 |
+
/* $time = date("D M j G:i:s T Y");
|
| 3627 |
+
|
| 3628 |
+
if($_SERVER['REMOTE_ADDR']){
|
| 3629 |
+
$log = "[".getmypid()."] "."[".$_SERVER['REMOTE_ADDR']."] "."[".$time."] ".$log."\n";
|
| 3630 |
+
error_log($log,3,LOG_FILE);
|
| 3631 |
+
}else{
|
| 3632 |
+
$log = "[".getmypid()."] "."[".$time."] ".$log."\n";
|
| 3633 |
+
error_log($log,3,LOG_FILE . ".cli");
|
| 3634 |
+
*/
|
| 3635 |
+
}
|
| 3636 |
+
}
|
| 3637 |
+
|
| 3638 |
+
#################################################################################################
|
| 3639 |
+
|
| 3640 |
+
function wget(){
|
| 3641 |
+
|
| 3642 |
+
$got = func_num_args();
|
| 3643 |
+
$url = $file = $flag = false;
|
| 3644 |
+
|
| 3645 |
+
if($got<1){
|
| 3646 |
+
return false;
|
| 3647 |
+
}elseif($got == 1){
|
| 3648 |
+
$url = func_get_arg(0);
|
| 3649 |
+
}elseif($got == 2){
|
| 3650 |
+
$url = func_get_arg(0);
|
| 3651 |
+
$file= func_get_arg(1);
|
| 3652 |
+
}elseif($got == 3){
|
| 3653 |
+
$url = func_get_arg(0);
|
| 3654 |
+
$file= func_get_arg(1);
|
| 3655 |
+
$flag= func_get_arg(2);
|
| 3656 |
+
}
|
| 3657 |
+
|
| 3658 |
+
if($flag == 'copy'){
|
| 3659 |
+
if(copy($url,$file)){
|
| 3660 |
return true;
|
| 3661 |
}else{
|
| 3662 |
return false;
|
| 3663 |
+
}
|
| 3664 |
+
}elseif($flag == 'system'){
|
| 3665 |
+
exec("wget -O$file $url");
|
| 3666 |
+
return true;
|
| 3667 |
+
}else{
|
| 3668 |
+
$c=curl_init($url);
|
| 3669 |
+
curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
|
| 3670 |
+
curl_setopt($c,CURLOPT_FOLLOWLOCATION,1);
|
| 3671 |
+
curl_setopt($c,CURLOPT_HEADER,array("Accept-Encoding: gzip"));
|
| 3672 |
+
if(!$file){
|
| 3673 |
+
$page = curl_exec($c);
|
| 3674 |
+
curl_close($c);
|
| 3675 |
+
return $page;
|
| 3676 |
+
}else{
|
| 3677 |
+
$FH = fopen($file,"wb");// or echo"Can't open for writing ".$file;
|
| 3678 |
+
fwrite($FH,curl_exec($c));
|
| 3679 |
+
fclose($FH);
|
| 3680 |
+
curl_close($c);
|
| 3681 |
+
return true;
|
| 3682 |
+
}
|
| 3683 |
+
}
|
| 3684 |
}
|
| 3685 |
+
#################################################################################################
|
| 3686 |
+
/**
|
| 3687 |
+
* Create the import directory Hierarchy
|
| 3688 |
+
* @return false if directory already exists
|
| 3689 |
+
*/
|
| 3690 |
+
public function createTemporaryImportDerictory(){
|
| 3691 |
+
$dirArray = explode('/', $this->varDir);
|
| 3692 |
+
end($dirArray);
|
| 3693 |
+
// $this->_LOG('before :'.$this->varDir);
|
| 3694 |
+
if (prev($dirArray)=='bintime'){
|
| 3695 |
+
return false;
|
| 3696 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3697 |
|
| 3698 |
|
| 3699 |
+
$this->varDir = $this->varDir . 'bintime/sinchimport/';
|
| 3700 |
+
if (!is_dir($this->varDir)) {
|
| 3701 |
+
mkdir($this->varDir,0777,true);
|
|
|
|
|
|
|
| 3702 |
}
|
| 3703 |
+
// $this->_LOG('after :'.$this->varDir);
|
| 3704 |
+
}
|
| 3705 |
#################################################################################################
|
| 3706 |
|
| 3707 |
+
function count_children($id){
|
| 3708 |
|
| 3709 |
+
$q="SELECT store_category_id
|
| 3710 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
|
| 3711 |
+
WHERE parent_store_category_id=".$id;
|
| 3712 |
$quer=$this->db_do($q);
|
| 3713 |
$count=0;
|
| 3714 |
while ($row=mysql_fetch_array($quer)){
|
| 3715 |
+
$count+=$this->count_children($row['store_category_id']);
|
| 3716 |
+
$count++;
|
| 3717 |
}
|
| 3718 |
return ($count);
|
| 3719 |
+
}
|
| 3720 |
#################################################################################################
|
| 3721 |
+
private function delete_old_sinch_categories_from_shop(){
|
| 3722 |
+
|
| 3723 |
+
$q="DELETE cat FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')." cat
|
| 3724 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 3725 |
+
ON cat.entity_id=scm.shop_entity_id
|
| 3726 |
+
WHERE
|
| 3727 |
+
(scm.shop_store_category_id is not null) AND
|
| 3728 |
+
(scm.store_category_id is null)";
|
| 3729 |
+
$this->db_do($q);
|
| 3730 |
|
| 3731 |
+
$q="DELETE cat FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_int')." cat
|
| 3732 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 3733 |
+
ON cat.entity_id=scm.shop_entity_id
|
| 3734 |
+
WHERE
|
| 3735 |
+
(scm.shop_store_category_id is not null) AND
|
| 3736 |
+
(scm.store_category_id is null)";
|
| 3737 |
+
$this->db_do($q);
|
| 3738 |
|
| 3739 |
+
$q="DELETE cat FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." cat
|
| 3740 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
| 3741 |
+
ON cat.entity_id=scm.shop_entity_id
|
| 3742 |
+
WHERE
|
| 3743 |
+
(scm.shop_store_category_id is not null) AND
|
| 3744 |
+
(scm.store_category_id is null)";
|
| 3745 |
+
$this->db_do($q);
|
| 3746 |
|
| 3747 |
+
}
|
|
|
|
|
|
|
|
|
|
| 3748 |
#################################################################################################
|
| 3749 |
|
| 3750 |
+
function culc_path($parent_id, $ent_id){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3751 |
$path='';
|
| 3752 |
$cat_id=$parent_id;
|
| 3753 |
+
$q="SELECT
|
| 3754 |
+
parent_id
|
| 3755 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
| 3756 |
+
WHERE entity_id=".$cat_id;
|
| 3757 |
$quer=$this->db_do($q);
|
| 3758 |
$row=mysql_fetch_array($quer);
|
| 3759 |
while($row['parent_id']){
|
| 3760 |
$path=$row['parent_id'].'/'.$path;
|
| 3761 |
+
$q="SELECT
|
| 3762 |
+
parent_id
|
| 3763 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
| 3764 |
+
WHERE entity_id=".$row['parent_id'];
|
| 3765 |
$quer=$this->db_do($q);
|
| 3766 |
$row=mysql_fetch_array($quer);
|
| 3767 |
|
| 3776 |
return($ent_id);
|
| 3777 |
}
|
| 3778 |
|
| 3779 |
+
}
|
| 3780 |
#################################################################################################
|
| 3781 |
|
| 3782 |
+
function get_category_level($id){
|
| 3783 |
+
$q="SELECT parent_store_category_id
|
| 3784 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
|
| 3785 |
+
WHERE store_category_id=".$id;
|
| 3786 |
+
$quer=$this->db_do($q);
|
| 3787 |
+
$level=1;
|
| 3788 |
+
$row=mysql_fetch_array($quer);
|
| 3789 |
while ($row['parent_store_category_id']!=0){
|
| 3790 |
+
$q="SELECT parent_store_category_id
|
| 3791 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
|
| 3792 |
+
WHERE store_category_id=".$row['parent_store_category_id'];
|
| 3793 |
+
$quer=$this->db_do($q);
|
| 3794 |
+
$row=mysql_fetch_array($quer);
|
| 3795 |
+
$level++;
|
| 3796 |
+
if($level>20){
|
| 3797 |
+
break;
|
| 3798 |
+
}
|
| 3799 |
}
|
| 3800 |
|
| 3801 |
+
return($level);
|
| 3802 |
+
}
|
| 3803 |
#################################################################################################
|
| 3804 |
|
| 3805 |
+
function InitImportStatuses($type){
|
| 3806 |
+
$this->db_do("DROP TABLE IF EXISTS ".$this->import_status_table);
|
| 3807 |
+
$this->db_do("CREATE TABLE ".$this->import_status_table."(
|
| 3808 |
+
id int(11) NOT NULL auto_increment PRIMARY KEY,
|
| 3809 |
+
message varchar(50),
|
| 3810 |
+
finished int(1) default 0
|
| 3811 |
+
)"
|
| 3812 |
+
);
|
| 3813 |
+
$this->db_do("INSERT INTO ".$this->import_status_statistic_table." (
|
| 3814 |
+
start_import,
|
| 3815 |
+
finish_import,
|
| 3816 |
+
import_type,
|
| 3817 |
+
global_status_import,
|
| 3818 |
+
import_run_type,
|
| 3819 |
+
error_report_message)
|
| 3820 |
+
VALUES(
|
| 3821 |
+
now(),
|
| 3822 |
+
NULL,
|
| 3823 |
+
'$type',
|
| 3824 |
+
'Run',
|
| 3825 |
+
'".$this->import_run_type."',
|
| 3826 |
+
''
|
| 3827 |
+
)
|
| 3828 |
+
");
|
| 3829 |
+
$q="SELECT MAX(id) AS id FROM ".$this->import_status_statistic_table;
|
| 3830 |
|
| 3831 |
+
$quer=$this->db_do($q);
|
| 3832 |
+
$row=mysql_fetch_array($quer);
|
| 3833 |
+
$this->current_import_status_statistic_id=$row['id'];
|
| 3834 |
+
$this->db_do("UPDATE ".$this->import_status_statistic_table."
|
| 3835 |
+
SET global_status_import='Failed'
|
| 3836 |
+
WHERE global_status_import='Run' AND id!=".$this->current_import_status_statistic_id);
|
| 3837 |
|
| 3838 |
+
}
|
| 3839 |
#################################################################################################
|
| 3840 |
+
function set_imports_failed(){
|
| 3841 |
+
$this->db_do("UPDATE ".$this->import_status_statistic_table."
|
| 3842 |
+
SET global_status_import='Failed'
|
| 3843 |
+
WHERE global_status_import='Run'");
|
| 3844 |
+
}
|
| 3845 |
+
#################################################################################################
|
| 3846 |
+
function set_import_error_reporting_message($message){
|
| 3847 |
+
$this->db_do("UPDATE ".$this->import_status_statistic_table."
|
| 3848 |
+
SET error_report_message='".mysql_real_escape_string($message)."'
|
| 3849 |
+
WHERE id=".$this->current_import_status_statistic_id);
|
| 3850 |
+
}
|
| 3851 |
+
#################################################################################################
|
| 3852 |
+
function getImportStatusHistory(){
|
| 3853 |
+
$res="SELECT COUNT(*) FROM ".$this->import_status_statistic_table;
|
| 3854 |
+
$cnt_arr=mysql_fetch_array($this->db_do($res));
|
| 3855 |
+
$cnt=$cnt_arr[0];
|
| 3856 |
+
if($cnt>0){
|
| 3857 |
+
$a=(($cnt>7)? ($cnt-7): 0);
|
| 3858 |
+
$b=$cnt;
|
| 3859 |
+
$q="SELECT
|
| 3860 |
+
id,
|
| 3861 |
+
start_import,
|
| 3862 |
+
finish_import,
|
| 3863 |
+
import_type,
|
| 3864 |
+
number_of_products,
|
| 3865 |
+
global_status_import,
|
| 3866 |
+
detail_status_import
|
| 3867 |
+
FROM ".$this->import_status_statistic_table."
|
| 3868 |
+
ORDER BY start_import limit ".$a.", ".$b;
|
| 3869 |
+
$result=$this->db_do($q);
|
| 3870 |
+
while($row=mysql_fetch_array($result)){
|
| 3871 |
+
$StatusHistory_arr[]=$row;
|
| 3872 |
+
}
|
| 3873 |
}
|
| 3874 |
+
return $StatusHistory_arr;
|
| 3875 |
}
|
|
|
|
|
|
|
| 3876 |
#################################################################################################
|
| 3877 |
+
function getDateOfLatestSuccessImport(){
|
| 3878 |
+
$q="SELECT start_import, finish_import
|
| 3879 |
+
FROM ".$this->import_status_statistic_table."
|
| 3880 |
+
WHERE global_status_import='Successful'
|
| 3881 |
+
ORDER BY id DESC LIMIT 1";
|
| 3882 |
+
$imp_date=mysql_fetch_array($this->db_do($q));
|
| 3883 |
+
return $imp_date['start_import'];
|
| 3884 |
+
}
|
| 3885 |
#################################################################################################
|
| 3886 |
+
function getDataOfLatestImport(){
|
| 3887 |
+
$q="SELECT
|
| 3888 |
+
start_import,
|
| 3889 |
+
finish_import,
|
| 3890 |
+
import_type,
|
| 3891 |
+
number_of_products,
|
| 3892 |
+
global_status_import,
|
| 3893 |
+
detail_status_import,
|
| 3894 |
+
number_of_products,
|
| 3895 |
+
error_report_message
|
| 3896 |
+
FROM ".$this->import_status_statistic_table."
|
| 3897 |
+
ORDER BY id DESC LIMIT 1";
|
| 3898 |
+
$imp_status=mysql_fetch_array($this->db_do($q));
|
| 3899 |
+
return $imp_status;
|
| 3900 |
+
}
|
| 3901 |
|
| 3902 |
#################################################################################################
|
| 3903 |
+
function addImportStatus($message, $finished=0){
|
| 3904 |
+
$q="INSERT INTO ".$this->import_status_table."
|
| 3905 |
+
(message, finished)
|
| 3906 |
+
VALUES('".$message."', $finished)";
|
| 3907 |
+
$this->db_do($q);
|
| 3908 |
+
$this->db_do("UPDATE ".$this->import_status_statistic_table."
|
| 3909 |
+
SET detail_status_import='".$message."'
|
| 3910 |
+
WHERE id=".$this->current_import_status_statistic_id);
|
| 3911 |
+
if($finished==1){
|
| 3912 |
+
$this->db_do("UPDATE ".$this->import_status_statistic_table."
|
| 3913 |
+
SET
|
| 3914 |
+
global_status_import='Successful',
|
| 3915 |
+
finish_import=now()
|
| 3916 |
+
WHERE
|
| 3917 |
+
error_report_message='' and
|
| 3918 |
+
id=".$this->current_import_status_statistic_id);
|
| 3919 |
+
}
|
| 3920 |
+
}
|
| 3921 |
+
#################################################################################################
|
| 3922 |
+
|
| 3923 |
+
function getImportStatuses(){
|
| 3924 |
+
$q="SELECT id, message, finished
|
| 3925 |
+
FROM ".$this->import_status_table."
|
| 3926 |
+
ORDER BY id LIMIT 1";
|
| 3927 |
+
$quer=$this->db_do($q);
|
| 3928 |
+
if($row=mysql_fetch_array($quer)){
|
| 3929 |
+
$messages=array('message'=>$row['message'], 'id'=>$row['id'], 'finished'=>$row['finished']);
|
| 3930 |
+
$id=$row['id'];
|
| 3931 |
+
}
|
| 3932 |
+
if($id){
|
| 3933 |
+
$q="DELETE FROM ".$this->import_status_table." WHERE id=".$id;
|
| 3934 |
+
$this->db_do($q);
|
| 3935 |
+
}
|
| 3936 |
+
return $messages;
|
| 3937 |
+
}
|
| 3938 |
#################################################################################################
|
| 3939 |
|
| 3940 |
+
private function _getEntityTypeId($code) {
|
| 3941 |
+
$sql = "
|
| 3942 |
+
SELECT entity_type_id
|
| 3943 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('eav_entity_type')."
|
| 3944 |
+
WHERE entity_type_code = '".$code."'
|
| 3945 |
+
LIMIT 1
|
| 3946 |
+
";
|
| 3947 |
+
$result = $this->db_do($sql);
|
| 3948 |
+
if ($row = mysql_fetch_assoc($result)) {
|
| 3949 |
+
return $row['entity_type_id'];
|
| 3950 |
+
}
|
| 3951 |
+
return false;
|
| 3952 |
}
|
| 3953 |
+
#################################################################################################
|
| 3954 |
+
|
| 3955 |
+
private function _getProductEntityTypeId(){
|
| 3956 |
+
if (!$this->_productEntityTypeId) {
|
| 3957 |
+
$this->_productEntityTypeId = $this->_getEntityTypeId('catalog_product');
|
| 3958 |
+
}
|
| 3959 |
+
return $this->_productEntityTypeId;
|
| 3960 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3961 |
#################################################################################
|
| 3962 |
|
| 3963 |
+
private function _getProductDefaulAttributeSetId(){
|
| 3964 |
+
if (!$this->defaultAttributeSetId) {
|
| 3965 |
+
$sql = "
|
| 3966 |
+
SELECT entity_type_id, default_attribute_set_id
|
| 3967 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('eav_entity_type')."
|
| 3968 |
+
WHERE entity_type_code = 'catalog_product'
|
| 3969 |
+
LIMIT 1
|
| 3970 |
+
";
|
| 3971 |
+
$result = $this->db_do($sql);
|
| 3972 |
+
if ($row = mysql_fetch_assoc($result)) {
|
| 3973 |
|
| 3974 |
$this->defaultAttributeSetId = $row['default_attribute_set_id'];
|
| 3975 |
+
}
|
| 3976 |
+
}
|
| 3977 |
+
return $this->defaultAttributeSetId;
|
| 3978 |
+
}
|
| 3979 |
+
#################################################################################################
|
| 3980 |
+
|
| 3981 |
+
private function _getCategoryEntityTypeIdAndDefault_attribute_set_id(){
|
| 3982 |
+
if (!$this->_categoryEntityTypeId || !$this->_categoryDefault_attribute_set_id) {
|
| 3983 |
+
$sql = "
|
| 3984 |
+
SELECT entity_type_id, default_attribute_set_id
|
| 3985 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('eav_entity_type')."
|
| 3986 |
+
WHERE entity_type_code = 'catalog_category'
|
| 3987 |
+
LIMIT 1
|
| 3988 |
+
";
|
| 3989 |
+
$result = $this->db_do($sql);
|
| 3990 |
+
if ($row = mysql_fetch_assoc($result)) {
|
| 3991 |
+
$this->_categoryEntityTypeId = $row['entity_type_id'];
|
| 3992 |
+
$this->_categoryDefault_attribute_set_id = $row['default_attribute_set_id'];
|
| 3993 |
+
}
|
| 3994 |
+
|
| 3995 |
+
}
|
| 3996 |
+
}
|
| 3997 |
##################################################################################################
|
| 3998 |
|
| 3999 |
+
private function _getAttributeId($attributeCode,$typeCode)
|
| 4000 |
+
{
|
| 4001 |
if ($typeCode=='catalog_product') {
|
| 4002 |
+
$typeId = $this->_getProductEntityTypeId();
|
| 4003 |
}
|
| 4004 |
else {
|
| 4005 |
+
$typeId = $this->_getEntityTypeId($typeCode);
|
| 4006 |
+
}
|
| 4007 |
+
if (!isset($this->_attributeId[$typeCode]) OR !is_array($this->_attributeId[$typeCode])) {
|
| 4008 |
+
$sql = "
|
| 4009 |
+
SELECT attribute_id, attribute_code
|
| 4010 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute')."
|
| 4011 |
+
WHERE entity_type_id = '" . $typeId . "'
|
| 4012 |
+
";
|
| 4013 |
+
$result = $this->db_do($sql);
|
| 4014 |
+
while ($row = mysql_fetch_assoc($result)) {
|
| 4015 |
+
$this->_attributeId[$typeCode][$row['attribute_code']] = $row['attribute_id'];
|
| 4016 |
+
}
|
| 4017 |
+
}
|
| 4018 |
+
// echo 'attribute code: '.$attributeCode.','.$typeCode.' => '.$this->_attributeId[$typeCode][$attributeCode].PHP_EOL;
|
| 4019 |
+
return $this->_attributeId[$typeCode][$attributeCode];
|
| 4020 |
+
}
|
| 4021 |
##################################################################################################
|
| 4022 |
|
| 4023 |
+
private function repl_ph($content,$hash){
|
| 4024 |
+
if($hash){
|
| 4025 |
+
foreach($hash as $key => $val){
|
| 4026 |
+
if ($key=="category_name") {
|
| 4027 |
+
if (strlen($val)>25) { $val = substr($val,0,24)."..."; }
|
| 4028 |
+
}
|
| 4029 |
+
$content = preg_replace("/%%%$key%%%/",$val,$content);
|
| 4030 |
+
}
|
| 4031 |
+
}
|
| 4032 |
+
return $content;
|
| 4033 |
+
}
|
| 4034 |
##################################################################################################
|
| 4035 |
|
| 4036 |
+
private function _getProductAttributeId($attributeCode) {
|
| 4037 |
+
return $this->_getAttributeId($attributeCode,'catalog_product');
|
| 4038 |
+
}
|
| 4039 |
##################################################################################################
|
| 4040 |
|
| 4041 |
+
private function _getCategoryAttributeId($attributeCode) {
|
| 4042 |
+
return $this->_getAttributeId($attributeCode,'catalog_category');
|
| 4043 |
+
}
|
| 4044 |
##################################################################################################
|
| 4045 |
+
private function _getShopRootCategoryId($cat_id=0){
|
| 4046 |
+
if($root_cat = Mage::app()->getStore()->getRootCategoryId()){
|
| 4047 |
+
return $root_cat;
|
| 4048 |
+
}else{
|
| 4049 |
+
$q="SELECT
|
| 4050 |
+
entity_id
|
| 4051 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar')."
|
| 4052 |
+
WHERE
|
| 4053 |
+
value='default-category'";
|
| 4054 |
+
$res=$this->db_do($q);
|
| 4055 |
+
$row=mysql_fetch_array($res);
|
| 4056 |
+
if($row['entity_id']>0){
|
| 4057 |
+
return $row['entity_id'];
|
| 4058 |
+
}else{
|
| 4059 |
+
$q="SELECT entity_id
|
| 4060 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
| 4061 |
+
WHERE parent_id=".$cat_id;
|
| 4062 |
+
$quer=$this->db_do($q);
|
| 4063 |
+
$count=0;
|
| 4064 |
+
while ($row=mysql_fetch_array($quer)){
|
| 4065 |
+
$count++;
|
| 4066 |
+
$entity_id=$row['entity_id'];
|
| 4067 |
+
}
|
| 4068 |
+
if($count>1 || $count==0){
|
| 4069 |
+
return ($cat_id);
|
| 4070 |
+
}else{
|
| 4071 |
+
return $this->_getShopRootCategoryId($entity_id);
|
| 4072 |
+
}
|
| 4073 |
+
}
|
| 4074 |
+
}
|
| 4075 |
+
}
|
| 4076 |
+
##################################################################################################
|
| 4077 |
+
private function _cleanCateoryProductFlatTable(){
|
| 4078 |
+
$dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
|
| 4079 |
+
$q='SHOW TABLES LIKE "'.Mage::getSingleton('core/resource')->getTableName('catalog_product_flat_').'%"';
|
| 4080 |
+
$quer=$this->db_do($q);
|
| 4081 |
+
$result=false;
|
| 4082 |
+
While($row=mysql_fetch_array($quer)){
|
| 4083 |
+
if(is_array($row)){
|
| 4084 |
+
$catalog_product_flat=array_pop($row);
|
| 4085 |
+
$q='DELETE pf1 FROM '.$catalog_product_flat.' pf1
|
| 4086 |
+
LEFT JOIN '.Mage::getSingleton('core/resource')->getTableName('catalog_product_entity').' p
|
| 4087 |
+
ON pf1.entity_id = p.entity_id
|
| 4088 |
+
WHERE p.entity_id IS NULL;';
|
| 4089 |
+
$this->db_do($q);
|
| 4090 |
+
$this->_LOG('cleaned wrong rows from '.$catalog_product_flat);
|
| 4091 |
+
}
|
| 4092 |
+
}
|
| 4093 |
+
return $result;
|
| 4094 |
+
|
| 4095 |
+
}
|
| 4096 |
+
##################################################################################################
|
| 4097 |
+
|
| 4098 |
+
|
| 4099 |
+
|
| 4100 |
+
|
| 4101 |
+
|
| 4102 |
+
##################################################################################################
|
| 4103 |
+
public function checkMemory() {
|
| 4104 |
+
$check_code = 'memory';
|
| 4105 |
+
|
| 4106 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4107 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4108 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4109 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4110 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4111 |
+
|
| 4112 |
+
|
| 4113 |
+
$Caption = $row['caption'];
|
| 4114 |
+
$CheckValue = $row['check_value'];
|
| 4115 |
+
$CheckMeasure = $row['check_measure'];
|
| 4116 |
+
$ErrorMessage = $row['error_msg'];
|
| 4117 |
+
$FixMessage = $row['fix_msg'];
|
| 4118 |
+
|
| 4119 |
+
$retvalue = array();
|
| 4120 |
+
$retvalue["'$check_code'"] = array();
|
| 4121 |
+
|
| 4122 |
+
$data = explode("\n", file_get_contents("/proc/meminfo"));
|
| 4123 |
+
|
| 4124 |
+
$meminfo = array();
|
| 4125 |
+
foreach ($data as $line) {
|
| 4126 |
+
list($key, $val) = explode(":", $line);
|
| 4127 |
+
$meminfo[$key] = trim($val);
|
| 4128 |
+
|
| 4129 |
+
if ($key == 'MemTotal') {
|
| 4130 |
+
$val = trim($val);
|
| 4131 |
+
$value = (int)substr($val, 0, strpos($val, ' kB'));
|
| 4132 |
+
$measure = substr($val, strpos($val, ' kB'));
|
| 4133 |
+
|
| 4134 |
+
$retvalue['memory']['value'] = (integer)(((float)$value)/1024); // (float)$value
|
| 4135 |
+
$retvalue['memory']['measure'] = 'MB'; // $measure;
|
| 4136 |
+
}
|
| 4137 |
+
}
|
| 4138 |
+
|
| 4139 |
+
$errmsg = '';
|
| 4140 |
+
$fixmsg = '';
|
| 4141 |
+
if ($retvalue['memory']['value'] <= $CheckValue) {
|
| 4142 |
+
$errmsg .= sprintf($ErrorMessage, $retvalue['memory']['value']); //." ".$retvalue['memory']['value']." ".$retvalue['memory']['measure'];
|
| 4143 |
+
$fixmsg .= sprintf($FixMessage, " ".$CheckValue." ".$CheckMeasure);
|
| 4144 |
+
$retvalue['memory']['status'] = 'error';
|
| 4145 |
+
} else {
|
| 4146 |
+
$errmsg .= 'none';
|
| 4147 |
+
$fixmsg .= 'none';
|
| 4148 |
+
$retvalue['memory']['status'] = 'OK';
|
| 4149 |
+
}
|
| 4150 |
+
|
| 4151 |
+
$ret = array();
|
| 4152 |
+
array_push($ret, $retvalue['memory']['status'], $Caption, $CheckValue, $retvalue['memory']['value'], $CheckMeasure, $errmsg, $fixmsg);
|
| 4153 |
+
|
| 4154 |
+
return $ret;
|
| 4155 |
+
} // public function getImportEnvironment()
|
| 4156 |
+
##################################################################################################
|
| 4157 |
+
|
| 4158 |
+
|
| 4159 |
+
|
| 4160 |
+
|
| 4161 |
+
##################################################################################################
|
| 4162 |
+
public function checkLoaddata() {
|
| 4163 |
+
$check_code = 'loaddata';
|
| 4164 |
+
|
| 4165 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4166 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4167 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4168 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4169 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4170 |
+
|
| 4171 |
+
$Caption = $row['caption'];
|
| 4172 |
+
$CheckValue = $row['check_value'];
|
| 4173 |
+
$CheckMeasure = $row['check_measure'];
|
| 4174 |
+
$ErrorMessage = $row['error_msg'];
|
| 4175 |
+
$FixMessage = $row['fix_msg'];
|
| 4176 |
+
|
| 4177 |
+
$retvalue = array();
|
| 4178 |
+
$retvalue["'$check_code'"] = array();
|
| 4179 |
+
|
| 4180 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4181 |
+
$result = $conn->query("SHOW VARIABLES LIKE 'local_infile'");
|
| 4182 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4183 |
+
$value = $row['Value'];
|
| 4184 |
+
|
| 4185 |
+
|
| 4186 |
+
$errmsg = '';
|
| 4187 |
+
$fixmsg = '';
|
| 4188 |
+
if ($value != $CheckValue) {
|
| 4189 |
+
$errmsg .= $ErrorMessage." ".$value." ".$CheckMeasure;
|
| 4190 |
+
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
| 4191 |
+
$status = 'error';
|
| 4192 |
+
} else {
|
| 4193 |
+
$errmsg .= 'none';
|
| 4194 |
+
$fixmsg .= 'none';
|
| 4195 |
+
$status = 'OK';
|
| 4196 |
+
}
|
| 4197 |
+
|
| 4198 |
+
$ret = array();
|
| 4199 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4200 |
+
|
| 4201 |
+
return $ret;
|
| 4202 |
+
} // public function getImportEnvironment()
|
| 4203 |
+
##################################################################################################
|
| 4204 |
+
|
| 4205 |
+
|
| 4206 |
+
|
| 4207 |
+
|
| 4208 |
+
##################################################################################################
|
| 4209 |
+
public function checkPhpsafemode() {
|
| 4210 |
+
$check_code = 'phpsafemode';
|
| 4211 |
+
|
| 4212 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4213 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4214 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4215 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4216 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4217 |
+
|
| 4218 |
+
$Caption = $row['caption'];
|
| 4219 |
+
$CheckValue = $row['check_value'];
|
| 4220 |
+
$CheckMeasure = $row['check_measure'];
|
| 4221 |
+
$ErrorMessage = $row['error_msg'];
|
| 4222 |
+
$FixMessage = $row['fix_msg'];
|
| 4223 |
+
|
| 4224 |
+
$retvalue = array();
|
| 4225 |
+
$retvalue["'$check_code'"] = array();
|
| 4226 |
+
|
| 4227 |
+
$a = ini_get('safe_mode');
|
| 4228 |
+
if ($a) {
|
| 4229 |
+
$value = 'ON';
|
| 4230 |
+
} else {
|
| 4231 |
+
$value = 'OFF';
|
| 4232 |
+
}
|
| 4233 |
+
|
| 4234 |
+
$errmsg = '';
|
| 4235 |
+
$fixmsg = '';
|
| 4236 |
+
if ($value != $CheckValue) {
|
| 4237 |
+
$errmsg .= sprintf($ErrorMessage, " ".$value." ".$CheckMeasure);
|
| 4238 |
+
$fixmsg .= sprintf($FixMessage, " ".$CheckValue." ".$CheckMeasure);
|
| 4239 |
+
$status = 'error';
|
| 4240 |
+
} else {
|
| 4241 |
+
$errmsg .= 'none';
|
| 4242 |
+
$fixmsg .= 'none';
|
| 4243 |
+
$status = 'OK';
|
| 4244 |
+
}
|
| 4245 |
+
|
| 4246 |
+
$ret = array();
|
| 4247 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4248 |
+
|
| 4249 |
+
return $ret;
|
| 4250 |
+
} // public function getImportEnvironment()
|
| 4251 |
##################################################################################################
|
| 4252 |
|
| 4253 |
+
|
| 4254 |
+
|
| 4255 |
+
|
| 4256 |
+
##################################################################################################
|
| 4257 |
+
public function checkWaittimeout() {
|
| 4258 |
+
$check_code = 'waittimeout';
|
| 4259 |
+
|
| 4260 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4261 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4262 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4263 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4264 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4265 |
+
|
| 4266 |
+
$Caption = $row['caption'];
|
| 4267 |
+
$CheckValue = $row['check_value'];
|
| 4268 |
+
$CheckMeasure = $row['check_measure'];
|
| 4269 |
+
$ErrorMessage = $row['error_msg'];
|
| 4270 |
+
$FixMessage = $row['fix_msg'];
|
| 4271 |
+
|
| 4272 |
+
$retvalue = array();
|
| 4273 |
+
$retvalue["'$check_code'"] = array();
|
| 4274 |
+
|
| 4275 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4276 |
+
$result = $conn->query("SHOW VARIABLES LIKE 'wait_timeout'");
|
| 4277 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4278 |
+
$value = $row['Value'];
|
| 4279 |
+
|
| 4280 |
+
$errmsg = '';
|
| 4281 |
+
$fixmsg = '';
|
| 4282 |
+
if ($value <= $CheckValue) {
|
| 4283 |
+
$errmsg .= $ErrorMessage." ".$value." ".$CheckMeasure;
|
| 4284 |
+
$fixmsg .= sprintf($FixMessage, " ".$CheckValue);
|
| 4285 |
+
$status = 'error';
|
| 4286 |
+
} else {
|
| 4287 |
+
$errmsg .= 'none';
|
| 4288 |
+
$fixmsg .= 'none';
|
| 4289 |
+
$status = 'OK';
|
| 4290 |
+
}
|
| 4291 |
+
|
| 4292 |
+
$ret = array();
|
| 4293 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4294 |
+
|
| 4295 |
+
return $ret;
|
| 4296 |
+
} // public function getImportEnvironment()
|
| 4297 |
+
##################################################################################################
|
| 4298 |
+
|
| 4299 |
+
|
| 4300 |
+
|
| 4301 |
+
|
| 4302 |
+
##################################################################################################
|
| 4303 |
+
public function checkInnodbbufferpoolsize() {
|
| 4304 |
+
$check_code = 'innodbbufpool';
|
| 4305 |
+
|
| 4306 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4307 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4308 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4309 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4310 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4311 |
+
|
| 4312 |
+
$Caption = $row['caption'];
|
| 4313 |
+
$CheckValue = $row['check_value'];
|
| 4314 |
+
$CheckMeasure = $row['check_measure'];
|
| 4315 |
+
$ErrorMessage = $row['error_msg'];
|
| 4316 |
+
$FixMessage = $row['fix_msg'];
|
| 4317 |
+
|
| 4318 |
+
$retvalue = array();
|
| 4319 |
+
$retvalue["'$check_code'"] = array();
|
| 4320 |
+
|
| 4321 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4322 |
+
$result = $conn->query("SHOW VARIABLES LIKE 'innodb_buffer_pool_size'");
|
| 4323 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4324 |
+
$value = (int)($row['Value']/(1024*1024));
|
| 4325 |
+
|
| 4326 |
+
$errmsg = '';
|
| 4327 |
+
$fixmsg = '';
|
| 4328 |
+
if ($value <= $CheckValue) {
|
| 4329 |
+
$errmsg .= sprintf($ErrorMessage, " ".$value." ".$CheckMeasure);
|
| 4330 |
+
$fixmsg .= sprintf($FixMessage, " ".$CheckValue." ".$CheckMeasure);
|
| 4331 |
+
$status = 'error';
|
| 4332 |
+
} else {
|
| 4333 |
+
$errmsg .= 'none';
|
| 4334 |
+
$fixmsg .= 'none';
|
| 4335 |
+
$status = 'OK';
|
| 4336 |
+
}
|
| 4337 |
+
|
| 4338 |
+
$ret = array();
|
| 4339 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4340 |
+
|
| 4341 |
+
return $ret;
|
| 4342 |
+
} // public function getImportEnvironment()
|
| 4343 |
+
##################################################################################################
|
| 4344 |
+
|
| 4345 |
+
|
| 4346 |
+
|
| 4347 |
+
|
| 4348 |
+
##################################################################################################
|
| 4349 |
+
public function checkPhprunstring() {
|
| 4350 |
+
$check_code = 'php5run';
|
| 4351 |
+
|
| 4352 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4353 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4354 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4355 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4356 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4357 |
+
|
| 4358 |
+
$Caption = $row['caption'];
|
| 4359 |
+
$CheckValue = $row['check_value'];
|
| 4360 |
+
$CheckMeasure = $row['check_measure'];
|
| 4361 |
+
$ErrorMessage = $row['error_msg'];
|
| 4362 |
+
$FixMessage = $row['fix_msg'];
|
| 4363 |
+
|
| 4364 |
+
$retvalue = array();
|
| 4365 |
+
$retvalue["'$check_code'"] = array();
|
| 4366 |
+
|
| 4367 |
+
$value = trim(PHP_RUN_STRING);
|
| 4368 |
+
|
| 4369 |
+
$errmsg = '';
|
| 4370 |
+
$fixmsg = '';
|
| 4371 |
+
if ($value != $CheckValue) {
|
| 4372 |
+
$errmsg .= $ErrorMessage." ".$value." ".$CheckMeasure;
|
| 4373 |
+
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
| 4374 |
+
$status = 'error';
|
| 4375 |
+
} else {
|
| 4376 |
+
$errmsg .= 'none';
|
| 4377 |
+
$fixmsg .= 'none';
|
| 4378 |
+
$status = 'OK';
|
| 4379 |
+
}
|
| 4380 |
+
|
| 4381 |
+
$ret = array();
|
| 4382 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4383 |
+
|
| 4384 |
+
return $ret;
|
| 4385 |
+
} // public function getImportEnvironment()
|
| 4386 |
+
##################################################################################################
|
| 4387 |
+
|
| 4388 |
+
|
| 4389 |
+
|
| 4390 |
+
|
| 4391 |
+
##################################################################################################
|
| 4392 |
+
public function checkChmodwgetdatafile() {
|
| 4393 |
+
$check_code = 'chmodwget';
|
| 4394 |
+
|
| 4395 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4396 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4397 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4398 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4399 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4400 |
+
|
| 4401 |
+
$Caption = $row['caption'];
|
| 4402 |
+
$CheckValue = $row['check_value'];
|
| 4403 |
+
$CheckMeasure = $row['check_measure'];
|
| 4404 |
+
$ErrorMessage = $row['error_msg'];
|
| 4405 |
+
$FixMessage = $row['fix_msg'];
|
| 4406 |
+
|
| 4407 |
+
$retvalue = array();
|
| 4408 |
+
$retvalue["'$check_code'"] = array();
|
| 4409 |
+
|
| 4410 |
+
$datafile_csv = '/usr/bin/wget';
|
| 4411 |
+
|
| 4412 |
+
$value = substr(sprintf('%o', fileperms($datafile_csv)), -4);
|
| 4413 |
+
|
| 4414 |
+
$CheckValue_own = $CheckValue{1};
|
| 4415 |
+
$CheckValue_group = $CheckValue{2};
|
| 4416 |
+
$CheckValue_other = $CheckValue{3};
|
| 4417 |
+
|
| 4418 |
+
$value_own = $value{1};
|
| 4419 |
+
$value_group = $value{2};
|
| 4420 |
+
$value_other = $value{3};
|
| 4421 |
+
|
| 4422 |
+
$errmsg = '';
|
| 4423 |
+
$fixmsg = '';
|
| 4424 |
+
//if ($value <= $CheckValue) {
|
| 4425 |
+
if (($value_own < $CheckValue_own) || ($value_group < $CheckValue_group) || ($value_other < $CheckValue_other)) {
|
| 4426 |
+
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
| 4427 |
+
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
| 4428 |
+
$status = 'error';
|
| 4429 |
+
} else {
|
| 4430 |
+
$errmsg .= 'none';
|
| 4431 |
+
$fixmsg .= 'none';
|
| 4432 |
+
$status = 'OK';
|
| 4433 |
+
}
|
| 4434 |
+
|
| 4435 |
+
$ret = array();
|
| 4436 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4437 |
+
|
| 4438 |
+
return $ret;
|
| 4439 |
+
} // public function getImportEnvironment()
|
| 4440 |
+
##################################################################################################
|
| 4441 |
+
|
| 4442 |
+
|
| 4443 |
+
|
| 4444 |
+
|
| 4445 |
+
##################################################################################################
|
| 4446 |
+
public function checkChmodwgetcronphpfile() {
|
| 4447 |
+
$check_code = 'chmodcronphp';
|
| 4448 |
+
|
| 4449 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4450 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4451 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4452 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4453 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4454 |
+
|
| 4455 |
+
$Caption = $row['caption'];
|
| 4456 |
+
$CheckValue = $row['check_value'];
|
| 4457 |
+
$CheckMeasure = $row['check_measure'];
|
| 4458 |
+
$ErrorMessage = $row['error_msg'];
|
| 4459 |
+
$FixMessage = $row['fix_msg'];
|
| 4460 |
+
|
| 4461 |
+
$retvalue = array();
|
| 4462 |
+
$retvalue["'$check_code'"] = array();
|
| 4463 |
+
|
| 4464 |
+
$cronfile_php = Mage::getBaseDir().'/cron.php';
|
| 4465 |
+
|
| 4466 |
+
$value = substr(sprintf('%o', fileperms($cronfile_php)), -4);
|
| 4467 |
+
|
| 4468 |
+
$CheckValue_own = $CheckValue{1};
|
| 4469 |
+
$CheckValue_group = $CheckValue{2};
|
| 4470 |
+
$CheckValue_other = $CheckValue{3};
|
| 4471 |
+
|
| 4472 |
+
$value_own = $value{1};
|
| 4473 |
+
$value_group = $value{2};
|
| 4474 |
+
$value_other = $value{3};
|
| 4475 |
+
|
| 4476 |
+
$errmsg = '';
|
| 4477 |
+
$fixmsg = '';
|
| 4478 |
+
//if ($value <= $CheckValue) {
|
| 4479 |
+
if (($value_own < $CheckValue_own) || ($value_group < $CheckValue_group) || ($value_other < $CheckValue_other)) {
|
| 4480 |
+
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
| 4481 |
+
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
| 4482 |
+
$status = 'error';
|
| 4483 |
+
} else {
|
| 4484 |
+
$errmsg .= 'none';
|
| 4485 |
+
$fixmsg .= 'none';
|
| 4486 |
+
$status = 'OK';
|
| 4487 |
+
}
|
| 4488 |
+
|
| 4489 |
+
$ret = array();
|
| 4490 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4491 |
+
|
| 4492 |
+
return $ret;
|
| 4493 |
+
} // public function checkChmodwgetcronphpfile()
|
| 4494 |
+
##################################################################################################
|
| 4495 |
+
|
| 4496 |
+
|
| 4497 |
+
|
| 4498 |
+
|
| 4499 |
+
##################################################################################################
|
| 4500 |
+
public function checkChmodwgetcronshfile() {
|
| 4501 |
+
$check_code = 'chmodcronsh';
|
| 4502 |
+
|
| 4503 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4504 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4505 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4506 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4507 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4508 |
+
|
| 4509 |
+
$Caption = $row['caption'];
|
| 4510 |
+
$CheckValue = $row['check_value'];
|
| 4511 |
+
$CheckMeasure = $row['check_measure'];
|
| 4512 |
+
$ErrorMessage = $row['error_msg'];
|
| 4513 |
+
$FixMessage = $row['fix_msg'];
|
| 4514 |
+
|
| 4515 |
+
$retvalue = array();
|
| 4516 |
+
$retvalue["'$check_code'"] = array();
|
| 4517 |
+
|
| 4518 |
+
$cronfile_sh = Mage::getBaseDir().'/cron.sh';
|
| 4519 |
+
|
| 4520 |
+
$value = substr(sprintf('%o', fileperms($cronfile_sh)), -4);
|
| 4521 |
+
|
| 4522 |
+
$CheckValue_own = $CheckValue{1};
|
| 4523 |
+
$CheckValue_group = $CheckValue{2};
|
| 4524 |
+
$CheckValue_other = $CheckValue{3};
|
| 4525 |
+
|
| 4526 |
+
$value_own = $value{1};
|
| 4527 |
+
$value_group = $value{2};
|
| 4528 |
+
$value_other = $value{3};
|
| 4529 |
+
|
| 4530 |
+
$errmsg = '';
|
| 4531 |
+
$fixmsg = '';
|
| 4532 |
+
//if ($value <= $CheckValue) {
|
| 4533 |
+
if (($value_own < $CheckValue_own) || ($value_group < $CheckValue_group) || ($value_other < $CheckValue_other)) {
|
| 4534 |
+
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
| 4535 |
+
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
| 4536 |
+
$status = 'error';
|
| 4537 |
+
} else {
|
| 4538 |
+
$errmsg .= 'none';
|
| 4539 |
+
$fixmsg .= 'none';
|
| 4540 |
+
$status = 'OK';
|
| 4541 |
+
}
|
| 4542 |
+
|
| 4543 |
+
$ret = array();
|
| 4544 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4545 |
+
|
| 4546 |
+
return $ret;
|
| 4547 |
+
} // public function checkChmodwgetcronphpfile()
|
| 4548 |
+
##################################################################################################
|
| 4549 |
+
|
| 4550 |
+
|
| 4551 |
+
|
| 4552 |
+
|
| 4553 |
+
##################################################################################################
|
| 4554 |
+
public function checkProcedure() {
|
| 4555 |
+
$check_code = 'routine';
|
| 4556 |
+
|
| 4557 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4558 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
| 4559 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
| 4560 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4561 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
| 4562 |
+
|
| 4563 |
+
$Caption = $row['caption'];
|
| 4564 |
+
$CheckValue = $row['check_value'];
|
| 4565 |
+
$CheckMeasure = $row['check_measure'];
|
| 4566 |
+
$ErrorMessage = $row['error_msg'];
|
| 4567 |
+
$FixMessage = $row['fix_msg'];
|
| 4568 |
+
|
| 4569 |
+
$retvalue = array();
|
| 4570 |
+
$retvalue["'$check_code'"] = array();
|
| 4571 |
+
|
| 4572 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 4573 |
+
$storedFunctionName = Mage::getSingleton('core/resource')->getTableName('filter_icecat_products_s');
|
| 4574 |
+
$result = $conn->query("SHOW PROCEDURE STATUS LIKE '$storedFunctionName'");
|
| 4575 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
| 4576 |
+
$value = $row['Name'];
|
| 4577 |
+
|
| 4578 |
+
$errmsg = '';
|
| 4579 |
+
$fixmsg = '';
|
| 4580 |
+
if ($value != $CheckValue) {
|
| 4581 |
+
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
| 4582 |
+
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
| 4583 |
+
$status = 'error';
|
| 4584 |
+
} else {
|
| 4585 |
+
$errmsg .= 'none';
|
| 4586 |
+
$fixmsg .= 'none';
|
| 4587 |
+
$status = 'OK';
|
| 4588 |
+
}
|
| 4589 |
+
|
| 4590 |
+
$ret = array();
|
| 4591 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
| 4592 |
+
|
| 4593 |
+
return $ret;
|
| 4594 |
+
} // public function getImportEnvironment()
|
| 4595 |
+
##################################################################################################
|
| 4596 |
+
|
| 4597 |
+
|
| 4598 |
+
|
| 4599 |
+
} // class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract
|
| 4600 |
+
|
| 4601 |
+
|
| 4602 |
+
|
| 4603 |
|
| 4604 |
?>
|
| 4605 |
+
|
| 4606 |
+
|
| 4607 |
+
|
| 4608 |
+
|
| 4609 |
+
|
app/code/local/Bintime/Sinchimport/Model/config.php
CHANGED
|
@@ -27,14 +27,6 @@
|
|
| 27 |
define(FILE_URL_AND_DIR, "ftp://%%%login%%%:%%%password%%%@ftp.stockinthechannel.com/"); // insert StockInTheChannel url (default ftp://%%%login%%%:%%%password%%%@ftp.stockinthechannel.com/)
|
| 28 |
define(DEFAULT_FILE_TERMINATED_CHAR, "|");
|
| 29 |
|
| 30 |
-
define (TABLE_SINCH_CAT, "categories_temp");
|
| 31 |
-
define (TABLE_SINCH_MANUF, "manufacturers_temp");
|
| 32 |
-
define (TABLE_CATEGORY_ENTITY, "catalog_category_entity");
|
| 33 |
-
define (TABLE_CATEGORY_ENTITY_VARCHAR, "catalog_category_entity_varchar");
|
| 34 |
-
define (TABLE_CATEGORY_ENTITY_INT, "catalog_category_entity_int");
|
| 35 |
-
define (TABLE_ATTRIBUTE_OPT, "eav_attribute_option");
|
| 36 |
-
define (TABLE_ATTRIBUTE_OPT_VALUE,"eav_attribute_option_value");
|
| 37 |
-
|
| 38 |
define(LANG_CODE, 'en');
|
| 39 |
define(REWRITE_CATEGORIES_ORDER_ID, 'FALSE'); //TRUE FALSE
|
| 40 |
define(PHP_RUN_STRING, 'php ');
|
|
@@ -50,7 +42,4 @@
|
|
| 50 |
");
|
| 51 |
define("UPDATE_CATEGORY_DATA", false);
|
| 52 |
|
| 53 |
-
// require_once(INCL_PATH . 'utils/utils.php');
|
| 54 |
-
// require_once(CLASS_PATH . 'StockInTheChannel.php');
|
| 55 |
-
|
| 56 |
?>
|
| 27 |
define(FILE_URL_AND_DIR, "ftp://%%%login%%%:%%%password%%%@ftp.stockinthechannel.com/"); // insert StockInTheChannel url (default ftp://%%%login%%%:%%%password%%%@ftp.stockinthechannel.com/)
|
| 28 |
define(DEFAULT_FILE_TERMINATED_CHAR, "|");
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
define(LANG_CODE, 'en');
|
| 31 |
define(REWRITE_CATEGORIES_ORDER_ID, 'FALSE'); //TRUE FALSE
|
| 32 |
define(PHP_RUN_STRING, 'php ');
|
| 42 |
");
|
| 43 |
define("UPDATE_CATEGORY_DATA", false);
|
| 44 |
|
|
|
|
|
|
|
|
|
|
| 45 |
?>
|
app/code/local/Bintime/Sinchimport/etc/config.xml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
|
| 5 |
<modules>
|
| 6 |
<Bintime_Sinchimport>
|
| 7 |
-
<version>0.1
|
| 8 |
<depends>
|
| 9 |
<!-- no dependencies -->
|
| 10 |
</depends>
|
|
@@ -228,13 +228,13 @@
|
|
| 228 |
<crontab>
|
| 229 |
<jobs>
|
| 230 |
<fullsinchimport>
|
| 231 |
-
<schedule><cron_expr>0
|
| 232 |
<run><model>sinchimport/sinch::cron_start_full_import</model></run>
|
| 233 |
|
| 234 |
</fullsinchimport>
|
| 235 |
<stockpricesinchimport>
|
| 236 |
|
| 237 |
-
<schedule><cron_expr>0
|
| 238 |
<run><model>sinchimport/sinch::cron_start_stock_price_import</model></run>
|
| 239 |
|
| 240 |
</stockpricesinchimport>
|
| 4 |
|
| 5 |
<modules>
|
| 6 |
<Bintime_Sinchimport>
|
| 7 |
+
<version>0.2.1</version>
|
| 8 |
<depends>
|
| 9 |
<!-- no dependencies -->
|
| 10 |
</depends>
|
| 228 |
<crontab>
|
| 229 |
<jobs>
|
| 230 |
<fullsinchimport>
|
| 231 |
+
<schedule><cron_expr>0 22 * * 6</cron_expr></schedule>
|
| 232 |
<run><model>sinchimport/sinch::cron_start_full_import</model></run>
|
| 233 |
|
| 234 |
</fullsinchimport>
|
| 235 |
<stockpricesinchimport>
|
| 236 |
|
| 237 |
+
<schedule><cron_expr>0 8 * * *</cron_expr></schedule>
|
| 238 |
<run><model>sinchimport/sinch::cron_start_stock_price_import</model></run>
|
| 239 |
|
| 240 |
</stockpricesinchimport>
|
app/code/local/Bintime/Sinchimport/etc/system.xml
CHANGED
|
@@ -146,9 +146,30 @@
|
|
| 146 |
<show_in_store>0</show_in_store>
|
| 147 |
</sinch_import_hist>
|
| 148 |
</fields>
|
| 149 |
-
|
| 150 |
-
|
| 151 |
</sinch_import_history>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
</groups>
|
| 153 |
</sinchimport_root>
|
| 154 |
</sections>
|
| 146 |
<show_in_store>0</show_in_store>
|
| 147 |
</sinch_import_hist>
|
| 148 |
</fields>
|
|
|
|
|
|
|
| 149 |
</sinch_import_history>
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
<sinch_import_environment>
|
| 153 |
+
<label>Check Server Configuration</label>
|
| 154 |
+
<frontend_type>text</frontend_type>
|
| 155 |
+
<comment></comment>
|
| 156 |
+
<sort_order>20</sort_order>
|
| 157 |
+
<show_in_default>1</show_in_default>
|
| 158 |
+
<show_in_website>1</show_in_website>
|
| 159 |
+
<show_in_store>1</show_in_store>
|
| 160 |
+
<fields>
|
| 161 |
+
<sinch_import_env translate="label">
|
| 162 |
+
<!--label>Your Stock In The Channel Environment Check Summary</label-->
|
| 163 |
+
<frontend_model>sinchimport/importenvironment</frontend_model>
|
| 164 |
+
<sort_order>4</sort_order>
|
| 165 |
+
<show_in_default>1</show_in_default>
|
| 166 |
+
<show_in_website>1</show_in_website>
|
| 167 |
+
<show_in_store>1</show_in_store>
|
| 168 |
+
</sinch_import_env>
|
| 169 |
+
</fields>
|
| 170 |
+
</sinch_import_environment>
|
| 171 |
+
|
| 172 |
+
|
| 173 |
</groups>
|
| 174 |
</sinchimport_root>
|
| 175 |
</sections>
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-install-0.1.0.php
CHANGED
|
@@ -24,10 +24,10 @@ $installer->run("CREATE TABLE {$installer->getTable('FilterListOfFeatures')}(
|
|
| 24 |
`feature_value` text
|
| 25 |
)");
|
| 26 |
|
| 27 |
-
$installer->run("DROP PROCEDURE IF EXISTS
|
| 28 |
|
| 29 |
$query = "
|
| 30 |
-
CREATE PROCEDURE
|
| 31 |
IN arg_table INT,
|
| 32 |
IN arg_category_id INT,
|
| 33 |
IN arg_image INT,
|
|
@@ -58,16 +58,16 @@ BEGIN
|
|
| 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 catalog_product_entity E
|
| 62 |
-
INNER JOIN catalog_category_product_index PCind
|
| 63 |
ON (E.entity_id = PCind.product_id)
|
| 64 |
-
INNER JOIN stINch_categories_features CF
|
| 65 |
ON (PCind.category_id=CF.store_category_id)
|
| 66 |
-
INNER JOIN stINch_products PR
|
| 67 |
ON (PR.store_product_id = E.entity_id)
|
| 68 |
-
INNER JOIN stINch_product_features PF
|
| 69 |
ON (PR.sinch_product_id = PF.sinch_product_id )
|
| 70 |
-
INNER JOIN stINch_restricted_values RV
|
| 71 |
ON (PF.restricted_value_id=RV.restricted_value_id)
|
| 72 |
WHERE
|
| 73 |
PCind.category_id = arg_category_id
|
|
@@ -77,16 +77,16 @@ BEGIN
|
|
| 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 catalog_product_entity E
|
| 81 |
-
INNER JOIN catalog_category_product_index PCind
|
| 82 |
ON (E.entity_id = PCind.product_id)
|
| 83 |
-
INNER JOIN stINch_categories_features CF
|
| 84 |
ON (PCind.category_id=CF.store_category_id)
|
| 85 |
-
INNER JOIN stINch_products PR
|
| 86 |
ON (PR.store_product_id = E.entity_id)
|
| 87 |
-
INNER JOIN stINch_product_features PF
|
| 88 |
ON (PR.sinch_product_id = PF.sinch_product_id )
|
| 89 |
-
INNER JOIN stINch_restricted_values RV
|
| 90 |
ON (PF.restricted_value_id=RV.restricted_value_id)
|
| 91 |
WHERE
|
| 92 |
PCind.category_id = arg_category_id
|
| 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,
|
| 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
|
| 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
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.1-0.1.2.php
CHANGED
|
@@ -4,26 +4,51 @@ stepan
|
|
| 4 |
*/
|
| 5 |
$installer = $this;
|
| 6 |
|
| 7 |
-
$installer->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
$installer->run("
|
| 10 |
-
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
| 11 |
-
ADD COLUMN `store_product_id` INT(11) UNSIGNED NULL
|
| 12 |
-
");
|
| 13 |
-
$installer->run("
|
| 14 |
-
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
| 15 |
-
ADD INDEX `store_product_id` (`store_product_id`);
|
| 16 |
-
");
|
| 17 |
-
|
| 18 |
-
$installer->run("
|
| 19 |
-
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
| 20 |
-
ADD COLUMN `sinch_product_id` INT(11) UNSIGNED NULL
|
| 21 |
-
");
|
| 22 |
-
$installer->run("
|
| 23 |
-
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
| 24 |
-
ADD INDEX `sinch_product_id` (`sinch_product_id`);
|
| 25 |
-
");
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
//$installer->installEntities();
|
| 29 |
|
| 4 |
*/
|
| 5 |
$installer = $this;
|
| 6 |
|
| 7 |
+
$config = $installer->getConnection()->getConfig();
|
| 8 |
+
$cnx = mysql_connect($config['host'], $config['username'], $config['password']);
|
| 9 |
+
if (!$cnx) {
|
| 10 |
+
throw new Exception('Failed to connect to database.');
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
if (!mysql_select_db($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=mysql_query($q);
|
| 21 |
+
while($row=mysql_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 |
+
$installer->run("
|
| 34 |
+
ALTER TABLE {$this->getTable('catalog_product_entity')}
|
| 35 |
+
ADD COLUMN `store_product_id` INT(11) UNSIGNED NULL
|
| 36 |
+
");
|
| 37 |
+
$installer->run("
|
| 38 |
+
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
| 39 |
+
ADD INDEX `store_product_id` (`store_product_id`);
|
| 40 |
+
");
|
| 41 |
+
}
|
| 42 |
+
if($check_sinch_product_id){
|
| 43 |
+
$installer->run("
|
| 44 |
+
ALTER TABLE {$this->getTable('catalog_product_entity')}
|
| 45 |
+
ADD COLUMN `sinch_product_id` INT(11) UNSIGNED NULL
|
| 46 |
+
");
|
| 47 |
+
$installer->run("
|
| 48 |
+
ALTER IGNORE TABLE {$this->getTable('catalog_product_entity')}
|
| 49 |
+
ADD INDEX `sinch_product_id` (`sinch_product_id`);
|
| 50 |
+
");
|
| 51 |
+
}
|
| 52 |
|
| 53 |
//$installer->installEntities();
|
| 54 |
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.2-0.1.3.php
CHANGED
|
@@ -15,10 +15,10 @@ $installer = $this;
|
|
| 15 |
|
| 16 |
$installer->startSetup();
|
| 17 |
|
| 18 |
-
$installer->run("DROP PROCEDURE IF EXISTS
|
| 19 |
|
| 20 |
$query = "
|
| 21 |
-
CREATE PROCEDURE
|
| 22 |
IN arg_table INT,
|
| 23 |
IN arg_category_id INT,
|
| 24 |
IN arg_image INT,
|
|
@@ -49,16 +49,16 @@ BEGIN
|
|
| 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 catalog_product_entity E
|
| 53 |
-
INNER JOIN catalog_category_product_index PCind
|
| 54 |
ON (E.entity_id = PCind.product_id)
|
| 55 |
-
INNER JOIN stINch_categories_features CF
|
| 56 |
ON (PCind.category_id=CF.store_category_id)
|
| 57 |
-
INNER JOIN stINch_products PR
|
| 58 |
ON (PR.store_product_id = E.store_product_id)
|
| 59 |
-
INNER JOIN stINch_product_features PF
|
| 60 |
ON (PR.sinch_product_id = PF.sinch_product_id )
|
| 61 |
-
INNER JOIN stINch_restricted_values RV
|
| 62 |
ON (PF.restricted_value_id=RV.restricted_value_id)
|
| 63 |
WHERE
|
| 64 |
PCind.category_id = arg_category_id
|
|
@@ -68,16 +68,16 @@ BEGIN
|
|
| 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 catalog_product_entity E
|
| 72 |
-
INNER JOIN catalog_category_product_index PCind
|
| 73 |
ON (E.entity_id = PCind.product_id)
|
| 74 |
-
INNER JOIN stINch_categories_features CF
|
| 75 |
ON (PCind.category_id=CF.store_category_id)
|
| 76 |
-
INNER JOIN stINch_products PR
|
| 77 |
ON (PR.store_product_id = E.store_product_id)
|
| 78 |
-
INNER JOIN stINch_product_features PF
|
| 79 |
ON (PR.sinch_product_id = PF.sinch_product_id )
|
| 80 |
-
INNER JOIN stINch_restricted_values RV
|
| 81 |
ON (PF.restricted_value_id=RV.restricted_value_id)
|
| 82 |
WHERE
|
| 83 |
PCind.category_id = arg_category_id
|
| 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,
|
| 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
|
| 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
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.4-0.1.5.php
CHANGED
|
@@ -6,9 +6,9 @@ $installer = $this;
|
|
| 6 |
$installer->startSetup();
|
| 7 |
|
| 8 |
$installer->run("
|
| 9 |
-
DROP TABLE IF EXISTS
|
| 10 |
|
| 11 |
-
CREATE TABLE 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',
|
| 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',
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.5-0.1.6.php
CHANGED
|
@@ -6,7 +6,7 @@ $installer = $this;
|
|
| 6 |
$installer->startSetup();
|
| 7 |
|
| 8 |
$installer->run("
|
| 9 |
-
ALTER IGNORE TABLE stINch_import_status_statistic
|
| 10 |
ADD COLUMN `import_type` ENUM('FULL', 'PRICE STOCK') default NULL after finish_import
|
| 11 |
");
|
| 12 |
|
| 6 |
$installer->startSetup();
|
| 7 |
|
| 8 |
$installer->run("
|
| 9 |
+
ALTER IGNORE TABLE ".$installer->getTable('stINch_import_status_statistic')."
|
| 10 |
ADD COLUMN `import_type` ENUM('FULL', 'PRICE STOCK') default NULL after finish_import
|
| 11 |
");
|
| 12 |
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.6-0.1.7.php
CHANGED
|
@@ -15,29 +15,45 @@ $installer = $this;
|
|
| 15 |
|
| 16 |
$installer->startSetup();
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
$
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
$
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
$
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
$query = "
|
| 40 |
-
CREATE PROCEDURE
|
| 41 |
IN arg_table INT,
|
| 42 |
IN arg_category_id INT,
|
| 43 |
IN arg_image INT,
|
|
@@ -46,105 +62,200 @@ CREATE PROCEDURE `filter_sinch_products_s`(
|
|
| 46 |
IN arg_greatest INT
|
| 47 |
)
|
| 48 |
BEGIN
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
@where,
|
| 137 |
-
|
| 138 |
-
|
|
|
|
| 139 |
|
| 140 |
-
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
|
| 146 |
END
|
| 147 |
-
|
| 148 |
|
| 149 |
if (!mysql_query($query, $cnx)) {
|
| 150 |
throw new Exception("Failed to create stored procedure");
|
| 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=mysql_query($q);
|
| 23 |
+
while($row=mysql_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 |
+
$installer->run("
|
| 33 |
+
ALTER TABLE {$this->getTable('catalog_category_entity')}
|
| 34 |
+
ADD COLUMN `store_category_id` INT(11) UNSIGNED NULL
|
| 35 |
+
");
|
| 36 |
+
$installer->run("
|
| 37 |
+
ALTER IGNORE TABLE {$this->getTable('catalog_category_entity')}
|
| 38 |
+
ADD INDEX `store_category_id` (`store_category_id`);
|
| 39 |
+
");
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if($check_parent_store_category_id){
|
| 43 |
+
$installer->run("
|
| 44 |
+
ALTER TABLE {$this->getTable('catalog_category_entity')}
|
| 45 |
+
ADD COLUMN `parent_store_category_id` INT(11) UNSIGNED NULL
|
| 46 |
+
");
|
| 47 |
+
$installer->run("
|
| 48 |
+
ALTER IGNORE TABLE {$this->getTable('catalog_category_entity')}
|
| 49 |
+
ADD INDEX `parent_store_category_id` (`parent_store_category_id`);
|
| 50 |
+
");
|
| 51 |
+
|
| 52 |
+
}
|
| 53 |
+
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
| 54 |
|
| 55 |
$query = "
|
| 56 |
+
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
| 57 |
IN arg_table INT,
|
| 58 |
IN arg_category_id INT,
|
| 59 |
IN arg_image INT,
|
| 62 |
IN arg_greatest INT
|
| 63 |
)
|
| 64 |
BEGIN
|
| 65 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
| 66 |
+
|
| 67 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
| 68 |
+
`entity_id` int(10) unsigned,
|
| 69 |
+
`category_id` int(10) unsigned,
|
| 70 |
+
`product_id` int,
|
| 71 |
+
`sinch_category_id` int,
|
| 72 |
+
`name` varchar(255),
|
| 73 |
+
`image` varchar(255),
|
| 74 |
+
`supplier_id` int,
|
| 75 |
+
`category_feature_id` int,
|
| 76 |
+
`feature_id` int,
|
| 77 |
+
`feature_name` varchar(255),
|
| 78 |
+
`feature_value` text
|
| 79 |
+
);
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
IF arg_image = 1 THEN
|
| 83 |
+
INSERT INTO `tmp_result` (
|
| 84 |
+
entity_id,
|
| 85 |
+
category_id,
|
| 86 |
+
product_id,
|
| 87 |
+
sinch_category_id,
|
| 88 |
+
`name`,
|
| 89 |
+
`image`,
|
| 90 |
+
supplier_id,
|
| 91 |
+
category_feature_id,
|
| 92 |
+
feature_id,
|
| 93 |
+
feature_name,
|
| 94 |
+
feature_value
|
| 95 |
+
)(
|
| 96 |
+
SELECT
|
| 97 |
+
E.entity_id,
|
| 98 |
+
PCind.category_id,
|
| 99 |
+
E.entity_id,
|
| 100 |
+
PCind.category_id as `sinch_category`,
|
| 101 |
+
PR.`product_name`,
|
| 102 |
+
PR.main_image_url,
|
| 103 |
+
PR.sinch_manufacturer_id,
|
| 104 |
+
CF.category_feature_id,
|
| 105 |
+
CF.category_feature_id,
|
| 106 |
+
CF.`feature_name`,
|
| 107 |
+
RV.`text`
|
| 108 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
| 109 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
| 110 |
+
ON (E.entity_id = PCind.product_id)
|
| 111 |
+
INNER JOIN ".$installer->getTable('cstINch_categories_mapping')." scm
|
| 112 |
+
ON PCind.category_id=scm.shop_entity_id
|
| 113 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
| 114 |
+
ON (scm.store_category_id=CF.store_category_id)
|
| 115 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
| 116 |
+
ON (PR.store_product_id = E.store_product_id)
|
| 117 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
| 118 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
| 119 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
| 120 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
| 121 |
+
WHERE
|
| 122 |
+
scm.shop_entity_id = arg_category_id
|
| 123 |
+
AND PR.main_image_url <> ''
|
| 124 |
+
);
|
| 125 |
+
|
| 126 |
+
ELSE
|
| 127 |
+
|
| 128 |
+
INSERT INTO `tmp_result` (
|
| 129 |
+
entity_id,
|
| 130 |
+
category_id,
|
| 131 |
+
product_id,
|
| 132 |
+
sinch_category_id,
|
| 133 |
+
`name`,
|
| 134 |
+
`image`,
|
| 135 |
+
supplier_id,
|
| 136 |
+
category_feature_id,
|
| 137 |
+
feature_id,
|
| 138 |
+
feature_name,
|
| 139 |
+
feature_value
|
| 140 |
+
)(
|
| 141 |
+
SELECT
|
| 142 |
+
E.entity_id,
|
| 143 |
+
PCind.category_id,
|
| 144 |
+
E.entity_id,
|
| 145 |
+
PCind.category_id as `sinch_category`,
|
| 146 |
+
PR.`product_name`,
|
| 147 |
+
PR.main_image_url,
|
| 148 |
+
PR.sinch_manufacturer_id,
|
| 149 |
+
CF.category_feature_id,
|
| 150 |
+
CF.category_feature_id,
|
| 151 |
+
CF.`feature_name`,
|
| 152 |
+
RV.`text`
|
| 153 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
| 154 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
| 155 |
+
ON (E.entity_id = PCind.product_id)
|
| 156 |
+
INNER JOIN ".$installer->getTable('cstINch_categories_mapping')." scm
|
| 157 |
+
ON PCind.category_id=scm.shop_entity_id
|
| 158 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
| 159 |
+
ON (scm.store_category_id=CF.store_category_id)
|
| 160 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
| 161 |
+
ON (PR.store_product_id = E.store_product_id)
|
| 162 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
| 163 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
| 164 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
| 165 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
| 166 |
+
WHERE
|
| 167 |
+
scm.shop_entity_id = arg_category_id
|
| 168 |
|
| 169 |
+
);
|
| 170 |
+
|
| 171 |
+
END IF;
|
| 172 |
+
|
| 173 |
+
IF (SELECT COUNT(*) FROM `FilterListOfFeatures`) > 0 THEN
|
| 174 |
+
SET @query = CONCAT('
|
| 175 |
+
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
| 176 |
+
entity_id,
|
| 177 |
+
category_id,
|
| 178 |
+
product_id,
|
| 179 |
+
sinch_category_id,
|
| 180 |
+
`name`,
|
| 181 |
+
`image`,
|
| 182 |
+
supplier_id,
|
| 183 |
+
category_feature_id,
|
| 184 |
+
feature_id,
|
| 185 |
+
feature_name,
|
| 186 |
+
feature_value
|
| 187 |
+
)(
|
| 188 |
+
SELECT
|
| 189 |
+
TR.entity_id,
|
| 190 |
+
TR.category_id,
|
| 191 |
+
TR.product_id,
|
| 192 |
+
TR.sinch_category_id,
|
| 193 |
+
TR.`name`,
|
| 194 |
+
TR.`image`,
|
| 195 |
+
TR.supplier_id,
|
| 196 |
+
TR.category_feature_id,
|
| 197 |
+
TR.feature_id,
|
| 198 |
+
TR.feature_name,
|
| 199 |
+
TR.feature_value
|
| 200 |
+
FROM `tmp_result` AS TR
|
| 201 |
+
INNER JOIN `FilterListOfFeatures` AS LF
|
| 202 |
+
ON (TR.category_feature_id = LF.category_feature_id)
|
| 203 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
| 204 |
+
)
|
| 205 |
+
');
|
| 206 |
+
|
| 207 |
+
ELSE
|
| 208 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
| 209 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
| 210 |
+
ELSE
|
| 211 |
+
IF arg_least IS null THEN
|
| 212 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
| 213 |
+
ELSE
|
| 214 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
| 215 |
+
END IF;
|
| 216 |
+
END IF;
|
| 217 |
+
|
| 218 |
+
SET @query = CONCAT('
|
| 219 |
+
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
| 220 |
+
entity_id,
|
| 221 |
+
category_id,
|
| 222 |
+
product_id,
|
| 223 |
+
sinch_category_id,
|
| 224 |
+
`name`,
|
| 225 |
+
`image`,
|
| 226 |
+
supplier_id,
|
| 227 |
+
category_feature_id,
|
| 228 |
+
feature_id,
|
| 229 |
+
feature_name,
|
| 230 |
+
feature_value
|
| 231 |
+
)(
|
| 232 |
+
SELECT
|
| 233 |
+
TR.entity_id,
|
| 234 |
+
TR.category_id,
|
| 235 |
+
TR.product_id,
|
| 236 |
+
TR.sinch_category_id,
|
| 237 |
+
TR.`name`,
|
| 238 |
+
TR.`image`,
|
| 239 |
+
TR.supplier_id,
|
| 240 |
+
TR.category_feature_id,
|
| 241 |
+
TR.feature_id,
|
| 242 |
+
TR.feature_name,
|
| 243 |
+
TR.feature_value
|
| 244 |
+
FROM `tmp_result` AS TR
|
| 245 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
| 246 |
@where,
|
| 247 |
+
'GROUP BY entity_id
|
| 248 |
+
)
|
| 249 |
+
');
|
| 250 |
|
| 251 |
+
END IF;
|
| 252 |
|
| 253 |
+
PREPARE myquery FROM @query;
|
| 254 |
+
EXECUTE myquery;
|
| 255 |
+
DROP PREPARE myquery;
|
| 256 |
|
| 257 |
END
|
| 258 |
+
";
|
| 259 |
|
| 260 |
if (!mysql_query($query, $cnx)) {
|
| 261 |
throw new Exception("Failed to create stored procedure");
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.7-0.1.8.php
ADDED
|
@@ -0,0 +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 |
+
mysql_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
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$installer = $this;
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
$installer->startSetup();
|
| 7 |
+
|
| 8 |
+
$installer->run("
|
| 9 |
+
ALTER IGNORE TABLE ".$installer->getTable('stINch_import_status_statistic')."
|
| 10 |
+
ADD COLUMN import_run_type ENUM ('MANUAL', 'CRON') DEFAULt NULL
|
| 11 |
+
AFTER detail_status_import;
|
| 12 |
+
");
|
| 13 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.9-0.2.0.php
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_category_product_id int(11),
|
| 17 |
+
store_product_id int(11),
|
| 18 |
+
sinch_product_id int(11),
|
| 19 |
+
product_sku varchar(255),
|
| 20 |
+
sinch_manufacturer_id int(11),
|
| 21 |
+
sinch_manufacturer_name varchar(255),
|
| 22 |
+
KEY entity_id (entity_id),
|
| 23 |
+
KEY manufacturer_option_id (manufacturer_option_id),
|
| 24 |
+
KEY manufacturer_name (manufacturer_name),
|
| 25 |
+
KEY store_product_id (store_product_id),
|
| 26 |
+
KEY sinch_product_id (sinch_product_id),
|
| 27 |
+
KEY sku (sku),
|
| 28 |
+
UNIQUE KEY(entity_id)
|
| 29 |
+
);
|
| 30 |
+
");
|
| 31 |
+
|
| 32 |
+
$installer->run("
|
| 33 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products')."(
|
| 34 |
+
store_category_product_id int(11),
|
| 35 |
+
store_product_id int(11),
|
| 36 |
+
sinch_product_id int(11),
|
| 37 |
+
product_sku varchar(255),
|
| 38 |
+
product_name varchar(255),
|
| 39 |
+
sinch_manufacturer_id int(11),
|
| 40 |
+
store_category_id int(11),
|
| 41 |
+
main_image_url varchar(255),
|
| 42 |
+
thumb_image_url varchar(255),
|
| 43 |
+
specifications text,
|
| 44 |
+
description text,
|
| 45 |
+
search_cache text,
|
| 46 |
+
spec_characte_u_count int(11),
|
| 47 |
+
description_type varchar(50),
|
| 48 |
+
medium_image_url varchar(255),
|
| 49 |
+
products_date_added datetime default NULL,
|
| 50 |
+
products_last_modified datetime default NULL,
|
| 51 |
+
availability_id_in_stock int(11) default '1',
|
| 52 |
+
availability_id_out_of_stock int(11) default '2',
|
| 53 |
+
products_locate varchar(30) default NULL,
|
| 54 |
+
products_ordered int(11) NOT NULL default '0',
|
| 55 |
+
products_url varchar(255) default NULL,
|
| 56 |
+
products_viewed int(5) default '0',
|
| 57 |
+
products_seo_url varchar(100) NOT NULL,
|
| 58 |
+
manufacturer_name varchar(255) default NULL,
|
| 59 |
+
KEY(store_category_product_id),
|
| 60 |
+
KEY(store_product_id),
|
| 61 |
+
KEY(sinch_manufacturer_id),
|
| 62 |
+
KEY(store_category_id)
|
| 63 |
+
)DEFAULT CHARSET=utf8;
|
| 64 |
+
");
|
| 65 |
+
|
| 66 |
+
$installer->run("
|
| 67 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_categories_features')."(
|
| 68 |
+
category_feature_id int(11),
|
| 69 |
+
store_category_id int(11),
|
| 70 |
+
feature_name varchar(50),
|
| 71 |
+
display_order_number int(11),
|
| 72 |
+
KEY(store_category_id),
|
| 73 |
+
KEY(category_feature_id)
|
| 74 |
+
);
|
| 75 |
+
");
|
| 76 |
+
|
| 77 |
+
$installer->run("
|
| 78 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_restricted_values')."(
|
| 79 |
+
restricted_value_id int(11),
|
| 80 |
+
category_feature_id int(11),
|
| 81 |
+
text text,
|
| 82 |
+
display_order_number int(11),
|
| 83 |
+
KEY(restricted_value_id),
|
| 84 |
+
KEY(category_feature_id)
|
| 85 |
+
);
|
| 86 |
+
");
|
| 87 |
+
|
| 88 |
+
$installer->run("
|
| 89 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_product_features')."(
|
| 90 |
+
product_feature_id int(11),
|
| 91 |
+
sinch_product_id int(11),
|
| 92 |
+
restricted_value_id int(11),
|
| 93 |
+
KEY(sinch_product_id),
|
| 94 |
+
KEY(restricted_value_id)
|
| 95 |
+
);
|
| 96 |
+
");
|
| 97 |
+
|
| 98 |
+
$installer->run("
|
| 99 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_categories_mapping')."(
|
| 100 |
+
shop_entity_id int(11) unsigned NOT NULL,
|
| 101 |
+
shop_entity_type_id int(11),
|
| 102 |
+
shop_attribute_set_id int(11),
|
| 103 |
+
shop_parent_id int(11),
|
| 104 |
+
shop_store_category_id int(11),
|
| 105 |
+
shop_parent_store_category_id int(11),
|
| 106 |
+
store_category_id int(11),
|
| 107 |
+
parent_store_category_id int(11),
|
| 108 |
+
category_name varchar(255),
|
| 109 |
+
order_number int(11),
|
| 110 |
+
products_within_this_category int(11),
|
| 111 |
+
KEY shop_entity_id (shop_entity_id),
|
| 112 |
+
KEY shop_parent_id (shop_parent_id),
|
| 113 |
+
KEY store_category_id (store_category_id),
|
| 114 |
+
KEY parent_store_category_id (parent_store_category_id),
|
| 115 |
+
UNIQUE KEY(shop_entity_id)
|
| 116 |
+
);
|
| 117 |
+
");
|
| 118 |
+
|
| 119 |
+
/*
|
| 120 |
+
$installer->run("
|
| 121 |
+
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products_mapping')."(
|
| 122 |
+
);
|
| 123 |
+
");
|
| 124 |
+
*/
|
| 125 |
+
|
| 126 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.0-0.2.1.php
ADDED
|
@@ -0,0 +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 |
+
mysql_close($cnx);
|
| 102 |
+
|
| 103 |
+
$installer->endSetup();
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
|
app/design/frontend/default/default/template/sinchimport/list.phtml
DELETED
|
@@ -1,153 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Magento
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
-
* It is also available through the world-wide-web at this URL:
|
| 10 |
-
* http://opensource.org/licenses/afl-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 design_default
|
| 22 |
-
* @package Mage
|
| 23 |
-
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
| 24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
-
*/
|
| 26 |
-
?>
|
| 27 |
-
<div class="page-head button-level">
|
| 28 |
-
<h3><?php echo $this->__('Compare Products') ?></h3>
|
| 29 |
-
<a href="#" class="link-print right" onclick="print();"><?php echo $this->__('Print This Page') ?></a>
|
| 30 |
-
</div>
|
| 31 |
-
<?php $_total=$this->getItems()->getSize() ?>
|
| 32 |
-
<?php if($_total): ?>
|
| 33 |
-
<div class="compare-products">
|
| 34 |
-
<table cellspacing="0" class="data-table box-table catalog-listing" id="product_comparison">
|
| 35 |
-
<?php if ($_total>2): ?>
|
| 36 |
-
<tbody class="remove-buttons">
|
| 37 |
-
<tr>
|
| 38 |
-
<?php $_i=0 ?>
|
| 39 |
-
<?php foreach($this->getItems() as $_item): ?>
|
| 40 |
-
<?php if($_i++%10==0): ?>
|
| 41 |
-
<td> </td>
|
| 42 |
-
<?php endif; ?>
|
| 43 |
-
<td><a href="#" onclick="setLocation('<?php echo $this->helper('catalog/product_compare')->getRemoveUrl($_item) ?>');window.opener.location.reload();"><img src="<?php echo $this->getSkinUrl('images/chart_remove.gif') ?>" alt="<?php echo $this->__('Remove Product') ?>" /></a></td>
|
| 44 |
-
<?php endforeach; ?>
|
| 45 |
-
</tr>
|
| 46 |
-
</tbody>
|
| 47 |
-
<?php endif ?>
|
| 48 |
-
<tbody>
|
| 49 |
-
<tr class="first">
|
| 50 |
-
<?php $_i=0 ?>
|
| 51 |
-
<?php foreach($this->getItems() as $_item): ?>
|
| 52 |
-
<?php if($_i++%10==0): ?>
|
| 53 |
-
<td class="label"> </td>
|
| 54 |
-
<?php endif; ?>
|
| 55 |
-
<td>
|
| 56 |
-
<a href="#" onclick="setPLocation('<?php echo $_item->getProductUrl() ?>', true)" title="<?php echo $this->htmlEscape($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" /></a>
|
| 57 |
-
<h5><a href="#" onclick="setPLocation('<?php echo $_item->getProductUrl() ?>', true)" title="<?php echo $this->htmlEscape($_item->getName()) ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a></h5>
|
| 58 |
-
<?php echo $this->getReviewsSummaryHtml($_item, 'short') ?>
|
| 59 |
-
<?php echo $this->getPriceHtml($_item, true) ?>
|
| 60 |
-
<?php if($_item->isSaleable()): ?>
|
| 61 |
-
<button class="form-button" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>', true)"><span><?php echo $this->__('Add to Cart') ?></span></button><br/>
|
| 62 |
-
<?php else: ?>
|
| 63 |
-
<div class="out-of-stock"><?php echo $this->__('Out of stock') ?></div>
|
| 64 |
-
<?php endif; ?>
|
| 65 |
-
<?php if ($this->helper('wishlist')->isAllow()) : ?>
|
| 66 |
-
<a href="#" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToWishlistUrl($_item) ?>', true)" class="link-cart"><small><?php echo $this->__('Add to Wishlist') ?></small></a>
|
| 67 |
-
<?php endif; ?>
|
| 68 |
-
</td>
|
| 69 |
-
<?php endforeach; ?>
|
| 70 |
-
</tr>
|
| 71 |
-
</tbody>
|
| 72 |
-
<tbody>
|
| 73 |
-
<?php /**************************************************** Sinch attributes ****************************************/ ?>
|
| 74 |
-
<?php $prod_attributes=$this->getSinchAttributes(); ?>
|
| 75 |
-
<?php foreach ($prod_attributes as $_attribute): ?>
|
| 76 |
-
|
| 77 |
-
<?php if($this->getSinchAttributeName($_attribute)) : ?>
|
| 78 |
-
<tr>
|
| 79 |
-
<?php $countItems = 0; ?>
|
| 80 |
-
<?php $_i=0; ?>
|
| 81 |
-
|
| 82 |
-
<?php foreach($this->getItems() as $_item) : ?>
|
| 83 |
-
<?php if ($this->getSinchProductAttributeValue($_item, $_attribute)) : $countItems++; endif; ?>
|
| 84 |
-
<?php endforeach; // Items (for count number) ?>
|
| 85 |
-
<?php foreach($this->getItems() as $_item) : ?>
|
| 86 |
-
<?php if ($countItems > 0 ) : ?>
|
| 87 |
-
<?php if($_i++%10==0): ?><td class="label"><?php echo $this->getSinchAttributeName($_attribute) ?></td><?php endif; ?>
|
| 88 |
-
<td>
|
| 89 |
-
<?php echo nl2br($this->getSinchProductAttributeValue($_item, $_attribute))." "; //.var_dump($this->getSinchProductAttributeValue($_item, $_attribute)); ?>
|
| 90 |
-
</td>
|
| 91 |
-
<?php endif; //AttributeValue ?>
|
| 92 |
-
|
| 93 |
-
<?php endforeach; // Items ?>
|
| 94 |
-
</tr>
|
| 95 |
-
<?php endif; //AttributeName ?>
|
| 96 |
-
|
| 97 |
-
<?php endforeach; ?>
|
| 98 |
-
<?php /**************************************************** End Sinch attributes ****************************************/ ?>
|
| 99 |
-
|
| 100 |
-
<?php /* foreach ($this->getAttributes() as $_attribute): ?>
|
| 101 |
-
<tr>
|
| 102 |
-
<?php $_i=0 ?>
|
| 103 |
-
<?php foreach($this->getItems() as $_item): ?>
|
| 104 |
-
<?php if($_i++%10==0): ?>
|
| 105 |
-
<td class="label"><?php echo $this->__($_attribute->getFrontendLabel()) ?><? //echo " "; print_r($_attribute->getFrontendLabel()); ?></td>
|
| 106 |
-
<?php endif; ?>
|
| 107 |
-
<td>
|
| 108 |
-
<?php switch ($_attribute->getAttributeCode()) {
|
| 109 |
-
case "price": ?>
|
| 110 |
-
<?php echo $this->getPriceHtml($_item, true) ?>
|
| 111 |
-
<?php break;
|
| 112 |
-
case "small_image": ?>
|
| 113 |
-
<img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" />
|
| 114 |
-
<?php break;
|
| 115 |
-
default: ?>
|
| 116 |
-
<?php echo nl2br($this->getProductAttributeValue($_item, $_attribute)) ?>
|
| 117 |
-
<?php break;
|
| 118 |
-
} ?>
|
| 119 |
-
</td>
|
| 120 |
-
<?php endforeach; ?>
|
| 121 |
-
</tr>
|
| 122 |
-
<?php endforeach; */ ?>
|
| 123 |
-
</tbody>
|
| 124 |
-
<tbody class="attribute-cart">
|
| 125 |
-
<tr>
|
| 126 |
-
<?php $_i=0 ?>
|
| 127 |
-
<?php foreach($this->getItems() as $_item): ?>
|
| 128 |
-
<?php if($_i++%10==0): ?>
|
| 129 |
-
<td class="label"> </td>
|
| 130 |
-
<?php endif; ?>
|
| 131 |
-
<td>
|
| 132 |
-
<?php echo $this->getPriceHtml($_item, true) ?>
|
| 133 |
-
<?php if($_item->isSaleable()): ?>
|
| 134 |
-
<button class="form-button" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>', true)"><span><?php echo $this->__('Add to Cart') ?></span></button><br/>
|
| 135 |
-
<?php else: ?>
|
| 136 |
-
<div class="out-of-stock"><?php echo $this->__('Out of stock') ?></div>
|
| 137 |
-
<?php endif; ?>
|
| 138 |
-
<?php if ($this->helper('wishlist')->isAllow()) : ?>
|
| 139 |
-
<a href="#" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToWishlistUrl($_item) ?>', true)" class="link-cart"><small><?php echo $this->__('Add to Wishlist') ?></small></a>
|
| 140 |
-
<?php endif; ?>
|
| 141 |
-
</td>
|
| 142 |
-
<?php endforeach; ?>
|
| 143 |
-
</tr>
|
| 144 |
-
</tbody>
|
| 145 |
-
</table>
|
| 146 |
-
<div class="button-set">
|
| 147 |
-
<button class="form-button" onclick="window.close();"><span><?php echo $this->__('Close Window') ?></span></button>
|
| 148 |
-
</div>
|
| 149 |
-
</div>
|
| 150 |
-
<script type="text/javascript">decorateTable('product_comparison');</script>
|
| 151 |
-
<?php else: ?>
|
| 152 |
-
<script type="text/javascript">window.close();</script>
|
| 153 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/default/default/template/sinchimport/media.phtml
DELETED
|
@@ -1,89 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Magento
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
-
* It is also available through the world-wide-web at this URL:
|
| 10 |
-
* http://opensource.org/licenses/afl-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 design_default
|
| 22 |
-
* @package Mage
|
| 23 |
-
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
| 24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
-
*/
|
| 26 |
-
|
| 27 |
-
/**
|
| 28 |
-
* Product media data template
|
| 29 |
-
*
|
| 30 |
-
* @see Mage_Catalog_Block_Product_View_Media
|
| 31 |
-
*/
|
| 32 |
-
?>
|
| 33 |
-
|
| 34 |
-
<?php
|
| 35 |
-
$_product = $this->getProduct();
|
| 36 |
-
$_helper = $this->helper('catalog/output');
|
| 37 |
-
$_productDescriptionHelper = $this->helper('sinchimport/getdata')->getProductDescription($_product);
|
| 38 |
-
|
| 39 |
-
?>
|
| 40 |
-
<?php //if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
|
| 41 |
-
<p class="product-image-zoom">
|
| 42 |
-
<?php
|
| 43 |
-
$_img = '<img id="image" src="'. $this->helper('catalog/image')->init($_product, 'image') .'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
|
| 44 |
-
echo $_helper->productAttribute($_product, $_img, 'image');
|
| 45 |
-
?>
|
| 46 |
-
</p>
|
| 47 |
-
<p class="a-center" id="track_hint"><?php echo $this->__('Double click on above image to view full picture') ?></p>
|
| 48 |
-
|
| 49 |
-
<div class="image-zoom zoom" id="track_outer">
|
| 50 |
-
<img id="zoom_out" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_out.gif') ?>" alt="<?php echo $this->__('Zoom Out') ?>" class="btn-zoom-out" />
|
| 51 |
-
<div id="track">
|
| 52 |
-
<div id="handle"></div>
|
| 53 |
-
</div>
|
| 54 |
-
<img id="zoom_in" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_in.gif') ?>" alt="<?php echo $this->__('Zoom In') ?>" class="btn-zoom-in" />
|
| 55 |
-
</div>
|
| 56 |
-
<script type="text/javascript">
|
| 57 |
-
Event.observe(window, 'load', function() {
|
| 58 |
-
product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
|
| 59 |
-
});
|
| 60 |
-
</script>
|
| 61 |
-
<?php /*else: ?>
|
| 62 |
-
<?php
|
| 63 |
-
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($_product->getImageLabel()).'" />';
|
| 64 |
-
echo $_helper->productAttribute($_product, $_img, 'image')
|
| 65 |
-
?>
|
| 66 |
-
<?php endif; */?>
|
| 67 |
-
<?php if (count($_productDescriptionHelper->getGalleryPhotos()) > 0): ?>
|
| 68 |
-
<div class="more-views">
|
| 69 |
-
<h4><?php echo $this->__('More Views') ?></h4>
|
| 70 |
-
<ul>
|
| 71 |
-
<?php foreach ($_productDescriptionHelper->getGalleryPhotos() as $_image): ?>
|
| 72 |
-
<li>
|
| 73 |
-
<a href="#" onclick="popWin('<?php echo $_image['pic'] ?>', 'gallery', 'width=<?php echo $_image['width']?>,height=<?php echo $_image['height']?>,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;"><img src="<?php echo $_image['thumb'] ?>" alt="<?php echo $_productDescriptionHelper->getProductName()?>" title="<?php echo $_productDescriptionHelper->getProductName()?>" /></a>
|
| 74 |
-
</li>
|
| 75 |
-
<?php endforeach; ?>
|
| 76 |
-
</ul>
|
| 77 |
-
</div>
|
| 78 |
-
<?php else :?>
|
| 79 |
-
<div class="more-views">
|
| 80 |
-
<h2><?php echo $this->__('More Views') ?></h2>
|
| 81 |
-
<ul>
|
| 82 |
-
<?php foreach ($this->getGalleryImages() as $_image): ?>
|
| 83 |
-
<li>
|
| 84 |
-
<a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
|
| 85 |
-
</li>
|
| 86 |
-
<?php endforeach; ?>
|
| 87 |
-
</ul>
|
| 88 |
-
</div>
|
| 89 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/default/default/template/sinchimport/view.phtml
DELETED
|
@@ -1,363 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Magento
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
-
* It is also available through the world-wide-web at this URL:
|
| 10 |
-
* http://opensource.org/licenses/afl-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 design_default
|
| 22 |
-
* @package Mage
|
| 23 |
-
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
| 24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
-
*/
|
| 26 |
-
|
| 27 |
-
/**
|
| 28 |
-
* Product view template
|
| 29 |
-
*
|
| 30 |
-
* @see Mage_Catalog_Block_Product_View
|
| 31 |
-
* @see Mage_Review_Block_Product_View
|
| 32 |
-
*/
|
| 33 |
-
?>
|
| 34 |
-
<?php
|
| 35 |
-
$_helper = $this->helper('catalog/output');
|
| 36 |
-
$_product = $this->getProduct();
|
| 37 |
-
$_catIds = $_product->getCategoryIds();
|
| 38 |
-
$_catId = $_catIds[0];
|
| 39 |
-
|
| 40 |
-
$_productDescriptionHelper = $this->helper('sinchimport/getdata')->getProductDescription($_product);
|
| 41 |
-
$message = $_productDescriptionHelper->getError();
|
| 42 |
-
if ($message){
|
| 43 |
-
$this->getMessagesBlock()->addError($_productDescriptionHelper->getError());
|
| 44 |
-
}
|
| 45 |
-
$specificationArray = $_productDescriptionHelper->getProductDescriptionList();
|
| 46 |
-
$sinchSpecification=$_productDescriptionHelper->getProductSpecifications();
|
| 47 |
-
$relatedProductsList = $_productDescriptionHelper->getRelatedProducts();
|
| 48 |
-
// echo "related= ".$_productDescriptionHelper->getVendor();
|
| 49 |
-
?>
|
| 50 |
-
<script type="text/javascript">
|
| 51 |
-
var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
|
| 52 |
-
</script>
|
| 53 |
-
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
|
| 54 |
-
<div style="display:none"><?php $message=$_productDescriptionHelper->hasSystemError(); if ($message){ echo $message; } ?></div>
|
| 55 |
-
<div class="product-info-box product-view">
|
| 56 |
-
<div class="product-essential">
|
| 57 |
-
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
|
| 58 |
-
|
| 59 |
-
<div class="product-img-box">
|
| 60 |
-
<?php echo $this->getChildHtml('media'); ?>
|
| 61 |
-
</div>
|
| 62 |
-
|
| 63 |
-
<div class="product-shop">
|
| 64 |
-
<?php if (!$_productDescriptionHelper->hasError()) : ?>
|
| 65 |
-
<h3 class="product-name"><?php echo $_productDescriptionHelper->getProductName()?></h3>
|
| 66 |
-
<?php else :?>
|
| 67 |
-
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name')?></h1>
|
| 68 |
-
<?php endif;?>
|
| 69 |
-
<?php if ($this->canEmailToFriend()): ?>
|
| 70 |
-
<a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a><br />
|
| 71 |
-
<?php endif; ?>
|
| 72 |
-
|
| 73 |
-
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
|
| 74 |
-
|
| 75 |
-
<fieldset class="no-display">
|
| 76 |
-
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
|
| 77 |
-
<input type="hidden" name="related_product" id="related-products-field" value="" />
|
| 78 |
-
</fieldset>
|
| 79 |
-
<?php if (!$_productDescriptionHelper->hasError()):?>
|
| 80 |
-
<div><b><?php echo $this->helper('sinchimport/getdata')->__('Brand:')?></b><?php echo $_productDescriptionHelper->getVendor();?></div>
|
| 81 |
-
<div><b><?php echo $this->helper('sinchimport/getdata')->__('Product code:')?></b><?php echo $_productDescriptionHelper->getMPN();?></div>
|
| 82 |
-
<div><b><?php echo $this->helper('sinchimport/getdata')->__('EAN/UPC code:')?></b><?php echo $_productDescriptionHelper->getEAN();?></div>
|
| 83 |
-
<div><b><?php echo $this->helper('sinchimport/getdata')->__('Category:')?></b><?php echo Mage::getModel('catalog/category')->load($_catId)->getName()?></div>
|
| 84 |
-
<?php endif;?>
|
| 85 |
-
<?php echo $this->getChildHtml('alert_urls') ?>
|
| 86 |
-
<?php echo $this->getChildHtml('product_type_data') ?>
|
| 87 |
-
<?php echo $this->getTierPriceHtml() ?>
|
| 88 |
-
|
| 89 |
-
<?php if (!$this->hasOptions()):?>
|
| 90 |
-
<div class="add-to-holder">
|
| 91 |
-
<?php if($_product->isSaleable()): ?>
|
| 92 |
-
<?php echo $this->getChildHtml('addtocart') ?>
|
| 93 |
-
<?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
|
| 94 |
-
<span class="add-or"><?php echo $this->__('OR') ?></span>
|
| 95 |
-
<?php endif; ?>
|
| 96 |
-
<?php endif; ?>
|
| 97 |
-
<?php echo $this->getChildHtml('addto') ?>
|
| 98 |
-
</div>
|
| 99 |
-
<?php else:?>
|
| 100 |
-
<?php echo $this->getChildHtml('addto') ?>
|
| 101 |
-
<?php endif; ?>
|
| 102 |
-
|
| 103 |
-
<?php if ($_product->getShortDescription() && $_productDescriptionHelper->hasError()):?>
|
| 104 |
-
<div class="short-description">
|
| 105 |
-
<h2><?php echo $this->__('Quick Overview') ?></h2>
|
| 106 |
-
<div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
|
| 107 |
-
</div>
|
| 108 |
-
<?php else :?>
|
| 109 |
-
<div class="divider"></div>
|
| 110 |
-
<?php endif;?>
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
<?php echo $this->getChildHtml('other');?>
|
| 114 |
-
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
|
| 115 |
-
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
|
| 116 |
-
<?php endif;?>
|
| 117 |
-
|
| 118 |
-
</div>
|
| 119 |
-
<div class="clear"></div>
|
| 120 |
-
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
|
| 121 |
-
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
|
| 122 |
-
<?php endif;?>
|
| 123 |
-
</form>
|
| 124 |
-
<script type="text/javascript">
|
| 125 |
-
var productAddToCartForm = new VarienForm('product_addtocart_form');
|
| 126 |
-
productAddToCartForm.submit = function(){
|
| 127 |
-
if (this.validator.validate()) {
|
| 128 |
-
this.form.submit();
|
| 129 |
-
}
|
| 130 |
-
}.bind(productAddToCartForm);
|
| 131 |
-
|
| 132 |
-
function changeTab(id){
|
| 133 |
-
for(var i=0;i<4;i++){
|
| 134 |
-
var tab_cont = (document.getElementById) ? document.getElementById("tab_cont_"+i) : eval('document.all["tab_cont_'+i+'"]');
|
| 135 |
-
var tab = (document.getElementById) ? document.getElementById("tab_"+i) : eval('document.all["tab_'+i+'"]');
|
| 136 |
-
|
| 137 |
-
if (tab_cont!=null && tab!=null) {
|
| 138 |
-
if(i==id){
|
| 139 |
-
tab_cont.style.display="";
|
| 140 |
-
tab.className="prod_doc_tab_div_sel";
|
| 141 |
-
} else {
|
| 142 |
-
tab_cont.style.display="none";
|
| 143 |
-
tab.className="prod_doc_tab_div";
|
| 144 |
-
}
|
| 145 |
-
}
|
| 146 |
-
}
|
| 147 |
-
}
|
| 148 |
-
</script>
|
| 149 |
-
</div>
|
| 150 |
-
<?php if (!$_productDescriptionHelper->hasError()) : ?>
|
| 151 |
-
<div class="description_b">
|
| 152 |
-
<div class="short_product_description"><?php echo $_productDescriptionHelper->getShortProductDescription() ?></div>
|
| 153 |
-
<?php
|
| 154 |
-
if (strlen($_productDescriptionHelper->getFullProductDescription())>450){
|
| 155 |
-
$firstPart = str_replace("\\n", "<br>", substr($_productDescriptionHelper->getFullProductDescription(), 0, 400));
|
| 156 |
-
$space = strrpos($firstPart, " ");
|
| 157 |
-
$dot = strrpos($firstPart, ".");
|
| 158 |
-
$column = strrpos($firstPart, ",");
|
| 159 |
-
$spanTagStart = strrpos($firstPart, "<span");
|
| 160 |
-
$spanTagEND = strrpos($firstPart, "</span>");
|
| 161 |
-
|
| 162 |
-
if ($space-5>$dot && $space-5>$column){
|
| 163 |
-
$firstPart = substr($firstPart, 0, $space);
|
| 164 |
-
}
|
| 165 |
-
else{
|
| 166 |
-
$firstPart = $column > $dot ? substr($firstPart, 0, $column) : substr($firstPart, 0, $dot);
|
| 167 |
-
}
|
| 168 |
-
if ((int)$spanTagEND<$spanTagStart){
|
| 169 |
-
$firstPart = substr($firstPart, 0, $spanTagStart);
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
?>
|
| 175 |
-
<div class="product_description">
|
| 176 |
-
<?php if (isset($firstPart)):?>
|
| 177 |
-
<span id="more_link"><?php echo $firstPart." "?>... <a class="more_link" href="javascript: showMore();"><?php echo htmlentities(' More>>>')?></a></span>
|
| 178 |
-
<span id="more_info" style="display: none;"><?php echo str_replace("\\n", "<br>", $_productDescriptionHelper->getFullProductDescription());?><a class="more_link" href="javascript: hideMore();"><?php echo htmlentities(' <<<Less')?></a></span>
|
| 179 |
-
<?php else: ?>
|
| 180 |
-
<span><?php echo str_replace("\\n", "<br>", $_productDescriptionHelper->getFullProductDescription());?></span>
|
| 181 |
-
<?php endif?>
|
| 182 |
-
</div >
|
| 183 |
-
</div>
|
| 184 |
-
<?php endif;?>
|
| 185 |
-
<div class="product-collateral">
|
| 186 |
-
<?php if ($_productDescriptionHelper->hasError()) :?>
|
| 187 |
-
<?php echo $this->getChildHtml('description') ?>
|
| 188 |
-
<?php else :
|
| 189 |
-
$tab_class0=$tab_class1=$tab_class2=$tab_class3='prod_doc_tab_div';
|
| 190 |
-
$data_tab_style0=$data_tab_style1=$data_tab_style2=$data_tab_style3="display:none";
|
| 191 |
-
if($sinchSpecification || $sinchSpecification!=''){
|
| 192 |
-
$tab_class0='prod_doc_tab_div_sel';
|
| 193 |
-
$data_tab_style0='';
|
| 194 |
-
}elseif(!empty($specificationArray)){
|
| 195 |
-
$tab_class1='prod_doc_tab_div_sel';
|
| 196 |
-
$data_tab_style1='';
|
| 197 |
-
}elseif($_catId && array_key_exists($_catId, $relatedProductsList)){
|
| 198 |
-
$tab_class2='prod_doc_tab_div_sel';
|
| 199 |
-
$data_tab_style2='';
|
| 200 |
-
}elseif(!empty($relatedProductsList)){
|
| 201 |
-
$tab_class3='prod_doc_tab_div_sel';
|
| 202 |
-
$data_tab_style3='';
|
| 203 |
-
}
|
| 204 |
-
?>
|
| 205 |
-
<? if(false): ?>
|
| 206 |
-
<table cellspacing="0" cellpadding="0" width="100%">
|
| 207 |
-
<tr>
|
| 208 |
-
<td>
|
| 209 |
-
<table cellspacing="0" cellpadding="0" class="prod_doc_tabs_row">
|
| 210 |
-
<tr>
|
| 211 |
-
<td class="prod_doc_tabs_space"> </td>
|
| 212 |
-
<?php if ($sinchSpecification || $sinchSpecification!=''):?>
|
| 213 |
-
<td class="prod_doc_tab"><div id="tab_0" class="<?php echo $tab_class0 ?>" onclick="changeTab(0)"><?php echo $this->helper('sinchimport/getdata')->__('Specification') ?></div></td>
|
| 214 |
-
<?php endif?>
|
| 215 |
-
<?php if (!empty($specificationArray)):?>
|
| 216 |
-
<td class="prod_doc_tab"><div id="tab_1" class="<?php echo $tab_class1 ?>" onclick="changeTab(1)"><?php echo $this->helper('sinchimport/getdata')->__('Star features') ?></div></td>
|
| 217 |
-
<?php endif?>
|
| 218 |
-
<?php if ($_catId && array_key_exists($_catId, $relatedProductsList)):?>
|
| 219 |
-
<td class="prod_doc_tab"><div id="tab_2" class="prod_doc_tab_div" onclick="changeTab(2)"><?php echo $this->helper('sinchimport/getdata')->__('Alternatives') ?></div></td>
|
| 220 |
-
<?php endif?>
|
| 221 |
-
<?php if (!empty($relatedProductsList)):?>
|
| 222 |
-
<td class="prod_doc_tab"><div id="tab_3" class="prod_doc_tab_div" onclick="changeTab(3)"><?php echo $this->helper('sinchimport/getdata')->__('Options') ?></div></td>
|
| 223 |
-
<?php endif?>
|
| 224 |
-
<td class="prod_doc_tabs_space" style="width:auto!important"> </td>
|
| 225 |
-
</tr>
|
| 226 |
-
</table>
|
| 227 |
-
</td>
|
| 228 |
-
</tr>
|
| 229 |
-
<tr>
|
| 230 |
-
<td>
|
| 231 |
-
<table cellspacing="0" cellpadding="2" class="prod_doc_content">
|
| 232 |
-
<tr>
|
| 233 |
-
<td class="prod_doc_content_cell">
|
| 234 |
-
<!-- ZERO TAB's CONTENT (VISIBLE BY DEFAULT) -->
|
| 235 |
-
<table id="tab_cont_0" cellspacing="6" cellpadding="0" width="100%" style="<?php echo $data_tab_style0; ?>">
|
| 236 |
-
<tr>
|
| 237 |
-
<td width="50%" valign="top">
|
| 238 |
-
<table cellspacing="0" cellpadding="2" class="prod_doc_table">
|
| 239 |
-
<tr><td>
|
| 240 |
-
<?php echo $sinchSpecification; ?>
|
| 241 |
-
</td></tr>
|
| 242 |
-
</table>
|
| 243 |
-
</td>
|
| 244 |
-
</tr>
|
| 245 |
-
</table>
|
| 246 |
-
|
| 247 |
-
<!-- FIRST TAB's CONTENT (VISIBLE BY DEFAULT) -->
|
| 248 |
-
<table id="tab_cont_1" cellspacing="6" cellpadding="0" width="100%" style="<?php echo $data_tab_style1; ?>">
|
| 249 |
-
<tr>
|
| 250 |
-
<td width="50%" valign="top">
|
| 251 |
-
<table cellspacing="0" cellpadding="2" class="prod_doc_table">
|
| 252 |
-
|
| 253 |
-
<?php foreach($specificationArray as $key => $value):?>
|
| 254 |
-
<tr>
|
| 255 |
-
<td colspan="2" class="prod_doc_item_head"><?php echo $key?></td>
|
| 256 |
-
<td class="prod_doc_item_descr"><?php if($value == "Y"){
|
| 257 |
-
echo '<img border="0" alt="" src="http://prf.icecat.biz/imgs/yes.gif"/>';
|
| 258 |
-
}
|
| 259 |
-
else if ($value == "N"){
|
| 260 |
-
echo '<img border="0" alt="" src="http://prf.icecat.biz/imgs/no.gif"/>';
|
| 261 |
-
}
|
| 262 |
-
else{
|
| 263 |
-
echo str_replace("\\n", "<br>",$value);
|
| 264 |
-
}
|
| 265 |
-
?></td>
|
| 266 |
-
</tr>
|
| 267 |
-
<?php endforeach;?>
|
| 268 |
-
</table>
|
| 269 |
-
</td>
|
| 270 |
-
</tr>
|
| 271 |
-
</table>
|
| 272 |
-
<!-- SECOND TAB's CONTENT (HIDDEN BY DEFAULT) -->
|
| 273 |
-
<table id="tab_cont_2" cellspacing="6" cellpadding="0" width="100%" style="<?php echo $data_tab_style2; ?>">
|
| 274 |
-
<tr>
|
| 275 |
-
<td>
|
| 276 |
-
<table cellspacing="1" cellpadding="5" class="prod_alt_table" width="100%" >
|
| 277 |
-
<tr>
|
| 278 |
-
<td class="prod_doc_block_head"><?php echo $this->helper('sinchimport/getdata')->__('Brand') ?></td>
|
| 279 |
-
<td class="prod_doc_block_head"><?php echo $this->helper('sinchimport/getdata')->__('Image') ?></td>
|
| 280 |
-
<td class="prod_doc_block_head"><?php echo $this->helper('sinchimport/getdata')->__('Article code') ?></td>
|
| 281 |
-
<td class="prod_doc_block_head"><?php echo $this->helper('sinchimport/getdata')->__('Product name') ?></td>
|
| 282 |
-
</tr>
|
| 283 |
-
<?php if ($_catId && array_key_exists($_catId, $relatedProductsList)):?>
|
| 284 |
-
<?php foreach($relatedProductsList[$_catId] as $product):?>
|
| 285 |
-
<tr>
|
| 286 |
-
<?php if($product['supplier_thumb']&&($product['supplier_thumb']!='')): ?>
|
| 287 |
-
<td><img src="<?php echo $product['supplier_thumb']?>" /></td>
|
| 288 |
-
<?php else :?>
|
| 289 |
-
<td><?php echo $product['supplier_name']?></td>
|
| 290 |
-
<?php endif ?>
|
| 291 |
-
<td><a href="<?php echo $product['url']?>"><img src="<?php echo $product['thumb']?>" /></a></td>
|
| 292 |
-
<td><?php echo $product['mpn']?></td>
|
| 293 |
-
<td><a href="<?php echo $product['url']?>" class="prod_link_small"><?php echo $product['name']?></a></td>
|
| 294 |
-
</tr>
|
| 295 |
-
<?php endforeach?>
|
| 296 |
-
<?php else: ?>
|
| 297 |
-
<tr><td></>No Alternative proposals for Current product avaible</td></tr>
|
| 298 |
-
<?php endif?>
|
| 299 |
-
</table>
|
| 300 |
-
</td>
|
| 301 |
-
</tr>
|
| 302 |
-
</table>
|
| 303 |
-
<!-- THIRD TAB's CONTENT (HIDDEN BY DEFAULT) -->
|
| 304 |
-
<table id="tab_cont_3" cellspacing="6" cellpadding="0" width="100%" style="<?php echo $data_tab_style3; ?>">
|
| 305 |
-
<tr>
|
| 306 |
-
<td>
|
| 307 |
-
|
| 308 |
-
<table cellspacing="1" cellpadding="5" width="100%" class="prod_alt_table">
|
| 309 |
-
<tr>
|
| 310 |
-
<td class="prod_doc_block_head"><?php echo $this->helper('sinchimport/getdata')->__('Brand') ?></td>
|
| 311 |
-
<td class="prod_doc_block_head"><?php echo $this->helper('sinchimport/getdata')->__('Image') ?></td>
|
| 312 |
-
<td class="prod_doc_block_head"><?php echo $this->helper('sinchimport/getdata')->__('Article code') ?></td>
|
| 313 |
-
<td class="prod_doc_block_head"><?php echo $this->helper('sinchimport/getdata')->__('Product name') ?></td>
|
| 314 |
-
</tr>
|
| 315 |
-
<?php if (!empty($relatedProductsList)):?>
|
| 316 |
-
<?php foreach($relatedProductsList as $categoryId => $productsArray):?>
|
| 317 |
-
<?php if ($categoryId == $_catId){
|
| 318 |
-
continue;
|
| 319 |
-
}?>
|
| 320 |
-
<?php if (!is_string($categoryId)):?>
|
| 321 |
-
<tr>
|
| 322 |
-
<td class="prod_doc_item_head2" colspan="4"><?php echo is_string($categoryId)? '' : Mage::getSingleton('catalog/category')->load($categoryId)->getName() ?></td>
|
| 323 |
-
|
| 324 |
-
</tr>
|
| 325 |
-
<?php endif?>
|
| 326 |
-
<?php foreach($productsArray as $product):?>
|
| 327 |
-
<tr>
|
| 328 |
-
<?php if($product['supplier_thumb']&&($product['supplier_thumb']!='')): ?>
|
| 329 |
-
<td><img src="<?php echo $product['supplier_thumb']?>" /></td>
|
| 330 |
-
<?php else :?>
|
| 331 |
-
<td><?php echo $product['supplier_name']?></td>
|
| 332 |
-
<?php endif ?>
|
| 333 |
-
<td><a href="<?php echo $product['url']?>"><img src="<?php echo $product['thumb']?>" /></a></td>
|
| 334 |
-
<td><?php echo $product['mpn']?></td>
|
| 335 |
-
<td><a href="<?php echo $product['url']?>" class="prod_link_small"><?php echo $product['name']?></a></td>
|
| 336 |
-
</tr>
|
| 337 |
-
<?php endforeach ?>
|
| 338 |
-
<?php endforeach ?>
|
| 339 |
-
<?php else: ?>
|
| 340 |
-
<tr><td></>No Related proposals for Current product avaible</td></tr>
|
| 341 |
-
<?php endif?>
|
| 342 |
-
</table>
|
| 343 |
-
</td>
|
| 344 |
-
</tr>
|
| 345 |
-
</table>
|
| 346 |
-
<!-- EOF -->
|
| 347 |
-
</td>
|
| 348 |
-
</tr>
|
| 349 |
-
</table>
|
| 350 |
-
<?php endif; ?>
|
| 351 |
-
</td>
|
| 352 |
-
</tr>
|
| 353 |
-
</table>
|
| 354 |
-
<?php endif;?>
|
| 355 |
-
<?php if ($_additional = $this->getChildHtml('additional')):?>
|
| 356 |
-
<div class="collateral-box">
|
| 357 |
-
<?php echo $_additional ?>
|
| 358 |
-
</div>
|
| 359 |
-
<?php endif;?>
|
| 360 |
-
<?php echo $this->getChildHtml('upsell_products') ?>
|
| 361 |
-
<?php echo $this->getChildHtml('product_additional_data') ?>
|
| 362 |
-
</div>
|
| 363 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
|
@@ -1,25 +1,24 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>stockinthechannel2012</name>
|
| 4 |
-
<version>1.0.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Stock In The Channel to Magento Connector - Sell virtual stock - drop ship ecommerce</summary>
|
| 10 |
-
<description>StockInTheChannel has released a free connector to Magento&#xD;
|
| 11 |
-
What you get&#xD;
|
| 12 |
-
A site full of products with stock, prices, product descriptions, categories, attribute filters, images, product comparison, related products and more pumped in to Magento automatically.&#xD;
|
| 13 |
-
A tool to manage the feed – see screenshot&#xD;
|
| 14 |
-
The ability to see your buy prices as you browse Sinch&#xD;
|
| 15 |
-
Free support and advice to help you get it working&#xD;</description>
|
| 16 |
-
<notes
|
| 17 |
-
|
| 18 |
-
<p>Installation guides will help you get it working quickly</p></notes>
|
| 19 |
<authors><author><name>stockinchannel</name><user>stockinchannel</user><email>marketing@stockinthechannel.com</email></author></authors>
|
| 20 |
-
<date>2012-04-
|
| 21 |
-
<time>
|
| 22 |
-
<contents><target name="magelocal"><dir name="Bintime"><dir name="Sinchimport"><dir name="Block"><file name="Importhistory.php" hash="
|
| 23 |
<compatible/>
|
| 24 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 25 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>stockinthechannel2012</name>
|
| 4 |
+
<version>1.0.0.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Stock In The Channel to Magento Connector - Sell virtual stock - drop ship ecommerce</summary>
|
| 10 |
+
<description>StockInTheChannel has released a free connector to Magento&amp;#xD;
|
| 11 |
+
What you get&amp;#xD;
|
| 12 |
+
A site full of products with stock, prices, product descriptions, categories, attribute filters, images, product comparison, related products and more pumped in to Magento automatically.&amp;#xD;
|
| 13 |
+
A tool to manage the feed – see screenshot&amp;#xD;
|
| 14 |
+
The ability to see your buy prices as you browse Sinch&amp;#xD;
|
| 15 |
+
Free support and advice to help you get it working&amp;#xD;</description>
|
| 16 |
+
<notes>Now has section to check server configuration for suitability of running extension.
|
| 17 |
+
</notes>
|
|
|
|
| 18 |
<authors><author><name>stockinchannel</name><user>stockinchannel</user><email>marketing@stockinthechannel.com</email></author></authors>
|
| 19 |
+
<date>2012-04-12</date>
|
| 20 |
+
<time>16:16:06</time>
|
| 21 |
+
<contents><target name="magelocal"><dir><dir name="Bintime"><dir name="Sinchimport"><dir name="Block"><file name="Importenvironment.php" hash="23af2586c0003c3bd3bdef82d85f3868"/><file name="Importhistory.php" hash="3748b6e5ccdd242fa8a8cdb96a53241e"/><dir name="Layer"><dir name="Filter"><file name="Feature.php" hash="239d86cde4cf08f5f50183df26e89eea"/></dir><file name="View.php" hash="97cf41b42afc26d46ee3d876721601c7"/></dir><file name="List.php" hash="fb81ed4b565c1099bc7a47d19538c730"/><dir name="Product"><dir name="View"><file name="Media.php" hash="401c8afd5af4d0edda0929e8df4d6cd4"/></dir></dir><file name="Startimportbutton.php" hash="7dafc8567377960378db533fc690fc07"/><file name="Startstockpriceimportbutton.php" hash="14f033367ee4df620494f57be8f26719"/></dir><dir name="Helper"><file name="Data.php" hash="c9baa21be5ba345512e5c390b1954c72"/><file name="Getdata.php" hash="dcdf2bd47b01a26ed9400497774c86f8"/><file name="Image.php" hash="4507e0741e1bf094ce558ffb908dbae8"/></dir><dir name="Model"><file name="Api.php" hash="dbcb072fdf2a27766df6aae8213b3e5e"/><file name="Category.php" hash="c3e3410e01e33334b058dd9781f5d84a"/><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="29090bb9c2f26695687b3bade231e8ce"/><file name="Product.php" hash="1e3be2c2c605b3eaf79aea1627ef4d49"/><dir name="Resource"><dir name="Layer"><dir name="Filter"><file name="Price.php" hash="e5011ebd212c5cc0f7004e1736a28a35"/></dir></dir><dir name="Mysql4"><dir name="Layer"><dir name="Filter"><file name="Feature.php" hash="56a412b5f50661514eec952f7b3f8a61"/></dir></dir><file name="Setup.php" hash="280a1ece3e1bb1f035e2cf265da05b63"/></dir></dir><file name="Sinch.php" hash="11152126076c943a18ce421d38d35f7c"/><dir name="System"><dir name="Config"><file name="CatRewrite.php" hash="2b4282283e068888a4ac527edc7d30b3"/><file name="Subscription.php" hash="985102ab2005f33e017818ef9247b633"/></dir></dir><file name="config.php" hash="70dc63650b9358af10cfa8bea7b10b3c"/></dir><dir name="controllers"><file name="AjaxController.php" hash="85d09a8a2fe9214dce3b6140f1b3983e"/><file name="IndexController.php" hash="910f7a5547e9bad529ea71f3e8cd37e6"/><file name="ProductController.php" hash="a7619ef76a1f48bd7f2c029b7c488385"/><file name="SplitfeaturesController.php" hash="a1c27276bced097e8b2a6667e4b6fdbd"/></dir><dir name="etc"><file name="api.xml" hash="4b9df3ba0ff94824f06a5c14497034cb"/><file name="config.xml" hash="298133e320944c7c908248211bb8199e"/><file name="system.xml" hash="1c13ce44bc0faae36b54dd48b4e35687"/></dir><file name="sinch_import_start_ajax.php" hash="3c81464e43f630270bb0376e15fe21fa"/><dir name="sql"><dir name="sinchimport_setup"><file name="filter_sinch_products_s.sql" hash="40a09a0bb83bce3b14564909cfe3cfc5"/><file name="mysql4-install-0.1.0.php" hash="b79406446cf40050ba29fad4c8057883"/><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="be2fd59f6c6d63b41622844be093283f"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="56aa5dc8f22a7b24b23c9d381e92f6dc"/><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="205a710081d51fc72c00ed1b64845673"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="f32c53dbdd4cb3f32269cd911b8178ea"/><file name="mysql4-upgrade-0.1.7-0.1.8.php" hash="aac20d4a587a68e665367d2c1f9d1068"/><file name="mysql4-upgrade-0.1.8-0.1.9.php" hash="846a3dd72289bfdec3695f913af3e1da"/><file name="mysql4-upgrade-0.1.9-0.2.0.php" hash="00602f51d8a1d63e646166a4c2b3651c"/><file name="mysql4-upgrade-0.2.0-0.2.1.php" hash="aac20d4a587a68e665367d2c1f9d1068"/></dir></dir><file name="stock_price_sinch_import_start_ajax.php" hash="960ba4cfdb5ea3548a17c2365c0fca80"/></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="js"><file name="product_view.js" hash=""/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="sinchimport.xml" hash="53dd99d9303049f92713aec45c21836f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Bintime_Sinchimport.xml" hash="8d5661b858250eeb154af10ee19300c3"/></dir></dir></target><target name="mageskin"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="sinchimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="sinchimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/></dir></dir></dir></dir></dir></target></contents>
|
| 22 |
<compatible/>
|
| 23 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 24 |
</package>
|
