Version Notes
Version 2.0.0
* NEW - Now supports new Magento feed format
* NEW - Allow for Toner Feed imports
* NEW - Allow Mapping of products to Multiple Categories
* Fixed Occasional Price Breaks Error
Download this release
Release Info
Developer | stockinchannel |
Extension | stockinthechannel2012 |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 2.0.0
- app/code/local/Bintime/Sinchimport/Block/Adminhtml/Catalog/Product/Sinchdistributors.php +25 -0
- app/code/local/Bintime/Sinchimport/Block/Importenvironment.php +14 -0
- app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php +2 -1
- app/code/local/Bintime/Sinchimport/Model/Sinch.php +1660 -127
- app/code/local/Bintime/Sinchimport/Model/System/Config/ProdRewrite.php +18 -0
- app/code/local/Bintime/Sinchimport/Model/config.php +7 -1
- app/code/local/Bintime/Sinchimport/controllers/AjaxController.php +16 -2
- app/code/local/Bintime/Sinchimport/etc/config.xml +24 -1
- app/code/local/Bintime/Sinchimport/etc/system.xml +10 -1
- app/code/local/Bintime/Sinchimport/sinch_import_start_ajax.php +0 -1
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/filter_sinch_products_s.sql +181 -84
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.9-0.2.0.php +0 -3
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.1-0.2.2.php +230 -0
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.0-3.0.1.php +307 -0
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.1-3.0.2.php +108 -0
- app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.2-3.0.3.php +42 -0
- app/design/adminhtml/default/default/layout/sinchimport.xml +57 -0
- app/design/adminhtml/default/default/template/sinchimport/sales/items/column/name.phtml +70 -0
- app/design/adminhtml/default/default/template/sinchimport/sinchdistributors.phtml +13 -0
- package.xml +14 -13
app/code/local/Bintime/Sinchimport/Block/Adminhtml/Catalog/Product/Sinchdistributors.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Bintime_Sinchimport_Block_Adminhtml_Catalog_Product_Sinchdistributors extends Mage_Core_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
3 |
+
{
|
4 |
+
public function __construct(){
|
5 |
+
$this->setTemplate('sinchimport/sinchdistributors.phtml');
|
6 |
+
parent::__construct();
|
7 |
+
}
|
8 |
+
|
9 |
+
//Label to be shown in the tab
|
10 |
+
public function getTabLabel(){
|
11 |
+
return Mage::helper('core')->__('Suppliers');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getTabTitle(){
|
15 |
+
return Mage::helper('core')->__('Suppliers');
|
16 |
+
}
|
17 |
+
|
18 |
+
public function canShowTab(){
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function isHidden(){
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
}
|
app/code/local/Bintime/Sinchimport/Block/Importenvironment.php
CHANGED
@@ -104,6 +104,20 @@ class Bintime_Sinchimport_Block_Importenvironment extends Mage_Adminhtml_Block_S
|
|
104 |
";
|
105 |
};
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
// PHP run string
|
109 |
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhprunstring();
|
104 |
";
|
105 |
};
|
106 |
|
107 |
+
|
108 |
+
// Conflict with installed module
|
109 |
+
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkConflictsWithInstalledModules();
|
110 |
+
if ($status == 'error') $errors_count++;
|
111 |
+
if ($status == 'error') {
|
112 |
+
$html .= // $caption: $value $measure
|
113 |
+
"
|
114 |
+
<tr> <td nowrap rowspan=4> $caption </td> </tr>
|
115 |
+
<tr> <td nowrap> {$this->_colored('Necessary:', 'blue')} $critical $measure </td> </tr>
|
116 |
+
<tr> <td nowrap> {$this->_colored('Notice:', 'blue')} $errmsg </td> </tr>
|
117 |
+
<tr> <td nowrap> {$this->_colored('Fix:', 'blue')} $fixmsg </td> </tr>
|
118 |
+
";
|
119 |
+
};
|
120 |
+
|
121 |
|
122 |
// PHP run string
|
123 |
list($status, $caption, $critical, $value, $measure, $errmsg, $fixmsg) = Mage::getModel('sinchimport/sinch')->checkPhprunstring();
|
app/code/local/Bintime/Sinchimport/Model/Resource/Mysql4/Layer/Filter/Feature.php
CHANGED
@@ -97,7 +97,8 @@ 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 |
-
$
|
|
|
101 |
Varien_Profiler::stop(__METHOD__);
|
102 |
return $resultTable;
|
103 |
}
|
97 |
$params .= $bounds[1] != '-' ? (int)$bounds[1] : 'null';
|
98 |
}
|
99 |
//$connection->query("CALL `filter_icecat_products_s`($cfid, $catId,0,$cfid, $params)"));
|
100 |
+
$tablePrefix = (string)Mage::app()->getConfig()->getTablePrefix();
|
101 |
+
$result = $connection->raw_query("CALL ".$this->_getTableName('filter_sinch_products_s')."($cfid, $catId,0, $cfid, $params, '$tablePrefix')");
|
102 |
Varien_Profiler::stop(__METHOD__);
|
103 |
return $resultTable;
|
104 |
}
|
app/code/local/Bintime/Sinchimport/Model/Sinch.php
CHANGED
@@ -40,9 +40,19 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
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 |
private $im_type;
|
@@ -56,6 +66,8 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
56 |
$this->import_log_table="stINch_import_log";
|
57 |
|
58 |
$this->php_run_string=PHP_RUN_STRING;
|
|
|
|
|
59 |
$this->price_breaks_filter=PRICE_BREAKS;
|
60 |
/*$this->db_connect();
|
61 |
$res = $this->db_do("select languages_id from languages where code='".LANG_CODE."'");
|
@@ -70,16 +82,20 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
70 |
$this->_LOG("constructor");
|
71 |
$this->files=array(
|
72 |
FILE_CATEGORIES,
|
|
|
73 |
FILE_CATEGORIES_FEATURES,
|
74 |
FILE_DISTRIBUTORS,
|
|
|
75 |
FILE_EANCODES,
|
76 |
FILE_MANUFACTURERS,
|
77 |
FILE_PRODUCT_FEATURES,
|
|
|
78 |
FILE_PRODUCTS,
|
79 |
FILE_RELATED_PRODUCTS,
|
80 |
FILE_RESTRICTED_VALUES,
|
81 |
FILE_STOCK_AND_PRICES,
|
82 |
-
FILE_PRODUCTS_PICTURES_GALLERY
|
|
|
83 |
);
|
84 |
$this->attributes['manufacturer']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('manufacturer')->getFirstItem()->getId();
|
85 |
$this->attributes['name']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('name')->getFirstItem()->getId();
|
@@ -187,6 +203,11 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
187 |
}
|
188 |
#################################################################################################
|
189 |
function run_sinch_import(){
|
|
|
|
|
|
|
|
|
|
|
190 |
$safe_mode_set = ini_get('safe_mode');
|
191 |
|
192 |
$this->InitImportStatuses('FULL');
|
@@ -216,6 +237,11 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
216 |
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
217 |
exit;
|
218 |
}
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
if($this->is_imort_not_run()){
|
221 |
try{
|
@@ -228,6 +254,9 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
228 |
$import->UploadFiles();
|
229 |
$import->addImportStatus('Upload Files');
|
230 |
|
|
|
|
|
|
|
231 |
echo "Parse Categories <br>";
|
232 |
$coincidence = $import->ParseCategories();
|
233 |
$import->addImportStatus('Parse Categories');
|
@@ -245,9 +274,11 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
245 |
|
246 |
echo "Parse Distributors <br>";
|
247 |
$import->ParseDistributors();
|
|
|
|
|
|
|
248 |
$import->addImportStatus('Parse Distributors');
|
249 |
|
250 |
-
|
251 |
echo "Parse EAN Codes <br>";
|
252 |
$import->ParseEANCodes();
|
253 |
$import->addImportStatus('Parse EAN Codes');
|
@@ -267,7 +298,8 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
267 |
$import->ParseProductFeatures();
|
268 |
$import->addImportStatus('Parse Product Features');
|
269 |
|
270 |
-
|
|
|
271 |
|
272 |
echo "Parse Products <br>";
|
273 |
$import->ParseProducts($coincidence);
|
@@ -285,11 +317,14 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
285 |
$import->ParseRestrictedValues();
|
286 |
$import->addImportStatus('Parse Restricted Values');
|
287 |
|
288 |
-
|
289 |
echo "Parse Stock And Prices <br>";
|
290 |
$import->ParseStockAndPrices();
|
291 |
$import->addImportStatus('Parse Stock And Prices');
|
292 |
-
|
|
|
|
|
|
|
|
|
293 |
|
294 |
Mage::log("Finish Sinch import", null, $this->_logFile);
|
295 |
echo "Finish Sinch import<br>";
|
@@ -378,7 +413,8 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
378 |
$import->addImportStatus('Stock Price Start Import');
|
379 |
echo "Upload Files <br>";
|
380 |
$this->files=array(
|
381 |
-
FILE_STOCK_AND_PRICES
|
|
|
382 |
);
|
383 |
|
384 |
$import->UploadFiles();
|
@@ -389,6 +425,10 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
389 |
$import->ParseStockAndPrices();
|
390 |
$import->addImportStatus('Stock Price Parse Products');
|
391 |
|
|
|
|
|
|
|
|
|
392 |
|
393 |
Mage::log("Finish Stock & Price Sinch import", null, $this->_logFile);
|
394 |
echo "Finish Stock & Price Sinch import<br>";
|
@@ -472,7 +512,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
472 |
}
|
473 |
exec("chmod a+rw ".$this->varDir.$file);
|
474 |
if(!filesize($this->varDir.$file)){
|
475 |
-
if($file!=FILE_CATEGORIES_FEATURES && $file!=FILE_PRODUCT_FEATURES && $file!=FILE_RELATED_PRODUCTS && $file!=FILE_RESTRICTED_VALUES){
|
476 |
$this->_LOG("Can't copy ".$file_url_and_dir.$file.". file $this->varDir.$file is emty");
|
477 |
$this->set_import_error_reporting_message("Can't copy ".$file_url_and_dir.$file.". file ".$this->varDir.$file." is emty");
|
478 |
$this->addImportStatus('Sinch import stoped. Impot file(s) empty', 1);
|
@@ -491,11 +531,31 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
491 |
}elseif($file==FILE_RESTRICTED_VALUES){
|
492 |
$this->_LOG("Can't copy ".FILE_RESTRICTED_VALUES." file ignored" );
|
493 |
$this->_ignore_restricted_values=true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
|
|
495 |
}
|
496 |
}
|
497 |
}
|
498 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
$this->_LOG("Finish upload files");
|
500 |
}
|
501 |
#################################################################################################
|
@@ -526,6 +586,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
526 |
$stINch_categories_mapping_temp = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp');
|
527 |
$stINch_categories_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping');
|
528 |
$stINch_categories = Mage::getSingleton('core/resource')->getTableName('stINch_categories');
|
|
|
529 |
|
530 |
$_categoryEntityTypeId = $this->_categoryEntityTypeId;
|
531 |
$_categoryDefault_attribute_set_id = $this->_categoryDefault_attribute_set_id;
|
@@ -533,6 +594,10 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
533 |
$name_attrid = $this->_getCategoryAttributeId('name');
|
534 |
$is_anchor_attrid = $this->_getCategoryAttributeId('is_anchor');
|
535 |
$image_attrid = $this->_getCategoryAttributeId('image');
|
|
|
|
|
|
|
|
|
536 |
$attr_url_key = $this->attributes['url_key'];
|
537 |
$attr_display_mode = $this->attributes['display_mode'];
|
538 |
$attr_is_active = $this->attributes['is_active'];
|
@@ -540,7 +605,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
|
|
540 |
|
541 |
|
542 |
$this->loadCategoriesTemp($categories_temp, $parse_file, $field_terminated_char);
|
543 |
-
$coincidence = $this->calculateCategoryCoincidence($categories_temp, $catalog_category_entity, $catalog_category_entity_varchar, $im_type);
|
544 |
|
545 |
/**/
|
546 |
if (!$this->check_loaded_data($parse_file, $categories_temp))
|
@@ -606,7 +671,7 @@ echo("\n\n\n\n\n\nOLD LOGIC\n\n\n\n\n\n\n\n\n");
|
|
606 |
$this->_LOG("Wrong file ".$parse_file);
|
607 |
}
|
608 |
$this->_LOG(' ');
|
609 |
-
|
610 |
return $coincidence;
|
611 |
} // function ParseCategories()
|
612 |
################################################################################################################################################################
|
@@ -648,7 +713,7 @@ echo("\n\n\n\n\n\nOLD LOGIC\n\n\n\n\n\n\n\n\n");
|
|
648 |
parent_store_category_id INT(11),
|
649 |
category_name VARCHAR(50),
|
650 |
order_number INT(11),
|
651 |
-
is_hidden
|
652 |
products_within_sub_categories INT(11),
|
653 |
products_within_this_category INT(11),
|
654 |
categories_image VARCHAR(255),
|
@@ -656,7 +721,10 @@ echo("\n\n\n\n\n\nOLD LOGIC\n\n\n\n\n\n\n\n\n");
|
|
656 |
children_count INT(11) NOT NULL DEFAULT 0,
|
657 |
UNSPSC INT(10) DEFAULT NULL,
|
658 |
RootName INT(10) DEFAULT NULL,
|
659 |
-
|
|
|
|
|
|
|
660 |
KEY(store_category_id),
|
661 |
KEY(parent_store_category_id)
|
662 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
@@ -666,6 +734,12 @@ echo("\n\n\n\n\n\nOLD LOGIC\n\n\n\n\n\n\n\n\n");
|
|
666 |
LOAD DATA LOCAL INFILE '$parse_file' INTO TABLE $categories_temp
|
667 |
FIELDS TERMINATED BY '$field_terminated_char' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\r\n\" IGNORE 1 LINES");
|
668 |
|
|
|
|
|
|
|
|
|
|
|
|
|
669 |
|
670 |
|
671 |
|
@@ -687,7 +761,6 @@ echo("\n\n\n\n\n\nOLD LOGIC\n\n\n\n\n\n\n\n\n");
|
|
687 |
//$this->db_do("DELETE FROM $categories_temp WHERE store_category_id IN (175687, 175553)"); // OLD CATS...//
|
688 |
|
689 |
/**/
|
690 |
-
|
691 |
} // private function loadCategoriesTemp()
|
692 |
################################################################################################################################################################
|
693 |
|
@@ -933,13 +1006,13 @@ echo("\n\n $query\n\n");
|
|
933 |
$attr_include_in_menu,
|
934 |
0,
|
935 |
scm.shop_entity_id,
|
936 |
-
|
937 |
FROM $categories_temp c
|
938 |
JOIN $stINch_categories_mapping scm
|
939 |
ON c.store_category_id = scm.store_category_id
|
940 |
)
|
941 |
ON DUPLICATE KEY UPDATE
|
942 |
-
value =
|
943 |
$this->db_do($q);
|
944 |
|
945 |
|
@@ -957,13 +1030,13 @@ echo("\n\n $query\n\n");
|
|
957 |
$is_anchor_attrid,
|
958 |
1,
|
959 |
scm.shop_entity_id,
|
960 |
-
|
961 |
FROM $categories_temp c
|
962 |
JOIN $stINch_categories_mapping scm
|
963 |
ON c.store_category_id = scm.store_category_id
|
964 |
)
|
965 |
ON DUPLICATE KEY UPDATE
|
966 |
-
value =
|
967 |
$this->db_do($q);
|
968 |
|
969 |
|
@@ -981,13 +1054,13 @@ echo("\n\n $query\n\n");
|
|
981 |
$is_anchor_attrid,
|
982 |
0,
|
983 |
scm.shop_entity_id,
|
984 |
-
|
985 |
FROM $categories_temp c
|
986 |
JOIN $stINch_categories_mapping scm
|
987 |
ON c.store_category_id = scm.store_category_id
|
988 |
)
|
989 |
ON DUPLICATE KEY UPDATE
|
990 |
-
value =
|
991 |
$this->db_do($q);
|
992 |
|
993 |
$q = "
|
@@ -1012,6 +1085,78 @@ echo("\n\n $query\n\n");
|
|
1012 |
ON DUPLICATE KEY UPDATE
|
1013 |
value = c.categories_image";
|
1014 |
$this->db_do($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1015 |
}
|
1016 |
else
|
1017 |
{
|
@@ -1076,7 +1221,7 @@ echo("\n\n $query\n\n");
|
|
1076 |
$attr_include_in_menu,
|
1077 |
0,
|
1078 |
scm.shop_entity_id,
|
1079 |
-
|
1080 |
FROM $categories_temp c
|
1081 |
JOIN $stINch_categories_mapping scm
|
1082 |
ON c.store_category_id = scm.store_category_id
|
@@ -1098,7 +1243,7 @@ echo("\n\n $query\n\n");
|
|
1098 |
$is_anchor_attrid,
|
1099 |
0,
|
1100 |
scm.shop_entity_id,
|
1101 |
-
|
1102 |
FROM $categories_temp c
|
1103 |
JOIN $stINch_categories_mapping scm
|
1104 |
ON c.store_category_id = scm.store_category_id
|
@@ -1126,6 +1271,76 @@ echo("\n\n $query\n\n");
|
|
1126 |
ON c.store_category_id = scm.store_category_id
|
1127 |
)";
|
1128 |
$this->db_do($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1129 |
}
|
1130 |
|
1131 |
|
@@ -1404,7 +1619,7 @@ echo("\n\n ==================================================================
|
|
1404 |
(entity_id, entity_type_id, attribute_set_id, parent_id, created_at, updated_at,
|
1405 |
path, position, level, children_count, store_category_id, parent_store_category_id)
|
1406 |
VALUES
|
1407 |
-
($i, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/$i', 1, 1,
|
1408 |
|
1409 |
|
1410 |
$this->db_do("INSERT $catalog_category_entity_varchar
|
@@ -1438,7 +1653,7 @@ echo("\n createNewDefaultCategories done... \n ===========================
|
|
1438 |
|
1439 |
|
1440 |
################################################################################################################################################################
|
1441 |
-
private function calculateCategoryCoincidence($categories_temp, $catalog_category_entity, $catalog_category_entity_varchar, $im_type)
|
1442 |
{
|
1443 |
$root_categories = $this->db_do("
|
1444 |
SELECT
|
@@ -1455,9 +1670,12 @@ echo("\n createNewDefaultCategories done... \n ===========================
|
|
1455 |
while($root_cat = mysql_fetch_array($root_categories)) $OLD[] = $root_cat['category_name'];
|
1456 |
|
1457 |
$new_categories = $this->db_do("SELECT DISTINCT RootName FROM $categories_temp");
|
|
|
|
|
|
|
1458 |
$NEW = array();
|
1459 |
while($new_root_cat = mysql_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['RootName']] = TRUE;
|
1460 |
-
|
1461 |
/**
|
1462 |
$exists_coincidence = array();
|
1463 |
|
@@ -1586,7 +1804,7 @@ echo("rewriteMultistoreCategories DONE\n");
|
|
1586 |
(entity_id, entity_type_id, attribute_set_id, parent_id, created_at, updated_at,
|
1587 |
path, position, level, children_count, store_category_id, parent_store_category_id)
|
1588 |
VALUES
|
1589 |
-
($i, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/$i', 1, 1,
|
1590 |
|
1591 |
|
1592 |
$this->db_do("INSERT $catalog_category_entity_varchar
|
@@ -1947,13 +2165,13 @@ echo("\n\n$query\n\n");
|
|
1947 |
$attr_include_in_menu,
|
1948 |
0,
|
1949 |
scm.shop_entity_id,
|
1950 |
-
|
1951 |
FROM $categories_temp c
|
1952 |
JOIN $stINch_categories_mapping scm
|
1953 |
ON c.store_category_id = scm.store_category_id
|
1954 |
)
|
1955 |
ON DUPLICATE KEY UPDATE
|
1956 |
-
value =
|
1957 |
$this->db_do($q);
|
1958 |
|
1959 |
|
@@ -1971,13 +2189,13 @@ echo("\n\n$query\n\n");
|
|
1971 |
$is_anchor_attrid,
|
1972 |
1,
|
1973 |
scm.shop_entity_id,
|
1974 |
-
|
1975 |
FROM $categories_temp c
|
1976 |
JOIN $stINch_categories_mapping scm
|
1977 |
ON c.store_category_id = scm.store_category_id
|
1978 |
)
|
1979 |
ON DUPLICATE KEY UPDATE
|
1980 |
-
value =
|
1981 |
$this->db_do($q);
|
1982 |
|
1983 |
|
@@ -1995,13 +2213,13 @@ echo("\n\n$query\n\n");
|
|
1995 |
$is_anchor_attrid,
|
1996 |
0,
|
1997 |
scm.shop_entity_id,
|
1998 |
-
|
1999 |
FROM $categories_temp c
|
2000 |
JOIN $stINch_categories_mapping scm
|
2001 |
ON c.store_category_id = scm.store_category_id
|
2002 |
)
|
2003 |
ON DUPLICATE KEY UPDATE
|
2004 |
-
value =
|
2005 |
$this->db_do($q);
|
2006 |
|
2007 |
$q = "
|
@@ -2026,6 +2244,78 @@ echo("\n\n$query\n\n");
|
|
2026 |
ON DUPLICATE KEY UPDATE
|
2027 |
value = c.categories_image";
|
2028 |
$this->db_do($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2029 |
}
|
2030 |
else
|
2031 |
{
|
@@ -2089,7 +2379,7 @@ echo("\n\n$query\n\n");
|
|
2089 |
$attr_include_in_menu,
|
2090 |
0,
|
2091 |
scm.shop_entity_id,
|
2092 |
-
|
2093 |
FROM $categories_temp c
|
2094 |
JOIN $stINch_categories_mapping scm
|
2095 |
ON c.store_category_id = scm.store_category_id
|
@@ -2111,7 +2401,7 @@ echo("\n\n$query\n\n");
|
|
2111 |
$is_anchor_attrid,
|
2112 |
0,
|
2113 |
scm.shop_entity_id,
|
2114 |
-
|
2115 |
FROM $categories_temp c
|
2116 |
JOIN $stINch_categories_mapping scm
|
2117 |
ON c.store_category_id = scm.store_category_id
|
@@ -2139,6 +2429,76 @@ echo("\n\n$query\n\n");
|
|
2139 |
ON c.store_category_id = scm.store_category_id
|
2140 |
)";
|
2141 |
$this->db_do($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2142 |
}
|
2143 |
|
2144 |
$this->delete_old_sinch_categories_from_shop();
|
@@ -2223,8 +2583,8 @@ echo("\n replaceMagentoProductsMultistoreMERGE 1\n");
|
|
2223 |
$core_store = Mage::getSingleton('core/resource')->getTableName('core_store');
|
2224 |
$catalog_product_enabled_index = Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index');
|
2225 |
$catalog_product_website = Mage::getSingleton('core/resource')->getTableName('catalog_product_website');
|
2226 |
-
$catalogsearch_fulltext = Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext');
|
2227 |
-
$catalogsearch_query = Mage::getSingleton('core/resource')->getTableName('catalogsearch_query');
|
2228 |
$catalog_category_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar');
|
2229 |
|
2230 |
$_getProductEntityTypeId = $this->_getProductEntityTypeId();
|
@@ -2530,6 +2890,31 @@ echo("\n replaceMagentoProductsMultistoreMERGE 15\n");
|
|
2530 |
|
2531 |
|
2532 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2533 |
echo("\n replaceMagentoProductsMultistoreMERGE 16\n");
|
2534 |
|
2535 |
//Indexing products and categories in the shop
|
@@ -2644,7 +3029,13 @@ echo("\n replaceMagentoProductsMultistoreMERGE 20\n");
|
|
2644 |
|
2645 |
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
2646 |
$this->addDescriptions();
|
2647 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2648 |
$this->addEAN();
|
2649 |
$this->addSpecification();
|
2650 |
$this->addManufacturers();
|
@@ -2949,7 +3340,7 @@ echo("\n replaceMagentoProductsMultistoreMERGE 36\n");
|
|
2949 |
|
2950 |
|
2951 |
|
2952 |
-
|
2953 |
//Refresh fulltext search
|
2954 |
$result = $this->db_do("DROP TABLE IF EXISTS {$catalogsearch_fulltext}_tmp");
|
2955 |
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS {$catalogsearch_fulltext}_tmp LIKE $catalogsearch_fulltext");
|
@@ -2977,7 +3368,7 @@ $q = "
|
|
2977 |
LEFT JOIN $catalog_product_website j
|
2978 |
ON a.entity_id = j.product_id
|
2979 |
LEFT JOIN $products_temp f
|
2980 |
-
ON a.
|
2981 |
)
|
2982 |
ON DUPLICATE KEY UPDATE
|
2983 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)";
|
@@ -3005,7 +3396,7 @@ echo("\n\n============================\n$q\n============================\n\n");
|
|
3005 |
LEFT JOIN $catalog_product_website j
|
3006 |
ON a.entity_id = j.product_id
|
3007 |
LEFT JOIN $products_temp f
|
3008 |
-
ON a.
|
3009 |
)
|
3010 |
ON DUPLICATE KEY UPDATE
|
3011 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
@@ -3032,7 +3423,7 @@ echo("\n replaceMagentoProductsMultistoreMERGE 37\n");
|
|
3032 |
ON a.entity_id = e.entity_id
|
3033 |
AND e.attribute_id = $attr_name
|
3034 |
LEFT JOIN $products_temp f
|
3035 |
-
ON a.
|
3036 |
)
|
3037 |
ON DUPLICATE KEY UPDATE
|
3038 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
@@ -3056,7 +3447,6 @@ echo("\n replaceMagentoProductsMultistoreMERGE 39\n");
|
|
3056 |
a.store_id,
|
3057 |
a.data_index
|
3058 |
FROM {$catalogsearch_fulltext}_tmp a
|
3059 |
-
WHERE product_id = a.product_id
|
3060 |
)
|
3061 |
ON DUPLICATE KEY UPDATE
|
3062 |
data_index = a.data_index");
|
@@ -3066,7 +3456,7 @@ echo("\n replaceMagentoProductsMultistoreMERGE 40\n");
|
|
3066 |
$this->db_do("UPDATE $catalogsearch_query SET is_processed = 0");
|
3067 |
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
3068 |
//TODO add something else
|
3069 |
-
|
3070 |
|
3071 |
$this->addRelatedProducts();
|
3072 |
echo("\n replaceMagentoProductsMultistoreMERGE 41\n");
|
@@ -3124,8 +3514,8 @@ echo("\n replaceMagentoProductsMultistore 1\n");
|
|
3124 |
$core_store = Mage::getSingleton('core/resource')->getTableName('core_store');
|
3125 |
$catalog_product_enabled_index = Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index');
|
3126 |
$catalog_product_website = Mage::getSingleton('core/resource')->getTableName('catalog_product_website');
|
3127 |
-
$catalogsearch_fulltext = Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext');
|
3128 |
-
$catalogsearch_query = Mage::getSingleton('core/resource')->getTableName('catalogsearch_query');
|
3129 |
$catalog_category_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar');
|
3130 |
|
3131 |
$_getProductEntityTypeId = $this->_getProductEntityTypeId();
|
@@ -3320,7 +3710,7 @@ echo("\n replaceMagentoProductsMultistore 9\n");
|
|
3320 |
echo("\n replaceMagentoProductsMultistore 10\n");
|
3321 |
|
3322 |
|
3323 |
-
$catalog_category_product_for_delete_temp =
|
3324 |
|
3325 |
// TEMPORARY
|
3326 |
$this->db_do(" DROP TABLE IF EXISTS $catalog_category_product_for_delete_temp");
|
@@ -3407,6 +3797,28 @@ echo("\n replaceMagentoProductsMultistore 15\n");
|
|
3407 |
product_id = cpe.entity_id");
|
3408 |
|
3409 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3410 |
|
3411 |
echo("\n replaceMagentoProductsMultistore 16\n");
|
3412 |
|
@@ -3455,7 +3867,7 @@ echo("\n replaceMagentoProductsMultistore 17\n");
|
|
3455 |
b.store_id,
|
3456 |
4
|
3457 |
FROM $catalog_category_product a
|
3458 |
-
JOIN root_cats rc
|
3459 |
ON a.category_id = rc.entity_id
|
3460 |
JOIN $core_store b
|
3461 |
)
|
@@ -3517,7 +3929,13 @@ echo("\n replaceMagentoProductsMultistore 20\n");
|
|
3517 |
|
3518 |
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
3519 |
$this->addDescriptions();
|
3520 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
3521 |
$this->addEAN();
|
3522 |
$this->addSpecification();
|
3523 |
$this->addManufacturers();
|
@@ -3801,7 +4219,7 @@ echo("\n replaceMagentoProductsMultistore 36\n");
|
|
3801 |
|
3802 |
|
3803 |
|
3804 |
-
|
3805 |
//Refresh fulltext search
|
3806 |
$result = $this->db_do("DROP TABLE IF EXISTS {$catalogsearch_fulltext}_tmp");
|
3807 |
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS {$catalogsearch_fulltext}_tmp LIKE $catalogsearch_fulltext");
|
@@ -3829,7 +4247,7 @@ $q = "
|
|
3829 |
LEFT JOIN $catalog_product_website j
|
3830 |
ON a.entity_id = j.product_id
|
3831 |
LEFT JOIN $products_temp f
|
3832 |
-
ON a.
|
3833 |
)
|
3834 |
ON DUPLICATE KEY UPDATE
|
3835 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)";
|
@@ -3857,7 +4275,7 @@ echo("\n\n============================\n$q\n============================\n\n");
|
|
3857 |
LEFT JOIN $catalog_product_website j
|
3858 |
ON a.entity_id = j.product_id
|
3859 |
LEFT JOIN $products_temp f
|
3860 |
-
ON a.
|
3861 |
)
|
3862 |
ON DUPLICATE KEY UPDATE
|
3863 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
@@ -3884,7 +4302,7 @@ echo("\n replaceMagentoProductsMultistore 37\n");
|
|
3884 |
ON a.entity_id = e.entity_id
|
3885 |
AND e.attribute_id = $attr_name
|
3886 |
LEFT JOIN $products_temp f
|
3887 |
-
ON a.
|
3888 |
)
|
3889 |
ON DUPLICATE KEY UPDATE
|
3890 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
@@ -3908,7 +4326,6 @@ echo("\n replaceMagentoProductsMultistore 39\n");
|
|
3908 |
a.store_id,
|
3909 |
a.data_index
|
3910 |
FROM {$catalogsearch_fulltext}_tmp a
|
3911 |
-
WHERE product_id = a.product_id
|
3912 |
)
|
3913 |
ON DUPLICATE KEY UPDATE
|
3914 |
data_index = a.data_index");
|
@@ -3918,7 +4335,7 @@ echo("\n replaceMagentoProductsMultistore 40\n");
|
|
3918 |
$this->db_do("UPDATE $catalogsearch_query SET is_processed = 0");
|
3919 |
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
3920 |
//TODO add something else
|
3921 |
-
|
3922 |
|
3923 |
$this->addRelatedProducts();
|
3924 |
echo("\n replaceMagentoProductsMultistore 41\n");
|
@@ -4039,7 +4456,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4039 |
)
|
4040 |
VALUES
|
4041 |
(1, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 0, '0000-00-00 00:00:00', now(), '1', 0, 0, 1, null, null),
|
4042 |
-
(2, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/2', 1, 1,
|
4043 |
|
4044 |
$this->db_do("TRUNCATE $catalog_category_entity_varchar");
|
4045 |
$this->db_do("
|
@@ -4434,13 +4851,13 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4434 |
$attr_include_in_menu,
|
4435 |
0,
|
4436 |
scm.shop_entity_id,
|
4437 |
-
|
4438 |
FROM $categories_temp c
|
4439 |
JOIN $stINch_categories_mapping scm
|
4440 |
ON c.store_category_id = scm.store_category_id
|
4441 |
)
|
4442 |
ON DUPLICATE KEY UPDATE
|
4443 |
-
value =
|
4444 |
$this->db_do($q);
|
4445 |
|
4446 |
$q = "
|
@@ -4457,13 +4874,13 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4457 |
$is_anchor_attrid,
|
4458 |
1,
|
4459 |
scm.shop_entity_id,
|
4460 |
-
|
4461 |
FROM $categories_temp c
|
4462 |
JOIN $stINch_categories_mapping scm
|
4463 |
ON c.store_category_id = scm.store_category_id
|
4464 |
)
|
4465 |
ON DUPLICATE KEY UPDATE
|
4466 |
-
value =
|
4467 |
$this->db_do($q);
|
4468 |
|
4469 |
$q = "
|
@@ -4480,13 +4897,13 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4480 |
$is_anchor_attrid,
|
4481 |
0,
|
4482 |
scm.shop_entity_id,
|
4483 |
-
|
4484 |
FROM $categories_temp c
|
4485 |
JOIN $stINch_categories_mapping scm
|
4486 |
ON c.store_category_id = scm.store_category_id
|
4487 |
)
|
4488 |
ON DUPLICATE KEY UPDATE
|
4489 |
-
value =
|
4490 |
$this->db_do($q);
|
4491 |
|
4492 |
$q = "
|
@@ -4511,6 +4928,78 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4511 |
ON DUPLICATE KEY UPDATE
|
4512 |
value = c.categories_image";
|
4513 |
$this->db_do($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4514 |
}
|
4515 |
else
|
4516 |
{
|
@@ -4572,7 +5061,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4572 |
$attr_include_in_menu,
|
4573 |
0,
|
4574 |
scm.shop_entity_id,
|
4575 |
-
|
4576 |
FROM $categories_temp c
|
4577 |
JOIN $stINch_categories_mapping scm
|
4578 |
ON c.store_category_id = scm.store_category_id
|
@@ -4593,7 +5082,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4593 |
$is_anchor_attrid,
|
4594 |
0,
|
4595 |
scm.shop_entity_id,
|
4596 |
-
|
4597 |
FROM $categories_temp c
|
4598 |
JOIN $stINch_categories_mapping scm
|
4599 |
ON c.store_category_id = scm.store_category_id
|
@@ -4620,6 +5109,76 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4620 |
ON c.store_category_id = scm.store_category_id
|
4621 |
)";
|
4622 |
$this->db_do($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4623 |
}
|
4624 |
|
4625 |
$this->delete_old_sinch_categories_from_shop();
|
@@ -4714,6 +5273,45 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4714 |
$this->_LOG(' ');
|
4715 |
}
|
4716 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4717 |
#################################################################################################
|
4718 |
|
4719 |
function ParseEANCodes(){
|
@@ -4879,11 +5477,79 @@ echo("\n replaceMagentoProductsMultistore 41\n");
|
|
4879 |
}
|
4880 |
$this->_LOG(" ");
|
4881 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4882 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4883 |
#################################################################################################
|
4884 |
|
4885 |
function ParseProducts($coincidence){
|
4886 |
echo("\nParseProducts 2\n");
|
|
|
|
|
|
|
4887 |
$parse_file=$this->varDir.FILE_PRODUCTS;
|
4888 |
if(filesize($parse_file)){
|
4889 |
$this->_LOG("Start parse ".FILE_PRODUCTS);
|
@@ -4902,22 +5568,25 @@ echo("\nParseProducts 2\n");
|
|
4902 |
|
4903 |
// $prod_file_str = file_get_contents($parse_file);
|
4904 |
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
|
|
|
4905 |
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."(
|
4906 |
-
store_category_product_id int(11),
|
4907 |
store_product_id int(11),
|
4908 |
-
sinch_product_id int(11),
|
4909 |
product_sku varchar(255),
|
4910 |
product_name varchar(255),
|
4911 |
sinch_manufacturer_id int(11),
|
4912 |
-
store_category_id int(11),
|
4913 |
main_image_url varchar(255),
|
4914 |
thumb_image_url varchar(255),
|
4915 |
specifications text,
|
4916 |
description text,
|
4917 |
search_cache text,
|
4918 |
-
spec_characte_u_count int(11),
|
4919 |
description_type varchar(50),
|
4920 |
medium_image_url varchar(255),
|
|
|
|
|
|
|
|
|
|
|
|
|
4921 |
products_date_added datetime default NULL,
|
4922 |
products_last_modified datetime default NULL,
|
4923 |
availability_id_in_stock int(11) default '1',
|
@@ -4928,12 +5597,45 @@ echo("\nParseProducts 2\n");
|
|
4928 |
products_viewed int(5) default '0',
|
4929 |
products_seo_url varchar(100) NOT NULL,
|
4930 |
manufacturer_name varchar(255) default NULL,
|
4931 |
-
KEY(store_category_product_id),
|
4932 |
KEY(store_product_id),
|
4933 |
-
KEY(sinch_manufacturer_id)
|
4934 |
-
KEY(store_category_id)
|
4935 |
)DEFAULT CHARSET=utf8
|
4936 |
");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4937 |
echo("\nParseProducts 3\n");
|
4938 |
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file.".conv'
|
4939 |
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
@@ -4941,6 +5643,38 @@ echo("\nParseProducts 3\n");
|
|
4941 |
OPTIONALLY ENCLOSED BY '\"'
|
4942 |
LINES TERMINATED BY \"\r\n\"
|
4943 |
IGNORE 1 LINES ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4944 |
echo("\nParseProducts 4\n");
|
4945 |
|
4946 |
|
@@ -4974,8 +5708,9 @@ echo("\nParseProducts 8\n");
|
|
4974 |
$this->mapSinchProducts();
|
4975 |
echo("\nParseProducts 9\n");
|
4976 |
|
4977 |
-
|
4978 |
-
|
|
|
4979 |
if (count($coincidence) == 1)
|
4980 |
{
|
4981 |
$this->replaceMagentoProducts();
|
@@ -5130,8 +5865,6 @@ echo("\nParseProducts 11\n");
|
|
5130 |
SET number_of_products=".$row['cnt']."
|
5131 |
WHERE id=".$this->current_import_status_statistic_id);
|
5132 |
|
5133 |
-
$this->addWeight();
|
5134 |
-
|
5135 |
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_stock_and_prices'));
|
5136 |
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')."
|
5137 |
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_stock_and_prices'));
|
@@ -5186,41 +5919,179 @@ echo("\nParseProducts 11\n");
|
|
5186 |
|
5187 |
}
|
5188 |
|
|
|
5189 |
|
5190 |
-
|
5191 |
-
|
5192 |
-
|
5193 |
-
|
5194 |
-
|
5195 |
-
|
5196 |
-
|
5197 |
-
|
5198 |
-
|
5199 |
-
|
5200 |
-
|
5201 |
-
|
5202 |
-
|
5203 |
-
|
5204 |
-
|
5205 |
-
|
5206 |
-
|
5207 |
-
|
5208 |
-
|
5209 |
-
|
5210 |
-
|
5211 |
-
KEY sinch_product_id (sinch_product_id),
|
5212 |
-
KEY sku (sku),
|
5213 |
-
UNIQUE KEY(entity_id)
|
5214 |
)
|
5215 |
-
|
5216 |
-
|
5217 |
-
|
5218 |
-
|
5219 |
-
|
5220 |
-
|
5221 |
-
|
5222 |
-
|
5223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5224 |
)(SELECT
|
5225 |
entity_id,
|
5226 |
sku,
|
@@ -5247,7 +6118,6 @@ echo("\nParseProducts 11\n");
|
|
5247 |
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
5248 |
ON pmt.sku=p.product_sku
|
5249 |
SET
|
5250 |
-
pmt.store_category_product_id=p.store_category_product_id,
|
5251 |
pmt.store_product_id=p.store_product_id,
|
5252 |
pmt.sinch_product_id=p.sinch_product_id,
|
5253 |
pmt.product_sku=p.product_sku,
|
@@ -5517,6 +6387,33 @@ echo("\ndone\n");
|
|
5517 |
product_id = cpe.entity_id
|
5518 |
");
|
5519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5520 |
//Indexing products and categories in the shop
|
5521 |
$result = $this->db_do("DELETE ccpi
|
5522 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." ccpi
|
@@ -5624,7 +6521,13 @@ echo("\ndone\n");
|
|
5624 |
|
5625 |
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
5626 |
$this->addDescriptions();
|
5627 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
5628 |
$this->addEAN();
|
5629 |
$this->addSpecification();
|
5630 |
$this->addManufacturers();
|
@@ -5934,7 +6837,7 @@ echo("\ndone\n");
|
|
5934 |
|
5935 |
");
|
5936 |
|
5937 |
-
|
5938 |
//Refresh fulltext search
|
5939 |
$result = $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp");
|
5940 |
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS
|
@@ -5965,7 +6868,7 @@ echo("\ndone\n");
|
|
5965 |
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_website')." j
|
5966 |
ON a.entity_id = j.product_id
|
5967 |
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." f
|
5968 |
-
ON a.
|
5969 |
)
|
5970 |
ON DUPLICATE KEY UPDATE
|
5971 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
@@ -5993,7 +6896,7 @@ echo("\ndone\n");
|
|
5993 |
ON a.entity_id = e.entity_id
|
5994 |
AND e.attribute_id = " . $this->_getProductAttributeId('name'). "
|
5995 |
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." f
|
5996 |
-
ON a.
|
5997 |
)
|
5998 |
ON DUPLICATE KEY UPDATE
|
5999 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
@@ -6025,10 +6928,64 @@ echo("\ndone\n");
|
|
6025 |
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_query')." SET is_processed = 0");
|
6026 |
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
6027 |
//TODO add something else
|
6028 |
-
|
6029 |
$this->addRelatedProducts();
|
6030 |
}
|
6031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6032 |
#################################################################################################
|
6033 |
function addDescriptions(){
|
6034 |
// product description for all web sites
|
@@ -6080,8 +7037,127 @@ echo("\ndone\n");
|
|
6080 |
");
|
6081 |
|
6082 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6083 |
}
|
6084 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6085 |
#################################################################################################
|
6086 |
function addShortDescriptions(){
|
6087 |
// product short description for all web sites
|
@@ -6098,7 +7174,7 @@ echo("\ndone\n");
|
|
6098 |
" . $this->_getProductAttributeId('short_description'). ",
|
6099 |
w.website,
|
6100 |
a.entity_id,
|
6101 |
-
|
6102 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
6103 |
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
6104 |
ON a.store_product_id = b.store_product_id
|
@@ -6106,7 +7182,7 @@ echo("\ndone\n");
|
|
6106 |
ON a.store_product_id=w.store_product_id
|
6107 |
)
|
6108 |
ON DUPLICATE KEY UPDATE
|
6109 |
-
value =
|
6110 |
");
|
6111 |
// product short description for all web sites
|
6112 |
$result = $this->db_do("
|
@@ -6122,13 +7198,13 @@ echo("\ndone\n");
|
|
6122 |
" . $this->_getProductAttributeId('short_description'). ",
|
6123 |
0,
|
6124 |
a.entity_id,
|
6125 |
-
|
6126 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
6127 |
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
6128 |
ON a.store_product_id = b.store_product_id
|
6129 |
)
|
6130 |
ON DUPLICATE KEY UPDATE
|
6131 |
-
value =
|
6132 |
");
|
6133 |
|
6134 |
}
|
@@ -6162,7 +7238,7 @@ echo("\ndone\n");
|
|
6162 |
ON e.sinch_product_id=p.sinch_product_id
|
6163 |
SET e.store_product_id=p.store_product_id");
|
6164 |
// product EANs for all web sites
|
6165 |
-
$result = $this->db_do("
|
6166 |
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
6167 |
entity_type_id,
|
6168 |
attribute_id,
|
@@ -6487,7 +7563,7 @@ echo("\ndone\n");
|
|
6487 |
}
|
6488 |
#################################################################################################
|
6489 |
function addWeight(){
|
6490 |
-
// product
|
6491 |
$result = $this->db_do("
|
6492 |
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
6493 |
entity_type_id,
|
@@ -6501,17 +7577,17 @@ echo("\ndone\n");
|
|
6501 |
" . $this->_getProductAttributeId('weight'). ",
|
6502 |
w.website,
|
6503 |
a.entity_id,
|
6504 |
-
|
6505 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
6506 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('
|
6507 |
ON a.store_product_id = b.store_product_id
|
6508 |
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
6509 |
ON a.store_product_id=w.store_product_id
|
6510 |
)
|
6511 |
ON DUPLICATE KEY UPDATE
|
6512 |
-
value =
|
6513 |
");
|
6514 |
-
// product
|
6515 |
$result = $this->db_do("
|
6516 |
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
6517 |
entity_type_id,
|
@@ -6525,19 +7601,239 @@ echo("\ndone\n");
|
|
6525 |
" . $this->_getProductAttributeId('weight'). ",
|
6526 |
0,
|
6527 |
a.entity_id,
|
6528 |
-
|
6529 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
6530 |
-
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('
|
6531 |
ON a.store_product_id = b.store_product_id
|
6532 |
)
|
6533 |
ON DUPLICATE KEY UPDATE
|
6534 |
-
value =
|
6535 |
|
6536 |
|
6537 |
");
|
6538 |
|
6539 |
|
6540 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6541 |
#################################################################################################
|
6542 |
function replaceMagentoProductsStockPrice(){
|
6543 |
//Add stock
|
@@ -8229,11 +9525,248 @@ echo("\ndone\n");
|
|
8229 |
|
8230 |
|
8231 |
|
8232 |
-
} // class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract
|
8233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8234 |
|
8235 |
|
8236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8237 |
?>
|
8238 |
|
8239 |
|
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_product_categories = false;
|
45 |
+
private $_ignore_price_rules = false;
|
46 |
+
private $product_file_format = "NEW";
|
47 |
private $_ignore_restricted_values = false;
|
48 |
+
private $_categoryMetaTitleAttrId;
|
49 |
+
private $_categoryMetadescriptionAttrId;
|
50 |
+
private $_categoryDescriptionAttrId;
|
51 |
+
|
52 |
+
|
53 |
public $php_run_string;
|
54 |
+
public $php_run_strings;
|
55 |
+
|
56 |
public $price_breaks_filter;
|
57 |
|
58 |
private $im_type;
|
66 |
$this->import_log_table="stINch_import_log";
|
67 |
|
68 |
$this->php_run_string=PHP_RUN_STRING;
|
69 |
+
$this->php_run_strings=PHP_RUN_STRINGS;
|
70 |
+
|
71 |
$this->price_breaks_filter=PRICE_BREAKS;
|
72 |
/*$this->db_connect();
|
73 |
$res = $this->db_do("select languages_id from languages where code='".LANG_CODE."'");
|
82 |
$this->_LOG("constructor");
|
83 |
$this->files=array(
|
84 |
FILE_CATEGORIES,
|
85 |
+
FILE_CATEGORY_TYPES,
|
86 |
FILE_CATEGORIES_FEATURES,
|
87 |
FILE_DISTRIBUTORS,
|
88 |
+
FILE_DISTRIBUTORS_STOCK_AND_PRICES,
|
89 |
FILE_EANCODES,
|
90 |
FILE_MANUFACTURERS,
|
91 |
FILE_PRODUCT_FEATURES,
|
92 |
+
FILE_PRODUCT_CATEGORIES,
|
93 |
FILE_PRODUCTS,
|
94 |
FILE_RELATED_PRODUCTS,
|
95 |
FILE_RESTRICTED_VALUES,
|
96 |
FILE_STOCK_AND_PRICES,
|
97 |
+
FILE_PRODUCTS_PICTURES_GALLERY,
|
98 |
+
FILE_PRICE_RULES
|
99 |
);
|
100 |
$this->attributes['manufacturer']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('manufacturer')->getFirstItem()->getId();
|
101 |
$this->attributes['name']=Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter('name')->getFirstItem()->getId();
|
203 |
}
|
204 |
#################################################################################################
|
205 |
function run_sinch_import(){
|
206 |
+
|
207 |
+
$this->_categoryMetaTitleAttrId = $this->_getCategoryAttributeId('meta_title');
|
208 |
+
$this->_categoryMetadescriptionAttrId = $this->_getCategoryAttributeId('meta_description');
|
209 |
+
$this->_categoryDescriptionAttrId = $this->_getCategoryAttributeId('description');
|
210 |
+
|
211 |
$safe_mode_set = ini_get('safe_mode');
|
212 |
|
213 |
$this->InitImportStatuses('FULL');
|
237 |
$this->set_import_error_reporting_message("Loaddata option not set - please check the documentation on how to fix this. Import stopped.");
|
238 |
exit;
|
239 |
}
|
240 |
+
//STP TEST
|
241 |
+
//$this->ApplyCustomerGroupPrice();
|
242 |
+
//echo $children_cat=$this->get_all_children_cat(6);
|
243 |
+
|
244 |
+
|
245 |
|
246 |
if($this->is_imort_not_run()){
|
247 |
try{
|
254 |
$import->UploadFiles();
|
255 |
$import->addImportStatus('Upload Files');
|
256 |
|
257 |
+
echo "Parse Category Types <br>";
|
258 |
+
$import->ParseCategoryTypes();
|
259 |
+
|
260 |
echo "Parse Categories <br>";
|
261 |
$coincidence = $import->ParseCategories();
|
262 |
$import->addImportStatus('Parse Categories');
|
274 |
|
275 |
echo "Parse Distributors <br>";
|
276 |
$import->ParseDistributors();
|
277 |
+
if($this->product_file_format == "NEW"){
|
278 |
+
$this->ParseDistributorsStockAndPrice();
|
279 |
+
}
|
280 |
$import->addImportStatus('Parse Distributors');
|
281 |
|
|
|
282 |
echo "Parse EAN Codes <br>";
|
283 |
$import->ParseEANCodes();
|
284 |
$import->addImportStatus('Parse EAN Codes');
|
298 |
$import->ParseProductFeatures();
|
299 |
$import->addImportStatus('Parse Product Features');
|
300 |
|
301 |
+
echo "Parse Product Categories <br>";
|
302 |
+
$import->ParseProductCategories();
|
303 |
|
304 |
echo "Parse Products <br>";
|
305 |
$import->ParseProducts($coincidence);
|
317 |
$import->ParseRestrictedValues();
|
318 |
$import->addImportStatus('Parse Restricted Values');
|
319 |
|
|
|
320 |
echo "Parse Stock And Prices <br>";
|
321 |
$import->ParseStockAndPrices();
|
322 |
$import->addImportStatus('Parse Stock And Prices');
|
323 |
+
|
324 |
+
echo "Apply Customer Group Price <br>";
|
325 |
+
$import->ParsePriceRules();
|
326 |
+
$import->AddPriceRules();
|
327 |
+
$import->ApplyCustomerGroupPrice();
|
328 |
|
329 |
Mage::log("Finish Sinch import", null, $this->_logFile);
|
330 |
echo "Finish Sinch import<br>";
|
413 |
$import->addImportStatus('Stock Price Start Import');
|
414 |
echo "Upload Files <br>";
|
415 |
$this->files=array(
|
416 |
+
FILE_STOCK_AND_PRICES,
|
417 |
+
FILE_PRICE_RULES
|
418 |
);
|
419 |
|
420 |
$import->UploadFiles();
|
425 |
$import->ParseStockAndPrices();
|
426 |
$import->addImportStatus('Stock Price Parse Products');
|
427 |
|
428 |
+
echo "Apply Customer Group Price <br>";
|
429 |
+
$import->ParsePriceRules();
|
430 |
+
$import->AddPriceRules();
|
431 |
+
$import->ApplyCustomerGroupPrice();
|
432 |
|
433 |
Mage::log("Finish Stock & Price Sinch import", null, $this->_logFile);
|
434 |
echo "Finish Stock & Price Sinch import<br>";
|
512 |
}
|
513 |
exec("chmod a+rw ".$this->varDir.$file);
|
514 |
if(!filesize($this->varDir.$file)){
|
515 |
+
if($file!=FILE_CATEGORIES_FEATURES && $file!=FILE_PRODUCT_FEATURES && $file!=FILE_RELATED_PRODUCTS && $file!=FILE_RESTRICTED_VALUES && $file!=FILE_PRODUCT_CATEGORIES && $file !=FILE_CATEGORY_TYPES && $file != FILE_DISTRIBUTORS_STOCK_AND_PRICES && $file != FILE_PRICE_RULES){
|
516 |
$this->_LOG("Can't copy ".$file_url_and_dir.$file.". file $this->varDir.$file is emty");
|
517 |
$this->set_import_error_reporting_message("Can't copy ".$file_url_and_dir.$file.". file ".$this->varDir.$file." is emty");
|
518 |
$this->addImportStatus('Sinch import stoped. Impot file(s) empty', 1);
|
531 |
}elseif($file==FILE_RESTRICTED_VALUES){
|
532 |
$this->_LOG("Can't copy ".FILE_RESTRICTED_VALUES." file ignored" );
|
533 |
$this->_ignore_restricted_values=true;
|
534 |
+
}elseif($file==FILE_PRODUCT_CATEGORIES){
|
535 |
+
$this->_LOG("Can't copy ".FILE_PRODUCT_CATEGORIES." file ignored" );
|
536 |
+
$this->_ignore_product_categories=true;
|
537 |
+
$this->product_file_format = "OLD";
|
538 |
+
}elseif($file==FILE_CATEGORY_TYPES){
|
539 |
+
$this->_LOG("Can't copy ".FILE_CATEGORY_TYPES." file ignored" );
|
540 |
+
$this->_ignore_category_types=true;
|
541 |
+
}elseif($file==FILE_DISTRIBUTORS_STOCK_AND_PRICES){
|
542 |
+
$this->_LOG("Can't copy ".FILE_DISTRIBUTORS_STOCK_AND_PRICES." file ignored" );
|
543 |
+
$this->_ignore_category_types=true;
|
544 |
+
}elseif($file==FILE_PRICE_RULES){
|
545 |
+
$this->_LOG("Can't copy ".FILE_PRICE_RULES." file ignored" );
|
546 |
+
$this->_ignore_price_rules=true;
|
547 |
}
|
548 |
+
|
549 |
}
|
550 |
}
|
551 |
}
|
552 |
+
if (file_exists($file_url_and_dir.FILE_PRODUCT_CATEGORIES)){
|
553 |
+
$this->product_file_format = "NEW";
|
554 |
+
$this->_LOG("File ".$file_url_and_dir.FILE_PRODUCT_CATEGORIES." exist. Will used parser for NEW format product.csv" );
|
555 |
+
}else{
|
556 |
+
$this->product_file_format = "OLD";
|
557 |
+
$this->_LOG("File ".$file_url_and_dir.FILE_PRODUCT_CATEGORIES." dosen't exist. Will used parser for OLD format product.csv" );
|
558 |
+
}
|
559 |
$this->_LOG("Finish upload files");
|
560 |
}
|
561 |
#################################################################################################
|
586 |
$stINch_categories_mapping_temp = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping_temp');
|
587 |
$stINch_categories_mapping = Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping');
|
588 |
$stINch_categories = Mage::getSingleton('core/resource')->getTableName('stINch_categories');
|
589 |
+
$category_types = Mage::getSingleton('core/resource')->getTableName('stINch_category_types');
|
590 |
|
591 |
$_categoryEntityTypeId = $this->_categoryEntityTypeId;
|
592 |
$_categoryDefault_attribute_set_id = $this->_categoryDefault_attribute_set_id;
|
594 |
$name_attrid = $this->_getCategoryAttributeId('name');
|
595 |
$is_anchor_attrid = $this->_getCategoryAttributeId('is_anchor');
|
596 |
$image_attrid = $this->_getCategoryAttributeId('image');
|
597 |
+
|
598 |
+
|
599 |
+
|
600 |
+
|
601 |
$attr_url_key = $this->attributes['url_key'];
|
602 |
$attr_display_mode = $this->attributes['display_mode'];
|
603 |
$attr_is_active = $this->attributes['is_active'];
|
605 |
|
606 |
|
607 |
$this->loadCategoriesTemp($categories_temp, $parse_file, $field_terminated_char);
|
608 |
+
$coincidence = $this->calculateCategoryCoincidence($categories_temp, $catalog_category_entity, $catalog_category_entity_varchar, $im_type, $category_types);
|
609 |
|
610 |
/**/
|
611 |
if (!$this->check_loaded_data($parse_file, $categories_temp))
|
671 |
$this->_LOG("Wrong file ".$parse_file);
|
672 |
}
|
673 |
$this->_LOG(' ');
|
674 |
+
$this->_set_default_root_category();
|
675 |
return $coincidence;
|
676 |
} // function ParseCategories()
|
677 |
################################################################################################################################################################
|
713 |
parent_store_category_id INT(11),
|
714 |
category_name VARCHAR(50),
|
715 |
order_number INT(11),
|
716 |
+
is_hidden VARCHAR(10),
|
717 |
products_within_sub_categories INT(11),
|
718 |
products_within_this_category INT(11),
|
719 |
categories_image VARCHAR(255),
|
721 |
children_count INT(11) NOT NULL DEFAULT 0,
|
722 |
UNSPSC INT(10) DEFAULT NULL,
|
723 |
RootName INT(10) DEFAULT NULL,
|
724 |
+
MainImageURL VARCHAR(255),
|
725 |
+
MetaTitle TEXT,
|
726 |
+
MetaDescription TEXT,
|
727 |
+
Description TEXT,
|
728 |
KEY(store_category_id),
|
729 |
KEY(parent_store_category_id)
|
730 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
734 |
LOAD DATA LOCAL INFILE '$parse_file' INTO TABLE $categories_temp
|
735 |
FIELDS TERMINATED BY '$field_terminated_char' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\r\n\" IGNORE 1 LINES");
|
736 |
|
737 |
+
$this->db_do("ALTER TABLE $categories_temp ADD COLUMN include_in_menu TINYINT(1) NOT NULL DEFAULT 1");
|
738 |
+
$this->db_do("UPDATE $categories_temp SET include_in_menu = 0 WHERE UCASE(is_hidden)='TRUE'");
|
739 |
+
|
740 |
+
$this->db_do("ALTER TABLE $categories_temp ADD COLUMN is_anchor TINYINT(1) NOT NULL DEFAULT 1");
|
741 |
+
$this->db_do("UPDATE $categories_temp SET level = (level+2) WHERE level >= 0");
|
742 |
+
# $this->db_do("UPDATE $categories_temp SET is_anchor = 0 WHERE level > 0");
|
743 |
|
744 |
|
745 |
|
761 |
//$this->db_do("DELETE FROM $categories_temp WHERE store_category_id IN (175687, 175553)"); // OLD CATS...//
|
762 |
|
763 |
/**/
|
|
|
764 |
} // private function loadCategoriesTemp()
|
765 |
################################################################################################################################################################
|
766 |
|
1006 |
$attr_include_in_menu,
|
1007 |
0,
|
1008 |
scm.shop_entity_id,
|
1009 |
+
c.include_in_menu
|
1010 |
FROM $categories_temp c
|
1011 |
JOIN $stINch_categories_mapping scm
|
1012 |
ON c.store_category_id = scm.store_category_id
|
1013 |
)
|
1014 |
ON DUPLICATE KEY UPDATE
|
1015 |
+
value = c.include_in_menu";
|
1016 |
$this->db_do($q);
|
1017 |
|
1018 |
|
1030 |
$is_anchor_attrid,
|
1031 |
1,
|
1032 |
scm.shop_entity_id,
|
1033 |
+
c.is_anchor
|
1034 |
FROM $categories_temp c
|
1035 |
JOIN $stINch_categories_mapping scm
|
1036 |
ON c.store_category_id = scm.store_category_id
|
1037 |
)
|
1038 |
ON DUPLICATE KEY UPDATE
|
1039 |
+
value = c.is_anchor";
|
1040 |
$this->db_do($q);
|
1041 |
|
1042 |
|
1054 |
$is_anchor_attrid,
|
1055 |
0,
|
1056 |
scm.shop_entity_id,
|
1057 |
+
c.is_anchor
|
1058 |
FROM $categories_temp c
|
1059 |
JOIN $stINch_categories_mapping scm
|
1060 |
ON c.store_category_id = scm.store_category_id
|
1061 |
)
|
1062 |
ON DUPLICATE KEY UPDATE
|
1063 |
+
value = c.is_anchor";
|
1064 |
$this->db_do($q);
|
1065 |
|
1066 |
$q = "
|
1085 |
ON DUPLICATE KEY UPDATE
|
1086 |
value = c.categories_image";
|
1087 |
$this->db_do($q);
|
1088 |
+
//STP
|
1089 |
+
$q = "
|
1090 |
+
INSERT INTO $catalog_category_entity_varchar
|
1091 |
+
(
|
1092 |
+
entity_type_id,
|
1093 |
+
attribute_id,
|
1094 |
+
store_id,
|
1095 |
+
entity_id,
|
1096 |
+
value
|
1097 |
+
)
|
1098 |
+
(SELECT
|
1099 |
+
$this->_categoryEntityTypeId,
|
1100 |
+
$this->_categoryMetaTitleAttrId,
|
1101 |
+
0,
|
1102 |
+
scm.shop_entity_id,
|
1103 |
+
c.MetaTitle
|
1104 |
+
FROM $categories_temp c
|
1105 |
+
JOIN $stINch_categories_mapping scm
|
1106 |
+
ON c.store_category_id = scm.store_category_id
|
1107 |
+
)
|
1108 |
+
ON DUPLICATE KEY UPDATE
|
1109 |
+
value = c.MetaTitle";
|
1110 |
+
$this->db_do($q);
|
1111 |
+
|
1112 |
+
$q = "
|
1113 |
+
INSERT INTO $catalog_category_entity_varchar
|
1114 |
+
(
|
1115 |
+
entity_type_id,
|
1116 |
+
attribute_id,
|
1117 |
+
store_id,
|
1118 |
+
entity_id,
|
1119 |
+
value
|
1120 |
+
)
|
1121 |
+
(SELECT
|
1122 |
+
$this->_categoryEntityTypeId,
|
1123 |
+
$this->_categoryMetadescriptionAttrId,
|
1124 |
+
0,
|
1125 |
+
scm.shop_entity_id,
|
1126 |
+
c.MetaDescription
|
1127 |
+
FROM $categories_temp c
|
1128 |
+
JOIN $stINch_categories_mapping scm
|
1129 |
+
ON c.store_category_id = scm.store_category_id
|
1130 |
+
)
|
1131 |
+
ON DUPLICATE KEY UPDATE
|
1132 |
+
value = c.MetaDescription";
|
1133 |
+
$this->db_do($q);
|
1134 |
+
|
1135 |
+
$q = "
|
1136 |
+
INSERT INTO $catalog_category_entity_varchar
|
1137 |
+
(
|
1138 |
+
entity_type_id,
|
1139 |
+
attribute_id,
|
1140 |
+
store_id,
|
1141 |
+
entity_id,
|
1142 |
+
value
|
1143 |
+
)
|
1144 |
+
(SELECT
|
1145 |
+
$this->_categoryEntityTypeId,
|
1146 |
+
$this->_categoryDescriptionAttrId,
|
1147 |
+
0,
|
1148 |
+
scm.shop_entity_id,
|
1149 |
+
c.Description
|
1150 |
+
FROM $categories_temp c
|
1151 |
+
JOIN $stINch_categories_mapping scm
|
1152 |
+
ON c.store_category_id = scm.store_category_id
|
1153 |
+
)
|
1154 |
+
ON DUPLICATE KEY UPDATE
|
1155 |
+
value = c.Description";
|
1156 |
+
$this->db_do($q);
|
1157 |
+
|
1158 |
+
|
1159 |
+
//stp
|
1160 |
}
|
1161 |
else
|
1162 |
{
|
1221 |
$attr_include_in_menu,
|
1222 |
0,
|
1223 |
scm.shop_entity_id,
|
1224 |
+
c.include_in_menu
|
1225 |
FROM $categories_temp c
|
1226 |
JOIN $stINch_categories_mapping scm
|
1227 |
ON c.store_category_id = scm.store_category_id
|
1243 |
$is_anchor_attrid,
|
1244 |
0,
|
1245 |
scm.shop_entity_id,
|
1246 |
+
c.is_anchor
|
1247 |
FROM $categories_temp c
|
1248 |
JOIN $stINch_categories_mapping scm
|
1249 |
ON c.store_category_id = scm.store_category_id
|
1271 |
ON c.store_category_id = scm.store_category_id
|
1272 |
)";
|
1273 |
$this->db_do($q);
|
1274 |
+
//STP
|
1275 |
+
$q = "
|
1276 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
1277 |
+
(
|
1278 |
+
entity_type_id,
|
1279 |
+
attribute_id,
|
1280 |
+
store_id,
|
1281 |
+
entity_id,
|
1282 |
+
value
|
1283 |
+
)
|
1284 |
+
(SELECT
|
1285 |
+
$this->_categoryEntityTypeId,
|
1286 |
+
$this->_categoryMetaTitleAttrId,
|
1287 |
+
0,
|
1288 |
+
scm.shop_entity_id,
|
1289 |
+
c.MetaTitle
|
1290 |
+
FROM $categories_temp c
|
1291 |
+
JOIN $stINch_categories_mapping scm
|
1292 |
+
ON c.store_category_id = scm.store_category_id
|
1293 |
+
)
|
1294 |
+
";
|
1295 |
+
$this->db_do($q);
|
1296 |
+
|
1297 |
+
$q = "
|
1298 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
1299 |
+
(
|
1300 |
+
entity_type_id,
|
1301 |
+
attribute_id,
|
1302 |
+
store_id,
|
1303 |
+
entity_id,
|
1304 |
+
value
|
1305 |
+
)
|
1306 |
+
(SELECT
|
1307 |
+
$this->_categoryEntityTypeId,
|
1308 |
+
$this->_categoryMetadescriptionAttrId,
|
1309 |
+
0,
|
1310 |
+
scm.shop_entity_id,
|
1311 |
+
c.MetaDescription
|
1312 |
+
FROM $categories_temp c
|
1313 |
+
JOIN $stINch_categories_mapping scm
|
1314 |
+
ON c.store_category_id = scm.store_category_id
|
1315 |
+
)
|
1316 |
+
";
|
1317 |
+
$this->db_do($q);
|
1318 |
+
|
1319 |
+
$q = "
|
1320 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
1321 |
+
(
|
1322 |
+
entity_type_id,
|
1323 |
+
attribute_id,
|
1324 |
+
store_id,
|
1325 |
+
entity_id,
|
1326 |
+
value
|
1327 |
+
)
|
1328 |
+
(SELECT
|
1329 |
+
$this->_categoryEntityTypeId,
|
1330 |
+
$this->_categoryDescriptionAttrId,
|
1331 |
+
0,
|
1332 |
+
scm.shop_entity_id,
|
1333 |
+
c.Description
|
1334 |
+
FROM $categories_temp c
|
1335 |
+
JOIN $stINch_categories_mapping scm
|
1336 |
+
ON c.store_category_id = scm.store_category_id
|
1337 |
+
)
|
1338 |
+
";
|
1339 |
+
$this->db_do($q);
|
1340 |
+
|
1341 |
+
|
1342 |
+
//stp
|
1343 |
+
|
1344 |
}
|
1345 |
|
1346 |
|
1619 |
(entity_id, entity_type_id, attribute_set_id, parent_id, created_at, updated_at,
|
1620 |
path, position, level, children_count, store_category_id, parent_store_category_id)
|
1621 |
VALUES
|
1622 |
+
($i, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/$i', 1, 1, 1, NULL, NULL)");
|
1623 |
|
1624 |
|
1625 |
$this->db_do("INSERT $catalog_category_entity_varchar
|
1653 |
|
1654 |
|
1655 |
################################################################################################################################################################
|
1656 |
+
private function calculateCategoryCoincidence($categories_temp, $catalog_category_entity, $catalog_category_entity_varchar, $im_type, $category_types)
|
1657 |
{
|
1658 |
$root_categories = $this->db_do("
|
1659 |
SELECT
|
1670 |
while($root_cat = mysql_fetch_array($root_categories)) $OLD[] = $root_cat['category_name'];
|
1671 |
|
1672 |
$new_categories = $this->db_do("SELECT DISTINCT RootName FROM $categories_temp");
|
1673 |
+
|
1674 |
+
//STP $new_categories = $this->db_do("SELECT DISTINCT ctemp.RootName, ctype.name FROM $categories_temp ctemp LEFT JOIN $category_types ctypes on ctemp.RootName = ctype.name");
|
1675 |
+
|
1676 |
$NEW = array();
|
1677 |
while($new_root_cat = mysql_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['RootName']] = TRUE;
|
1678 |
+
/////STP while($new_root_cat = mysql_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['name']] = TRUE;
|
1679 |
/**
|
1680 |
$exists_coincidence = array();
|
1681 |
|
1804 |
(entity_id, entity_type_id, attribute_set_id, parent_id, created_at, updated_at,
|
1805 |
path, position, level, children_count, store_category_id, parent_store_category_id)
|
1806 |
VALUES
|
1807 |
+
($i, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/$i', 1, 1, 1, NULL, NULL)");
|
1808 |
|
1809 |
|
1810 |
$this->db_do("INSERT $catalog_category_entity_varchar
|
2165 |
$attr_include_in_menu,
|
2166 |
0,
|
2167 |
scm.shop_entity_id,
|
2168 |
+
c.include_in_menu
|
2169 |
FROM $categories_temp c
|
2170 |
JOIN $stINch_categories_mapping scm
|
2171 |
ON c.store_category_id = scm.store_category_id
|
2172 |
)
|
2173 |
ON DUPLICATE KEY UPDATE
|
2174 |
+
value = c.include_in_menu";
|
2175 |
$this->db_do($q);
|
2176 |
|
2177 |
|
2189 |
$is_anchor_attrid,
|
2190 |
1,
|
2191 |
scm.shop_entity_id,
|
2192 |
+
c.is_anchor
|
2193 |
FROM $categories_temp c
|
2194 |
JOIN $stINch_categories_mapping scm
|
2195 |
ON c.store_category_id = scm.store_category_id
|
2196 |
)
|
2197 |
ON DUPLICATE KEY UPDATE
|
2198 |
+
value = c.is_anchor";
|
2199 |
$this->db_do($q);
|
2200 |
|
2201 |
|
2213 |
$is_anchor_attrid,
|
2214 |
0,
|
2215 |
scm.shop_entity_id,
|
2216 |
+
c.is_anchor
|
2217 |
FROM $categories_temp c
|
2218 |
JOIN $stINch_categories_mapping scm
|
2219 |
ON c.store_category_id = scm.store_category_id
|
2220 |
)
|
2221 |
ON DUPLICATE KEY UPDATE
|
2222 |
+
value = c.is_anchor";
|
2223 |
$this->db_do($q);
|
2224 |
|
2225 |
$q = "
|
2244 |
ON DUPLICATE KEY UPDATE
|
2245 |
value = c.categories_image";
|
2246 |
$this->db_do($q);
|
2247 |
+
//STP
|
2248 |
+
$q = "
|
2249 |
+
INSERT INTO $catalog_category_entity_varchar
|
2250 |
+
(
|
2251 |
+
entity_type_id,
|
2252 |
+
attribute_id,
|
2253 |
+
store_id,
|
2254 |
+
entity_id,
|
2255 |
+
value
|
2256 |
+
)
|
2257 |
+
(SELECT
|
2258 |
+
$this->_categoryEntityTypeId,
|
2259 |
+
$this->_categoryMetaTitleAttrId,
|
2260 |
+
0,
|
2261 |
+
scm.shop_entity_id,
|
2262 |
+
c.MetaTitle
|
2263 |
+
FROM $categories_temp c
|
2264 |
+
JOIN $stINch_categories_mapping scm
|
2265 |
+
ON c.store_category_id = scm.store_category_id
|
2266 |
+
)
|
2267 |
+
ON DUPLICATE KEY UPDATE
|
2268 |
+
value = c.MetaTitle";
|
2269 |
+
$this->db_do($q);
|
2270 |
+
|
2271 |
+
$q = "
|
2272 |
+
INSERT INTO $catalog_category_entity_varchar
|
2273 |
+
(
|
2274 |
+
entity_type_id,
|
2275 |
+
attribute_id,
|
2276 |
+
store_id,
|
2277 |
+
entity_id,
|
2278 |
+
value
|
2279 |
+
)
|
2280 |
+
(SELECT
|
2281 |
+
$this->_categoryEntityTypeId,
|
2282 |
+
$this->_categoryMetadescriptionAttrId,
|
2283 |
+
0,
|
2284 |
+
scm.shop_entity_id,
|
2285 |
+
c.MetaDescription
|
2286 |
+
FROM $categories_temp c
|
2287 |
+
JOIN $stINch_categories_mapping scm
|
2288 |
+
ON c.store_category_id = scm.store_category_id
|
2289 |
+
)
|
2290 |
+
ON DUPLICATE KEY UPDATE
|
2291 |
+
value = c.MetaDescription";
|
2292 |
+
$this->db_do($q);
|
2293 |
+
|
2294 |
+
$q = "
|
2295 |
+
INSERT INTO $catalog_category_entity_varchar
|
2296 |
+
(
|
2297 |
+
entity_type_id,
|
2298 |
+
attribute_id,
|
2299 |
+
store_id,
|
2300 |
+
entity_id,
|
2301 |
+
value
|
2302 |
+
)
|
2303 |
+
(SELECT
|
2304 |
+
$this->_categoryEntityTypeId,
|
2305 |
+
$this->_categoryDescriptionAttrId,
|
2306 |
+
0,
|
2307 |
+
scm.shop_entity_id,
|
2308 |
+
c.Description
|
2309 |
+
FROM $categories_temp c
|
2310 |
+
JOIN $stINch_categories_mapping scm
|
2311 |
+
ON c.store_category_id = scm.store_category_id
|
2312 |
+
)
|
2313 |
+
ON DUPLICATE KEY UPDATE
|
2314 |
+
value = c.Description";
|
2315 |
+
$this->db_do($q);
|
2316 |
+
|
2317 |
+
|
2318 |
+
//stp
|
2319 |
}
|
2320 |
else
|
2321 |
{
|
2379 |
$attr_include_in_menu,
|
2380 |
0,
|
2381 |
scm.shop_entity_id,
|
2382 |
+
c.include_in_menu
|
2383 |
FROM $categories_temp c
|
2384 |
JOIN $stINch_categories_mapping scm
|
2385 |
ON c.store_category_id = scm.store_category_id
|
2401 |
$is_anchor_attrid,
|
2402 |
0,
|
2403 |
scm.shop_entity_id,
|
2404 |
+
c.is_anchor
|
2405 |
FROM $categories_temp c
|
2406 |
JOIN $stINch_categories_mapping scm
|
2407 |
ON c.store_category_id = scm.store_category_id
|
2429 |
ON c.store_category_id = scm.store_category_id
|
2430 |
)";
|
2431 |
$this->db_do($q);
|
2432 |
+
//STP
|
2433 |
+
$q = "
|
2434 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
2435 |
+
(
|
2436 |
+
entity_type_id,
|
2437 |
+
attribute_id,
|
2438 |
+
store_id,
|
2439 |
+
entity_id,
|
2440 |
+
value
|
2441 |
+
)
|
2442 |
+
(SELECT
|
2443 |
+
$this->_categoryEntityTypeId,
|
2444 |
+
$this->_categoryMetaTitleAttrId,
|
2445 |
+
0,
|
2446 |
+
scm.shop_entity_id,
|
2447 |
+
c.MetaTitle
|
2448 |
+
FROM $categories_temp c
|
2449 |
+
JOIN $stINch_categories_mapping scm
|
2450 |
+
ON c.store_category_id = scm.store_category_id
|
2451 |
+
)
|
2452 |
+
";
|
2453 |
+
$this->db_do($q);
|
2454 |
+
|
2455 |
+
$q = "
|
2456 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
2457 |
+
(
|
2458 |
+
entity_type_id,
|
2459 |
+
attribute_id,
|
2460 |
+
store_id,
|
2461 |
+
entity_id,
|
2462 |
+
value
|
2463 |
+
)
|
2464 |
+
(SELECT
|
2465 |
+
$this->_categoryEntityTypeId,
|
2466 |
+
$this->_categoryMetadescriptionAttrId,
|
2467 |
+
0,
|
2468 |
+
scm.shop_entity_id,
|
2469 |
+
c.MetaDescription
|
2470 |
+
FROM $categories_temp c
|
2471 |
+
JOIN $stINch_categories_mapping scm
|
2472 |
+
ON c.store_category_id = scm.store_category_id
|
2473 |
+
)
|
2474 |
+
";
|
2475 |
+
$this->db_do($q);
|
2476 |
+
|
2477 |
+
$q = "
|
2478 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
2479 |
+
(
|
2480 |
+
entity_type_id,
|
2481 |
+
attribute_id,
|
2482 |
+
store_id,
|
2483 |
+
entity_id,
|
2484 |
+
value
|
2485 |
+
)
|
2486 |
+
(SELECT
|
2487 |
+
$this->_categoryEntityTypeId,
|
2488 |
+
$this->_categoryDescriptionAttrId,
|
2489 |
+
0,
|
2490 |
+
scm.shop_entity_id,
|
2491 |
+
c.Description
|
2492 |
+
FROM $categories_temp c
|
2493 |
+
JOIN $stINch_categories_mapping scm
|
2494 |
+
ON c.store_category_id = scm.store_category_id
|
2495 |
+
)
|
2496 |
+
";
|
2497 |
+
$this->db_do($q);
|
2498 |
+
|
2499 |
+
|
2500 |
+
//stp
|
2501 |
+
|
2502 |
}
|
2503 |
|
2504 |
$this->delete_old_sinch_categories_from_shop();
|
2583 |
$core_store = Mage::getSingleton('core/resource')->getTableName('core_store');
|
2584 |
$catalog_product_enabled_index = Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index');
|
2585 |
$catalog_product_website = Mage::getSingleton('core/resource')->getTableName('catalog_product_website');
|
2586 |
+
//STP DELETE $catalogsearch_fulltext = Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext');
|
2587 |
+
// $catalogsearch_query = Mage::getSingleton('core/resource')->getTableName('catalogsearch_query');
|
2588 |
$catalog_category_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar');
|
2589 |
|
2590 |
$_getProductEntityTypeId = $this->_getProductEntityTypeId();
|
2890 |
|
2891 |
|
2892 |
|
2893 |
+
echo("\n replaceMagentoProductsMultistoreMERGE 15.1 (add multi categories)\n");
|
2894 |
+
|
2895 |
+
|
2896 |
+
|
2897 |
+
|
2898 |
+
$result = $this->db_do("
|
2899 |
+
INSERT INTO $catalog_category_product
|
2900 |
+
(category_id, product_id)
|
2901 |
+
(SELECT
|
2902 |
+
scm.shop_entity_id,
|
2903 |
+
cpe.entity_id
|
2904 |
+
FROM $catalog_product_entity cpe
|
2905 |
+
JOIN $products_temp p
|
2906 |
+
ON cpe.store_product_id = p.store_product_id
|
2907 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_categories')." spc
|
2908 |
+
ON p.store_product_id=spc.store_product_id
|
2909 |
+
JOIN $stINch_categories_mapping scm
|
2910 |
+
ON spc.store_category_id = scm.store_category_id
|
2911 |
+
)
|
2912 |
+
ON DUPLICATE KEY UPDATE
|
2913 |
+
product_id = cpe.entity_id
|
2914 |
+
");
|
2915 |
+
|
2916 |
+
|
2917 |
+
|
2918 |
echo("\n replaceMagentoProductsMultistoreMERGE 16\n");
|
2919 |
|
2920 |
//Indexing products and categories in the shop
|
3029 |
|
3030 |
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
3031 |
$this->addDescriptions();
|
3032 |
+
if($this->product_file_format == "NEW"){
|
3033 |
+
$this->addReviews();
|
3034 |
+
$this->addWeight();
|
3035 |
+
$this->addSearchCache();
|
3036 |
+
$this->addPdfUrl();
|
3037 |
+
$this->addShortDescriptions();
|
3038 |
+
}
|
3039 |
$this->addEAN();
|
3040 |
$this->addSpecification();
|
3041 |
$this->addManufacturers();
|
3340 |
|
3341 |
|
3342 |
|
3343 |
+
/* STP DELETE
|
3344 |
//Refresh fulltext search
|
3345 |
$result = $this->db_do("DROP TABLE IF EXISTS {$catalogsearch_fulltext}_tmp");
|
3346 |
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS {$catalogsearch_fulltext}_tmp LIKE $catalogsearch_fulltext");
|
3368 |
LEFT JOIN $catalog_product_website j
|
3369 |
ON a.entity_id = j.product_id
|
3370 |
LEFT JOIN $products_temp f
|
3371 |
+
ON a.store_product_id = f.store_product_id
|
3372 |
)
|
3373 |
ON DUPLICATE KEY UPDATE
|
3374 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)";
|
3396 |
LEFT JOIN $catalog_product_website j
|
3397 |
ON a.entity_id = j.product_id
|
3398 |
LEFT JOIN $products_temp f
|
3399 |
+
ON a.store_product_id = f.store_product_id
|
3400 |
)
|
3401 |
ON DUPLICATE KEY UPDATE
|
3402 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
3423 |
ON a.entity_id = e.entity_id
|
3424 |
AND e.attribute_id = $attr_name
|
3425 |
LEFT JOIN $products_temp f
|
3426 |
+
ON a.store_product_id = f.store_product_id
|
3427 |
)
|
3428 |
ON DUPLICATE KEY UPDATE
|
3429 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
3447 |
a.store_id,
|
3448 |
a.data_index
|
3449 |
FROM {$catalogsearch_fulltext}_tmp a
|
|
|
3450 |
)
|
3451 |
ON DUPLICATE KEY UPDATE
|
3452 |
data_index = a.data_index");
|
3456 |
$this->db_do("UPDATE $catalogsearch_query SET is_processed = 0");
|
3457 |
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
3458 |
//TODO add something else
|
3459 |
+
STP DELETE*/
|
3460 |
|
3461 |
$this->addRelatedProducts();
|
3462 |
echo("\n replaceMagentoProductsMultistoreMERGE 41\n");
|
3514 |
$core_store = Mage::getSingleton('core/resource')->getTableName('core_store');
|
3515 |
$catalog_product_enabled_index = Mage::getSingleton('core/resource')->getTableName('catalog_product_enabled_index');
|
3516 |
$catalog_product_website = Mage::getSingleton('core/resource')->getTableName('catalog_product_website');
|
3517 |
+
//STP DELETE $catalogsearch_fulltext = Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext');
|
3518 |
+
// $catalogsearch_query = Mage::getSingleton('core/resource')->getTableName('catalogsearch_query');
|
3519 |
$catalog_category_entity_varchar = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity_varchar');
|
3520 |
|
3521 |
$_getProductEntityTypeId = $this->_getProductEntityTypeId();
|
3710 |
echo("\n replaceMagentoProductsMultistore 10\n");
|
3711 |
|
3712 |
|
3713 |
+
$catalog_category_product_for_delete_temp = $catalog_category_product."_for_delete_temp";
|
3714 |
|
3715 |
// TEMPORARY
|
3716 |
$this->db_do(" DROP TABLE IF EXISTS $catalog_category_product_for_delete_temp");
|
3797 |
product_id = cpe.entity_id");
|
3798 |
|
3799 |
|
3800 |
+
echo("\n replaceMagentoProductsMultistore 15.1 (add multi categories)\n");
|
3801 |
+
|
3802 |
+
$result = $this->db_do("
|
3803 |
+
INSERT INTO $catalog_category_product
|
3804 |
+
(category_id, product_id)
|
3805 |
+
(SELECT
|
3806 |
+
scm.shop_entity_id,
|
3807 |
+
cpe.entity_id
|
3808 |
+
FROM $catalog_product_entity cpe
|
3809 |
+
JOIN $products_temp p
|
3810 |
+
ON cpe.store_product_id = p.store_product_id
|
3811 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_categories')." spc
|
3812 |
+
ON p.store_product_id=spc.store_product_id
|
3813 |
+
JOIN $stINch_categories_mapping scm
|
3814 |
+
ON spc.store_category_id = scm.store_category_id
|
3815 |
+
)
|
3816 |
+
ON DUPLICATE KEY UPDATE
|
3817 |
+
product_id = cpe.entity_id
|
3818 |
+
");
|
3819 |
+
|
3820 |
+
|
3821 |
+
|
3822 |
|
3823 |
echo("\n replaceMagentoProductsMultistore 16\n");
|
3824 |
|
3867 |
b.store_id,
|
3868 |
4
|
3869 |
FROM $catalog_category_product a
|
3870 |
+
JOIN $root_cats rc
|
3871 |
ON a.category_id = rc.entity_id
|
3872 |
JOIN $core_store b
|
3873 |
)
|
3929 |
|
3930 |
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
3931 |
$this->addDescriptions();
|
3932 |
+
if($this->product_file_format == "NEW"){
|
3933 |
+
$this->addReviews();
|
3934 |
+
$this->addWeight();
|
3935 |
+
$this->addSearchCache();
|
3936 |
+
$this->addPdfUrl();
|
3937 |
+
$this->addShortDescriptions();
|
3938 |
+
}
|
3939 |
$this->addEAN();
|
3940 |
$this->addSpecification();
|
3941 |
$this->addManufacturers();
|
4219 |
|
4220 |
|
4221 |
|
4222 |
+
/*STP DELETE
|
4223 |
//Refresh fulltext search
|
4224 |
$result = $this->db_do("DROP TABLE IF EXISTS {$catalogsearch_fulltext}_tmp");
|
4225 |
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS {$catalogsearch_fulltext}_tmp LIKE $catalogsearch_fulltext");
|
4247 |
LEFT JOIN $catalog_product_website j
|
4248 |
ON a.entity_id = j.product_id
|
4249 |
LEFT JOIN $products_temp f
|
4250 |
+
ON a.store_product_id = f.store_product_id
|
4251 |
)
|
4252 |
ON DUPLICATE KEY UPDATE
|
4253 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)";
|
4275 |
LEFT JOIN $catalog_product_website j
|
4276 |
ON a.entity_id = j.product_id
|
4277 |
LEFT JOIN $products_temp f
|
4278 |
+
ON a.store_product_id = f.store_product_id
|
4279 |
)
|
4280 |
ON DUPLICATE KEY UPDATE
|
4281 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
4302 |
ON a.entity_id = e.entity_id
|
4303 |
AND e.attribute_id = $attr_name
|
4304 |
LEFT JOIN $products_temp f
|
4305 |
+
ON a.store_product_id = f.store_product_id
|
4306 |
)
|
4307 |
ON DUPLICATE KEY UPDATE
|
4308 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)");
|
4326 |
a.store_id,
|
4327 |
a.data_index
|
4328 |
FROM {$catalogsearch_fulltext}_tmp a
|
|
|
4329 |
)
|
4330 |
ON DUPLICATE KEY UPDATE
|
4331 |
data_index = a.data_index");
|
4335 |
$this->db_do("UPDATE $catalogsearch_query SET is_processed = 0");
|
4336 |
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
4337 |
//TODO add something else
|
4338 |
+
STP DELETE*/
|
4339 |
|
4340 |
$this->addRelatedProducts();
|
4341 |
echo("\n replaceMagentoProductsMultistore 41\n");
|
4456 |
)
|
4457 |
VALUES
|
4458 |
(1, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 0, '0000-00-00 00:00:00', now(), '1', 0, 0, 1, null, null),
|
4459 |
+
(2, $_categoryEntityTypeId, $_categoryDefault_attribute_set_id, 1, now(), now(), '1/2', 1, 1, 1, null, null)");
|
4460 |
|
4461 |
$this->db_do("TRUNCATE $catalog_category_entity_varchar");
|
4462 |
$this->db_do("
|
4851 |
$attr_include_in_menu,
|
4852 |
0,
|
4853 |
scm.shop_entity_id,
|
4854 |
+
c.include_in_menu
|
4855 |
FROM $categories_temp c
|
4856 |
JOIN $stINch_categories_mapping scm
|
4857 |
ON c.store_category_id = scm.store_category_id
|
4858 |
)
|
4859 |
ON DUPLICATE KEY UPDATE
|
4860 |
+
value = c.include_in_menu";
|
4861 |
$this->db_do($q);
|
4862 |
|
4863 |
$q = "
|
4874 |
$is_anchor_attrid,
|
4875 |
1,
|
4876 |
scm.shop_entity_id,
|
4877 |
+
c.is_anchor
|
4878 |
FROM $categories_temp c
|
4879 |
JOIN $stINch_categories_mapping scm
|
4880 |
ON c.store_category_id = scm.store_category_id
|
4881 |
)
|
4882 |
ON DUPLICATE KEY UPDATE
|
4883 |
+
value = c.is_anchor";
|
4884 |
$this->db_do($q);
|
4885 |
|
4886 |
$q = "
|
4897 |
$is_anchor_attrid,
|
4898 |
0,
|
4899 |
scm.shop_entity_id,
|
4900 |
+
c.is_anchor
|
4901 |
FROM $categories_temp c
|
4902 |
JOIN $stINch_categories_mapping scm
|
4903 |
ON c.store_category_id = scm.store_category_id
|
4904 |
)
|
4905 |
ON DUPLICATE KEY UPDATE
|
4906 |
+
value = c.is_anchor";
|
4907 |
$this->db_do($q);
|
4908 |
|
4909 |
$q = "
|
4928 |
ON DUPLICATE KEY UPDATE
|
4929 |
value = c.categories_image";
|
4930 |
$this->db_do($q);
|
4931 |
+
//STP
|
4932 |
+
$q = "
|
4933 |
+
INSERT INTO $catalog_category_entity_varchar
|
4934 |
+
(
|
4935 |
+
entity_type_id,
|
4936 |
+
attribute_id,
|
4937 |
+
store_id,
|
4938 |
+
entity_id,
|
4939 |
+
value
|
4940 |
+
)
|
4941 |
+
(SELECT
|
4942 |
+
$this->_categoryEntityTypeId,
|
4943 |
+
$this->_categoryMetaTitleAttrId,
|
4944 |
+
0,
|
4945 |
+
scm.shop_entity_id,
|
4946 |
+
c.MetaTitle
|
4947 |
+
FROM $categories_temp c
|
4948 |
+
JOIN $stINch_categories_mapping scm
|
4949 |
+
ON c.store_category_id = scm.store_category_id
|
4950 |
+
)
|
4951 |
+
ON DUPLICATE KEY UPDATE
|
4952 |
+
value = c.MetaTitle";
|
4953 |
+
$this->db_do($q);
|
4954 |
+
|
4955 |
+
$q = "
|
4956 |
+
INSERT INTO $catalog_category_entity_varchar
|
4957 |
+
(
|
4958 |
+
entity_type_id,
|
4959 |
+
attribute_id,
|
4960 |
+
store_id,
|
4961 |
+
entity_id,
|
4962 |
+
value
|
4963 |
+
)
|
4964 |
+
(SELECT
|
4965 |
+
$this->_categoryEntityTypeId,
|
4966 |
+
$this->_categoryMetadescriptionAttrId,
|
4967 |
+
0,
|
4968 |
+
scm.shop_entity_id,
|
4969 |
+
c.MetaDescription
|
4970 |
+
FROM $categories_temp c
|
4971 |
+
JOIN $stINch_categories_mapping scm
|
4972 |
+
ON c.store_category_id = scm.store_category_id
|
4973 |
+
)
|
4974 |
+
ON DUPLICATE KEY UPDATE
|
4975 |
+
value = c.MetaDescription";
|
4976 |
+
$this->db_do($q);
|
4977 |
+
|
4978 |
+
$q = "
|
4979 |
+
INSERT INTO $catalog_category_entity_varchar
|
4980 |
+
(
|
4981 |
+
entity_type_id,
|
4982 |
+
attribute_id,
|
4983 |
+
store_id,
|
4984 |
+
entity_id,
|
4985 |
+
value
|
4986 |
+
)
|
4987 |
+
(SELECT
|
4988 |
+
$this->_categoryEntityTypeId,
|
4989 |
+
$this->_categoryDescriptionAttrId,
|
4990 |
+
0,
|
4991 |
+
scm.shop_entity_id,
|
4992 |
+
c.Description
|
4993 |
+
FROM $categories_temp c
|
4994 |
+
JOIN $stINch_categories_mapping scm
|
4995 |
+
ON c.store_category_id = scm.store_category_id
|
4996 |
+
)
|
4997 |
+
ON DUPLICATE KEY UPDATE
|
4998 |
+
value = c.Description";
|
4999 |
+
$this->db_do($q);
|
5000 |
+
|
5001 |
+
|
5002 |
+
//stp
|
5003 |
}
|
5004 |
else
|
5005 |
{
|
5061 |
$attr_include_in_menu,
|
5062 |
0,
|
5063 |
scm.shop_entity_id,
|
5064 |
+
c.include_in_menu
|
5065 |
FROM $categories_temp c
|
5066 |
JOIN $stINch_categories_mapping scm
|
5067 |
ON c.store_category_id = scm.store_category_id
|
5082 |
$is_anchor_attrid,
|
5083 |
0,
|
5084 |
scm.shop_entity_id,
|
5085 |
+
c.is_anchor
|
5086 |
FROM $categories_temp c
|
5087 |
JOIN $stINch_categories_mapping scm
|
5088 |
ON c.store_category_id = scm.store_category_id
|
5109 |
ON c.store_category_id = scm.store_category_id
|
5110 |
)";
|
5111 |
$this->db_do($q);
|
5112 |
+
//STP
|
5113 |
+
$q = "
|
5114 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
5115 |
+
(
|
5116 |
+
entity_type_id,
|
5117 |
+
attribute_id,
|
5118 |
+
store_id,
|
5119 |
+
entity_id,
|
5120 |
+
value
|
5121 |
+
)
|
5122 |
+
(SELECT
|
5123 |
+
$this->_categoryEntityTypeId,
|
5124 |
+
$this->_categoryMetaTitleAttrId,
|
5125 |
+
0,
|
5126 |
+
scm.shop_entity_id,
|
5127 |
+
c.MetaTitle
|
5128 |
+
FROM $categories_temp c
|
5129 |
+
JOIN $stINch_categories_mapping scm
|
5130 |
+
ON c.store_category_id = scm.store_category_id
|
5131 |
+
)
|
5132 |
+
";
|
5133 |
+
$this->db_do($q);
|
5134 |
+
|
5135 |
+
$q = "
|
5136 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
5137 |
+
(
|
5138 |
+
entity_type_id,
|
5139 |
+
attribute_id,
|
5140 |
+
store_id,
|
5141 |
+
entity_id,
|
5142 |
+
value
|
5143 |
+
)
|
5144 |
+
(SELECT
|
5145 |
+
$this->_categoryEntityTypeId,
|
5146 |
+
$this->_categoryMetadescriptionAttrId,
|
5147 |
+
0,
|
5148 |
+
scm.shop_entity_id,
|
5149 |
+
c.MetaDescription
|
5150 |
+
FROM $categories_temp c
|
5151 |
+
JOIN $stINch_categories_mapping scm
|
5152 |
+
ON c.store_category_id = scm.store_category_id
|
5153 |
+
)
|
5154 |
+
";
|
5155 |
+
$this->db_do($q);
|
5156 |
+
|
5157 |
+
$q = "
|
5158 |
+
INSERT IGNORE INTO $catalog_category_entity_varchar
|
5159 |
+
(
|
5160 |
+
entity_type_id,
|
5161 |
+
attribute_id,
|
5162 |
+
store_id,
|
5163 |
+
entity_id,
|
5164 |
+
value
|
5165 |
+
)
|
5166 |
+
(SELECT
|
5167 |
+
$this->_categoryEntityTypeId,
|
5168 |
+
$this->_categoryDescriptionAttrId,
|
5169 |
+
0,
|
5170 |
+
scm.shop_entity_id,
|
5171 |
+
c.Description
|
5172 |
+
FROM $categories_temp c
|
5173 |
+
JOIN $stINch_categories_mapping scm
|
5174 |
+
ON c.store_category_id = scm.store_category_id
|
5175 |
+
)
|
5176 |
+
";
|
5177 |
+
$this->db_do($q);
|
5178 |
+
|
5179 |
+
|
5180 |
+
//stp
|
5181 |
+
|
5182 |
}
|
5183 |
|
5184 |
$this->delete_old_sinch_categories_from_shop();
|
5273 |
$this->_LOG(' ');
|
5274 |
}
|
5275 |
|
5276 |
+
#################################################################################################
|
5277 |
+
|
5278 |
+
function ParseDistributorsStockAndPrice(){
|
5279 |
+
$parse_file=$this->varDir.FILE_DISTRIBUTORS_STOCK_AND_PRICES;
|
5280 |
+
if(filesize($parse_file)){
|
5281 |
+
$this->_LOG("Start parse ".FILE_DISTRIBUTORS_STOCK_AND_PRICES);
|
5282 |
+
|
5283 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('distributors_stock_and_price_temp'));
|
5284 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('distributors_stock_and_price_temp')."(
|
5285 |
+
`store_product_id` int(11) DEFAULT NULL,
|
5286 |
+
`distributor_id` int(11) DEFAULT NULL,
|
5287 |
+
`stock` int(11) DEFAULT NULL,
|
5288 |
+
`cost` decimal(15,4) DEFAULT NULL,
|
5289 |
+
`distributor_sku` varchar(255) DEFAULT NULL,
|
5290 |
+
`distributor_category` varchar(50) DEFAULT NULL,
|
5291 |
+
`eta` varchar(50) DEFAULT NULL,
|
5292 |
+
UNIQUE KEY `product_distri` (store_product_id, distributor_id)
|
5293 |
+
)");
|
5294 |
+
|
5295 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
5296 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('distributors_stock_and_price_temp')."
|
5297 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
5298 |
+
OPTIONALLY ENCLOSED BY '\"'
|
5299 |
+
LINES TERMINATED BY \"\r\n\"
|
5300 |
+
IGNORE 1 LINES ");
|
5301 |
+
|
5302 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price'));
|
5303 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('distributors_stock_and_price_temp')."
|
5304 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price'));
|
5305 |
+
|
5306 |
+
$this->_LOG("Finish parse ".FILE_DISTRIBUTORS_STOCK_AND_PRICES);
|
5307 |
+
}else{
|
5308 |
+
$this->_LOG("Wrong file ".$parse_file);
|
5309 |
+
}
|
5310 |
+
$this->_LOG(' ');
|
5311 |
+
|
5312 |
+
}
|
5313 |
+
|
5314 |
+
|
5315 |
#################################################################################################
|
5316 |
|
5317 |
function ParseEANCodes(){
|
5477 |
}
|
5478 |
$this->_LOG(" ");
|
5479 |
}
|
5480 |
+
#################################################################################################
|
5481 |
+
|
5482 |
+
function ParseCategoryTypes(){
|
5483 |
+
$parse_file=$this->varDir.FILE_CATEGORY_TYPES;
|
5484 |
+
if(filesize($parse_file)){
|
5485 |
+
$this->_LOG("Start parse ".FILE_CATEGORY_TYPES);
|
5486 |
+
|
5487 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('category_types_temp'));
|
5488 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('category_types_temp')."(
|
5489 |
+
id int(11),
|
5490 |
+
name varchar(255),
|
5491 |
+
key(id)
|
5492 |
+
)");
|
5493 |
+
|
5494 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
5495 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('category_types_temp')."
|
5496 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
5497 |
+
OPTIONALLY ENCLOSED BY '\"'
|
5498 |
+
LINES TERMINATED BY \"\r\n\"
|
5499 |
+
IGNORE 1 LINES ");
|
5500 |
+
|
5501 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_category_types'));
|
5502 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('category_types_temp')."
|
5503 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_category_types'));
|
5504 |
+
|
5505 |
+
$this->_LOG("Finish parse ".FILE_CATEGORY_TYPES);
|
5506 |
+
}else{
|
5507 |
+
$this->_LOG("Wrong file ".$parse_file);
|
5508 |
+
}
|
5509 |
+
$this->_LOG(' ');
|
5510 |
+
|
5511 |
+
}
|
5512 |
+
|
5513 |
+
#################################################################################################
|
5514 |
+
|
5515 |
+
function ParseProductCategories(){
|
5516 |
+
$parse_file=$this->varDir.FILE_PRODUCT_CATEGORIES;
|
5517 |
+
if(filesize($parse_file)){
|
5518 |
+
$this->_LOG("Start parse ".FILE_PRODUCT_CATEGORIES);
|
5519 |
+
|
5520 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('product_categories_temp'));
|
5521 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('product_categories_temp')."(
|
5522 |
+
store_product_id int(11),
|
5523 |
+
store_category_id int(11),
|
5524 |
+
key(store_product_id),
|
5525 |
+
key(store_category_id)
|
5526 |
+
)");
|
5527 |
+
|
5528 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
5529 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('product_categories_temp')."
|
5530 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
5531 |
+
OPTIONALLY ENCLOSED BY '\"'
|
5532 |
+
LINES TERMINATED BY \"\r\n\"
|
5533 |
+
IGNORE 1 LINES ");
|
5534 |
+
|
5535 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_product_categories'));
|
5536 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('product_categories_temp')."
|
5537 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_product_categories'));
|
5538 |
|
5539 |
+
$this->_LOG("Finish parse ".FILE_PRODUCT_CATEGORIES);
|
5540 |
+
}else{
|
5541 |
+
$this->_LOG("Wrong file ".$parse_file);
|
5542 |
+
}
|
5543 |
+
$this->_LOG(' ');
|
5544 |
+
|
5545 |
+
}
|
5546 |
#################################################################################################
|
5547 |
|
5548 |
function ParseProducts($coincidence){
|
5549 |
echo("\nParseProducts 2\n");
|
5550 |
+
$dataConf = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
|
5551 |
+
$replace_merge_product = $dataConf['replace_products'];
|
5552 |
+
|
5553 |
$parse_file=$this->varDir.FILE_PRODUCTS;
|
5554 |
if(filesize($parse_file)){
|
5555 |
$this->_LOG("Start parse ".FILE_PRODUCTS);
|
5568 |
|
5569 |
// $prod_file_str = file_get_contents($parse_file);
|
5570 |
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
|
5571 |
+
if($this->product_file_format == "NEW"){
|
5572 |
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."(
|
|
|
5573 |
store_product_id int(11),
|
|
|
5574 |
product_sku varchar(255),
|
5575 |
product_name varchar(255),
|
5576 |
sinch_manufacturer_id int(11),
|
|
|
5577 |
main_image_url varchar(255),
|
5578 |
thumb_image_url varchar(255),
|
5579 |
specifications text,
|
5580 |
description text,
|
5581 |
search_cache text,
|
|
|
5582 |
description_type varchar(50),
|
5583 |
medium_image_url varchar(255),
|
5584 |
+
Title varchar(255),
|
5585 |
+
Weight decimal(15,4),
|
5586 |
+
Family varchar(255),
|
5587 |
+
Reviews varchar(255),
|
5588 |
+
pdf_url varchar(255),
|
5589 |
+
product_short_description varchar(255),
|
5590 |
products_date_added datetime default NULL,
|
5591 |
products_last_modified datetime default NULL,
|
5592 |
availability_id_in_stock int(11) default '1',
|
5597 |
products_viewed int(5) default '0',
|
5598 |
products_seo_url varchar(100) NOT NULL,
|
5599 |
manufacturer_name varchar(255) default NULL,
|
|
|
5600 |
KEY(store_product_id),
|
5601 |
+
KEY(sinch_manufacturer_id)
|
|
|
5602 |
)DEFAULT CHARSET=utf8
|
5603 |
");
|
5604 |
+
}elseif($this->product_file_format == "OLD"){
|
5605 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."(
|
5606 |
+
store_category_product_id int(11),
|
5607 |
+
store_product_id int(11),
|
5608 |
+
sinch_product_id int(11),
|
5609 |
+
product_sku varchar(255),
|
5610 |
+
product_name varchar(255),
|
5611 |
+
sinch_manufacturer_id int(11),
|
5612 |
+
store_category_id int(11),
|
5613 |
+
main_image_url varchar(255),
|
5614 |
+
thumb_image_url varchar(255),
|
5615 |
+
specifications text,
|
5616 |
+
description text,
|
5617 |
+
search_cache text,
|
5618 |
+
spec_characte_u_count int(11),
|
5619 |
+
description_type varchar(50),
|
5620 |
+
medium_image_url varchar(255),
|
5621 |
+
products_date_added datetime default NULL,
|
5622 |
+
products_last_modified datetime default NULL,
|
5623 |
+
availability_id_in_stock int(11) default '1',
|
5624 |
+
availability_id_out_of_stock int(11) default '2',
|
5625 |
+
products_locate varchar(30) default NULL,
|
5626 |
+
products_ordered int(11) NOT NULL default '0',
|
5627 |
+
products_url varchar(255) default NULL,
|
5628 |
+
products_viewed int(5) default '0',
|
5629 |
+
products_seo_url varchar(100) NOT NULL,
|
5630 |
+
manufacturer_name varchar(255) default NULL,
|
5631 |
+
KEY(store_category_product_id),
|
5632 |
+
KEY(store_product_id),
|
5633 |
+
KEY(sinch_manufacturer_id),
|
5634 |
+
KEY(store_category_id)
|
5635 |
+
)DEFAULT CHARSET=utf8
|
5636 |
+
");
|
5637 |
+
|
5638 |
+
}
|
5639 |
echo("\nParseProducts 3\n");
|
5640 |
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file.".conv'
|
5641 |
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
5643 |
OPTIONALLY ENCLOSED BY '\"'
|
5644 |
LINES TERMINATED BY \"\r\n\"
|
5645 |
IGNORE 1 LINES ");
|
5646 |
+
|
5647 |
+
if($this->product_file_format == "NEW"){
|
5648 |
+
$this->db_do("ALTER TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
5649 |
+
ADD COLUMN sinch_product_id int(11) AFTER store_product_id
|
5650 |
+
");
|
5651 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
5652 |
+
SET sinch_product_id=store_product_id
|
5653 |
+
");
|
5654 |
+
|
5655 |
+
$this->db_do("ALTER TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
5656 |
+
ADD COLUMN store_category_id int(11) AFTER sinch_manufacturer_id
|
5657 |
+
");
|
5658 |
+
$this->db_do("ALTER TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
5659 |
+
ADD KEY(store_category_id)
|
5660 |
+
");
|
5661 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
5662 |
+
SET product_name = Title WHERE Title != ''
|
5663 |
+
");
|
5664 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')." pt
|
5665 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_categories')." spc
|
5666 |
+
SET pt.store_category_id=spc.store_category_id
|
5667 |
+
WHERE pt.store_product_id=spc.store_product_id
|
5668 |
+
");
|
5669 |
+
//http://redmine.bintime.com/issues/4127
|
5670 |
+
//3.
|
5671 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
5672 |
+
SET main_image_url = medium_image_url WHERE main_image_url = ''
|
5673 |
+
");
|
5674 |
+
//end
|
5675 |
+
|
5676 |
+
}
|
5677 |
+
|
5678 |
echo("\nParseProducts 4\n");
|
5679 |
|
5680 |
|
5708 |
$this->mapSinchProducts();
|
5709 |
echo("\nParseProducts 9\n");
|
5710 |
|
5711 |
+
if ($replace_merge_product == "REWRITE"){
|
5712 |
+
$this->db_do ("TRUNCATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity'));
|
5713 |
+
}
|
5714 |
if (count($coincidence) == 1)
|
5715 |
{
|
5716 |
$this->replaceMagentoProducts();
|
5865 |
SET number_of_products=".$row['cnt']."
|
5866 |
WHERE id=".$this->current_import_status_statistic_id);
|
5867 |
|
|
|
|
|
5868 |
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_stock_and_prices'));
|
5869 |
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')."
|
5870 |
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_stock_and_prices'));
|
5919 |
|
5920 |
}
|
5921 |
|
5922 |
+
#################################################################################################
|
5923 |
|
5924 |
+
function ParsePriceRules(){
|
5925 |
+
$parse_file=$this->varDir.FILE_PRICE_RULES;
|
5926 |
+
if(filesize($parse_file) || $this->_ignore_price_rules){
|
5927 |
+
$this->_LOG("Start parse ".FILE_PRICE_RULES);
|
5928 |
+
|
5929 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp'));
|
5930 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')."(
|
5931 |
+
`id` int(11) NOT NULL,
|
5932 |
+
`price_from` decimal(10,2) DEFAULT NULL,
|
5933 |
+
`price_to` decimal(10,2) DEFAULT NULL,
|
5934 |
+
`category_id` int(10) unsigned DEFAULT NULL,
|
5935 |
+
`vendor_id` int(11) DEFAULT NULL,
|
5936 |
+
`vendor_product_id` varchar(255) DEFAULT NULL,
|
5937 |
+
`customergroup_id` varchar(32) DEFAULT NULL,
|
5938 |
+
`marge` decimal(10,2) DEFAULT NULL,
|
5939 |
+
`fixed` decimal(10,2) DEFAULT NULL,
|
5940 |
+
`final_price` decimal(10,2) DEFAULT NULL,
|
5941 |
+
PRIMARY KEY (`id`),
|
5942 |
+
UNIQUE KEY `price_from` (`price_from`,`price_to`,`vendor_id`,`category_id`,`vendor_product_id`,`customergroup_id`),
|
5943 |
+
KEY `vendor_product_id` (`vendor_product_id`),
|
5944 |
+
KEY `category_id` (`category_id`)
|
|
|
|
|
|
|
5945 |
)
|
5946 |
+
");
|
5947 |
+
if(!$this->_ignore_price_rules){
|
5948 |
+
|
5949 |
+
$this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
|
5950 |
+
INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')."
|
5951 |
+
FIELDS TERMINATED BY '".$this->field_terminated_char."'
|
5952 |
+
OPTIONALLY ENCLOSED BY '\"'
|
5953 |
+
LINES TERMINATED BY \"\r\n\"
|
5954 |
+
IGNORE 1 LINES
|
5955 |
+
(id, @vprice_from, @vprice_to, @vcategory_id, @vvendor_id, @vvendor_product_id, @vcustomergroup_id, @vmarge, @vfixed, @vfinal_price)
|
5956 |
+
SET price_from = nullif(@vprice_from,''),
|
5957 |
+
price_to = nullif(@vprice_to,''),
|
5958 |
+
category_id = nullif(@vcategory_id,''),
|
5959 |
+
vendor_id = nullif(@vvendor_id,''),
|
5960 |
+
vendor_product_id = nullif(@vvendor_product_id,''),
|
5961 |
+
customergroup_id = nullif(@vcustomergroup_id,''),
|
5962 |
+
marge = nullif(@vmarge,''),
|
5963 |
+
fixed = nullif(@vfixed,''),
|
5964 |
+
final_price = nullif(@vfinal_price,'')
|
5965 |
+
");
|
5966 |
+
}
|
5967 |
+
|
5968 |
+
$this->db_do("ALTER TABLE ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')."
|
5969 |
+
ADD COLUMN `shop_category_id` int(10) unsigned DEFAULT NULL,
|
5970 |
+
ADD COLUMN `shop_vendor_id` int(11) DEFAULT NULL,
|
5971 |
+
ADD COLUMN `shop_vendor_product_id` varchar(255) DEFAULT NULL,
|
5972 |
+
ADD COLUMN `shop_customergroup_id` varchar(32) DEFAULT NULL
|
5973 |
+
");
|
5974 |
+
|
5975 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')." prt
|
5976 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." cce
|
5977 |
+
ON prt.category_id = cce.store_category_id
|
5978 |
+
SET prt.shop_category_id = cce.entity_id");
|
5979 |
+
|
5980 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')." prt
|
5981 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')." sicm
|
5982 |
+
ON prt.vendor_id = sicm.sinch_manufacturer_id
|
5983 |
+
SET prt.shop_vendor_id = sicm.shop_option_id");
|
5984 |
+
|
5985 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')." prt
|
5986 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')." sicpm
|
5987 |
+
ON prt.vendor_product_id = sicpm.product_sku
|
5988 |
+
SET prt.shop_vendor_product_id = sicpm.sku");
|
5989 |
+
|
5990 |
+
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')." prt
|
5991 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('customer_group')." cg
|
5992 |
+
ON prt.customergroup_id = cg.customer_group_id
|
5993 |
+
SET prt.shop_customergroup_id = cg.customer_group_id");
|
5994 |
+
|
5995 |
+
$this->db_do("DELETE FROM ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')."
|
5996 |
+
WHERE
|
5997 |
+
(category_id IS NOT NULL AND shop_category_id IS NULL) OR
|
5998 |
+
(vendor_id IS NOT NULL AND shop_vendor_id IS NULL) OR
|
5999 |
+
(vendor_product_id IS NOT NULL AND shop_vendor_product_id IS NULL) OR
|
6000 |
+
(customergroup_id IS NOT NULL AND shop_customergroup_id IS NULL)
|
6001 |
+
");
|
6002 |
+
|
6003 |
+
|
6004 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_price_rules'));
|
6005 |
+
$this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('price_rules_temp')."
|
6006 |
+
TO ".Mage::getSingleton('core/resource')->getTableName('stINch_price_rules'));
|
6007 |
+
|
6008 |
+
$this->_LOG("Finish parse ".FILE_PRICE_RULES);
|
6009 |
+
}else{
|
6010 |
+
$this->_LOG("Wrong file ".$parse_file);
|
6011 |
+
}
|
6012 |
+
$this->_LOG(" ");
|
6013 |
+
}
|
6014 |
+
|
6015 |
+
#################################################################################################
|
6016 |
+
|
6017 |
+
function AddPriceRules(){
|
6018 |
+
if (!$this->check_table_exist('import_pricerules_standards')){
|
6019 |
+
return;
|
6020 |
+
}
|
6021 |
+
|
6022 |
+
$result = $this->db_do("
|
6023 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('import_pricerules')." (
|
6024 |
+
id,
|
6025 |
+
price_from,
|
6026 |
+
price_to,
|
6027 |
+
vendor_id,
|
6028 |
+
category_id,
|
6029 |
+
vendor_product_id,
|
6030 |
+
customergroup_id,
|
6031 |
+
marge,
|
6032 |
+
fixed,
|
6033 |
+
final_price
|
6034 |
+
)(SELECT
|
6035 |
+
id,
|
6036 |
+
price_from,
|
6037 |
+
price_to,
|
6038 |
+
shop_vendor_id,
|
6039 |
+
shop_category_id,
|
6040 |
+
shop_vendor_product_id,
|
6041 |
+
shop_customergroup_id,
|
6042 |
+
marge,
|
6043 |
+
fixed,
|
6044 |
+
final_price
|
6045 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_price_rules')." a
|
6046 |
+
)
|
6047 |
+
ON DUPLICATE KEY UPDATE
|
6048 |
+
id = a.id,
|
6049 |
+
price_from = a.price_from,
|
6050 |
+
price_to = a.price_to,
|
6051 |
+
vendor_id = a.shop_vendor_id,
|
6052 |
+
category_id = a.shop_category_id,
|
6053 |
+
vendor_product_id = a.shop_vendor_product_id,
|
6054 |
+
customergroup_id = a.shop_customergroup_id,
|
6055 |
+
marge = a.marge,
|
6056 |
+
fixed = a.fixed,
|
6057 |
+
final_price = a.final_price
|
6058 |
+
");
|
6059 |
+
|
6060 |
+
}
|
6061 |
+
|
6062 |
+
#################################################################################################
|
6063 |
+
|
6064 |
+
public function mapSinchProducts(){
|
6065 |
+
$this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp'));
|
6066 |
+
$this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp')." (
|
6067 |
+
entity_id int(11) unsigned NOT NULL,
|
6068 |
+
manufacturer_option_id int(11),
|
6069 |
+
manufacturer_name varchar(255),
|
6070 |
+
shop_store_product_id int(11),
|
6071 |
+
shop_sinch_product_id int(11),
|
6072 |
+
sku varchar(64) default NULL,
|
6073 |
+
store_product_id int(11),
|
6074 |
+
sinch_product_id int(11),
|
6075 |
+
product_sku varchar(255),
|
6076 |
+
sinch_manufacturer_id int(11),
|
6077 |
+
sinch_manufacturer_name varchar(255),
|
6078 |
+
KEY entity_id (entity_id),
|
6079 |
+
KEY manufacturer_option_id (manufacturer_option_id),
|
6080 |
+
KEY manufacturer_name (manufacturer_name),
|
6081 |
+
KEY store_product_id (store_product_id),
|
6082 |
+
KEY sinch_product_id (sinch_product_id),
|
6083 |
+
KEY sku (sku),
|
6084 |
+
UNIQUE KEY(entity_id)
|
6085 |
+
)
|
6086 |
+
");
|
6087 |
+
$this->db_do("CREATE TABLE IF NOT EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')."
|
6088 |
+
LIKE ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp'));
|
6089 |
+
$result = $this->db_do("
|
6090 |
+
INSERT ignore INTO ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping_temp')." (
|
6091 |
+
entity_id,
|
6092 |
+
sku,
|
6093 |
+
shop_store_product_id,
|
6094 |
+
shop_sinch_product_id
|
6095 |
)(SELECT
|
6096 |
entity_id,
|
6097 |
sku,
|
6118 |
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
6119 |
ON pmt.sku=p.product_sku
|
6120 |
SET
|
|
|
6121 |
pmt.store_product_id=p.store_product_id,
|
6122 |
pmt.sinch_product_id=p.sinch_product_id,
|
6123 |
pmt.product_sku=p.product_sku,
|
6387 |
product_id = cpe.entity_id
|
6388 |
");
|
6389 |
|
6390 |
+
|
6391 |
+
//add multi categories;
|
6392 |
+
|
6393 |
+
|
6394 |
+
|
6395 |
+
|
6396 |
+
$result = $this->db_do("
|
6397 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')."
|
6398 |
+
(category_id, product_id)
|
6399 |
+
(SELECT
|
6400 |
+
scm.shop_entity_id,
|
6401 |
+
cpe.entity_id
|
6402 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
6403 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." p
|
6404 |
+
ON cpe.store_product_id = p.store_product_id
|
6405 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_product_categories')." spc
|
6406 |
+
ON p.store_product_id=spc.store_product_id
|
6407 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_mapping')." scm
|
6408 |
+
ON spc.store_category_id = scm.store_category_id
|
6409 |
+
)
|
6410 |
+
ON DUPLICATE KEY UPDATE
|
6411 |
+
product_id = cpe.entity_id
|
6412 |
+
");
|
6413 |
+
|
6414 |
+
|
6415 |
+
|
6416 |
+
|
6417 |
//Indexing products and categories in the shop
|
6418 |
$result = $this->db_do("DELETE ccpi
|
6419 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product_index')." ccpi
|
6521 |
|
6522 |
$this->dropHTMLentities($this->_getProductEntityTypeId(), $this->_getProductAttributeId('name'));
|
6523 |
$this->addDescriptions();
|
6524 |
+
if($this->product_file_format == "NEW"){
|
6525 |
+
$this->addReviews();
|
6526 |
+
$this->addWeight();
|
6527 |
+
$this->addSearchCache();
|
6528 |
+
$this->addPdfUrl();
|
6529 |
+
$this->addShortDescriptions();
|
6530 |
+
}
|
6531 |
$this->addEAN();
|
6532 |
$this->addSpecification();
|
6533 |
$this->addManufacturers();
|
6837 |
|
6838 |
");
|
6839 |
|
6840 |
+
/*STP DELETE
|
6841 |
//Refresh fulltext search
|
6842 |
$result = $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_fulltext')."_tmp");
|
6843 |
$result = $this->db_do("CREATE TEMPORARY TABLE IF NOT EXISTS
|
6868 |
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_website')." j
|
6869 |
ON a.entity_id = j.product_id
|
6870 |
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." f
|
6871 |
+
ON a.store_product_id = f.store_product_id
|
6872 |
)
|
6873 |
ON DUPLICATE KEY UPDATE
|
6874 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
6896 |
ON a.entity_id = e.entity_id
|
6897 |
AND e.attribute_id = " . $this->_getProductAttributeId('name'). "
|
6898 |
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." f
|
6899 |
+
ON a.store_product_id = f.store_product_id
|
6900 |
)
|
6901 |
ON DUPLICATE KEY UPDATE
|
6902 |
data_index = CONCAT_WS(' ', a.sku, f.search_cache, c.value, e.value)
|
6928 |
$this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalogsearch_query')." SET is_processed = 0");
|
6929 |
//INNER JOIN eav_attribute_option_value d ON a.vendor_id = d.option_id
|
6930 |
//TODO add something else
|
6931 |
+
STP DELETE*/
|
6932 |
$this->addRelatedProducts();
|
6933 |
}
|
6934 |
|
6935 |
+
#################################################################################################
|
6936 |
+
function addReviews(){
|
6937 |
+
// product reviews for all web sites
|
6938 |
+
$result = $this->db_do("
|
6939 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')." (
|
6940 |
+
entity_type_id,
|
6941 |
+
attribute_id,
|
6942 |
+
store_id,
|
6943 |
+
entity_id,
|
6944 |
+
value
|
6945 |
+
)(
|
6946 |
+
SELECT
|
6947 |
+
" . $this->_getProductEntityTypeId(). ",
|
6948 |
+
" . $this->_getProductAttributeId('reviews'). ",
|
6949 |
+
w.website,
|
6950 |
+
a.entity_id,
|
6951 |
+
b.Reviews
|
6952 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
6953 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
6954 |
+
ON a.store_product_id = b.store_product_id
|
6955 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
6956 |
+
ON a.store_product_id=w.store_product_id
|
6957 |
+
)
|
6958 |
+
ON DUPLICATE KEY UPDATE
|
6959 |
+
value = b.Reviews
|
6960 |
+
");
|
6961 |
+
|
6962 |
+
// product Reviews for all web sites
|
6963 |
+
$result = $this->db_do("
|
6964 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')." (
|
6965 |
+
entity_type_id,
|
6966 |
+
attribute_id,
|
6967 |
+
store_id,
|
6968 |
+
entity_id,
|
6969 |
+
value
|
6970 |
+
)(
|
6971 |
+
SELECT
|
6972 |
+
" . $this->_getProductEntityTypeId(). ",
|
6973 |
+
" . $this->_getProductAttributeId('reviews'). ",
|
6974 |
+
0,
|
6975 |
+
a.entity_id,
|
6976 |
+
b.Reviews
|
6977 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
6978 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
6979 |
+
ON a.store_product_id = b.store_product_id
|
6980 |
+
)
|
6981 |
+
ON DUPLICATE KEY UPDATE
|
6982 |
+
value = b.Reviews
|
6983 |
+
");
|
6984 |
+
|
6985 |
+
|
6986 |
+
}
|
6987 |
+
|
6988 |
+
|
6989 |
#################################################################################################
|
6990 |
function addDescriptions(){
|
6991 |
// product description for all web sites
|
7037 |
");
|
7038 |
|
7039 |
|
7040 |
+
}
|
7041 |
+
############################### ##################################################################
|
7042 |
+
function addSearchCache(){
|
7043 |
+
// product search_cache for all web sites
|
7044 |
+
$result = $this->db_do("
|
7045 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')." (
|
7046 |
+
entity_type_id,
|
7047 |
+
attribute_id,
|
7048 |
+
store_id,
|
7049 |
+
entity_id,
|
7050 |
+
value
|
7051 |
+
)(
|
7052 |
+
SELECT
|
7053 |
+
" . $this->_getProductEntityTypeId(). ",
|
7054 |
+
" . $this->_getProductAttributeId('sinch_search_cache'). ",
|
7055 |
+
w.website,
|
7056 |
+
a.entity_id,
|
7057 |
+
b.search_cache
|
7058 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
7059 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
7060 |
+
ON a.store_product_id = b.store_product_id
|
7061 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
7062 |
+
ON a.store_product_id=w.store_product_id
|
7063 |
+
)
|
7064 |
+
ON DUPLICATE KEY UPDATE
|
7065 |
+
value = b.search_cache
|
7066 |
+
");
|
7067 |
+
|
7068 |
+
// product search_cache for all web sites
|
7069 |
+
$result = $this->db_do("
|
7070 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')." (
|
7071 |
+
entity_type_id,
|
7072 |
+
attribute_id,
|
7073 |
+
store_id,
|
7074 |
+
entity_id,
|
7075 |
+
value
|
7076 |
+
)(
|
7077 |
+
SELECT
|
7078 |
+
" . $this->_getProductEntityTypeId(). ",
|
7079 |
+
" . $this->_getProductAttributeId('sinch_search_cache'). ",
|
7080 |
+
0,
|
7081 |
+
a.entity_id,
|
7082 |
+
b.search_cache
|
7083 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
7084 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
7085 |
+
ON a.store_product_id = b.store_product_id
|
7086 |
+
)
|
7087 |
+
ON DUPLICATE KEY UPDATE
|
7088 |
+
value = b.search_cache
|
7089 |
+
");
|
7090 |
+
|
7091 |
+
|
7092 |
}
|
7093 |
|
7094 |
+
#################################################################################################
|
7095 |
+
function addPdfUrl(){
|
7096 |
+
// product PDF Url for all web sites
|
7097 |
+
$result = $this->db_do("
|
7098 |
+
UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
|
7099 |
+
SET pdf_url = CONCAT(
|
7100 |
+
'<a href=\"#\" onclick=\"popWin(',
|
7101 |
+
\"'\",
|
7102 |
+
pdf_url,
|
7103 |
+
\"'\",
|
7104 |
+
\", 'pdf', 'width=500,height=800,left=50,top=50, location=no,status=yes,scrollbars=yes,resizable=yes'); return false;\",
|
7105 |
+
'\"',
|
7106 |
+
'>',
|
7107 |
+
pdf_url,
|
7108 |
+
'</a>')
|
7109 |
+
WHERE pdf_url != ''
|
7110 |
+
");
|
7111 |
+
//<a title="" onclick="popWin('http://images.icecat.biz/img/gallery/14532248_4539.jpg', 'gallery', 'width=500,height=500,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" href="#">
|
7112 |
+
$result = $this->db_do("
|
7113 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
7114 |
+
entity_type_id,
|
7115 |
+
attribute_id,
|
7116 |
+
store_id,
|
7117 |
+
entity_id,
|
7118 |
+
value
|
7119 |
+
)(
|
7120 |
+
SELECT
|
7121 |
+
" . $this->_getProductEntityTypeId(). ",
|
7122 |
+
" . $this->_getProductAttributeId('pdf_url'). ",
|
7123 |
+
w.website,
|
7124 |
+
a.entity_id,
|
7125 |
+
b.pdf_url
|
7126 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
7127 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
7128 |
+
ON a.store_product_id = b.store_product_id
|
7129 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
7130 |
+
ON a.store_product_id=w.store_product_id
|
7131 |
+
)
|
7132 |
+
ON DUPLICATE KEY UPDATE
|
7133 |
+
value = b.pdf_url
|
7134 |
+
");
|
7135 |
+
// product PDF url for all web sites
|
7136 |
+
$result = $this->db_do("
|
7137 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
7138 |
+
entity_type_id,
|
7139 |
+
attribute_id,
|
7140 |
+
store_id,
|
7141 |
+
entity_id,
|
7142 |
+
value
|
7143 |
+
)(
|
7144 |
+
SELECT
|
7145 |
+
" . $this->_getProductEntityTypeId(). ",
|
7146 |
+
" . $this->_getProductAttributeId('pdf_url'). ",
|
7147 |
+
0,
|
7148 |
+
a.entity_id,
|
7149 |
+
b.pdf_url
|
7150 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
7151 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
7152 |
+
ON a.store_product_id = b.store_product_id
|
7153 |
+
)
|
7154 |
+
ON DUPLICATE KEY UPDATE
|
7155 |
+
value = b.pdf_url
|
7156 |
+
");
|
7157 |
+
|
7158 |
+
}
|
7159 |
+
|
7160 |
+
|
7161 |
#################################################################################################
|
7162 |
function addShortDescriptions(){
|
7163 |
// product short description for all web sites
|
7174 |
" . $this->_getProductAttributeId('short_description'). ",
|
7175 |
w.website,
|
7176 |
a.entity_id,
|
7177 |
+
b.product_short_description
|
7178 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
7179 |
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
7180 |
ON a.store_product_id = b.store_product_id
|
7182 |
ON a.store_product_id=w.store_product_id
|
7183 |
)
|
7184 |
ON DUPLICATE KEY UPDATE
|
7185 |
+
value = b.product_short_description
|
7186 |
");
|
7187 |
// product short description for all web sites
|
7188 |
$result = $this->db_do("
|
7198 |
" . $this->_getProductAttributeId('short_description'). ",
|
7199 |
0,
|
7200 |
a.entity_id,
|
7201 |
+
b.product_short_description
|
7202 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
7203 |
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
7204 |
ON a.store_product_id = b.store_product_id
|
7205 |
)
|
7206 |
ON DUPLICATE KEY UPDATE
|
7207 |
+
value = b.product_short_description
|
7208 |
");
|
7209 |
|
7210 |
}
|
7238 |
ON e.sinch_product_id=p.sinch_product_id
|
7239 |
SET e.store_product_id=p.store_product_id");
|
7240 |
// product EANs for all web sites
|
7241 |
+
$result = $this->db_do("
|
7242 |
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')." (
|
7243 |
entity_type_id,
|
7244 |
attribute_id,
|
7563 |
}
|
7564 |
#################################################################################################
|
7565 |
function addWeight(){
|
7566 |
+
// product weight for specific web site
|
7567 |
$result = $this->db_do("
|
7568 |
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
7569 |
entity_type_id,
|
7577 |
" . $this->_getProductAttributeId('weight'). ",
|
7578 |
w.website,
|
7579 |
a.entity_id,
|
7580 |
+
b.Weight
|
7581 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
7582 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
7583 |
ON a.store_product_id = b.store_product_id
|
7584 |
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." w
|
7585 |
ON a.store_product_id=w.store_product_id
|
7586 |
)
|
7587 |
ON DUPLICATE KEY UPDATE
|
7588 |
+
value = b.Weight
|
7589 |
");
|
7590 |
+
// product weight for all web sites
|
7591 |
$result = $this->db_do("
|
7592 |
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." (
|
7593 |
entity_type_id,
|
7601 |
" . $this->_getProductAttributeId('weight'). ",
|
7602 |
0,
|
7603 |
a.entity_id,
|
7604 |
+
b.Weight
|
7605 |
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
|
7606 |
+
INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('products_temp')." b
|
7607 |
ON a.store_product_id = b.store_product_id
|
7608 |
)
|
7609 |
ON DUPLICATE KEY UPDATE
|
7610 |
+
value = b.Weight
|
7611 |
|
7612 |
|
7613 |
");
|
7614 |
|
7615 |
|
7616 |
}
|
7617 |
+
|
7618 |
+
#################################################################################################
|
7619 |
+
function _getProductsForCustomerGroupPrice(){
|
7620 |
+
// TEMPORARY
|
7621 |
+
$this->db_do(" DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp'));
|
7622 |
+
$this->db_do("
|
7623 |
+
CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp')."
|
7624 |
+
(
|
7625 |
+
`category_id` int(10) unsigned NOT NULL default '0',
|
7626 |
+
`product_id` int(10) unsigned NOT NULL default '0',
|
7627 |
+
`store_product_id` int(10) NOT NULL default '0',
|
7628 |
+
`sku` varchar(64) DEFAULT NULL COMMENT 'SKU',
|
7629 |
+
`manufacturer_id` int(10) NOT NULL default '0',
|
7630 |
+
`price` decimal(15,4) DEFAULT NULL,
|
7631 |
+
UNIQUE KEY `UNQ_CATEGORY_PRODUCT` (`product_id`,`category_id`),
|
7632 |
+
KEY `CATALOG_CATEGORY_PRODUCT_CATEGORY` (`category_id`),
|
7633 |
+
KEY `CATALOG_CATEGORY_PRODUCT_PRODUCT` (`product_id`)
|
7634 |
+
)");
|
7635 |
+
|
7636 |
+
$result = $this->db_do("
|
7637 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp')."
|
7638 |
+
(category_id, product_id, store_product_id, sku)
|
7639 |
+
(SELECT
|
7640 |
+
ccp.category_id,
|
7641 |
+
ccp.product_id,
|
7642 |
+
cpe.store_product_id,
|
7643 |
+
cpe.sku
|
7644 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_product')." ccp
|
7645 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." cpe
|
7646 |
+
ON ccp.product_id = cpe.entity_id
|
7647 |
+
WHERE cpe.store_product_id IS NOT NULL)");
|
7648 |
+
|
7649 |
+
$result = $this->db_do("
|
7650 |
+
UPDATE ". Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp')." pfcgpt
|
7651 |
+
JOIN ". Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_int')." cpei
|
7652 |
+
ON pfcgpt.product_id = cpei.entity_id
|
7653 |
+
AND cpei.entity_type_id = " . $this->_getProductEntityTypeId(). "
|
7654 |
+
AND cpei.attribute_id = " . $this->_getProductAttributeId('manufacturer'). "
|
7655 |
+
SET pfcgpt.manufacturer_id = cpei.value
|
7656 |
+
");
|
7657 |
+
|
7658 |
+
$result = $this->db_do("
|
7659 |
+
UPDATE ". Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp')." pfcgpt
|
7660 |
+
JOIN ". Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_decimal')." cped
|
7661 |
+
ON pfcgpt.product_id = cped.entity_id
|
7662 |
+
AND cped.entity_type_id = " . $this->_getProductEntityTypeId(). "
|
7663 |
+
AND cped.attribute_id = " . $this->_getProductAttributeId('price'). "
|
7664 |
+
SET pfcgpt.price = cped.value
|
7665 |
+
");
|
7666 |
+
|
7667 |
+
|
7668 |
+
|
7669 |
+
}
|
7670 |
+
|
7671 |
+
#################################################################################################
|
7672 |
+
function ApplyCustomerGroupPrice(){
|
7673 |
+
if (!$this->check_table_exist('import_pricerules_standards')){
|
7674 |
+
return;
|
7675 |
+
}
|
7676 |
+
$this->_getProductsForCustomerGroupPrice();
|
7677 |
+
$pricerulesArray = $this->_getPricerulesList();
|
7678 |
+
if(is_array($pricerulesArray)){
|
7679 |
+
$this->db_do("TRUNCATE TABLE ". Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_group_price'));
|
7680 |
+
$this->db_do("TRUNCATE TABLE ". Mage::getSingleton('core/resource')->getTableName('catalog_product_index_group_price'));
|
7681 |
+
|
7682 |
+
}
|
7683 |
+
// $i=1;
|
7684 |
+
foreach($pricerulesArray as $pricerule) {
|
7685 |
+
$this->_LOG("Calculation group price for rule ".$pricerule['id']."
|
7686 |
+
(\nname = ".$pricerule['name']."
|
7687 |
+
\nfinal_price = ".$pricerule['final_price']."
|
7688 |
+
\nprice_from = ".$pricerule['price_from']."
|
7689 |
+
\nprice_to = ".$pricerule['price_to']."
|
7690 |
+
\nvendor_id = ".$pricerule['vendor_id']."
|
7691 |
+
\ncategory_id = ".$pricerule['category_id']."
|
7692 |
+
\nproduct_entity_id = ".$pricerule['product_entity_id']."
|
7693 |
+
\nvendor_product_id = ".$pricerule['vendor_product_id']."
|
7694 |
+
\ncustomergroup_id = ".$pricerule['customergroup_id']."
|
7695 |
+
\ndistributor_id = ".$pricerule['distributor_id']."
|
7696 |
+
\nrating = ".$pricerule['rating']."
|
7697 |
+
\nmarge = ".$pricerule['marge']."
|
7698 |
+
\nfixed = ".$pricerule['fixed']."
|
7699 |
+
\nallow_subcat = ".$pricerule['allow_subcat']."
|
7700 |
+
\nstore_id = ".$pricerule['store_id']."
|
7701 |
+
)");
|
7702 |
+
|
7703 |
+
$vendor_product_id_str = "'".str_replace(';', "','", $pricerule['vendor_product_id'])."'";
|
7704 |
+
$where = "";
|
7705 |
+
if (empty($pricerule['marge'])) $marge = "NULL";
|
7706 |
+
else $marge = $pricerule['marge'];
|
7707 |
+
|
7708 |
+
if (empty($pricerule['fixed'])) $fixed = "NULL";
|
7709 |
+
else $fixed = $pricerule['fixed'];
|
7710 |
+
|
7711 |
+
if (empty($pricerule['final_price'])) $final_price = "NULL";
|
7712 |
+
else $final_price = $pricerule['final_price'];
|
7713 |
+
|
7714 |
+
if (!empty($pricerule['price_from'])) $where.= " AND a.price > ".$pricerule['price_from'];
|
7715 |
+
|
7716 |
+
if (!empty($pricerule['price_to'])) $where.= " AND a.price < ".$pricerule['price_to'];
|
7717 |
+
|
7718 |
+
if (!empty($pricerule['vendor_id'])) $where.= " AND a.manufacturer_id = ".$pricerule['vendor_id'];
|
7719 |
+
|
7720 |
+
//if(!empty($pricerule['vendor_product_id']))
|
7721 |
+
// $where.= " AND vendor_product_id = ".$pricerule['vendor_product_id'];
|
7722 |
+
if (!empty($pricerule['product_entity_id'])) $where.= " AND a.product_id = '".$pricerule['product_entity_id']."'";
|
7723 |
+
|
7724 |
+
// if (!empty($pricerule['vendor_product_id'])) $where.= " AND a.sku = '".$pricerule['vendor_product_id']."'";
|
7725 |
+
if (!empty($pricerule['vendor_product_id'])) $where.= " AND a.sku IN (". $vendor_product_id_str.")";
|
7726 |
+
|
7727 |
+
if(!empty($pricerule['allow_subcat'])){
|
7728 |
+
if (!empty($pricerule['category_id'])){
|
7729 |
+
$children_cat=$this->get_all_children_cat($pricerule['category_id']);
|
7730 |
+
$where.= " AND a.category_id IN (".$children_cat.")";
|
7731 |
+
}
|
7732 |
+
}else{
|
7733 |
+
if (!empty($pricerule['category_id'])) $where.= " AND a.category_id = ".$pricerule['category_id'];
|
7734 |
+
}
|
7735 |
+
|
7736 |
+
|
7737 |
+
// if (!empty($pricerule['store_id'])) $where.= " AND store_id = ".$pricerule['store_id'];
|
7738 |
+
|
7739 |
+
// if (!empty($pricerule['distributor_id'])) $where.= " AND distributor_id = ".$pricerule['distributor_id'];
|
7740 |
+
|
7741 |
+
// $this->createCalcPriceFunc();
|
7742 |
+
//echo "\n\nAAAAAAAAAAAAAAAAAAAAa".$pricerule['customergroup_id']."----------";
|
7743 |
+
$customer_group_id_array = array();
|
7744 |
+
if(strstr($pricerule['customergroup_id'], ",")){
|
7745 |
+
//echo "55555555555555555";
|
7746 |
+
$customer_group_id_array = explode(",", $pricerule['customergroup_id']);
|
7747 |
+
}else{
|
7748 |
+
$customer_group_id_array[0] = $pricerule['customergroup_id'];
|
7749 |
+
}
|
7750 |
+
// var_dump($pricerule);
|
7751 |
+
// echo "CCCCCCC\n";
|
7752 |
+
// var_dump($customer_group_id_array);
|
7753 |
+
foreach($customer_group_id_array as $customer_group_id){
|
7754 |
+
if(isset($customer_group_id) && $customer_group_id>=0){
|
7755 |
+
$query="
|
7756 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_group_price')." (entity_id,
|
7757 |
+
all_groups,
|
7758 |
+
customer_group_id,
|
7759 |
+
value,
|
7760 |
+
website_id
|
7761 |
+
)
|
7762 |
+
(SELECT
|
7763 |
+
a.product_id,
|
7764 |
+
0,
|
7765 |
+
".$customer_group_id.",
|
7766 |
+
".Mage::getSingleton('core/resource')->getTableName('func_calc_price')."(
|
7767 |
+
a.price,
|
7768 |
+
".$marge." ,
|
7769 |
+
".$fixed.",
|
7770 |
+
".$final_price."),
|
7771 |
+
0
|
7772 |
+
FROM ". Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp')." a
|
7773 |
+
WHERE true ".$where."
|
7774 |
+
)
|
7775 |
+
ON DUPLICATE KEY UPDATE
|
7776 |
+
value =
|
7777 |
+
".Mage::getSingleton('core/resource')->getTableName('func_calc_price')."(
|
7778 |
+
a.price,
|
7779 |
+
".$marge." ,
|
7780 |
+
".$fixed.",
|
7781 |
+
".$final_price.")
|
7782 |
+
";
|
7783 |
+
// echo "\n\n".$query;
|
7784 |
+
$this->db_do($query);
|
7785 |
+
if (!empty($pricerule['store_id']) && $pricerule['store_id']>0){
|
7786 |
+
$query="
|
7787 |
+
INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_group_price')." (entity_id,
|
7788 |
+
customer_group_id,
|
7789 |
+
price,
|
7790 |
+
website_id
|
7791 |
+
)
|
7792 |
+
(SELECT
|
7793 |
+
a.product_id,
|
7794 |
+
".$customer_group_id.",
|
7795 |
+
".Mage::getSingleton('core/resource')->getTableName('func_calc_price')."(
|
7796 |
+
a.price,
|
7797 |
+
".$marge." ,
|
7798 |
+
".$fixed.",
|
7799 |
+
".$final_price."),
|
7800 |
+
".$pricerule['store_id']."
|
7801 |
+
FROM ". Mage::getSingleton('core/resource')->getTableName('stINch_products_for_customer_group_price_temp')." a
|
7802 |
+
WHERE true ".$where."
|
7803 |
+
)
|
7804 |
+
ON DUPLICATE KEY UPDATE
|
7805 |
+
price =
|
7806 |
+
".Mage::getSingleton('core/resource')->getTableName('func_calc_price')."(
|
7807 |
+
a.price,
|
7808 |
+
".$marge." ,
|
7809 |
+
".$fixed.",
|
7810 |
+
".$final_price.")
|
7811 |
+
";
|
7812 |
+
// echo "\n\n".$query;
|
7813 |
+
$this->db_do($query);
|
7814 |
+
|
7815 |
+
}
|
7816 |
+
}
|
7817 |
+
}
|
7818 |
+
}
|
7819 |
+
|
7820 |
+
}
|
7821 |
+
#################################################################################################
|
7822 |
+
|
7823 |
+
protected function _getPricerulesList() {
|
7824 |
+
$rulesArray = array();
|
7825 |
+
$result = $this->db_do("
|
7826 |
+
SELECT *
|
7827 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('import_pricerules')."
|
7828 |
+
ORDER BY rating DESC
|
7829 |
+
");
|
7830 |
+
while($row = mysql_fetch_assoc($result)) {
|
7831 |
+
$rulesArray[$row['id']] = $row;
|
7832 |
+
}
|
7833 |
+
return $rulesArray;
|
7834 |
+
}
|
7835 |
+
|
7836 |
+
|
7837 |
#################################################################################################
|
7838 |
function replaceMagentoProductsStockPrice(){
|
7839 |
//Add stock
|
9525 |
|
9526 |
|
9527 |
|
|
|
9528 |
|
9529 |
+
##################################################################################################
|
9530 |
+
public function checkConflictsWithInstalledModules() {
|
9531 |
+
$check_code = 'conflictwithinstalledmodules';
|
9532 |
+
|
9533 |
+
$conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9534 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('stINch_sinchcheck');
|
9535 |
+
$result = $conn->query("SELECT * FROM $tableName WHERE check_code = '$check_code'");
|
9536 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9537 |
+
//echo " [".$row['id']."] [".$row['caption']."] [".$row['descr']."] [".$row['check_code']."] [".$row['check_value']."] [".$row['check_measure']."] [".$row['error_msg']."] [".$row['fix_msg']."] <br>";
|
9538 |
+
|
9539 |
+
$Caption = $row['caption'];
|
9540 |
+
$CheckValue = $row['check_value'];
|
9541 |
+
$CheckMeasure = $row['check_measure'];
|
9542 |
+
$ErrorMessage = $row['error_msg'];
|
9543 |
+
$FixMessage = $row['fix_msg'];
|
9544 |
+
|
9545 |
+
$retvalue = array();
|
9546 |
+
$retvalue["'$check_code'"] = array();
|
9547 |
+
|
9548 |
+
/* $conn = Mage::getSingleton('core/resource')->getConnection('core_read');
|
9549 |
+
$storedFunctionName = Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s');
|
9550 |
+
$result = $conn->query("SHOW PROCEDURE STATUS LIKE '$storedFunctionName'");
|
9551 |
+
$row = $result->fetch(PDO::FETCH_ASSOC);
|
9552 |
+
$value = $row['Name'];
|
9553 |
+
*/
|
9554 |
+
$config_file = (Mage::app()->getConfig()->getNode()->asXML());
|
9555 |
+
|
9556 |
+
$errmsg = $ErrorMessage;
|
9557 |
+
$fixmsg = $FixMessage;
|
9558 |
+
/*
|
9559 |
+
if ($value != $CheckValue) {
|
9560 |
+
$errmsg .= $ErrorMessage; // ." ".$value." ".$CheckMeasure
|
9561 |
+
$fixmsg .= $FixMessage; // ." ".$CheckValue." ".$CheckMeasure
|
9562 |
+
$status = 'error';
|
9563 |
+
*/
|
9564 |
+
$status = 'OK';
|
9565 |
+
|
9566 |
+
if (!strstr($config_file, '<image>Bintime_Sinchimport_Helper_Image</image>')) {
|
9567 |
+
$errmsg .= " Can't find <image>Bintime_Sinchimport_Helper_Image</image> in <helpers><catalog></catalog></helpers>"; // ." ".$value." ".$CheckMeasure
|
9568 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9569 |
+
$status = 'error';
|
9570 |
+
}
|
9571 |
+
|
9572 |
+
if (!strstr($config_file, '<product_image>Bintime_Sinchimport_Model_Image</product_image>')) {
|
9573 |
+
$errmsg .= " Can't find <product_image>Bintime_Sinchimport_Model_Image</product_image> in <models><catalog></catalog></models>"; // ." ".$value." ".$CheckMeasure
|
9574 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9575 |
+
$status = 'error';
|
9576 |
+
}
|
9577 |
+
|
9578 |
+
if (!strstr($config_file, '<category>Bintime_Sinchimport_Model_Category</category>')) {
|
9579 |
+
$errmsg .= " Can't find <category>Bintime_Sinchimport_Model_Category</category> in <models><catalog></catalog></models>"; // ." ".$value." ".$CheckMeasure
|
9580 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9581 |
+
$status = 'error';
|
9582 |
+
}
|
9583 |
+
|
9584 |
+
if (!strstr($config_file, '<product_compare_list>Bintime_Sinchimport_Block_List</product_compare_list>')) {
|
9585 |
+
$errmsg .= " Can't find <product_compare_list>Bintime_Sinchimport_Block_List</product_compare_list> in <blocks><catalog></catalog></blocks>"; // ." ".$value." ".$CheckMeasure
|
9586 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9587 |
+
$status = 'error';
|
9588 |
+
}
|
9589 |
+
|
9590 |
+
if (!strstr($config_file, '<product_view_media>Bintime_Sinchimport_Block_Product_View_Media</product_view_media>')) {
|
9591 |
+
$errmsg .= " Can't find <product_view_media>Bintime_Sinchimport_Block_Product_View_Media</product_view_media> in <blocks><catalog></catalog></blocks>"; // ." ".$value." ".$CheckMeasure
|
9592 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9593 |
+
$status = 'error';
|
9594 |
+
}
|
9595 |
+
|
9596 |
+
if (!strstr($config_file, '<product>Bintime_Sinchimport_Model_Product</product>')) {
|
9597 |
+
$errmsg .= " Can't find <product>Bintime_Sinchimport_Model_Product</product> in <models><catalog></catalog></models>"; // ." ".$value." ".$CheckMeasure
|
9598 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9599 |
+
$status = 'error';
|
9600 |
+
}
|
9601 |
+
|
9602 |
+
if (!strstr($config_file, '<layer_filter_price>Bintime_Sinchimport_Model_Layer_Filter_Price</layer_filter_price>')) {
|
9603 |
+
$errmsg .= " Can't find <layer_filter_price>Bintime_Sinchimport_Model_Layer_Filter_Price</layer_filter_price> in <models><catalog></catalog><models>"; // ." ".$value." ".$CheckMeasure
|
9604 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9605 |
+
$status = 'error';
|
9606 |
+
}
|
9607 |
+
|
9608 |
+
if (!strstr($config_file, '<layer_view>Bintime_Sinchimport_Block_Layer_View</layer_view>')) {
|
9609 |
+
$errmsg .= " Can't find <layer_view>Bintime_Sinchimport_Block_Layer_View</layer_view> in <blocks><catalog></catalog></blocks>"; // ." ".$value." ".$CheckMeasure
|
9610 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9611 |
+
$status = 'error';
|
9612 |
+
}
|
9613 |
+
|
9614 |
+
if (!strstr($config_file, '<layer>Bintime_Sinchimport_Model_Layer</layer>')) {
|
9615 |
+
$errmsg .= " Can't find <layer>Bintime_Sinchimport_Model_Layer</layer> in <models><catalog></catalog><models>"; // ." ".$value." ".$CheckMeasure
|
9616 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9617 |
+
$status = 'error';
|
9618 |
+
}
|
9619 |
+
|
9620 |
+
if (!strstr($config_file, '<layer_filter_price>Bintime_Sinchimport_Model_Resource_Layer_Filter_Price</layer_filter_price>')) {
|
9621 |
+
$errmsg .= " Can't find <layer_filter_price>Bintime_Sinchimport_Model_Resource_Layer_Filter_Price</layer_filter_price> in <models><catalog_resource_eav_mysql4></catalog_resource_eav_mysql4></models>"; // ." ".$value." ".$CheckMeasure
|
9622 |
+
$fixmsg = $FixMessage;//.$CheckValue." ".$CheckMeasure
|
9623 |
+
$status = 'error';
|
9624 |
+
}
|
9625 |
+
|
9626 |
+
|
9627 |
+
if ($status == 'OK'){
|
9628 |
+
$errmsg = 'none';
|
9629 |
+
$fixmsg = 'none';
|
9630 |
+
}
|
9631 |
+
$ret = array();
|
9632 |
+
array_push($ret, $status, $Caption, $CheckValue, $value, $CheckMeasure, $errmsg, $fixmsg);
|
9633 |
+
|
9634 |
+
return $ret;
|
9635 |
+
} // public function getImportEnvironment()
|
9636 |
+
##################################################################################################
|
9637 |
+
|
9638 |
+
|
9639 |
+
|
9640 |
+
##################################################################################################
|
9641 |
+
public function getSinchDistribotorsTableHtml($entity_id=null) {
|
9642 |
+
/*/ Load the collection
|
9643 |
+
$collection = getResourceModel('sales/order_grid_collection');
|
9644 |
+
|
9645 |
+
// Add custom data
|
9646 |
+
$collection->addToAll('example', 'This is a test');
|
9647 |
+
|
9648 |
+
// Set the collection
|
9649 |
+
$this->setCollection($collection);
|
9650 |
+
// return parent::_prepareCollection();
|
9651 |
+
*/
|
9652 |
+
if(!$entity_id){
|
9653 |
+
$entity_id = Mage::registry('current_product')->getId();
|
9654 |
+
}
|
9655 |
+
if (!$entity_id){
|
9656 |
+
return '';
|
9657 |
+
}
|
9658 |
+
|
9659 |
+
$distributors_stock_price = $this->getDistributorStockPriceByProductid($entity_id);
|
9660 |
+
$distributors_table = '
|
9661 |
+
<table>
|
9662 |
+
<thead>
|
9663 |
+
<tr class="headings">
|
9664 |
+
<th>Supplier</th>
|
9665 |
+
<th>Stock</th>
|
9666 |
+
<th>Price</th>
|
9667 |
+
</tr>
|
9668 |
+
</thead>
|
9669 |
+
<tbody>';
|
9670 |
+
$i = 1;
|
9671 |
+
foreach($distributors_stock_price as $offer){
|
9672 |
+
if ($i > 0){
|
9673 |
+
$class = "even pointer";
|
9674 |
+
$i = 0;
|
9675 |
+
}else{
|
9676 |
+
$class = "pointer";
|
9677 |
+
$i = 1;
|
9678 |
+
}
|
9679 |
+
$distributors_table .= '
|
9680 |
+
<tr class="'.$class.'">
|
9681 |
+
<td nowrap style="font-weight: normal">'.$offer['distributor_name'].'</td>
|
9682 |
+
<td style="font-weight: normal">'.$offer['stock'].'</td>
|
9683 |
+
<td style="font-weight: normal">'.Mage::helper('core')->currency($offer['cost']).'</td>
|
9684 |
+
</tr>';
|
9685 |
+
}
|
9686 |
+
$distributors_table .= '
|
9687 |
+
</tbody>
|
9688 |
+
</table>
|
9689 |
+
';
|
9690 |
+
return $distributors_table;
|
9691 |
+
}
|
9692 |
+
##################################################################################################
|
9693 |
|
9694 |
|
9695 |
|
9696 |
+
|
9697 |
+
##################################################################################################
|
9698 |
+
private function getDistributorStockPriceByProductid($entity_id) {
|
9699 |
+
$store_product_id=$this->getStoreProductIdByEntity($entity_id);
|
9700 |
+
if(!$store_product_id){
|
9701 |
+
// echo "AAAAAAA"; exit;
|
9702 |
+
return;
|
9703 |
+
}
|
9704 |
+
$q="SELECT
|
9705 |
+
d.distributor_name,
|
9706 |
+
d.website,
|
9707 |
+
dsp.stock,
|
9708 |
+
dsp.cost,
|
9709 |
+
dsp.distributor_sku,
|
9710 |
+
dsp.distributor_category,
|
9711 |
+
dsp.eta
|
9712 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_distributors_stock_and_price')." dsp
|
9713 |
+
JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_distributors')." d
|
9714 |
+
ON dsp.distributor_id = d.distributor_id
|
9715 |
+
WHERE store_product_id =".$store_product_id;
|
9716 |
+
$quer=$this->db_do($q);
|
9717 |
+
$offers = null;
|
9718 |
+
while($row = mysql_fetch_array($quer)){
|
9719 |
+
$offers[]=$row;
|
9720 |
+
}
|
9721 |
+
return $offers;
|
9722 |
+
|
9723 |
+
}
|
9724 |
+
#################################################################################################
|
9725 |
+
|
9726 |
+
private function get_all_children_cat($entity_id){
|
9727 |
+
$children_cat = "'" . $entity_id . "'" . $this->get_all_children_cat_recursive($entity_id);
|
9728 |
+
return ($children_cat);
|
9729 |
+
}
|
9730 |
+
#################################################################################################
|
9731 |
+
|
9732 |
+
private function get_all_children_cat_recursive($entity_id) {
|
9733 |
+
$q="SELECT entity_id
|
9734 |
+
FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
|
9735 |
+
WHERE parent_id=".$entity_id;
|
9736 |
+
$quer=$this->db_do($q);
|
9737 |
+
$children_cat='';
|
9738 |
+
while ($row=mysql_fetch_array($quer)){
|
9739 |
+
$children_cat .= ", '".$row['entity_id']."'";
|
9740 |
+
$children_cat .= $this->get_all_children_cat_recursive($row['entity_id']);
|
9741 |
+
}
|
9742 |
+
return ($children_cat);
|
9743 |
+
}
|
9744 |
+
#################################################################################################
|
9745 |
+
|
9746 |
+
private function check_table_exist($table){
|
9747 |
+
|
9748 |
+
$q="SHOW TABLES LIKE \"%".Mage::getSingleton('core/resource')->getTableName($table)."%\"";
|
9749 |
+
// echo $q;
|
9750 |
+
$quer=$this->db_do($q);
|
9751 |
+
$i=0;
|
9752 |
+
while ($row=mysql_fetch_array($quer)){
|
9753 |
+
$i++;
|
9754 |
+
}
|
9755 |
+
return ($i);
|
9756 |
+
}
|
9757 |
+
#################################################################################################
|
9758 |
+
|
9759 |
+
private function _set_default_root_category(){
|
9760 |
+
$q="UPDATE ".Mage::getSingleton('core/resource')->getTableName('core_store_group')." csg
|
9761 |
+
LEFT JOIN ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." cce
|
9762 |
+
ON csg.root_category_id = cce.entity_id
|
9763 |
+
SET csg.root_category_id=(SELECT entity_id FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')." WHERE parent_id = 1 LIMIT 1)
|
9764 |
+
WHERE csg.root_category_id > 0 AND cce.entity_id IS NULL";
|
9765 |
+
$this->db_do($q);
|
9766 |
+
}
|
9767 |
+
|
9768 |
+
} // class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract
|
9769 |
+
|
9770 |
?>
|
9771 |
|
9772 |
|
app/code/local/Bintime/Sinchimport/Model/System/Config/ProdRewrite.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class provides data for Magento BO
|
4 |
+
* @author Sergey Stepanchuk <info@bintime.com>
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
class Bintime_Sinchimport_Model_System_Config_ProdRewrite
|
8 |
+
{
|
9 |
+
public function toOptionArray()
|
10 |
+
{
|
11 |
+
$paramsArray = array(
|
12 |
+
'MERGE' => 'Merge',
|
13 |
+
'REWRITE' => 'Overwrite',
|
14 |
+
);
|
15 |
+
return $paramsArray;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
?>
|
app/code/local/Bintime/Sinchimport/Model/config.php
CHANGED
@@ -14,16 +14,20 @@
|
|
14 |
define('LOG_FILE', 'LOG_PATH'.'import'.date("_Y_m").'.log');
|
15 |
|
16 |
define('FILE_CATEGORIES', 'Categories.csv');
|
|
|
17 |
define('FILE_CATEGORIES_FEATURES', 'CategoryFeatures.csv');
|
18 |
define('FILE_DISTRIBUTORS', 'Distributors.csv');
|
|
|
19 |
define('FILE_EANCODES', 'EANCodes.csv');
|
20 |
define('FILE_MANUFACTURERS', 'Manufacturers.csv');
|
21 |
define('FILE_PRODUCT_FEATURES', 'ProductFeatures.csv');
|
|
|
22 |
define('FILE_PRODUCTS', 'Products.csv');
|
23 |
define('FILE_RELATED_PRODUCTS', 'RelatedProducts.csv');
|
24 |
define('FILE_RESTRICTED_VALUES', 'RestrictedValues.csv');
|
25 |
define('FILE_STOCK_AND_PRICES', 'StockAndPrices.csv');
|
26 |
define('FILE_PRODUCTS_PICTURES_GALLERY', 'ProductPictures.csv');
|
|
|
27 |
define('FILE_URL_AND_DIR', "ftp://%%%login%%%:%%%password%%%@%%%server%%%/"); // insert StockInTheChannel url (default ftp://%%%login%%%:%%%password%%%@ftp.stockinthechannel.com/)
|
28 |
define('DEFAULT_FILE_TERMINATED_CHAR', "|");
|
29 |
|
@@ -36,14 +40,16 @@
|
|
36 |
100-200;
|
37 |
200-500;
|
38 |
500-1000;
|
|
|
39 |
2000-5000;
|
40 |
5000-*;
|
41 |
");
|
42 |
define("UPDATE_CATEGORY_DATA", false);
|
43 |
-
|
44 |
if( exec("which php") ){
|
45 |
define('PHP_RUN_STRING', 'php ');
|
46 |
}elseif( exec("which php5") ){
|
47 |
define('PHP_RUN_STRING', 'php5 ');
|
48 |
}
|
|
|
49 |
?>
|
14 |
define('LOG_FILE', 'LOG_PATH'.'import'.date("_Y_m").'.log');
|
15 |
|
16 |
define('FILE_CATEGORIES', 'Categories.csv');
|
17 |
+
define('FILE_CATEGORY_TYPES', 'CategoryTypes.csv');
|
18 |
define('FILE_CATEGORIES_FEATURES', 'CategoryFeatures.csv');
|
19 |
define('FILE_DISTRIBUTORS', 'Distributors.csv');
|
20 |
+
define('FILE_DISTRIBUTORS_STOCK_AND_PRICES', 'DistributorStockAndPrices.csv');
|
21 |
define('FILE_EANCODES', 'EANCodes.csv');
|
22 |
define('FILE_MANUFACTURERS', 'Manufacturers.csv');
|
23 |
define('FILE_PRODUCT_FEATURES', 'ProductFeatures.csv');
|
24 |
+
define('FILE_PRODUCT_CATEGORIES', 'ProductCategories.csv');
|
25 |
define('FILE_PRODUCTS', 'Products.csv');
|
26 |
define('FILE_RELATED_PRODUCTS', 'RelatedProducts.csv');
|
27 |
define('FILE_RESTRICTED_VALUES', 'RestrictedValues.csv');
|
28 |
define('FILE_STOCK_AND_PRICES', 'StockAndPrices.csv');
|
29 |
define('FILE_PRODUCTS_PICTURES_GALLERY', 'ProductPictures.csv');
|
30 |
+
define('FILE_PRICE_RULES', 'contractprices.csv');
|
31 |
define('FILE_URL_AND_DIR', "ftp://%%%login%%%:%%%password%%%@%%%server%%%/"); // insert StockInTheChannel url (default ftp://%%%login%%%:%%%password%%%@ftp.stockinthechannel.com/)
|
32 |
define('DEFAULT_FILE_TERMINATED_CHAR', "|");
|
33 |
|
40 |
100-200;
|
41 |
200-500;
|
42 |
500-1000;
|
43 |
+
1000-2000;
|
44 |
2000-5000;
|
45 |
5000-*;
|
46 |
");
|
47 |
define("UPDATE_CATEGORY_DATA", false);
|
48 |
+
define('PHP_RUN_STRINGS', 'php5;php');
|
49 |
if( exec("which php") ){
|
50 |
define('PHP_RUN_STRING', 'php ');
|
51 |
}elseif( exec("which php5") ){
|
52 |
define('PHP_RUN_STRING', 'php5 ');
|
53 |
}
|
54 |
+
|
55 |
?>
|
app/code/local/Bintime/Sinchimport/controllers/AjaxController.php
CHANGED
@@ -30,7 +30,14 @@ class Bintime_Sinchimport_AjaxController extends Mage_Adminhtml_Controller_Actio
|
|
30 |
|
31 |
echo "Start import <br>";
|
32 |
$dir = dirname(__FILE__);
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
/*
|
36 |
$import=Mage::getModel('sinchimport/sinch');
|
@@ -49,7 +56,14 @@ class Bintime_Sinchimport_AjaxController extends Mage_Adminhtml_Controller_Actio
|
|
49 |
|
50 |
echo "Start Stock & Price import <br>";
|
51 |
$dir = dirname(__FILE__);
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
/*
|
55 |
$import=Mage::getModel('sinchimport/sinch');
|
30 |
|
31 |
echo "Start import <br>";
|
32 |
$dir = dirname(__FILE__);
|
33 |
+
$php_run_string_array = split(";", $sinch->php_run_strings);
|
34 |
+
foreach($php_run_string_array as $php_run_string){
|
35 |
+
exec("nohup ".$php_run_string." ".$dir."/../sinch_import_start_ajax.php > /dev/null & echo $!", $out);
|
36 |
+
sleep(1);
|
37 |
+
if (($out[0] > 0) && !$sinch->is_imort_not_run()){
|
38 |
+
break;
|
39 |
+
}
|
40 |
+
}
|
41 |
|
42 |
/*
|
43 |
$import=Mage::getModel('sinchimport/sinch');
|
56 |
|
57 |
echo "Start Stock & Price import <br>";
|
58 |
$dir = dirname(__FILE__);
|
59 |
+
$php_run_string_array = split(";", $sinch->php_run_strings);
|
60 |
+
foreach($php_run_string_array as $php_run_string){
|
61 |
+
exec("nohup ".$php_run_string." ".$dir."/../stock_price_sinch_import_start_ajax.php > /dev/null & echo $!", $out);
|
62 |
+
sleep(1);
|
63 |
+
if (($out[0] > 0) && !$sinch->is_imort_not_run()){
|
64 |
+
break;
|
65 |
+
}
|
66 |
+
}
|
67 |
|
68 |
/*
|
69 |
$import=Mage::getModel('sinchimport/sinch');
|
app/code/local/Bintime/Sinchimport/etc/config.xml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
<modules>
|
6 |
<Bintime_Sinchimport>
|
7 |
-
<version>3.0.
|
8 |
<depends>
|
9 |
<!-- no dependencies -->
|
10 |
</depends>
|
@@ -186,6 +186,20 @@
|
|
186 |
</admin>
|
187 |
|
188 |
<adminhtml>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
<acl>
|
190 |
<resources>
|
191 |
<admin>
|
@@ -216,6 +230,15 @@
|
|
216 |
</mage_adminhtml>
|
217 |
</modules>
|
218 |
</translate>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
</adminhtml>
|
220 |
|
221 |
<default>
|
4 |
|
5 |
<modules>
|
6 |
<Bintime_Sinchimport>
|
7 |
+
<version>3.0.3</version>
|
8 |
<depends>
|
9 |
<!-- no dependencies -->
|
10 |
</depends>
|
186 |
</admin>
|
187 |
|
188 |
<adminhtml>
|
189 |
+
<menu>
|
190 |
+
<sinch translate="title">
|
191 |
+
<title>Stock in the Channel</title>
|
192 |
+
<sort_order>200</sort_order>
|
193 |
+
<children>
|
194 |
+
<sinchimport translate="title">
|
195 |
+
<sort_order>10</sort_order>
|
196 |
+
<title>Stock In The Channel Import</title>
|
197 |
+
<action>adminhtml/system_config/edit/section/sinchimport_root</action>
|
198 |
+
</sinchimport>
|
199 |
+
</children>
|
200 |
+
</sinch>
|
201 |
+
</menu>
|
202 |
+
|
203 |
<acl>
|
204 |
<resources>
|
205 |
<admin>
|
230 |
</mage_adminhtml>
|
231 |
</modules>
|
232 |
</translate>
|
233 |
+
|
234 |
+
<layout>
|
235 |
+
<updates>
|
236 |
+
<sinchimport>
|
237 |
+
<file>sinchimport.xml</file>
|
238 |
+
</sinchimport>
|
239 |
+
</updates>
|
240 |
+
</layout>
|
241 |
+
|
242 |
</adminhtml>
|
243 |
|
244 |
<default>
|
app/code/local/Bintime/Sinchimport/etc/system.xml
CHANGED
@@ -32,7 +32,7 @@
|
|
32 |
<login translate="label">
|
33 |
<label>FTP User Name</label>
|
34 |
<frontend_type>text</frontend_type>
|
35 |
-
<sort_order>
|
36 |
<show_in_default>1</show_in_default>
|
37 |
<show_in_website>1</show_in_website>
|
38 |
<show_in_store>1</show_in_store>
|
@@ -64,6 +64,15 @@
|
|
64 |
<show_in_website>1</show_in_website>
|
65 |
<show_in_store>1</show_in_store>
|
66 |
</replace_category>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
<!--
|
68 |
<price_breaks translate="label">
|
69 |
<label>Inser price breaks (insert ranges like 0-10; 10-100; etc.)</label>
|
32 |
<login translate="label">
|
33 |
<label>FTP User Name</label>
|
34 |
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>15</sort_order>
|
36 |
<show_in_default>1</show_in_default>
|
37 |
<show_in_website>1</show_in_website>
|
38 |
<show_in_store>1</show_in_store>
|
64 |
<show_in_website>1</show_in_website>
|
65 |
<show_in_store>1</show_in_store>
|
66 |
</replace_category>
|
67 |
+
<replace_products>
|
68 |
+
<label>Merge or Overwrite Products</label>
|
69 |
+
<frontend_type>select</frontend_type>
|
70 |
+
<source_model>sinchimport/system_config_ProdRewrite</source_model>
|
71 |
+
<sort_order>40</sort_order>
|
72 |
+
<show_in_default>1</show_in_default>
|
73 |
+
<show_in_website>1</show_in_website>
|
74 |
+
<show_in_store>1</show_in_store>
|
75 |
+
</replace_products>
|
76 |
<!--
|
77 |
<price_breaks translate="label">
|
78 |
<label>Inser price breaks (insert ranges like 0-10; 10-100; etc.)</label>
|
app/code/local/Bintime/Sinchimport/sinch_import_start_ajax.php
CHANGED
@@ -6,7 +6,6 @@
|
|
6 |
|
7 |
$import=Mage::getModel('sinchimport/sinch');
|
8 |
|
9 |
-
|
10 |
$import->run_sinch_import();
|
11 |
|
12 |
$import->addImportStatus('Finish import', 1);
|
6 |
|
7 |
$import=Mage::getModel('sinchimport/sinch');
|
8 |
|
|
|
9 |
$import->run_sinch_import();
|
10 |
|
11 |
$import->addImportStatus('Finish import', 1);
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/filter_sinch_products_s.sql
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
DROP PROCEDURE IF EXISTS `filter_sinch_products_s`;
|
2 |
delimiter =/=
|
|
|
3 |
CREATE PROCEDURE `filter_sinch_products_s`(
|
4 |
IN arg_table INT,
|
5 |
IN arg_category_id INT,
|
@@ -9,102 +10,198 @@ CREATE PROCEDURE `filter_sinch_products_s`(
|
|
9 |
IN arg_greatest INT
|
10 |
)
|
11 |
BEGIN
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
CREATE TEMPORARY TABLE `tmp_result`(
|
15 |
-
`entity_id` int(10) unsigned,
|
16 |
-
`category_id` int(10) unsigned,
|
17 |
-
`product_id` int,
|
18 |
-
`sinch_category_id` int,
|
19 |
-
`name` varchar(255),
|
20 |
-
`image` varchar(255),
|
21 |
-
`supplier_id` int,
|
22 |
-
`category_feature_id` int,
|
23 |
-
`feature_id` int,
|
24 |
-
`feature_name` varchar(255),
|
25 |
-
`feature_value` text
|
26 |
-
);
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
69 |
|
70 |
-
|
71 |
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
@where,
|
100 |
-
|
101 |
-
|
|
|
102 |
|
103 |
-
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
|
109 |
END=/=
|
|
|
110 |
delimiter ;
|
1 |
DROP PROCEDURE IF EXISTS `filter_sinch_products_s`;
|
2 |
delimiter =/=
|
3 |
+
|
4 |
CREATE PROCEDURE `filter_sinch_products_s`(
|
5 |
IN arg_table INT,
|
6 |
IN arg_category_id INT,
|
10 |
IN arg_greatest INT
|
11 |
)
|
12 |
BEGIN
|
13 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
14 |
+
|
15 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
16 |
+
`entity_id` int(10) unsigned,
|
17 |
+
`category_id` int(10) unsigned,
|
18 |
+
`product_id` int,
|
19 |
+
`sinch_category_id` int,
|
20 |
+
`name` varchar(255),
|
21 |
+
`image` varchar(255),
|
22 |
+
`supplier_id` int,
|
23 |
+
`category_feature_id` int,
|
24 |
+
`feature_id` int,
|
25 |
+
`feature_name` varchar(255),
|
26 |
+
`feature_value` text
|
27 |
+
);
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
IF arg_image = 1 THEN
|
31 |
+
INSERT INTO `tmp_result` (
|
32 |
+
entity_id,
|
33 |
+
category_id,
|
34 |
+
product_id,
|
35 |
+
sinch_category_id,
|
36 |
+
`name`,
|
37 |
+
`image`,
|
38 |
+
supplier_id,
|
39 |
+
category_feature_id,
|
40 |
+
feature_id,
|
41 |
+
feature_name,
|
42 |
+
feature_value
|
43 |
+
)(
|
44 |
+
SELECT
|
45 |
+
E.entity_id,
|
46 |
+
PCind.category_id,
|
47 |
+
E.entity_id,
|
48 |
+
PCind.category_id as `sinch_category`,
|
49 |
+
PR.`product_name`,
|
50 |
+
PR.main_image_url,
|
51 |
+
PR.sinch_manufacturer_id,
|
52 |
+
CF.category_feature_id,
|
53 |
+
CF.category_feature_id,
|
54 |
+
CF.`feature_name`,
|
55 |
+
RV.`text`
|
56 |
+
FROM catalog_product_entity E
|
57 |
+
INNER JOIN catalog_category_product_index PCind
|
58 |
+
ON (E.entity_id = PCind.product_id)
|
59 |
+
INNER JOIN stINch_categories_mapping scm
|
60 |
+
ON PCind.category_id=scm.shop_entity_id
|
61 |
+
INNER JOIN stINch_categories_features CF
|
62 |
+
ON (scm.store_category_id=CF.store_category_id)
|
63 |
+
INNER JOIN stINch_products PR
|
64 |
+
ON (PR.store_product_id = E.store_product_id)
|
65 |
+
INNER JOIN stINch_product_features PF
|
66 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
67 |
+
INNER JOIN stINch_restricted_values RV
|
68 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
69 |
+
WHERE
|
70 |
+
scm.shop_entity_id = arg_category_id
|
71 |
+
AND PR.main_image_url <> ''
|
72 |
+
);
|
73 |
|
74 |
+
ELSE
|
75 |
|
76 |
+
INSERT INTO `tmp_result` (
|
77 |
+
entity_id,
|
78 |
+
category_id,
|
79 |
+
product_id,
|
80 |
+
sinch_category_id,
|
81 |
+
`name`,
|
82 |
+
`image`,
|
83 |
+
supplier_id,
|
84 |
+
category_feature_id,
|
85 |
+
feature_id,
|
86 |
+
feature_name,
|
87 |
+
feature_value
|
88 |
+
)(
|
89 |
+
SELECT
|
90 |
+
E.entity_id,
|
91 |
+
PCind.category_id,
|
92 |
+
E.entity_id,
|
93 |
+
PCind.category_id as `sinch_category`,
|
94 |
+
PR.`product_name`,
|
95 |
+
PR.main_image_url,
|
96 |
+
PR.sinch_manufacturer_id,
|
97 |
+
CF.category_feature_id,
|
98 |
+
CF.category_feature_id,
|
99 |
+
CF.`feature_name`,
|
100 |
+
RV.`text`
|
101 |
+
FROM catalog_product_entity E
|
102 |
+
INNER JOIN catalog_category_product_index PCind
|
103 |
+
ON (E.entity_id = PCind.product_id)
|
104 |
+
INNER JOIN stINch_categories_mapping scm
|
105 |
+
ON PCind.category_id=scm.shop_entity_id
|
106 |
+
INNER JOIN stINch_categories_features CF
|
107 |
+
ON (scm.store_category_id=CF.store_category_id)
|
108 |
+
INNER JOIN stINch_products PR
|
109 |
+
ON (PR.store_product_id = E.store_product_id)
|
110 |
+
INNER JOIN stINch_product_features PF
|
111 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
112 |
+
INNER JOIN stINch_restricted_values RV
|
113 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
114 |
+
WHERE
|
115 |
+
scm.shop_entity_id = arg_category_id
|
116 |
|
117 |
+
);
|
118 |
|
119 |
+
END IF;
|
120 |
|
121 |
+
IF (SELECT COUNT(*) FROM FilterListOfFeatures) > 0 THEN
|
122 |
+
SET @query = CONCAT('
|
123 |
+
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
124 |
+
entity_id,
|
125 |
+
category_id,
|
126 |
+
product_id,
|
127 |
+
sinch_category_id,
|
128 |
+
`name`,
|
129 |
+
`image`,
|
130 |
+
supplier_id,
|
131 |
+
category_feature_id,
|
132 |
+
feature_id,
|
133 |
+
feature_name,
|
134 |
+
feature_value
|
135 |
+
)(
|
136 |
+
SELECT
|
137 |
+
TR.entity_id,
|
138 |
+
TR.category_id,
|
139 |
+
TR.product_id,
|
140 |
+
TR.sinch_category_id,
|
141 |
+
TR.`name`,
|
142 |
+
TR.`image`,
|
143 |
+
TR.supplier_id,
|
144 |
+
TR.category_feature_id,
|
145 |
+
TR.feature_id,
|
146 |
+
TR.feature_name,
|
147 |
+
TR.feature_value
|
148 |
+
FROM `tmp_result` AS TR
|
149 |
+
INNER JOIN `FilterListOfFeatures` AS LF
|
150 |
+
ON (TR.category_feature_id = LF.category_feature_id)
|
151 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
152 |
+
)
|
153 |
+
');
|
154 |
|
155 |
+
ELSE
|
156 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
157 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
158 |
+
ELSE
|
159 |
+
IF arg_least IS null THEN
|
160 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
161 |
+
ELSE
|
162 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
163 |
+
END IF;
|
164 |
+
END IF;
|
165 |
|
166 |
+
SET @query = CONCAT('
|
167 |
+
INSERT INTO `SinchFilterResult_', arg_table, '` (
|
168 |
+
entity_id,
|
169 |
+
category_id,
|
170 |
+
product_id,
|
171 |
+
sinch_category_id,
|
172 |
+
`name`,
|
173 |
+
`image`,
|
174 |
+
supplier_id,
|
175 |
+
category_feature_id,
|
176 |
+
feature_id,
|
177 |
+
feature_name,
|
178 |
+
feature_value
|
179 |
+
)(
|
180 |
+
SELECT
|
181 |
+
TR.entity_id,
|
182 |
+
TR.category_id,
|
183 |
+
TR.product_id,
|
184 |
+
TR.sinch_category_id,
|
185 |
+
TR.`name`,
|
186 |
+
TR.`image`,
|
187 |
+
TR.supplier_id,
|
188 |
+
TR.category_feature_id,
|
189 |
+
TR.feature_id,
|
190 |
+
TR.feature_name,
|
191 |
+
TR.feature_value
|
192 |
+
FROM `tmp_result` AS TR
|
193 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
194 |
@where,
|
195 |
+
'GROUP BY entity_id
|
196 |
+
)
|
197 |
+
');
|
198 |
|
199 |
+
END IF;
|
200 |
|
201 |
+
PREPARE myquery FROM @query;
|
202 |
+
EXECUTE myquery;
|
203 |
+
DROP PREPARE myquery;
|
204 |
|
205 |
END=/=
|
206 |
+
|
207 |
delimiter ;
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.9-0.2.0.php
CHANGED
@@ -13,7 +13,6 @@ $installer->run("
|
|
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),
|
@@ -31,7 +30,6 @@ $installer->run("
|
|
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),
|
@@ -56,7 +54,6 @@ $installer->run("
|
|
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)
|
13 |
shop_store_product_id int(11),
|
14 |
shop_sinch_product_id int(11),
|
15 |
sku varchar(64) default NULL,
|
|
|
16 |
store_product_id int(11),
|
17 |
sinch_product_id int(11),
|
18 |
product_sku varchar(255),
|
30 |
|
31 |
$installer->run("
|
32 |
CREATE TABLE IF NOT EXISTS ".$installer->getTable('stINch_products')."(
|
|
|
33 |
store_product_id int(11),
|
34 |
sinch_product_id int(11),
|
35 |
product_sku varchar(255),
|
54 |
products_viewed int(5) default '0',
|
55 |
products_seo_url varchar(100) NOT NULL,
|
56 |
manufacturer_name varchar(255) default NULL,
|
|
|
57 |
KEY(store_product_id),
|
58 |
KEY(sinch_manufacturer_id),
|
59 |
KEY(store_category_id)
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.1-0.2.2.php
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
+
$config = $installer->getConnection()->getConfig();
|
7 |
+
$cnx = mysql_connect($config['host'], $config['username'], $config['password']);
|
8 |
+
if (!$cnx) {
|
9 |
+
throw new Exception('Failed to connect to database.');
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!mysql_select_db($config['dbname'])) {
|
13 |
+
throw new Exception('Failed to select a database.');
|
14 |
+
}
|
15 |
+
|
16 |
+
$installer->startSetup();
|
17 |
+
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
18 |
+
|
19 |
+
$query = "
|
20 |
+
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
21 |
+
IN arg_table INT,
|
22 |
+
IN arg_category_id INT,
|
23 |
+
IN arg_image INT,
|
24 |
+
IN arg_category_feature INT,
|
25 |
+
IN arg_least INT,
|
26 |
+
IN arg_greatest INT
|
27 |
+
)
|
28 |
+
BEGIN
|
29 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
30 |
+
|
31 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
32 |
+
`entity_id` int(10) unsigned,
|
33 |
+
`category_id` int(10) unsigned,
|
34 |
+
`product_id` int,
|
35 |
+
`sinch_category_id` int,
|
36 |
+
`name` varchar(255),
|
37 |
+
`image` varchar(255),
|
38 |
+
`supplier_id` int,
|
39 |
+
`category_feature_id` int,
|
40 |
+
`feature_id` int,
|
41 |
+
`feature_name` varchar(255),
|
42 |
+
`feature_value` text
|
43 |
+
);
|
44 |
+
|
45 |
+
|
46 |
+
IF arg_image = 1 THEN
|
47 |
+
INSERT INTO `tmp_result` (
|
48 |
+
entity_id,
|
49 |
+
category_id,
|
50 |
+
product_id,
|
51 |
+
sinch_category_id,
|
52 |
+
`name`,
|
53 |
+
`image`,
|
54 |
+
supplier_id,
|
55 |
+
category_feature_id,
|
56 |
+
feature_id,
|
57 |
+
feature_name,
|
58 |
+
feature_value
|
59 |
+
)(
|
60 |
+
SELECT
|
61 |
+
E.entity_id,
|
62 |
+
PCind.category_id,
|
63 |
+
E.entity_id,
|
64 |
+
PCind.category_id as `sinch_category`,
|
65 |
+
PR.`product_name`,
|
66 |
+
PR.main_image_url,
|
67 |
+
PR.sinch_manufacturer_id,
|
68 |
+
CF.category_feature_id,
|
69 |
+
CF.category_feature_id,
|
70 |
+
CF.`feature_name`,
|
71 |
+
RV.`text`
|
72 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
73 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
74 |
+
ON (E.entity_id = PCind.product_id)
|
75 |
+
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
76 |
+
ON PCind.category_id=scm.shop_entity_id
|
77 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
78 |
+
ON (scm.store_category_id=CF.store_category_id)
|
79 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
80 |
+
ON (PR.store_product_id = E.store_product_id)
|
81 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
82 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
83 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
84 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
85 |
+
WHERE
|
86 |
+
scm.shop_entity_id = arg_category_id
|
87 |
+
AND PR.main_image_url <> ''
|
88 |
+
);
|
89 |
+
|
90 |
+
ELSE
|
91 |
+
|
92 |
+
INSERT INTO `tmp_result` (
|
93 |
+
entity_id,
|
94 |
+
category_id,
|
95 |
+
product_id,
|
96 |
+
sinch_category_id,
|
97 |
+
`name`,
|
98 |
+
`image`,
|
99 |
+
supplier_id,
|
100 |
+
category_feature_id,
|
101 |
+
feature_id,
|
102 |
+
feature_name,
|
103 |
+
feature_value
|
104 |
+
)(
|
105 |
+
SELECT
|
106 |
+
E.entity_id,
|
107 |
+
PCind.category_id,
|
108 |
+
E.entity_id,
|
109 |
+
PCind.category_id as `sinch_category`,
|
110 |
+
PR.`product_name`,
|
111 |
+
PR.main_image_url,
|
112 |
+
PR.sinch_manufacturer_id,
|
113 |
+
CF.category_feature_id,
|
114 |
+
CF.category_feature_id,
|
115 |
+
CF.`feature_name`,
|
116 |
+
RV.`text`
|
117 |
+
FROM ".$installer->getTable('catalog_product_entity')." E
|
118 |
+
INNER JOIN ".$installer->getTable('catalog_category_product_index')." PCind
|
119 |
+
ON (E.entity_id = PCind.product_id)
|
120 |
+
INNER JOIN ".$installer->getTable('stINch_categories_mapping')." scm
|
121 |
+
ON PCind.category_id=scm.shop_entity_id
|
122 |
+
INNER JOIN ".$installer->getTable('stINch_categories_features')." CF
|
123 |
+
ON (scm.store_category_id=CF.store_category_id)
|
124 |
+
INNER JOIN ".$installer->getTable('stINch_products')." PR
|
125 |
+
ON (PR.store_product_id = E.store_product_id)
|
126 |
+
INNER JOIN ".$installer->getTable('stINch_product_features')." PF
|
127 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
128 |
+
INNER JOIN ".$installer->getTable('stINch_restricted_values')." RV
|
129 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
130 |
+
WHERE
|
131 |
+
scm.shop_entity_id = arg_category_id
|
132 |
+
|
133 |
+
);
|
134 |
+
|
135 |
+
END IF;
|
136 |
+
|
137 |
+
IF (SELECT COUNT(*) FROM `".$installer->getTable('FilterListOfFeatures')."`) > 0 THEN
|
138 |
+
SET @query = CONCAT('
|
139 |
+
INSERT INTO `".$installer->getTable('SinchFilterResult_')."', arg_table, '` (
|
140 |
+
entity_id,
|
141 |
+
category_id,
|
142 |
+
product_id,
|
143 |
+
sinch_category_id,
|
144 |
+
`name`,
|
145 |
+
`image`,
|
146 |
+
supplier_id,
|
147 |
+
category_feature_id,
|
148 |
+
feature_id,
|
149 |
+
feature_name,
|
150 |
+
feature_value
|
151 |
+
)(
|
152 |
+
SELECT
|
153 |
+
TR.entity_id,
|
154 |
+
TR.category_id,
|
155 |
+
TR.product_id,
|
156 |
+
TR.sinch_category_id,
|
157 |
+
TR.`name`,
|
158 |
+
TR.`image`,
|
159 |
+
TR.supplier_id,
|
160 |
+
TR.category_feature_id,
|
161 |
+
TR.feature_id,
|
162 |
+
TR.feature_name,
|
163 |
+
TR.feature_value
|
164 |
+
FROM `tmp_result` AS TR
|
165 |
+
INNER JOIN `".$installer->getTable('FilterListOfFeatures')."` AS LF
|
166 |
+
ON (TR.category_feature_id = LF.category_feature_id)
|
167 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
168 |
+
)
|
169 |
+
');
|
170 |
+
|
171 |
+
ELSE
|
172 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
173 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
174 |
+
ELSE
|
175 |
+
IF arg_least IS null THEN
|
176 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
177 |
+
ELSE
|
178 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
179 |
+
END IF;
|
180 |
+
END IF;
|
181 |
+
|
182 |
+
SET @query = CONCAT('
|
183 |
+
INSERT INTO `".$installer->getTable('SinchFilterResult_')."', arg_table, '` (
|
184 |
+
entity_id,
|
185 |
+
category_id,
|
186 |
+
product_id,
|
187 |
+
sinch_category_id,
|
188 |
+
`name`,
|
189 |
+
`image`,
|
190 |
+
supplier_id,
|
191 |
+
category_feature_id,
|
192 |
+
feature_id,
|
193 |
+
feature_name,
|
194 |
+
feature_value
|
195 |
+
)(
|
196 |
+
SELECT
|
197 |
+
TR.entity_id,
|
198 |
+
TR.category_id,
|
199 |
+
TR.product_id,
|
200 |
+
TR.sinch_category_id,
|
201 |
+
TR.`name`,
|
202 |
+
TR.`image`,
|
203 |
+
TR.supplier_id,
|
204 |
+
TR.category_feature_id,
|
205 |
+
TR.feature_id,
|
206 |
+
TR.feature_name,
|
207 |
+
TR.feature_value
|
208 |
+
FROM `tmp_result` AS TR
|
209 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
210 |
+
@where,
|
211 |
+
'GROUP BY entity_id
|
212 |
+
)
|
213 |
+
');
|
214 |
+
|
215 |
+
END IF;
|
216 |
+
|
217 |
+
PREPARE myquery FROM @query;
|
218 |
+
EXECUTE myquery;
|
219 |
+
DROP PREPARE myquery;
|
220 |
+
|
221 |
+
END
|
222 |
+
";
|
223 |
+
|
224 |
+
if (!mysql_query($query, $cnx)) {
|
225 |
+
throw new Exception("Failed to create stored procedure");
|
226 |
+
}
|
227 |
+
|
228 |
+
mysql_close($cnx);
|
229 |
+
|
230 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.0-3.0.1.php
ADDED
@@ -0,0 +1,307 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
|
4 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
5 |
+
$config = $installer->getConnection()->getConfig();
|
6 |
+
$cnx = mysql_connect($config['host'], $config['username'], $config['password']);
|
7 |
+
if (!$cnx) {
|
8 |
+
throw new Exception('Failed to connect to database.');
|
9 |
+
}
|
10 |
+
|
11 |
+
if (!mysql_select_db($config['dbname'])) {
|
12 |
+
throw new Exception('Failed to select a database.');
|
13 |
+
}
|
14 |
+
|
15 |
+
$installer->startSetup();
|
16 |
+
|
17 |
+
|
18 |
+
$attr_text=array(
|
19 |
+
'reviews' => 'Reviews'
|
20 |
+
);
|
21 |
+
|
22 |
+
foreach($attr_text as $key=>$value){
|
23 |
+
|
24 |
+
$installer->addAttribute('catalog_product', $key,array(
|
25 |
+
'label' => $value,
|
26 |
+
'type' => 'text',
|
27 |
+
'input' => 'textarea',
|
28 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
29 |
+
'frontend' => '',
|
30 |
+
'source' => '',
|
31 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
32 |
+
'visible' => true,
|
33 |
+
'required' => false,
|
34 |
+
'user_defined' => false,
|
35 |
+
'searchable' => false,
|
36 |
+
'filterable' => false,
|
37 |
+
'comparable' => false,
|
38 |
+
'visible_on_front' => true,
|
39 |
+
'is_visible_on_front' => 1,
|
40 |
+
'is_html_allowed_on_front' => 1,
|
41 |
+
'visible_in_advanced_search' => false,
|
42 |
+
'unique' => false
|
43 |
+
));
|
44 |
+
|
45 |
+
$data=array(
|
46 |
+
'is_visible_on_front' => 1,
|
47 |
+
'is_html_allowed_on_front' => 1
|
48 |
+
);
|
49 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
50 |
+
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
51 |
+
$installer->updateAttribute($entityTypeId, $id, $data);
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
$installer->run("
|
59 |
+
INSERT ".$installer->getTable('stINch_sinchcheck')."(
|
60 |
+
caption,
|
61 |
+
descr,
|
62 |
+
check_code,
|
63 |
+
check_value,
|
64 |
+
check_measure,
|
65 |
+
error_msg, fix_msg
|
66 |
+
)
|
67 |
+
VALUE(
|
68 |
+
'Conflicts with installed plug-ins',
|
69 |
+
'checking conflicts with installed plug-ins and showing how to fix it',
|
70 |
+
'conflictwithinstalledmodules',
|
71 |
+
'Conflicts with installed plug-ins :',
|
72 |
+
'',
|
73 |
+
'Some of installed plug-ins rewrite Sinchimport module config',
|
74 |
+
'You can uninstall them or make inactive in [shop dir]/app/etc/modules '
|
75 |
+
);
|
76 |
+
");
|
77 |
+
|
78 |
+
|
79 |
+
$installer->run("DROP PROCEDURE IF EXISTS ".$installer->getTable('filter_sinch_products_s'));
|
80 |
+
|
81 |
+
$query = "
|
82 |
+
CREATE PROCEDURE ".$installer->getTable('filter_sinch_products_s')."(
|
83 |
+
IN arg_table INT,
|
84 |
+
IN arg_category_id INT,
|
85 |
+
IN arg_image INT,
|
86 |
+
IN arg_category_feature INT,
|
87 |
+
IN arg_least INT,
|
88 |
+
IN arg_greatest INT,
|
89 |
+
IN arg_table_prefix VARCHAR(255)
|
90 |
+
)
|
91 |
+
BEGIN
|
92 |
+
DROP TABLE IF EXISTS `tmp_result`;
|
93 |
+
|
94 |
+
CREATE TEMPORARY TABLE `tmp_result`(
|
95 |
+
`entity_id` int(10) unsigned,
|
96 |
+
`category_id` int(10) unsigned,
|
97 |
+
`product_id` int,
|
98 |
+
`sinch_category_id` int,
|
99 |
+
`name` varchar(255),
|
100 |
+
`image` varchar(255),
|
101 |
+
`supplier_id` int,
|
102 |
+
`category_feature_id` int,
|
103 |
+
`feature_id` int,
|
104 |
+
`feature_name` varchar(255),
|
105 |
+
`feature_value` text
|
106 |
+
);
|
107 |
+
|
108 |
+
|
109 |
+
IF arg_image = 1 THEN
|
110 |
+
SET @updquery = CONCAT('
|
111 |
+
|
112 |
+
INSERT INTO `tmp_result` (
|
113 |
+
entity_id,
|
114 |
+
category_id,
|
115 |
+
product_id,
|
116 |
+
sinch_category_id,
|
117 |
+
`name`,
|
118 |
+
`image`,
|
119 |
+
supplier_id,
|
120 |
+
category_feature_id,
|
121 |
+
feature_id,
|
122 |
+
feature_name,
|
123 |
+
feature_value
|
124 |
+
)(
|
125 |
+
SELECT
|
126 |
+
E.entity_id,
|
127 |
+
PCind.category_id,
|
128 |
+
E.entity_id,
|
129 |
+
PCind.category_id as `sinch_category`,
|
130 |
+
PR.`product_name`,
|
131 |
+
PR.main_image_url,
|
132 |
+
PR.sinch_manufacturer_id,
|
133 |
+
CF.category_feature_id,
|
134 |
+
CF.category_feature_id,
|
135 |
+
CF.`feature_name`,
|
136 |
+
RV.`text`
|
137 |
+
FROM ', arg_table_prefix, 'catalog_product_entity E
|
138 |
+
INNER JOIN ', arg_table_prefix, 'catalog_category_product_index PCind
|
139 |
+
ON (E.entity_id = PCind.product_id)
|
140 |
+
INNER JOIN ', arg_table_prefix, 'stINch_categories_mapping scm
|
141 |
+
ON PCind.category_id=scm.shop_entity_id
|
142 |
+
INNER JOIN ',arg_table_prefix, 'stINch_categories_features CF
|
143 |
+
ON (scm.store_category_id=CF.store_category_id)
|
144 |
+
INNER JOIN ',arg_table_prefix, 'stINch_products PR
|
145 |
+
ON (PR.store_product_id = E.store_product_id)
|
146 |
+
INNER JOIN ',arg_table_prefix, 'stINch_product_features PF
|
147 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
148 |
+
INNER JOIN ',arg_table_prefix, 'stINch_restricted_values RV
|
149 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
150 |
+
WHERE
|
151 |
+
scm.shop_entity_id = ', arg_category_id, '
|
152 |
+
AND PR.main_image_url <> \'\'
|
153 |
+
)
|
154 |
+
');
|
155 |
+
ELSE
|
156 |
+
SET @updquery = CONCAT('
|
157 |
+
|
158 |
+
INSERT INTO `tmp_result` (
|
159 |
+
entity_id,
|
160 |
+
category_id,
|
161 |
+
product_id,
|
162 |
+
sinch_category_id,
|
163 |
+
`name`,
|
164 |
+
`image`,
|
165 |
+
supplier_id,
|
166 |
+
category_feature_id,
|
167 |
+
feature_id,
|
168 |
+
feature_name,
|
169 |
+
feature_value
|
170 |
+
)(
|
171 |
+
SELECT
|
172 |
+
E.entity_id,
|
173 |
+
PCind.category_id,
|
174 |
+
E.entity_id,
|
175 |
+
PCind.category_id as `sinch_category`,
|
176 |
+
PR.`product_name`,
|
177 |
+
PR.main_image_url,
|
178 |
+
PR.sinch_manufacturer_id,
|
179 |
+
CF.category_feature_id,
|
180 |
+
CF.category_feature_id,
|
181 |
+
CF.`feature_name`,
|
182 |
+
RV.`text`
|
183 |
+
FROM ', arg_table_prefix ,'catalog_product_entity E
|
184 |
+
INNER JOIN ', arg_table_prefix, 'catalog_category_product_index PCind
|
185 |
+
ON (E.entity_id = PCind.product_id)
|
186 |
+
INNER JOIN ', arg_table_prefix, 'stINch_categories_mapping scm
|
187 |
+
ON PCind.category_id=scm.shop_entity_id
|
188 |
+
INNER JOIN ', arg_table_prefix, 'stINch_categories_features CF
|
189 |
+
ON (scm.store_category_id=CF.store_category_id)
|
190 |
+
INNER JOIN ', arg_table_prefix, 'stINch_products PR
|
191 |
+
ON (PR.store_product_id = E.store_product_id)
|
192 |
+
INNER JOIN ', arg_table_prefix, 'stINch_product_features PF
|
193 |
+
ON (PR.sinch_product_id = PF.sinch_product_id )
|
194 |
+
INNER JOIN ', arg_table_prefix, 'stINch_restricted_values RV
|
195 |
+
ON (PF.restricted_value_id=RV.restricted_value_id)
|
196 |
+
WHERE
|
197 |
+
scm.shop_entity_id = ', arg_category_id, '
|
198 |
+
|
199 |
+
)
|
200 |
+
');
|
201 |
+
END IF;
|
202 |
+
|
203 |
+
PREPARE myquery FROM @updquery;
|
204 |
+
EXECUTE myquery;
|
205 |
+
DROP PREPARE myquery;
|
206 |
+
|
207 |
+
SET @filter_features_count = 0;
|
208 |
+
SET @ifquery = CONCAT('SELECT COUNT(*) INTO @filter_features_count FROM `', arg_table_prefix, 'FilterListOfFeatures`');
|
209 |
+
PREPARE myquery FROM @ifquery;
|
210 |
+
EXECUTE myquery;
|
211 |
+
DROP PREPARE myquery;
|
212 |
+
|
213 |
+
IF (@filter_features_count) > 0 THEN
|
214 |
+
SET @query = CONCAT('
|
215 |
+
INSERT INTO `', arg_table_prefix, 'SinchFilterResult_', arg_table, '` (
|
216 |
+
entity_id,
|
217 |
+
category_id,
|
218 |
+
product_id,
|
219 |
+
sinch_category_id,
|
220 |
+
`name`,
|
221 |
+
`image`,
|
222 |
+
supplier_id,
|
223 |
+
category_feature_id,
|
224 |
+
feature_id,
|
225 |
+
feature_name,
|
226 |
+
feature_value
|
227 |
+
)(
|
228 |
+
SELECT
|
229 |
+
TR.entity_id,
|
230 |
+
TR.category_id,
|
231 |
+
TR.product_id,
|
232 |
+
TR.sinch_category_id,
|
233 |
+
TR.`name`,
|
234 |
+
TR.`image`,
|
235 |
+
TR.supplier_id,
|
236 |
+
TR.category_feature_id,
|
237 |
+
TR.feature_id,
|
238 |
+
TR.feature_name,
|
239 |
+
TR.feature_value
|
240 |
+
FROM `tmp_result` AS TR
|
241 |
+
INNER JOIN `', arg_table_prefix, 'FilterListOfFeatures` AS LF
|
242 |
+
ON (TR.category_feature_id = LF.category_feature_id)
|
243 |
+
WHERE TR.feature_value LIKE LF.feature_value GROUP BY entity_id
|
244 |
+
)
|
245 |
+
');
|
246 |
+
|
247 |
+
ELSE
|
248 |
+
IF (arg_least IS NOT null AND arg_greatest IS NOT null) THEN
|
249 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' AND TR.feature_value <', arg_greatest, ' ');
|
250 |
+
ELSE
|
251 |
+
IF arg_least IS null THEN
|
252 |
+
SET @where = CONCAT(' AND TR.feature_value < ', arg_greatest, ' ');
|
253 |
+
ELSE
|
254 |
+
SET @where = CONCAT(' AND TR.feature_value >= ', arg_least, ' ');
|
255 |
+
END IF;
|
256 |
+
END IF;
|
257 |
+
|
258 |
+
SET @query = CONCAT('
|
259 |
+
INSERT INTO `', arg_table_prefix, 'SinchFilterResult_', arg_table, '` (
|
260 |
+
entity_id,
|
261 |
+
category_id,
|
262 |
+
product_id,
|
263 |
+
sinch_category_id,
|
264 |
+
`name`,
|
265 |
+
`image`,
|
266 |
+
supplier_id,
|
267 |
+
category_feature_id,
|
268 |
+
feature_id,
|
269 |
+
feature_name,
|
270 |
+
feature_value
|
271 |
+
)(
|
272 |
+
SELECT
|
273 |
+
TR.entity_id,
|
274 |
+
TR.category_id,
|
275 |
+
TR.product_id,
|
276 |
+
TR.sinch_category_id,
|
277 |
+
TR.`name`,
|
278 |
+
TR.`image`,
|
279 |
+
TR.supplier_id,
|
280 |
+
TR.category_feature_id,
|
281 |
+
TR.feature_id,
|
282 |
+
TR.feature_name,
|
283 |
+
TR.feature_value
|
284 |
+
FROM `tmp_result` AS TR
|
285 |
+
WHERE TR.category_feature_id = \'', arg_category_feature, '\'',
|
286 |
+
@where,
|
287 |
+
'GROUP BY entity_id
|
288 |
+
)
|
289 |
+
');
|
290 |
+
|
291 |
+
END IF;
|
292 |
+
|
293 |
+
PREPARE myquery FROM @query;
|
294 |
+
EXECUTE myquery;
|
295 |
+
DROP PREPARE myquery;
|
296 |
+
|
297 |
+
END
|
298 |
+
";
|
299 |
+
|
300 |
+
if (!mysql_query($query, $cnx)) {
|
301 |
+
throw new Exception("Failed to create stored procedure".$query);
|
302 |
+
}
|
303 |
+
|
304 |
+
|
305 |
+
mysql_close($cnx);
|
306 |
+
|
307 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.1-3.0.2.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
$installer->run("
|
7 |
+
DROP TABLE IF EXISTS ".$installer->getTable('stINch_distributors').";
|
8 |
+
");
|
9 |
+
|
10 |
+
$installer->run("
|
11 |
+
CREATE TABLE ".$installer->getTable('stINch_distributors')."
|
12 |
+
(
|
13 |
+
distributor_id int(11),
|
14 |
+
distributor_name varchar(255),
|
15 |
+
website varchar(255),
|
16 |
+
KEY(distributor_id)
|
17 |
+
);
|
18 |
+
");
|
19 |
+
|
20 |
+
$installer->run("
|
21 |
+
DROP TABLE IF EXISTS ".$installer->getTable('stINch_distributors_stock_and_price').";
|
22 |
+
");
|
23 |
+
|
24 |
+
$installer->run("
|
25 |
+
CREATE TABLE ".$installer->getTable('stINch_distributors_stock_and_price')."
|
26 |
+
(
|
27 |
+
`store_product_id` int(11) DEFAULT NULL,
|
28 |
+
`distributor_id` int(11) DEFAULT NULL,
|
29 |
+
`stock` int(11) DEFAULT NULL,
|
30 |
+
`cost` decimal(15,4) DEFAULT NULL,
|
31 |
+
`distributor_sku` varchar(255) DEFAULT NULL,
|
32 |
+
`distributor_category` varchar(50) DEFAULT NULL,
|
33 |
+
`eta` varchar(50) DEFAULT NULL,
|
34 |
+
UNIQUE KEY `product_distri` (store_product_id, distributor_id)
|
35 |
+
);
|
36 |
+
");
|
37 |
+
|
38 |
+
|
39 |
+
$attr_text=array(
|
40 |
+
'sinch_search_cache' => 'Sinch Search Cache'
|
41 |
+
);
|
42 |
+
|
43 |
+
foreach($attr_text as $key=>$value){
|
44 |
+
|
45 |
+
$installer->addAttribute('catalog_product', $key,array(
|
46 |
+
'label' => $value,
|
47 |
+
'type' => 'text',
|
48 |
+
'input' => 'textarea',
|
49 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
50 |
+
'frontend' => '',
|
51 |
+
'source' => '',
|
52 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
53 |
+
'visible' => false,
|
54 |
+
'required' => false,
|
55 |
+
'user_defined' => false,
|
56 |
+
'searchable' => 1,
|
57 |
+
'filterable' => false,
|
58 |
+
'comparable' => false,
|
59 |
+
'visible_on_front' => true,
|
60 |
+
'is_visible_on_front' => 1,
|
61 |
+
'is_html_allowed_on_front' => 1,
|
62 |
+
'visible_in_advanced_search' => false,
|
63 |
+
'unique' => false
|
64 |
+
));
|
65 |
+
|
66 |
+
$installer->updateAttribute('catalog_product', $key, 'is_searchable', '1');
|
67 |
+
}
|
68 |
+
|
69 |
+
$attr_varchar=array(
|
70 |
+
'pdf_url' => 'PDF Url'
|
71 |
+
);
|
72 |
+
|
73 |
+
foreach($attr_varchar as $key=>$value){
|
74 |
+
|
75 |
+
$installer->addAttribute('catalog_product', $key,array(
|
76 |
+
'label' => $value,
|
77 |
+
'type' => 'varchar',
|
78 |
+
'input' => 'text',
|
79 |
+
'backend' => 'eav/entity_attribute_backend_array',
|
80 |
+
'frontend' => '',
|
81 |
+
'source' => '',
|
82 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
83 |
+
'visible' => true,
|
84 |
+
'required' => false,
|
85 |
+
'user_defined' => false,
|
86 |
+
'searchable' => false,
|
87 |
+
'filterable' => false,
|
88 |
+
'comparable' => false,
|
89 |
+
'visible_on_front' => true,
|
90 |
+
'visible_in_advanced_search' => false,
|
91 |
+
'unique' => false
|
92 |
+
));
|
93 |
+
|
94 |
+
|
95 |
+
$data=array(
|
96 |
+
'is_visible_on_front' => 1,
|
97 |
+
'is_html_allowed_on_front' => 1
|
98 |
+
);
|
99 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_product');
|
100 |
+
if ($id = $installer->getAttribute($entityTypeId, $key, 'attribute_id')) {
|
101 |
+
$installer->updateAttribute($entityTypeId, $id, $data);
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
$installer->endSetup();
|
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.2-3.0.3.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
//прямое подключение к базе необходимо для добавления хранимки
|
6 |
+
$config = $installer->getConnection()->getConfig();
|
7 |
+
$cnx = mysql_connect($config['host'], $config['username'], $config['password']);
|
8 |
+
if (!$cnx) {
|
9 |
+
throw new Exception('Failed to connect to database.');
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!mysql_select_db($config['dbname'])) {
|
13 |
+
throw new Exception('Failed to select a database.');
|
14 |
+
}
|
15 |
+
|
16 |
+
$installer->startSetup();
|
17 |
+
|
18 |
+
$installer->run("DROP FUNCTION IF EXISTS ".$installer->getTable('func_calc_price'));
|
19 |
+
|
20 |
+
$query = "
|
21 |
+
CREATE FUNCTION ".$installer->getTable('func_calc_price')." (price decimal(8,2) , marge decimal(10,2), fixed decimal(10,2), final_price decimal(10,2)) RETURNS decimal(8,2)
|
22 |
+
BEGIN
|
23 |
+
IF marge IS NOT NULL THEN
|
24 |
+
RETURN price + price * marge / 100;
|
25 |
+
END IF;
|
26 |
+
IF fixed IS NOT NULL THEN
|
27 |
+
RETURN price + fixed;
|
28 |
+
END IF;
|
29 |
+
IF final_price IS NOT NULL THEN
|
30 |
+
RETURN final_price;
|
31 |
+
END IF;
|
32 |
+
RETURN price;
|
33 |
+
END
|
34 |
+
";
|
35 |
+
|
36 |
+
if (!mysql_query($query, $cnx)) {
|
37 |
+
throw new Exception("Failed to create stored function");
|
38 |
+
}
|
39 |
+
|
40 |
+
mysql_close($cnx);
|
41 |
+
|
42 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/sinchimport.xml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
|
4 |
+
<!-- To add a tab on edit product page -->
|
5 |
+
<adminhtml_catalog_product_edit>
|
6 |
+
<reference name="product_tabs">
|
7 |
+
<action method="addTab">
|
8 |
+
<name>sinch_distributors_tab</name>
|
9 |
+
<block template="sinchimport/sinchdistributors.phtml">sinchimport/adminhtml_catalog_product_sinchdistributors</block>
|
10 |
+
</action>
|
11 |
+
</reference>
|
12 |
+
</adminhtml_catalog_product_edit>
|
13 |
+
<!-- To add a tab on edit product page -->
|
14 |
+
|
15 |
+
<!-- Change -->
|
16 |
+
<adminhtml_sales_order_view>
|
17 |
+
<reference name="head">
|
18 |
+
<action method="addJs"><file>mage/adminhtml/giftmessage.js</file></action>
|
19 |
+
<action method="addJs"><file>mage/adminhtml/giftoptions/tooltip.js</file></action>
|
20 |
+
</reference>
|
21 |
+
<reference name="content">
|
22 |
+
<block type="adminhtml/sales_order_view" name="sales_order_edit"></block>
|
23 |
+
</reference>
|
24 |
+
<reference name="left">
|
25 |
+
<block type="adminhtml/sales_order_view_tabs" name="sales_order_tabs">
|
26 |
+
<block type="adminhtml/sales_order_view_tab_info" name="order_tab_info" template="sales/order/view/tab/info.phtml">
|
27 |
+
<block type="adminhtml/sales_order_view_messages" name="order_messages"></block>
|
28 |
+
<block type="adminhtml/sales_order_view_info" name="order_info" template="sales/order/view/info.phtml"></block>
|
29 |
+
<block type="adminhtml/sales_order_view_items" name="order_items" template="sales/order/view/items.phtml">
|
30 |
+
<action method="addItemRender"><type>default</type><block>adminhtml/sales_order_view_items_renderer_default</block><template>sales/order/view/items/renderer/default.phtml</template></action>
|
31 |
+
<action method="addColumnRender"><column>qty</column><block>adminhtml/sales_items_column_qty</block><template>sales/items/column/qty.phtml</template></action>
|
32 |
+
<action method="addColumnRender"><column>name</column><block>adminhtml/sales_items_column_name</block><template>sinchimport/sales/items/column/name.phtml</template></action>
|
33 |
+
<action method="addColumnRender"><column>name</column><block>adminhtml/sales_items_column_name_grouped</block><template>sales/items/column/name.phtml</template><type>grouped</type></action>
|
34 |
+
<block type="core/text_list" name="order_item_extra_info" />
|
35 |
+
</block>
|
36 |
+
<block type="adminhtml/sales_order_payment" name="order_payment"/>
|
37 |
+
<block type="adminhtml/sales_order_view_history" name="order_history" template="sales/order/view/history.phtml"></block>
|
38 |
+
<block type="adminhtml/template" name="gift_options" template="sales/order/giftoptions.phtml">
|
39 |
+
<block type="adminhtml/sales_order_view_giftmessage" name="order_giftmessage" template="sales/order/view/giftmessa ge.phtml"></block>
|
40 |
+
</block>
|
41 |
+
<block type="adminhtml/sales_order_totals" name="order_totals" template="sales/order/totals.phtml">
|
42 |
+
<block type="adminhtml/sales_order_totals_tax" name="tax" template="sales/order/totals/tax.phtml" />
|
43 |
+
</block>
|
44 |
+
</block>
|
45 |
+
<action method="addTab"><name>order_info</name><block>order_tab_info</block></action>
|
46 |
+
<action method="addTab"><name>order_invoices</name><block>adminhtml/sales_order_view_tab_invoices</block></action>
|
47 |
+
<action method="addTab"><name>order_creditmemos</name><block>adminhtml/sales_order_view_tab_creditmemos</block></action>
|
48 |
+
<action method="addTab"><name>order_shipments</name><block>adminhtml/sales_order_view_tab_shipments</block></action>
|
49 |
+
<action method="addTab"><name>order_history</name><block>adminhtml/sales_order_view_tab_history</block></action>
|
50 |
+
<action method="addTab"><name>order_transactions</name><block>adminhtml/sales_order_view_tab_transactions</block></action>
|
51 |
+
</block>
|
52 |
+
</reference>
|
53 |
+
</adminhtml_sales_order_view>
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
</layout>
|
app/design/adminhtml/default/default/template/sinchimport/sales/items/column/name.phtml
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
/**
|
29 |
+
* @see Mage_Adminhtml_Block_Sales_Items_Column_Name
|
30 |
+
*/
|
31 |
+
?>
|
32 |
+
|
33 |
+
<?php if ($_item = $this->getItem()): ?>
|
34 |
+
<h5 class="title">
|
35 |
+
<span id="order_item_<?php echo $_item->getId() ?>_title"><?php echo $this->htmlEscape($_item->getName()) ?></span>
|
36 |
+
<span style="float:right"><a id="<?php echo $_product = "product_".$_item->getProduct()->getId()?>" >View Suppliers</a></span>
|
37 |
+
<div style="position: relative; left: 200px; top: -25px; background: #EA7601; width: 300px" id="<?php echo $_offers = "offers_".$_item->getProduct()->getId()?>"><?php echo Mage::getModel('sinchimport/sinch')->getSinchDistribotorsTableHtml($_item->getProduct()->getId())?></div>
|
38 |
+
</h5>
|
39 |
+
<script type="text/javascript">
|
40 |
+
$('<?php echo $_offers ?>').hide();
|
41 |
+
$('<?php echo $_offers ?>').up().observe('mouseover', function(){$('<?php echo $_offers ?>').show();});
|
42 |
+
$('<?php echo $_offers ?>').up().observe('mouseout', function(){$('<?php echo $_offers ?>').hide();});
|
43 |
+
</script>
|
44 |
+
|
45 |
+
<div><strong><?php echo $this->helper('sales')->__('SKU') ?>:</strong> <?php echo implode('<br />', Mage::helper('catalog')->splitSku($this->htmlEscape($this->getSku()))); ?></div>
|
46 |
+
<?php if ($this->getOrderOptions()): ?>
|
47 |
+
<dl class="item-options">
|
48 |
+
<?php foreach ($this->getOrderOptions() as $_option): ?>
|
49 |
+
<dt><?php echo $_option['label'] ?></dt>
|
50 |
+
<dd>
|
51 |
+
<?php if (isset($_option['custom_view']) && $_option['custom_view']): ?>
|
52 |
+
<?php echo $this->getCustomizedOptionValue($_option); ?>
|
53 |
+
<?php else: ?>
|
54 |
+
<?php $_option = $this->getFormattedOption($_option['value']); ?>
|
55 |
+
<?php echo $_option['value']; ?><?php if (isset($_option['remainder']) && $_option['remainder']): ?><span id="<?php echo $_dots = 'dots' . uniqid()?>"> ...</span><span id="<?php echo $_id = 'id' . uniqid()?>"><?php echo $_option['remainder'] ?></span>
|
56 |
+
<script type="text/javascript">
|
57 |
+
$('<?php echo $_id ?>').hide();
|
58 |
+
$('<?php echo $_id ?>').up().observe('mouseover', function(){$('<?php echo $_id ?>').show();});
|
59 |
+
$('<?php echo $_id ?>').up().observe('mouseover', function(){$('<?php echo $_dots?>').hide();});
|
60 |
+
$('<?php echo $_id ?>').up().observe('mouseout', function(){$('<?php echo $_id ?>').hide();});
|
61 |
+
$('<?php echo $_id ?>').up().observe('mouseout', function(){$('<?php echo $_dots ?>').show();});
|
62 |
+
</script>
|
63 |
+
<?php endif; ?>
|
64 |
+
<?php endif; ?>
|
65 |
+
</dd>
|
66 |
+
<?php endforeach; ?>
|
67 |
+
</dl>
|
68 |
+
<?php endif; ?>
|
69 |
+
<?php echo $this->htmlEscape($_item->getDescription()) ?>
|
70 |
+
<?php endif; ?>
|
app/design/adminhtml/default/default/template/sinchimport/sinchdistributors.phtml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<div class="entry-edit">
|
3 |
+
<div class="entry-edit-head">
|
4 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Suppliers</h4>
|
5 |
+
</div>
|
6 |
+
<div id="group_fields4" class="fieldset fieldset-wide">
|
7 |
+
<div class="grid">
|
8 |
+
<?php
|
9 |
+
echo Mage::getModel('sinchimport/sinch')->getSinchDistribotorsTableHtml();
|
10 |
+
?>
|
11 |
+
</div>
|
12 |
+
</div>
|
13 |
+
</div>
|
package.xml
CHANGED
@@ -1,22 +1,23 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>stockinthechannel2012</name>
|
4 |
-
<version>
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="http://www.
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
<
|
18 |
-
<
|
19 |
-
<
|
|
|
20 |
<compatible/>
|
21 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>stockinthechannel2012</name>
|
4 |
+
<version>2.0.0</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://www.gnu.org/licenses/gpl.html">GNU GPL v3</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Import Plugin for the Stock in the Channel Magento Data Feed</summary>
|
10 |
+
<description>Import Plugin for the Stock in the Channel Magento Data Feed.
|
11 |
+
Requires a Magento Formatted Data feed from http://stockinthechannel.com</description>
|
12 |
+
<notes>Version 2.0.0
|
13 |
+
* NEW - Now supports new Magento feed format
|
14 |
+
* NEW - Allow for Toner Feed imports
|
15 |
+
* NEW - Allow Mapping of products to Multiple Categories
|
16 |
+
* Fixed Occasional Price Breaks Error</notes>
|
17 |
+
<authors><author><name>stockinchannel</name><user>stockinchannel</user><email>support@stockinthechannel.com</email></author><author><name>Nick Anstee</name><user>nicka101</user><email>nick@stockinthechannel.com</email></author></authors>
|
18 |
+
<date>2013-09-11</date>
|
19 |
+
<time>15:11:36</time>
|
20 |
+
<contents><target name="magelocal"><dir name="Bintime"><dir name="Sinchimport"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Sinchdistributors.php" hash="20c2452bfbf7206c72b2402e4eaa1541"/></dir></dir></dir><file name="Importenvironment.php" hash="85ac7cf582ad798fc31d85855319d6e1"/><file name="Importhistory.php" hash="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="2c0131265f18450126d7a0988d6ed284"/><file name="Product.php" hash="1e3be2c2c605b3eaf79aea1627ef4d49"/><dir name="Resource"><dir name="Layer"><dir name="Filter"><file name="Price.php" hash="0d1fd59eb80f281ebad11bf15d3007da"/></dir></dir><dir name="Mysql4"><dir name="Layer"><dir name="Filter"><file name="Feature.php" hash="ea9c35e365239bdcc362ff98369cbd87"/></dir></dir><file name="Setup.php" hash="280a1ece3e1bb1f035e2cf265da05b63"/></dir></dir><file name="Sinch.php" hash="6067ac8667e12861921b8112f5097966"/><file name="Sinch_new_code.php" hash="45139a984755a15503ee0c4c987f1e11"/><dir name="System"><dir name="Config"><file name="CatRewrite.php" hash="f54ba849b2342dfb177f4cd4736eaa48"/><file name="ProdRewrite.php" hash="95c993c6ef3258fd0c2745f39f3fcec7"/><file name="ServerList.php" hash="ff26802c85ed0733241a2166a702f34a"/><file name="Subscription.php" hash="985102ab2005f33e017818ef9247b633"/></dir></dir><file name="config.php" hash="89690f17588698f736ff9070d6f947a2"/></dir><dir name="controllers"><file name="AjaxController.php" hash="997ca1a6c79ad85b7eff86e2b3125bf1"/><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="a747f503c406e95f7df011a63e54467f"/><file name="system.xml" hash="b725941c89c9695ac9ff6e15e30ffb8e"/></dir><file name="sinch_import_start_ajax.php" hash="3f34acad1b0618d5350d28fd1acf506d"/><dir name="sql"><dir name="sinchimport_setup"><file name="filter_sinch_products_s.sql" hash="a66330a1c2717091c1752ddd89f63960"/><file name="mysql4-install-0.1.0.php" hash="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="c8c38201a96d38f84c5c0021148c3f25"/><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="f4ee53d9644c16c80327b40fec432d1d"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="fbf4d87769c26c1d9d011a180f46b98d"/><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="de6b560cef7edf7914cc4f135b0678b9"/><file name="mysql4-upgrade-0.1.9-0.2.0.php" hash="33618a810c8b88d28fc1b504eb65c657"/><file name="mysql4-upgrade-0.2.0-0.2.1.php" hash="03b25c8b9c2993723a2995316c22a120"/><file name="mysql4-upgrade-0.2.1-0.2.2.php" hash="0252804da33fc6355bd6369370eed837"/><file name="mysql4-upgrade-3.0.0-3.0.1.php" hash="f0415ff848934fc18f659fae66288100"/><file name="mysql4-upgrade-3.0.1-3.0.2.php" hash="12853ce85af460e0d462fbf3297715c0"/><file name="mysql4-upgrade-3.0.2-3.0.3.php" hash="5f5be3c6c971abcb7a53121545e2f6c5"/></dir></dir><file name="stock_price_sinch_import_start_ajax.php" hash="960ba4cfdb5ea3548a17c2365c0fca80"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bintime_Sinchimport.xml" hash="8d5661b858250eeb154af10ee19300c3"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="sinchimport.xml" hash="53dd99d9303049f92713aec45c21836f"/></dir><dir name="template"><dir name="sinchimport"><file name="list.phtml" hash="adc46e247797cdad4582792266d381e4"/><file name="media.phtml" hash="af44d0371493235e4d0a5d0e9223bd9e"/><file name="view.phtml" hash="f160f6226d774a82ab1b312ffb30eb3e"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sinchimport.xml" hash="a8e87145ca351c55f118e8f2db2126b9"/></dir><dir name="template"><dir name="sinchimport"><dir name="sales"><dir name="items"><dir name="column"><file name="name.phtml" hash="27c9c11cbf99919dfdf819e788281f5f"/></dir></dir></dir><file name="sinchdistributors.phtml" hash="cfda729147fd7b03b9f1bdc582e0d07f"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="sinchimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="sinchimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/></dir></dir></dir></dir></target></contents>
|
21 |
<compatible/>
|
22 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
23 |
</package>
|