stockinthechannel2012 - Version 2.0.3

Version Notes

Version 2.0.3:
* Now uses MySQLi instead of the MySQL plugin
* Updated Server's list to contain every region we support
* International fix is now part of the plugin by default

Download this release

Release Info

Developer stockinchannel
Extension stockinthechannel2012
Version 2.0.3
Comparing to
See all releases


Code changes from version 2.0.2 to 2.0.3

Files changed (23) hide show
  1. app/code/local/Bintime/Sinchimport/Block/Layer/View.php +0 -1
  2. app/code/local/Bintime/Sinchimport/Block/List.php +1 -1
  3. app/code/local/Bintime/Sinchimport/Model/Sinch.php +74 -112
  4. app/code/local/Bintime/Sinchimport/Model/Sinch_new_code.php +69 -68
  5. app/code/local/Bintime/Sinchimport/Model/System/Config/ServerList.php +6 -3
  6. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-install-0.1.0.php +4 -4
  7. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.1-0.1.2.php +4 -4
  8. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.2-0.1.3.php +4 -4
  9. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.6-0.1.7.php +6 -6
  10. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.7-0.1.8.php +1 -1
  11. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.0-0.2.1.php +1 -1
  12. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.1-0.2.2.php +4 -4
  13. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.0-3.0.1.php +4 -4
  14. app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.2-3.0.3.php +4 -4
  15. app/design/adminhtml/default/default/layout/sinchimport.xml +57 -57
  16. app/design/adminhtml/default/default/template/sinchimport/sales/items/column/name.phtml +70 -70
  17. app/design/adminhtml/default/default/template/sinchimport/sinchdistributors.phtml +13 -13
  18. app/design/frontend/default/default/layout/sinchimport.xml +110 -110
  19. app/design/frontend/default/default/template/sinchimport/list.phtml +153 -153
  20. app/design/frontend/default/default/template/sinchimport/media.phtml +89 -89
  21. app/design/frontend/default/default/template/sinchimport/view.phtml +363 -363
  22. app/etc/modules/Bintime_Sinchimport.xml +10 -10
  23. package.xml +11 -10
app/code/local/Bintime/Sinchimport/Block/Layer/View.php CHANGED
@@ -1,4 +1,3 @@
1
-
2
  <?php
3
 
4
  class Bintime_Sinchimport_Block_Layer_View extends Mage_Catalog_Block_Layer_View
 
1
  <?php
2
 
3
  class Bintime_Sinchimport_Block_Layer_View extends Mage_Catalog_Block_Layer_View
app/code/local/Bintime/Sinchimport/Block/List.php CHANGED
@@ -144,7 +144,7 @@ class Bintime_Sinchimport_Block_List extends Mage_Catalog_Block_Product_Compare_
144
  $q=" insert ignore into ".$tmp_table_sorted." (store_product_id, sinch_product_id, feature_name, text) values(".$store_product_id.",".$sinch_product_id.",'".$name."','".$value."')";
145
  $this->tep_db_query($q);
146
  }
147
- //mysql_real_escape_string($name)
148
  $i++;
149
  }
150
  }
144
  $q=" insert ignore into ".$tmp_table_sorted." (store_product_id, sinch_product_id, feature_name, text) values(".$store_product_id.",".$sinch_product_id.",'".$name."','".$value."')";
145
  $this->tep_db_query($q);
146
  }
147
+ //mysqli_real_escape_string($name)
148
  $i++;
149
  }
150
  }
app/code/local/Bintime/Sinchimport/Model/Sinch.php CHANGED
@@ -71,7 +71,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
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."'");
74
- $row = mysql_fetch_assoc($res);
75
  $this->lang_id = $row['languages_id'];
76
  */
77
  $this->varDir = TEMPORARY_DIRECTORY_FOR_STORING_FILES;
@@ -150,7 +150,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
150
  function is_imort_not_run(){
151
  $q="SELECT IS_FREE_LOCK('sinchimport') as getlock";
152
  $quer=$this->db_do($q);
153
- $row=mysql_fetch_array($quer);
154
  return $row['getlock'];
155
  }
156
  #################################################################################################
@@ -159,7 +159,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
159
  $q='SHOW PROCEDURE STATUS LIKE "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'"';
160
  $quer=$this->db_do($q);
161
  $result=false;
162
- While($row=mysql_fetch_array($quer)){
163
  if(($row['Name']==Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s')) && ($row['Db']==$dbConf->dbname)){
164
  $result = true;
165
  }
@@ -170,7 +170,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
170
  function check_db_privileges(){
171
  $q='SHOW PRIVILEGES';
172
  $quer=$this->db_do($q);
173
- while($row=mysql_fetch_array($quer)){
174
  if($row['Privilege']=='File' && $row['Context']=='File access on server'){
175
  return true;
176
  }
@@ -181,7 +181,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
181
  function check_local_infile(){
182
  $q='SHOW VARIABLES LIKE "local_infile"';
183
  $quer=$this->db_do($q);
184
- $row=mysql_fetch_array($quer);
185
  if($row['Variable_name']=='local_infile' && $row['Value']=="ON"){
186
  return true;
187
  }else{
@@ -194,7 +194,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
194
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic')."
195
  WHERE import_type='FULL' AND global_status_import='Successful'";
196
  $quer=$this->db_do($q);
197
- $row=mysql_fetch_array($quer);
198
  if($row['cnt']>0){
199
  return true;
200
  }else{
@@ -628,7 +628,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
628
  /**/
629
  if (!$this->check_loaded_data($parse_file, $categories_temp))
630
  {
631
- $inf = mysql_info();
632
  $this->set_import_error_reporting_message('The Stock In The Channel data files do not appear to be in the correct format. Check file'.$parse_file. "(LOAD DATA ... ".$inf.")");
633
  exit;
634
  }/**/
@@ -892,7 +892,7 @@ echo("\n\n $query\n\n");
892
 
893
 
894
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
895
- while ($row = mysql_fetch_array($categories))
896
  {
897
  $parent_id = $row['parent_id'];
898
  $entity_id = $row['entity_id'];
@@ -903,7 +903,7 @@ echo("\n\n $query\n\n");
903
  UPDATE $catalog_category_entity
904
  SET path = '$path'
905
  WHERE entity_id = $entity_id");
906
- } // while ($row = mysql_fetch_array($categories))
907
 
908
 
909
 
@@ -1523,7 +1523,7 @@ $query = "
1523
  echo("\n $query\n");
1524
  $root_categories = $this->db_do($query);
1525
 
1526
- while($root_cat = mysql_fetch_array($root_categories))
1527
  {
1528
  $root_id = $root_cat['entity_id'];
1529
  $root_name = $root_cat['RootName'];
@@ -1594,13 +1594,13 @@ echo("\n\n ==================================================================
1594
  AND cce.entity_type_id = ccev.entity_type_id
1595
  AND ccev.attribute_id = 41
1596
  WHERE parent_id = 1"); // 41 - category name
1597
- while ($row = mysql_fetch_array($query)) $old_cats[] = $row['category_name'];
1598
 
1599
  //var_dump($old_cats);
1600
 
1601
 
1602
  $query = $this->db_do("SELECT MAX(entity_id) AS max_entity_id FROM $catalog_category_entity");
1603
- $max_entity_id = mysql_fetch_array($query);
1604
 
1605
  //var_dump($max_entity_id);
1606
 
@@ -1685,15 +1685,15 @@ echo("\n createNewDefaultCategories done... \n ===========================
1685
  AND ccev.attribute_id = 41
1686
  WHERE parent_id = 1"); // 41 - category name
1687
  $OLD = array();
1688
- while($root_cat = mysql_fetch_array($root_categories)) $OLD[] = $root_cat['category_name'];
1689
 
1690
  $new_categories = $this->db_do("SELECT DISTINCT RootName FROM $categories_temp");
1691
 
1692
  //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");
1693
 
1694
  $NEW = array();
1695
- while($new_root_cat = mysql_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['RootName']] = TRUE;
1696
- /////STP while($new_root_cat = mysql_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['name']] = TRUE;
1697
  /**
1698
  $exists_coincidence = array();
1699
 
@@ -1902,7 +1902,7 @@ $query = "
1902
  echo("\n\n$query\n\n");
1903
  $root_categories = $this->db_do($query);
1904
 
1905
- while($root_cat = mysql_fetch_array($root_categories))
1906
  {
1907
  $root_id = $root_cat['entity_id'];
1908
  $root_name = $root_cat['RootName'];
@@ -2052,7 +2052,7 @@ echo("\n\n$query\n\n");
2052
 
2053
 
2054
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
2055
- while ($row = mysql_fetch_array($categories))
2056
  {
2057
  $parent_id = $row['parent_id'];
2058
  $entity_id = $row['entity_id'];
@@ -2063,7 +2063,7 @@ echo("\n\n$query\n\n");
2063
  UPDATE $catalog_category_entity
2064
  SET path = '$path'
2065
  WHERE entity_id = $entity_id");
2066
- } // while ($row = mysql_fetch_array($categories))
2067
 
2068
 
2069
  ///////////////////////////////////////////////////////
@@ -2543,7 +2543,7 @@ echo("\n\n$query\n\n");
2543
  FROM $catalog_category_entity
2544
  WHERE entity_id = $cat_id";
2545
  $quer = $this->db_do($q);
2546
- $row = mysql_fetch_array($quer);
2547
  while ($row['parent_id'])
2548
  {
2549
  $path = $row['parent_id'].'/'.$path;
@@ -2555,7 +2555,7 @@ echo("\n\n$query\n\n");
2555
  FROM $catalog_category_entity
2556
  WHERE entity_id = $parent_id";
2557
  $quer = $this->db_do($q);
2558
- $row = mysql_fetch_array($quer);
2559
  }
2560
 
2561
  if ($cat_id) $path.=$cat_id."/";
@@ -4587,7 +4587,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
4587
  WHERE parent_store_category_id = 0");
4588
 
4589
  $store_cat_ids = $this->db_do("SELECT store_category_id FROM $categories_temp");
4590
- while ($row = mysql_fetch_array($store_cat_ids))
4591
  {
4592
  $store_category_id = $row['store_category_id'];
4593
 
@@ -4803,7 +4803,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
4803
 
4804
 
4805
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
4806
- while ($row = mysql_fetch_array($categories))
4807
  {
4808
  $parent_id = $row['parent_id'];
4809
  $entity_id = $row['entity_id'];
@@ -5477,7 +5477,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
5477
  WHERE aov.value IS NULL";
5478
  $quer=$this->db_do($q);
5479
 
5480
- while($row=mysql_fetch_array($quer)){
5481
  $q0="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
5482
  (attribute_id)
5483
  VALUES(".$this->attributes['manufacturer'].")";
@@ -5489,7 +5489,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
5489
  )(
5490
  SELECT
5491
  max(option_id) as option_id,
5492
- "."'".mysql_real_escape_string($row['manufacturer_name'])."'
5493
  FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
5494
  WHERE attribute_id=".$this->attributes['manufacturer']."
5495
  )
@@ -5630,20 +5630,8 @@ echo("\nParseProducts 2\n");
5630
  $parse_file=$this->varDir.FILE_PRODUCTS;
5631
  if(filesize($parse_file)){
5632
  $this->_LOG("Start parse ".FILE_PRODUCTS);
5633
-
5634
- $file_handle_from = fopen($parse_file, "r");
5635
- unlink($parse_file.".conv");
5636
- $file_handle_to = fopen($parse_file.".conv", "w");
5637
- while (!feof($file_handle_from)) {
5638
- $line = fgets($file_handle_from);
5639
- $line = $this->valid_utf($line);
5640
- fwrite($file_handle_to, $line);
5641
- }
5642
- fclose($file_handle_from);
5643
- fclose($file_handle_to);
5644
  echo("\nParseProducts 2\n");
5645
 
5646
- // $prod_file_str = file_get_contents($parse_file);
5647
  $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
5648
  if($this->product_file_format == "NEW"){
5649
  $this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."(
@@ -5714,7 +5702,7 @@ echo("\nParseProducts 2\n");
5714
 
5715
  }
5716
  echo("\nParseProducts 3\n");
5717
- $this->db_do("LOAD DATA LOCAL INFILE '".$parse_file.".conv'
5718
  INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
5719
  FIELDS TERMINATED BY '".$this->field_terminated_char."'
5720
  OPTIONALLY ENCLOSED BY '\"'
@@ -5754,15 +5742,6 @@ echo("\nParseProducts 3\n");
5754
 
5755
  echo("\nParseProducts 4\n");
5756
 
5757
-
5758
- //$this->db_do("DELETE FROM stINch_products WHERE sinch_product_id IN (4936140, 4326529)");
5759
-
5760
- //echo("\n\n clear parse products....\n\n"); //exit;
5761
-
5762
-
5763
-
5764
- $this->db_do("ALTER TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
5765
- CONVERT TO CHARACTER SET \"latin1\"");
5766
  echo("\nParseProducts 5\n");
5767
  $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
5768
  SET products_date_added=now(), products_last_modified=now()");
@@ -5775,7 +5754,7 @@ echo("\nParseProducts 7\n");
5775
  if($this->current_import_status_statistic_id){
5776
  $res = $this->db_do("SELECT COUNT(*) AS cnt
5777
  FROM ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
5778
- $row = mysql_fetch_assoc($res);
5779
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
5780
  SET number_of_products=".$row['cnt']."
5781
  WHERE id=".$this->current_import_status_statistic_id);
@@ -5869,18 +5848,6 @@ echo("\nParseProducts 11\n");
5869
  $parse_file=$this->varDir.FILE_RESTRICTED_VALUES;
5870
  if(filesize($parse_file) || $this->_ignore_restricted_values){
5871
  $this->_LOG("Start parse ".FILE_RESTRICTED_VALUES);
5872
- $file_handle_from = fopen($parse_file, "r");
5873
- unlink($parse_file.".conv");
5874
- $file_handle_to = fopen($parse_file.".conv", "w");
5875
- while (!feof($file_handle_from)) {
5876
- $line = fgets($file_handle_from);
5877
- $line = $this->valid_utf($line);
5878
- fwrite($file_handle_to, $line);
5879
- }
5880
- fclose($file_handle_from);
5881
- fclose($file_handle_to);
5882
-
5883
-
5884
  $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp'));
5885
  $this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')." (
5886
  restricted_value_id int(11),
@@ -5891,15 +5858,13 @@ echo("\nParseProducts 11\n");
5891
  KEY(category_feature_id)
5892
  )");
5893
  if(!$this->_ignore_restricted_values){
5894
- $this->db_do("LOAD DATA LOCAL INFILE '".$parse_file.".conv'
5895
  INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')."
5896
  FIELDS TERMINATED BY '".$this->field_terminated_char."'
5897
  OPTIONALLY ENCLOSED BY '\"'
5898
  LINES TERMINATED BY \"\r\n\"
5899
  IGNORE 1 LINES ");
5900
  }
5901
- $this->db_do("ALTER TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')."
5902
- CONVERT TO CHARACTER SET \"latin1\"");
5903
  $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values'));
5904
  $this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')."
5905
  TO ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values'));
@@ -5942,7 +5907,7 @@ echo("\nParseProducts 11\n");
5942
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
5943
  INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
5944
  ON a.store_product_id=b.store_product_id");
5945
- $row = mysql_fetch_assoc($res);
5946
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
5947
  SET number_of_products=".$row['cnt']."
5948
  WHERE id=".$this->current_import_status_statistic_id);
@@ -6245,7 +6210,7 @@ echo("\nParseProducts 11\n");
6245
  FROM ".Mage::getSingleton('core/resource')->getTableName('core_store')."
6246
  WHERE code!='admin'
6247
  "); // where code!='admin' was adder for editing Featured products;
6248
- while ($row = mysql_fetch_assoc($result)) {
6249
  $sql = "INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." (
6250
  store_product_id,
6251
  sinch_product_id,
@@ -7655,7 +7620,7 @@ STP DELETE*/
7655
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_type')
7656
  );
7657
  $link_type=array();
7658
- while ($row = mysql_fetch_array($result)) {
7659
  $link_type[$row['code']]=$row['link_type_id'];
7660
  }
7661
 
@@ -7732,7 +7697,7 @@ STP DELETE*/
7732
  /* $q="select distinct store_product_id from stINch_related_products";
7733
  $quer=$this->db_do($q);
7734
  $prod = Mage::getModel('catalog/product');
7735
- while ($row = mysql_fetch_assoc($quer)) {
7736
  $q1="select distinct store_related_product_id store_product_id from stINch_related_products where store_product_id=".$row['store_product_id'].;
7737
  $quer1=$this->db_do($q1);
7738
  $prod->load($row['store_product_id']);
@@ -7749,7 +7714,7 @@ STP DELETE*/
7749
  ###$product->save();
7750
  ###
7751
  $i=1;
7752
- while ($row1 = mysql_fetch_assoc($quer1)) {
7753
  $param[$row1['store_related_product_id']]['position']=$i++;
7754
 
7755
  }
@@ -8026,7 +7991,7 @@ STP DELETE*/
8026
  FROM ".Mage::getSingleton('core/resource')->getTableName('import_pricerules')."
8027
  ORDER BY rating DESC
8028
  ");
8029
- while($row = mysql_fetch_assoc($result)) {
8030
  $rulesArray[$row['id']] = $row;
8031
  }
8032
  return $rulesArray;
@@ -8216,7 +8181,7 @@ STP DELETE*/
8216
  $q="SELECT customer_group_id FROM ".Mage::getSingleton('core/resource')->getTableName('customer_group');
8217
  $quer=$this->db_do($q);
8218
 
8219
- while ($row = mysql_fetch_assoc($quer)) {
8220
  $result = $this->db_do("
8221
  INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." (
8222
  entity_id,
@@ -8346,7 +8311,7 @@ STP DELETE*/
8346
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products')."
8347
  WHERE store_product_id =".$store_product_id;
8348
  $quer=$this->db_do($q);
8349
- $product=mysql_fetch_array($quer);
8350
 
8351
  $this->productDescription = (string) substr($product['description'],50,0);
8352
  $this->fullProductDescription = (string)$product['description'];
@@ -8361,7 +8326,7 @@ STP DELETE*/
8361
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')."
8362
  WHERE sinch_manufacturer_id=".$product['sinch_manufacturer_id'];
8363
  $quer=$this->db_do($q);
8364
- $manufacturer=mysql_fetch_array($quer);
8365
  $this->vendor = (string)$manufacturer['manufacturer_name'];
8366
  }
8367
  $q="SELECT DISTINCT ean_code
@@ -8370,7 +8335,7 @@ STP DELETE*/
8370
  ON sec.product_id=sp.sinch_product_id
8371
  WHERE sp.store_product_id=".$store_product_id;
8372
  $quer=$this->db_do($q);
8373
- while ($row=mysql_fetch_array($quer)){
8374
  $EANarr[]=$row['ean_code'];
8375
  }
8376
  // $prodEAN = $productTag->EANCode;
@@ -8395,7 +8360,7 @@ STP DELETE*/
8395
  INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features')." c
8396
  ON b.category_feature_id = c.category_feature_id
8397
  WHERE a.sinch_product_id = '" .$this->sinchProductId . "'" );
8398
- while ($features = mysql_fetch_array($product_info_features)) {
8399
  $descriptionArray[$features['name']] = $features['value'];
8400
  }
8401
 
@@ -8432,7 +8397,7 @@ STP DELETE*/
8432
 
8433
  // echo $q;
8434
  $quer=$this->db_do($q);
8435
- while($row=mysql_fetch_array($quer)){
8436
 
8437
  $productArray = array();
8438
  $productArray['name'] = (string)$row['product_name'];
@@ -8463,7 +8428,7 @@ STP DELETE*/
8463
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery')."
8464
  WHERE store_product_id=".$store_product_id);
8465
 
8466
- $res=mysql_fetch_array($q);
8467
  if(!$res || !$res['cnt']){
8468
  return false;
8469
  }
@@ -8475,7 +8440,7 @@ STP DELETE*/
8475
 
8476
  $res=$this->db_do($q);
8477
 
8478
- while($photo=mysql_fetch_array($res)){
8479
  $picHeight = (int)500;//$photo["PicHeight"];
8480
  $picWidth = (int)500;//$photo["PicWidth"];
8481
  $thumbUrl = (string)$photo["ThumbPic"];
@@ -8612,7 +8577,7 @@ STP DELETE*/
8612
  $q=$this->db_do("SELECT store_product_id
8613
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')."
8614
  WHERE entity_id=".$entity_id);
8615
- $res=mysql_fetch_array($q);
8616
  // echo $entity_id."AAAA".$res['store_product_id']; exit;
8617
  return ($res['store_product_id']);
8618
  }
@@ -8623,14 +8588,15 @@ STP DELETE*/
8623
  // $connection = Mage::getModel('core/resource')->getConnection('core_write');
8624
  $dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
8625
 
8626
- if ($this->db = mysql_connect($dbConf->host, $dbConf->username, $dbConf->password, true, 128)) {
8627
- if(mysql_select_db($dbConf->dbname)){
 
8628
  $this->_LOG("Connected..");
8629
  }else{
8630
- die("Can't select the database: " . mysql_error());
8631
  }
8632
  }else{
8633
- die("Could not connect: " . mysql_error());
8634
 
8635
  }
8636
 
@@ -8639,15 +8605,11 @@ STP DELETE*/
8639
 
8640
  private function db_do($query) {
8641
  if($this->debug_mode){
8642
- // $this->_LOG("Query: " . $query);
8643
  Mage::log("Query: " . $query, null, $this->_logFile);
8644
  }
8645
- // $result = $this->this->db_do($query);//
8646
- // $query=mysql_real_escape_string($query);
8647
- //mysql_query('set names utf8');
8648
- $result = mysql_query($query) or die("Query failed: " . mysql_error());
8649
  if (!$result) {
8650
- throw new Exception("Invalid query: $sql\n" . mysql_error());
8651
  } else {
8652
  return $result;
8653
  }
@@ -8657,7 +8619,7 @@ STP DELETE*/
8657
  ##################################################################################################
8658
  function table_rows_count($table){
8659
  $rows_count_res=$this->db_do("select count(*) as cnt from ".$table);
8660
- $rows_count=mysql_fetch_array($rows_count_res);
8661
  return ($rows_count['cnt']);
8662
  }
8663
  ##################################################################################################
@@ -8713,11 +8675,11 @@ STP DELETE*/
8713
  WHERE entity_type_id=".$entity_type_id."
8714
  AND attribute_id=".$attribute_id
8715
  );
8716
- while($row=mysql_fetch_array($result)){
8717
  $value=$this->valid_char($row['value']);
8718
  if($value!='' and $value!=$row['value']){
8719
  $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')."
8720
- SET value='".mysql_real_escape_string($value)."'
8721
  WHERE entity_id=".$row['entity_id']."
8722
  AND entity_type_id=".$entity_type_id."
8723
  AND attribute_id=".$attribute_id);
@@ -8847,7 +8809,7 @@ STP DELETE*/
8847
  WHERE parent_store_category_id=".$id;
8848
  $quer=$this->db_do($q);
8849
  $count=0;
8850
- while ($row=mysql_fetch_array($quer)){
8851
  $count+=$this->count_children($row['store_category_id']);
8852
  $count++;
8853
  }
@@ -8894,7 +8856,7 @@ STP DELETE*/
8894
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
8895
  WHERE entity_id=".$cat_id;
8896
  $quer=$this->db_do($q);
8897
- $row=mysql_fetch_array($quer);
8898
  while($row['parent_id']){
8899
  $path=$row['parent_id'].'/'.$path;
8900
  $q="SELECT
@@ -8902,7 +8864,7 @@ STP DELETE*/
8902
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
8903
  WHERE entity_id=".$row['parent_id'];
8904
  $quer=$this->db_do($q);
8905
- $row=mysql_fetch_array($quer);
8906
 
8907
  }
8908
  if($cat_id){
@@ -8924,13 +8886,13 @@ STP DELETE*/
8924
  WHERE store_category_id=".$id;
8925
  $quer=$this->db_do($q);
8926
  $level=1;
8927
- $row=mysql_fetch_array($quer);
8928
  while ($row['parent_store_category_id']!=0){
8929
  $q="SELECT parent_store_category_id
8930
  FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
8931
  WHERE store_category_id=".$row['parent_store_category_id'];
8932
  $quer=$this->db_do($q);
8933
- $row=mysql_fetch_array($quer);
8934
  $level++;
8935
  if($level>20){
8936
  break;
@@ -8968,7 +8930,7 @@ STP DELETE*/
8968
  $q="SELECT MAX(id) AS id FROM ".$this->import_status_statistic_table;
8969
 
8970
  $quer=$this->db_do($q);
8971
- $row=mysql_fetch_array($quer);
8972
  $this->current_import_status_statistic_id=$row['id'];
8973
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
8974
  SET global_status_import='Failed'
@@ -8984,13 +8946,13 @@ STP DELETE*/
8984
  #################################################################################################
8985
  function set_import_error_reporting_message($message){
8986
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
8987
- SET error_report_message='".mysql_real_escape_string($message)."'
8988
  WHERE id=".$this->current_import_status_statistic_id);
8989
  }
8990
  #################################################################################################
8991
  function getImportStatusHistory(){
8992
  $res="SELECT COUNT(*) FROM ".$this->import_status_statistic_table;
8993
- $cnt_arr=mysql_fetch_array($this->db_do($res));
8994
  $cnt=$cnt_arr[0];
8995
  $StatusHistory_arr = array();
8996
  if($cnt>0){
@@ -9007,7 +8969,7 @@ STP DELETE*/
9007
  FROM ".$this->import_status_statistic_table."
9008
  ORDER BY start_import limit ".$a.", ".$b;
9009
  $result=$this->db_do($q);
9010
- while($row=mysql_fetch_array($result)){
9011
  $StatusHistory_arr[]=$row;
9012
  }
9013
  }
@@ -9019,7 +8981,7 @@ STP DELETE*/
9019
  FROM ".$this->import_status_statistic_table."
9020
  WHERE global_status_import='Successful'
9021
  ORDER BY id DESC LIMIT 1";
9022
- $imp_date=mysql_fetch_array($this->db_do($q));
9023
  return $imp_date['start_import'];
9024
  }
9025
  #################################################################################################
@@ -9035,7 +8997,7 @@ STP DELETE*/
9035
  error_report_message
9036
  FROM ".$this->import_status_statistic_table."
9037
  ORDER BY id DESC LIMIT 1";
9038
- $imp_status=mysql_fetch_array($this->db_do($q));
9039
  return $imp_status;
9040
  }
9041
 
@@ -9065,7 +9027,7 @@ STP DELETE*/
9065
  FROM ".$this->import_status_table."
9066
  ORDER BY id LIMIT 1";
9067
  $quer=$this->db_do($q);
9068
- if($row=mysql_fetch_array($quer)){
9069
  $messages=array('message'=>$row['message'], 'id'=>$row['id'], 'finished'=>$row['finished']);
9070
  $id=$row['id'];
9071
  }
@@ -9085,7 +9047,7 @@ STP DELETE*/
9085
  LIMIT 1
9086
  ";
9087
  $result = $this->db_do($sql);
9088
- if ($row = mysql_fetch_assoc($result)) {
9089
  return $row['entity_type_id'];
9090
  }
9091
  return false;
@@ -9109,7 +9071,7 @@ STP DELETE*/
9109
  LIMIT 1
9110
  ";
9111
  $result = $this->db_do($sql);
9112
- if ($row = mysql_fetch_assoc($result)) {
9113
 
9114
  $this->defaultAttributeSetId = $row['default_attribute_set_id'];
9115
  }
@@ -9127,7 +9089,7 @@ STP DELETE*/
9127
  LIMIT 1
9128
  ";
9129
  $result = $this->db_do($sql);
9130
- if ($row = mysql_fetch_assoc($result)) {
9131
  $this->_categoryEntityTypeId = $row['entity_type_id'];
9132
  $this->_categoryDefault_attribute_set_id = $row['default_attribute_set_id'];
9133
  }
@@ -9151,7 +9113,7 @@ STP DELETE*/
9151
  WHERE entity_type_id = '" . $typeId . "'
9152
  ";
9153
  $result = $this->db_do($sql);
9154
- while ($row = mysql_fetch_assoc($result)) {
9155
  $this->_attributeId[$typeCode][$row['attribute_code']] = $row['attribute_id'];
9156
  }
9157
  }
@@ -9192,7 +9154,7 @@ STP DELETE*/
9192
  WHERE
9193
  value='default-category'";
9194
  $res=$this->db_do($q);
9195
- $row=mysql_fetch_array($res);
9196
  if($row['entity_id']>0){
9197
  return $row['entity_id'];
9198
  }else{
@@ -9201,7 +9163,7 @@ STP DELETE*/
9201
  WHERE parent_id=".$cat_id;
9202
  $quer=$this->db_do($q);
9203
  $count=0;
9204
- while ($row=mysql_fetch_array($quer)){
9205
  $count++;
9206
  $entity_id=$row['entity_id'];
9207
  }
@@ -9219,7 +9181,7 @@ STP DELETE*/
9219
  $q='SHOW TABLES LIKE "'.Mage::getSingleton('core/resource')->getTableName('catalog_product_flat_').'%"';
9220
  $quer=$this->db_do($q);
9221
  $result=false;
9222
- While($row=mysql_fetch_array($quer)){
9223
  if(is_array($row)){
9224
  $catalog_product_flat=array_pop($row);
9225
  $q='DELETE pf1 FROM '.$catalog_product_flat.' pf1
@@ -9921,7 +9883,7 @@ STP DELETE*/
9921
  WHERE store_product_id =".$store_product_id;
9922
  $quer=$this->db_do($q);
9923
  $offers = null;
9924
- while($row = mysql_fetch_array($quer)){
9925
  $offers[]=$row;
9926
  }
9927
  return $offers;
@@ -9941,7 +9903,7 @@ STP DELETE*/
9941
  WHERE parent_id=".$entity_id;
9942
  $quer=$this->db_do($q);
9943
  $children_cat='';
9944
- while ($row=mysql_fetch_array($quer)){
9945
  $children_cat .= ", '".$row['entity_id']."'";
9946
  $children_cat .= $this->get_all_children_cat_recursive($row['entity_id']);
9947
  }
@@ -9955,7 +9917,7 @@ STP DELETE*/
9955
  // echo $q;
9956
  $quer=$this->db_do($q);
9957
  $i=0;
9958
- while ($row=mysql_fetch_array($quer)){
9959
  $i++;
9960
  }
9961
  return ($i);
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."'");
74
+ $row = mysqli_fetch_assoc($res);
75
  $this->lang_id = $row['languages_id'];
76
  */
77
  $this->varDir = TEMPORARY_DIRECTORY_FOR_STORING_FILES;
150
  function is_imort_not_run(){
151
  $q="SELECT IS_FREE_LOCK('sinchimport') as getlock";
152
  $quer=$this->db_do($q);
153
+ $row=mysqli_fetch_array($quer);
154
  return $row['getlock'];
155
  }
156
  #################################################################################################
159
  $q='SHOW PROCEDURE STATUS LIKE "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'"';
160
  $quer=$this->db_do($q);
161
  $result=false;
162
+ While($row=mysqli_fetch_array($quer)){
163
  if(($row['Name']==Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s')) && ($row['Db']==$dbConf->dbname)){
164
  $result = true;
165
  }
170
  function check_db_privileges(){
171
  $q='SHOW PRIVILEGES';
172
  $quer=$this->db_do($q);
173
+ while($row=mysqli_fetch_array($quer)){
174
  if($row['Privilege']=='File' && $row['Context']=='File access on server'){
175
  return true;
176
  }
181
  function check_local_infile(){
182
  $q='SHOW VARIABLES LIKE "local_infile"';
183
  $quer=$this->db_do($q);
184
+ $row=mysqli_fetch_array($quer);
185
  if($row['Variable_name']=='local_infile' && $row['Value']=="ON"){
186
  return true;
187
  }else{
194
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic')."
195
  WHERE import_type='FULL' AND global_status_import='Successful'";
196
  $quer=$this->db_do($q);
197
+ $row=mysqli_fetch_array($quer);
198
  if($row['cnt']>0){
199
  return true;
200
  }else{
628
  /**/
629
  if (!$this->check_loaded_data($parse_file, $categories_temp))
630
  {
631
+ $inf = mysqli_info();
632
  $this->set_import_error_reporting_message('The Stock In The Channel data files do not appear to be in the correct format. Check file'.$parse_file. "(LOAD DATA ... ".$inf.")");
633
  exit;
634
  }/**/
892
 
893
 
894
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
895
+ while ($row = mysqli_fetch_array($categories))
896
  {
897
  $parent_id = $row['parent_id'];
898
  $entity_id = $row['entity_id'];
903
  UPDATE $catalog_category_entity
904
  SET path = '$path'
905
  WHERE entity_id = $entity_id");
906
+ } // while ($row = mysqli_fetch_array($categories))
907
 
908
 
909
 
1523
  echo("\n $query\n");
1524
  $root_categories = $this->db_do($query);
1525
 
1526
+ while($root_cat = mysqli_fetch_array($root_categories))
1527
  {
1528
  $root_id = $root_cat['entity_id'];
1529
  $root_name = $root_cat['RootName'];
1594
  AND cce.entity_type_id = ccev.entity_type_id
1595
  AND ccev.attribute_id = 41
1596
  WHERE parent_id = 1"); // 41 - category name
1597
+ while ($row = mysqli_fetch_array($query)) $old_cats[] = $row['category_name'];
1598
 
1599
  //var_dump($old_cats);
1600
 
1601
 
1602
  $query = $this->db_do("SELECT MAX(entity_id) AS max_entity_id FROM $catalog_category_entity");
1603
+ $max_entity_id = mysqli_fetch_array($query);
1604
 
1605
  //var_dump($max_entity_id);
1606
 
1685
  AND ccev.attribute_id = 41
1686
  WHERE parent_id = 1"); // 41 - category name
1687
  $OLD = array();
1688
+ while($root_cat = mysqli_fetch_array($root_categories)) $OLD[] = $root_cat['category_name'];
1689
 
1690
  $new_categories = $this->db_do("SELECT DISTINCT RootName FROM $categories_temp");
1691
 
1692
  //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");
1693
 
1694
  $NEW = array();
1695
+ while($new_root_cat = mysqli_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['RootName']] = TRUE;
1696
+ /////STP while($new_root_cat = mysqli_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['name']] = TRUE;
1697
  /**
1698
  $exists_coincidence = array();
1699
 
1902
  echo("\n\n$query\n\n");
1903
  $root_categories = $this->db_do($query);
1904
 
1905
+ while($root_cat = mysqli_fetch_array($root_categories))
1906
  {
1907
  $root_id = $root_cat['entity_id'];
1908
  $root_name = $root_cat['RootName'];
2052
 
2053
 
2054
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
2055
+ while ($row = mysqli_fetch_array($categories))
2056
  {
2057
  $parent_id = $row['parent_id'];
2058
  $entity_id = $row['entity_id'];
2063
  UPDATE $catalog_category_entity
2064
  SET path = '$path'
2065
  WHERE entity_id = $entity_id");
2066
+ } // while ($row = mysqli_fetch_array($categories))
2067
 
2068
 
2069
  ///////////////////////////////////////////////////////
2543
  FROM $catalog_category_entity
2544
  WHERE entity_id = $cat_id";
2545
  $quer = $this->db_do($q);
2546
+ $row = mysqli_fetch_array($quer);
2547
  while ($row['parent_id'])
2548
  {
2549
  $path = $row['parent_id'].'/'.$path;
2555
  FROM $catalog_category_entity
2556
  WHERE entity_id = $parent_id";
2557
  $quer = $this->db_do($q);
2558
+ $row = mysqli_fetch_array($quer);
2559
  }
2560
 
2561
  if ($cat_id) $path.=$cat_id."/";
4587
  WHERE parent_store_category_id = 0");
4588
 
4589
  $store_cat_ids = $this->db_do("SELECT store_category_id FROM $categories_temp");
4590
+ while ($row = mysqli_fetch_array($store_cat_ids))
4591
  {
4592
  $store_category_id = $row['store_category_id'];
4593
 
4803
 
4804
 
4805
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
4806
+ while ($row = mysqli_fetch_array($categories))
4807
  {
4808
  $parent_id = $row['parent_id'];
4809
  $entity_id = $row['entity_id'];
5477
  WHERE aov.value IS NULL";
5478
  $quer=$this->db_do($q);
5479
 
5480
+ while($row=mysqli_fetch_array($quer)){
5481
  $q0="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
5482
  (attribute_id)
5483
  VALUES(".$this->attributes['manufacturer'].")";
5489
  )(
5490
  SELECT
5491
  max(option_id) as option_id,
5492
+ "."'".mysqli_real_escape_string($row['manufacturer_name'])."'
5493
  FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
5494
  WHERE attribute_id=".$this->attributes['manufacturer']."
5495
  )
5630
  $parse_file=$this->varDir.FILE_PRODUCTS;
5631
  if(filesize($parse_file)){
5632
  $this->_LOG("Start parse ".FILE_PRODUCTS);
 
 
 
 
 
 
 
 
 
 
 
5633
  echo("\nParseProducts 2\n");
5634
 
 
5635
  $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
5636
  if($this->product_file_format == "NEW"){
5637
  $this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."(
5702
 
5703
  }
5704
  echo("\nParseProducts 3\n");
5705
+ $this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
5706
  INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
5707
  FIELDS TERMINATED BY '".$this->field_terminated_char."'
5708
  OPTIONALLY ENCLOSED BY '\"'
5742
 
5743
  echo("\nParseProducts 4\n");
5744
 
 
 
 
 
 
 
 
 
 
5745
  echo("\nParseProducts 5\n");
5746
  $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('products_temp')."
5747
  SET products_date_added=now(), products_last_modified=now()");
5754
  if($this->current_import_status_statistic_id){
5755
  $res = $this->db_do("SELECT COUNT(*) AS cnt
5756
  FROM ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
5757
+ $row = mysqli_fetch_assoc($res);
5758
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
5759
  SET number_of_products=".$row['cnt']."
5760
  WHERE id=".$this->current_import_status_statistic_id);
5848
  $parse_file=$this->varDir.FILE_RESTRICTED_VALUES;
5849
  if(filesize($parse_file) || $this->_ignore_restricted_values){
5850
  $this->_LOG("Start parse ".FILE_RESTRICTED_VALUES);
 
 
 
 
 
 
 
 
 
 
 
 
5851
  $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp'));
5852
  $this->db_do("CREATE TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')." (
5853
  restricted_value_id int(11),
5858
  KEY(category_feature_id)
5859
  )");
5860
  if(!$this->_ignore_restricted_values){
5861
+ $this->db_do("LOAD DATA LOCAL INFILE '".$parse_file."'
5862
  INTO TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')."
5863
  FIELDS TERMINATED BY '".$this->field_terminated_char."'
5864
  OPTIONALLY ENCLOSED BY '\"'
5865
  LINES TERMINATED BY \"\r\n\"
5866
  IGNORE 1 LINES ");
5867
  }
 
 
5868
  $this->db_do("DROP TABLE IF EXISTS ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values'));
5869
  $this->db_do("RENAME TABLE ".Mage::getSingleton('core/resource')->getTableName('restricted_values_temp')."
5870
  TO ".Mage::getSingleton('core/resource')->getTableName('stINch_restricted_values'));
5907
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
5908
  INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
5909
  ON a.store_product_id=b.store_product_id");
5910
+ $row = mysqli_fetch_assoc($res);
5911
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
5912
  SET number_of_products=".$row['cnt']."
5913
  WHERE id=".$this->current_import_status_statistic_id);
6210
  FROM ".Mage::getSingleton('core/resource')->getTableName('core_store')."
6211
  WHERE code!='admin'
6212
  "); // where code!='admin' was adder for editing Featured products;
6213
+ while ($row = mysqli_fetch_assoc($result)) {
6214
  $sql = "INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." (
6215
  store_product_id,
6216
  sinch_product_id,
7620
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_type')
7621
  );
7622
  $link_type=array();
7623
+ while ($row = mysqli_fetch_array($result)) {
7624
  $link_type[$row['code']]=$row['link_type_id'];
7625
  }
7626
 
7697
  /* $q="select distinct store_product_id from stINch_related_products";
7698
  $quer=$this->db_do($q);
7699
  $prod = Mage::getModel('catalog/product');
7700
+ while ($row = mysqli_fetch_assoc($quer)) {
7701
  $q1="select distinct store_related_product_id store_product_id from stINch_related_products where store_product_id=".$row['store_product_id'].;
7702
  $quer1=$this->db_do($q1);
7703
  $prod->load($row['store_product_id']);
7714
  ###$product->save();
7715
  ###
7716
  $i=1;
7717
+ while ($row1 = mysqli_fetch_assoc($quer1)) {
7718
  $param[$row1['store_related_product_id']]['position']=$i++;
7719
 
7720
  }
7991
  FROM ".Mage::getSingleton('core/resource')->getTableName('import_pricerules')."
7992
  ORDER BY rating DESC
7993
  ");
7994
+ while($row = mysqli_fetch_assoc($result)) {
7995
  $rulesArray[$row['id']] = $row;
7996
  }
7997
  return $rulesArray;
8181
  $q="SELECT customer_group_id FROM ".Mage::getSingleton('core/resource')->getTableName('customer_group');
8182
  $quer=$this->db_do($q);
8183
 
8184
+ while ($row = mysqli_fetch_assoc($quer)) {
8185
  $result = $this->db_do("
8186
  INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." (
8187
  entity_id,
8311
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products')."
8312
  WHERE store_product_id =".$store_product_id;
8313
  $quer=$this->db_do($q);
8314
+ $product=mysqli_fetch_array($quer);
8315
 
8316
  $this->productDescription = (string) substr($product['description'],50,0);
8317
  $this->fullProductDescription = (string)$product['description'];
8326
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')."
8327
  WHERE sinch_manufacturer_id=".$product['sinch_manufacturer_id'];
8328
  $quer=$this->db_do($q);
8329
+ $manufacturer=mysqli_fetch_array($quer);
8330
  $this->vendor = (string)$manufacturer['manufacturer_name'];
8331
  }
8332
  $q="SELECT DISTINCT ean_code
8335
  ON sec.product_id=sp.sinch_product_id
8336
  WHERE sp.store_product_id=".$store_product_id;
8337
  $quer=$this->db_do($q);
8338
+ while ($row=mysqli_fetch_array($quer)){
8339
  $EANarr[]=$row['ean_code'];
8340
  }
8341
  // $prodEAN = $productTag->EANCode;
8360
  INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features')." c
8361
  ON b.category_feature_id = c.category_feature_id
8362
  WHERE a.sinch_product_id = '" .$this->sinchProductId . "'" );
8363
+ while ($features = mysqli_fetch_array($product_info_features)) {
8364
  $descriptionArray[$features['name']] = $features['value'];
8365
  }
8366
 
8397
 
8398
  // echo $q;
8399
  $quer=$this->db_do($q);
8400
+ while($row=mysqli_fetch_array($quer)){
8401
 
8402
  $productArray = array();
8403
  $productArray['name'] = (string)$row['product_name'];
8428
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery')."
8429
  WHERE store_product_id=".$store_product_id);
8430
 
8431
+ $res=mysqli_fetch_array($q);
8432
  if(!$res || !$res['cnt']){
8433
  return false;
8434
  }
8440
 
8441
  $res=$this->db_do($q);
8442
 
8443
+ while($photo=mysqli_fetch_array($res)){
8444
  $picHeight = (int)500;//$photo["PicHeight"];
8445
  $picWidth = (int)500;//$photo["PicWidth"];
8446
  $thumbUrl = (string)$photo["ThumbPic"];
8577
  $q=$this->db_do("SELECT store_product_id
8578
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')."
8579
  WHERE entity_id=".$entity_id);
8580
+ $res=mysqli_fetch_array($q);
8581
  // echo $entity_id."AAAA".$res['store_product_id']; exit;
8582
  return ($res['store_product_id']);
8583
  }
8588
  // $connection = Mage::getModel('core/resource')->getConnection('core_write');
8589
  $dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
8590
 
8591
+ if ($this->db = mysqli_connect($dbConf->host, $dbConf->username, $dbConf->password)) {
8592
+ mysqli_options($this->db, MYSQLI_OPT_LOCAL_INFILE, true);
8593
+ if(mysqli_select_db($this->db, $dbConf->dbname)){
8594
  $this->_LOG("Connected..");
8595
  }else{
8596
+ die("Can't select the database: " . mysqli_error($this->db));
8597
  }
8598
  }else{
8599
+ die("Could not connect: " . mysqli_error($this->db));
8600
 
8601
  }
8602
 
8605
 
8606
  private function db_do($query) {
8607
  if($this->debug_mode){
 
8608
  Mage::log("Query: " . $query, null, $this->_logFile);
8609
  }
8610
+ $result = mysqli_query($this->db, $query) or die("Query failed: " . mysqli_error($this->db));
 
 
 
8611
  if (!$result) {
8612
+ throw new Exception("Invalid query: $sql\n" . mysqli_error($this->db));
8613
  } else {
8614
  return $result;
8615
  }
8619
  ##################################################################################################
8620
  function table_rows_count($table){
8621
  $rows_count_res=$this->db_do("select count(*) as cnt from ".$table);
8622
+ $rows_count=mysqli_fetch_array($rows_count_res);
8623
  return ($rows_count['cnt']);
8624
  }
8625
  ##################################################################################################
8675
  WHERE entity_type_id=".$entity_type_id."
8676
  AND attribute_id=".$attribute_id
8677
  );
8678
+ while($row=mysqli_fetch_array($result)){
8679
  $value=$this->valid_char($row['value']);
8680
  if($value!='' and $value!=$row['value']){
8681
  $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')."
8682
+ SET value='".mysqli_real_escape_string($value)."'
8683
  WHERE entity_id=".$row['entity_id']."
8684
  AND entity_type_id=".$entity_type_id."
8685
  AND attribute_id=".$attribute_id);
8809
  WHERE parent_store_category_id=".$id;
8810
  $quer=$this->db_do($q);
8811
  $count=0;
8812
+ while ($row=mysqli_fetch_array($quer)){
8813
  $count+=$this->count_children($row['store_category_id']);
8814
  $count++;
8815
  }
8856
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
8857
  WHERE entity_id=".$cat_id;
8858
  $quer=$this->db_do($q);
8859
+ $row=mysqli_fetch_array($quer);
8860
  while($row['parent_id']){
8861
  $path=$row['parent_id'].'/'.$path;
8862
  $q="SELECT
8864
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
8865
  WHERE entity_id=".$row['parent_id'];
8866
  $quer=$this->db_do($q);
8867
+ $row=mysqli_fetch_array($quer);
8868
 
8869
  }
8870
  if($cat_id){
8886
  WHERE store_category_id=".$id;
8887
  $quer=$this->db_do($q);
8888
  $level=1;
8889
+ $row=mysqli_fetch_array($quer);
8890
  while ($row['parent_store_category_id']!=0){
8891
  $q="SELECT parent_store_category_id
8892
  FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
8893
  WHERE store_category_id=".$row['parent_store_category_id'];
8894
  $quer=$this->db_do($q);
8895
+ $row=mysqli_fetch_array($quer);
8896
  $level++;
8897
  if($level>20){
8898
  break;
8930
  $q="SELECT MAX(id) AS id FROM ".$this->import_status_statistic_table;
8931
 
8932
  $quer=$this->db_do($q);
8933
+ $row=mysqli_fetch_array($quer);
8934
  $this->current_import_status_statistic_id=$row['id'];
8935
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
8936
  SET global_status_import='Failed'
8946
  #################################################################################################
8947
  function set_import_error_reporting_message($message){
8948
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
8949
+ SET error_report_message='".mysqli_real_escape_string($message)."'
8950
  WHERE id=".$this->current_import_status_statistic_id);
8951
  }
8952
  #################################################################################################
8953
  function getImportStatusHistory(){
8954
  $res="SELECT COUNT(*) FROM ".$this->import_status_statistic_table;
8955
+ $cnt_arr=mysqli_fetch_array($this->db_do($res));
8956
  $cnt=$cnt_arr[0];
8957
  $StatusHistory_arr = array();
8958
  if($cnt>0){
8969
  FROM ".$this->import_status_statistic_table."
8970
  ORDER BY start_import limit ".$a.", ".$b;
8971
  $result=$this->db_do($q);
8972
+ while($row=mysqli_fetch_array($result)){
8973
  $StatusHistory_arr[]=$row;
8974
  }
8975
  }
8981
  FROM ".$this->import_status_statistic_table."
8982
  WHERE global_status_import='Successful'
8983
  ORDER BY id DESC LIMIT 1";
8984
+ $imp_date=mysqli_fetch_array($this->db_do($q));
8985
  return $imp_date['start_import'];
8986
  }
8987
  #################################################################################################
8997
  error_report_message
8998
  FROM ".$this->import_status_statistic_table."
8999
  ORDER BY id DESC LIMIT 1";
9000
+ $imp_status=mysqli_fetch_array($this->db_do($q));
9001
  return $imp_status;
9002
  }
9003
 
9027
  FROM ".$this->import_status_table."
9028
  ORDER BY id LIMIT 1";
9029
  $quer=$this->db_do($q);
9030
+ if($row=mysqli_fetch_array($quer)){
9031
  $messages=array('message'=>$row['message'], 'id'=>$row['id'], 'finished'=>$row['finished']);
9032
  $id=$row['id'];
9033
  }
9047
  LIMIT 1
9048
  ";
9049
  $result = $this->db_do($sql);
9050
+ if ($row = mysqli_fetch_assoc($result)) {
9051
  return $row['entity_type_id'];
9052
  }
9053
  return false;
9071
  LIMIT 1
9072
  ";
9073
  $result = $this->db_do($sql);
9074
+ if ($row = mysqli_fetch_assoc($result)) {
9075
 
9076
  $this->defaultAttributeSetId = $row['default_attribute_set_id'];
9077
  }
9089
  LIMIT 1
9090
  ";
9091
  $result = $this->db_do($sql);
9092
+ if ($row = mysqli_fetch_assoc($result)) {
9093
  $this->_categoryEntityTypeId = $row['entity_type_id'];
9094
  $this->_categoryDefault_attribute_set_id = $row['default_attribute_set_id'];
9095
  }
9113
  WHERE entity_type_id = '" . $typeId . "'
9114
  ";
9115
  $result = $this->db_do($sql);
9116
+ while ($row = mysqli_fetch_assoc($result)) {
9117
  $this->_attributeId[$typeCode][$row['attribute_code']] = $row['attribute_id'];
9118
  }
9119
  }
9154
  WHERE
9155
  value='default-category'";
9156
  $res=$this->db_do($q);
9157
+ $row=mysqli_fetch_array($res);
9158
  if($row['entity_id']>0){
9159
  return $row['entity_id'];
9160
  }else{
9163
  WHERE parent_id=".$cat_id;
9164
  $quer=$this->db_do($q);
9165
  $count=0;
9166
+ while ($row=mysqli_fetch_array($quer)){
9167
  $count++;
9168
  $entity_id=$row['entity_id'];
9169
  }
9181
  $q='SHOW TABLES LIKE "'.Mage::getSingleton('core/resource')->getTableName('catalog_product_flat_').'%"';
9182
  $quer=$this->db_do($q);
9183
  $result=false;
9184
+ While($row=mysqli_fetch_array($quer)){
9185
  if(is_array($row)){
9186
  $catalog_product_flat=array_pop($row);
9187
  $q='DELETE pf1 FROM '.$catalog_product_flat.' pf1
9883
  WHERE store_product_id =".$store_product_id;
9884
  $quer=$this->db_do($q);
9885
  $offers = null;
9886
+ while($row = mysqli_fetch_array($quer)){
9887
  $offers[]=$row;
9888
  }
9889
  return $offers;
9903
  WHERE parent_id=".$entity_id;
9904
  $quer=$this->db_do($q);
9905
  $children_cat='';
9906
+ while ($row=mysqli_fetch_array($quer)){
9907
  $children_cat .= ", '".$row['entity_id']."'";
9908
  $children_cat .= $this->get_all_children_cat_recursive($row['entity_id']);
9909
  }
9917
  // echo $q;
9918
  $quer=$this->db_do($q);
9919
  $i=0;
9920
+ while ($row=mysqli_fetch_array($quer)){
9921
  $i++;
9922
  }
9923
  return ($i);
app/code/local/Bintime/Sinchimport/Model/Sinch_new_code.php CHANGED
@@ -57,7 +57,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
57
  $this->price_breaks_filter=PRICE_BREAKS;
58
  /*$this->db_connect();
59
  $res = $this->db_do("select languages_id from languages where code='".LANG_CODE."'");
60
- $row = mysql_fetch_assoc($res);
61
  $this->lang_id = $row['languages_id'];
62
  */
63
  $this->varDir = TEMPORARY_DIRECTORY_FOR_STORING_FILES;
@@ -132,7 +132,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
132
  function is_imort_not_run(){
133
  $q="SELECT IS_FREE_LOCK('sinchimport') as getlock";
134
  $quer=$this->db_do($q);
135
- $row=mysql_fetch_array($quer);
136
  return $row['getlock'];
137
  }
138
  #################################################################################################
@@ -141,7 +141,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
141
  $q='SHOW PROCEDURE STATUS LIKE "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'"';
142
  $quer=$this->db_do($q);
143
  $result=false;
144
- While($row=mysql_fetch_array($quer)){
145
  if(($row['Name']==Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s')) && ($row['Db']==$dbConf->dbname)){
146
  $result = true;
147
  }
@@ -152,7 +152,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
152
  function check_db_privileges(){
153
  $q='SHOW PRIVILEGES';
154
  $quer=$this->db_do($q);
155
- while($row=mysql_fetch_array($quer)){
156
  if($row['Privilege']=='File' && $row['Context']=='File access on server'){
157
  return true;
158
  }
@@ -163,7 +163,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
163
  function check_local_infile(){
164
  $q='SHOW VARIABLES LIKE "local_infile"';
165
  $quer=$this->db_do($q);
166
- $row=mysql_fetch_array($quer);
167
  if($row['Variable_name']=='local_infile' && $row['Value']=="ON"){
168
  return true;
169
  }else{
@@ -176,7 +176,7 @@ class Bintime_Sinchimport_Model_Sinch extends Mage_Core_Model_Abstract {
176
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic')."
177
  WHERE import_type='FULL' AND global_status_import='Successful'";
178
  $quer=$this->db_do($q);
179
- $row=mysql_fetch_array($quer);
180
  if($row['cnt']>0){
181
  return true;
182
  }else{
@@ -528,7 +528,7 @@ echo("\n\n\n==================RETURN=================\n\n\n");
528
 
529
  /**if (!$this->check_loaded_data($parse_file, $categories_temp))
530
  {
531
- $inf = mysql_info();
532
  $this->set_import_error_reporting_message('The Stock In The Channel data files do not appear to be in the correct format. Check file'.$parse_file. "(LOAD DATA ... ".$inf.")");
533
  exit;
534
  }/**/
@@ -764,7 +764,7 @@ echo("\n\n $query\n\n");
764
 
765
 
766
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
767
- while ($row = mysql_fetch_array($categories))
768
  {
769
  $parent_id = $row['parent_id'];
770
  $entity_id = $row['entity_id'];
@@ -775,7 +775,7 @@ echo("\n\n $query\n\n");
775
  UPDATE $catalog_category_entity
776
  SET path = '$path'
777
  WHERE entity_id = $entity_id");
778
- } // while ($row = mysql_fetch_array($categories))
779
 
780
 
781
 
@@ -1211,7 +1211,7 @@ $query = "
1211
  echo("\n $query\n");
1212
  $root_categories = $this->db_do($query);
1213
 
1214
- while($root_cat = mysql_fetch_array($root_categories))
1215
  {
1216
  $root_id = $root_cat['entity_id'];
1217
  $root_name = $root_cat['RootName'];
@@ -1282,13 +1282,13 @@ echo("\n\n ==================================================================
1282
  AND cce.entity_type_id = ccev.entity_type_id
1283
  AND ccev.attribute_id = 41
1284
  WHERE parent_id = 1"); // 41 - category name
1285
- while ($row = mysql_fetch_array($query)) $old_cats[] = $row['category_name'];
1286
 
1287
  //var_dump($old_cats);
1288
 
1289
 
1290
  $query = $this->db_do("SELECT MAX(entity_id) AS max_entity_id FROM $catalog_category_entity");
1291
- $max_entity_id = mysql_fetch_array($query);
1292
 
1293
  //var_dump($max_entity_id);
1294
 
@@ -1373,11 +1373,11 @@ echo("\n createNewDefaultCategories done... \n ===========================
1373
  AND ccev.attribute_id = 41
1374
  WHERE parent_id = 1"); // 41 - category name
1375
  $OLD = array();
1376
- while($root_cat = mysql_fetch_array($root_categories)) $OLD[] = $root_cat['category_name'];
1377
 
1378
  $new_categories = $this->db_do("SELECT DISTINCT RootName FROM $categories_temp");
1379
  $NEW = array();
1380
- while($new_root_cat = mysql_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['RootName']] = TRUE;
1381
 
1382
  /**
1383
  $exists_coincidence = array();
@@ -1587,7 +1587,7 @@ $query = "
1587
  echo("\n\n$query\n\n");
1588
  $root_categories = $this->db_do($query);
1589
 
1590
- while($root_cat = mysql_fetch_array($root_categories))
1591
  {
1592
  $root_id = $root_cat['entity_id'];
1593
  $root_name = $root_cat['RootName'];
@@ -1737,7 +1737,7 @@ echo("\n\n$query\n\n");
1737
 
1738
 
1739
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
1740
- while ($row = mysql_fetch_array($categories))
1741
  {
1742
  $parent_id = $row['parent_id'];
1743
  $entity_id = $row['entity_id'];
@@ -1748,7 +1748,7 @@ echo("\n\n$query\n\n");
1748
  UPDATE $catalog_category_entity
1749
  SET path = '$path'
1750
  WHERE entity_id = $entity_id");
1751
- } // while ($row = mysql_fetch_array($categories))
1752
 
1753
 
1754
  ///////////////////////////////////////////////////////
@@ -2086,7 +2086,7 @@ echo("\n\n$query\n\n");
2086
  FROM $catalog_category_entity
2087
  WHERE entity_id = $cat_id";
2088
  $quer = $this->db_do($q);
2089
- $row = mysql_fetch_array($quer);
2090
  while ($row['parent_id'])
2091
  {
2092
  $path = $row['parent_id'].'/'.$path;
@@ -2098,7 +2098,7 @@ echo("\n\n$query\n\n");
2098
  FROM $catalog_category_entity
2099
  WHERE entity_id = $parent_id";
2100
  $quer = $this->db_do($q);
2101
- $row = mysql_fetch_array($quer);
2102
  }
2103
 
2104
  if ($cat_id) $path.=$cat_id."/";
@@ -3043,7 +3043,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
3043
  WHERE parent_store_category_id = 0");
3044
 
3045
  $store_cat_ids = $this->db_do("SELECT store_category_id FROM $categories_temp");
3046
- while ($row = mysql_fetch_array($store_cat_ids))
3047
  {
3048
  $store_category_id = $row['store_category_id'];
3049
 
@@ -3259,7 +3259,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
3259
 
3260
 
3261
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
3262
- while ($row = mysql_fetch_array($categories))
3263
  {
3264
  $parent_id = $row['parent_id'];
3265
  $entity_id = $row['entity_id'];
@@ -3752,7 +3752,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
3752
  WHERE aov.value IS NULL";
3753
  $quer=$this->db_do($q);
3754
 
3755
- while($row=mysql_fetch_array($quer)){
3756
  $q0="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
3757
  (attribute_id)
3758
  VALUES(".$this->attributes['manufacturer'].")";
@@ -3764,7 +3764,7 @@ echo("\n replaceMagentoProductsMultistore 41\n");
3764
  )(
3765
  SELECT
3766
  max(option_id) as option_id,
3767
- "."'".mysql_real_escape_string($row['manufacturer_name'])."'
3768
  FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
3769
  WHERE attribute_id=".$this->attributes['manufacturer']."
3770
  )
@@ -3906,7 +3906,7 @@ echo("\nParseProducts 7\n");
3906
  if($this->current_import_status_statistic_id){
3907
  $res = $this->db_do("SELECT COUNT(*) AS cnt
3908
  FROM ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
3909
- $row = mysql_fetch_assoc($res);
3910
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
3911
  SET number_of_products=".$row['cnt']."
3912
  WHERE id=".$this->current_import_status_statistic_id);
@@ -4059,7 +4059,7 @@ echo("\nParseProducts 11\n");
4059
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
4060
  INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
4061
  ON a.store_product_id=b.store_product_id");
4062
- $row = mysql_fetch_assoc($res);
4063
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
4064
  SET number_of_products=".$row['cnt']."
4065
  WHERE id=".$this->current_import_status_statistic_id);
@@ -4227,7 +4227,7 @@ echo("\nParseProducts 11\n");
4227
  FROM ".Mage::getSingleton('core/resource')->getTableName('core_store')."
4228
  WHERE code!='admin'
4229
  "); // where code!='admin' was adder for editing Featured products;
4230
- while ($row = mysql_fetch_assoc($result)) {
4231
  $sql = "INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." (
4232
  store_product_id,
4233
  sinch_product_id,
@@ -5314,7 +5314,7 @@ echo("\ndone\n");
5314
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_type')
5315
  );
5316
  $link_type=array();
5317
- while ($row = mysql_fetch_array($result)) {
5318
  $link_type[$row['code']]=$row['link_type_id'];
5319
  }
5320
 
@@ -5391,7 +5391,7 @@ echo("\ndone\n");
5391
  /* $q="select distinct store_product_id from stINch_related_products";
5392
  $quer=$this->db_do($q);
5393
  $prod = Mage::getModel('catalog/product');
5394
- while ($row = mysql_fetch_assoc($quer)) {
5395
  $q1="select distinct store_related_product_id store_product_id from stINch_related_products where store_product_id=".$row['store_product_id'].;
5396
  $quer1=$this->db_do($q1);
5397
  $prod->load($row['store_product_id']);
@@ -5408,7 +5408,7 @@ echo("\ndone\n");
5408
  ###$product->save();
5409
  ###
5410
  $i=1;
5411
- while ($row1 = mysql_fetch_assoc($quer1)) {
5412
  $param[$row1['store_related_product_id']]['position']=$i++;
5413
 
5414
  }
@@ -5655,7 +5655,7 @@ echo("\ndone\n");
5655
  $q="SELECT customer_group_id FROM ".Mage::getSingleton('core/resource')->getTableName('customer_group');
5656
  $quer=$this->db_do($q);
5657
 
5658
- while ($row = mysql_fetch_assoc($quer)) {
5659
  $result = $this->db_do("
5660
  INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." (
5661
  entity_id,
@@ -5785,7 +5785,7 @@ echo("\ndone\n");
5785
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products')."
5786
  WHERE store_product_id =".$store_product_id;
5787
  $quer=$this->db_do($q);
5788
- $product=mysql_fetch_array($quer);
5789
 
5790
  $this->productDescription = (string) substr($product['description'],50,0);
5791
  $this->fullProductDescription = (string)$product['description'];
@@ -5800,7 +5800,7 @@ echo("\ndone\n");
5800
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')."
5801
  WHERE sinch_manufacturer_id=".$product['sinch_manufacturer_id'];
5802
  $quer=$this->db_do($q);
5803
- $manufacturer=mysql_fetch_array($quer);
5804
  $this->vendor = (string)$manufacturer['manufacturer_name'];
5805
  }
5806
  $q="SELECT DISTINCT ean_code
@@ -5809,7 +5809,7 @@ echo("\ndone\n");
5809
  ON sec.product_id=sp.sinch_product_id
5810
  WHERE sp.store_product_id=".$store_product_id;
5811
  $quer=$this->db_do($q);
5812
- while ($row=mysql_fetch_array($quer)){
5813
  $EANarr[]=$row['ean_code'];
5814
  }
5815
  // $prodEAN = $productTag->EANCode;
@@ -5834,7 +5834,7 @@ echo("\ndone\n");
5834
  INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features')." c
5835
  ON b.category_feature_id = c.category_feature_id
5836
  WHERE a.sinch_product_id = '" .$this->sinchProductId . "'" );
5837
- while ($features = mysql_fetch_array($product_info_features)) {
5838
  $descriptionArray[$features['name']] = $features['value'];
5839
  }
5840
 
@@ -5871,7 +5871,7 @@ echo("\ndone\n");
5871
 
5872
  // echo $q;
5873
  $quer=$this->db_do($q);
5874
- while($row=mysql_fetch_array($quer)){
5875
 
5876
  $productArray = array();
5877
  $productArray['name'] = (string)$row['product_name'];
@@ -5902,7 +5902,7 @@ echo("\ndone\n");
5902
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery')."
5903
  WHERE store_product_id=".$store_product_id);
5904
 
5905
- $res=mysql_fetch_array($q);
5906
  if(!$res || !$res['cnt']){
5907
  return false;
5908
  }
@@ -5914,7 +5914,7 @@ echo("\ndone\n");
5914
 
5915
  $res=$this->db_do($q);
5916
 
5917
- while($photo=mysql_fetch_array($res)){
5918
  $picHeight = (int)500;//$photo["PicHeight"];
5919
  $picWidth = (int)500;//$photo["PicWidth"];
5920
  $thumbUrl = (string)$photo["ThumbPic"];
@@ -6044,7 +6044,7 @@ echo("\ndone\n");
6044
  $q=$this->db_do("SELECT store_product_id
6045
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')."
6046
  WHERE entity_id=".$entity_id);
6047
- $res=mysql_fetch_array($q);
6048
  // echo $entity_id."AAAA".$res['store_product_id']; exit;
6049
  return ($res['store_product_id']);
6050
  }
@@ -6055,14 +6055,15 @@ echo("\ndone\n");
6055
  // $connection = Mage::getModel('core/resource')->getConnection('core_write');
6056
  $dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
6057
 
6058
- if ($this->db = mysql_connect($dbConf->host, $dbConf->username, $dbConf->password, true, 128)) {
6059
- if(mysql_select_db($dbConf->dbname)){
 
6060
  $this->_LOG("Connected..");
6061
  }else{
6062
- die("Can't select the database: " . mysql_error());
6063
  }
6064
  }else{
6065
- die("Could not connect: " . mysql_error());
6066
 
6067
  }
6068
 
@@ -6075,11 +6076,11 @@ echo("\ndone\n");
6075
  Mage::log("Query: " . $query, null, $this->_logFile);
6076
  }
6077
  // $result = $this->this->db_do($query);//
6078
- // $query=mysql_real_escape_string($query);
6079
- //mysql_query('set names utf8');
6080
- $result = mysql_query($query) or die("Query failed: " . mysql_error());
6081
  if (!$result) {
6082
- throw new Exception("Invalid query: $sql\n" . mysql_error());
6083
  } else {
6084
  return $result;
6085
  }
@@ -6089,7 +6090,7 @@ echo("\ndone\n");
6089
  ##################################################################################################
6090
  function table_rows_count($table){
6091
  $rows_count_res=$this->db_do("select count(*) as cnt from ".$table);
6092
- $rows_count=mysql_fetch_array($rows_count_res);
6093
  return ($rows_count['cnt']);
6094
  }
6095
  ##################################################################################################
@@ -6145,11 +6146,11 @@ echo("\ndone\n");
6145
  WHERE entity_type_id=".$entity_type_id."
6146
  AND attribute_id=".$attribute_id
6147
  );
6148
- while($row=mysql_fetch_array($result)){
6149
  $value=$this->valid_char($row['value']);
6150
  if($value!='' and $value!=$row['value']){
6151
  $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')."
6152
- SET value='".mysql_real_escape_string($value)."'
6153
  WHERE entity_id=".$row['entity_id']."
6154
  AND entity_type_id=".$entity_type_id."
6155
  AND attribute_id=".$attribute_id);
@@ -6279,7 +6280,7 @@ echo("\ndone\n");
6279
  WHERE parent_store_category_id=".$id;
6280
  $quer=$this->db_do($q);
6281
  $count=0;
6282
- while ($row=mysql_fetch_array($quer)){
6283
  $count+=$this->count_children($row['store_category_id']);
6284
  $count++;
6285
  }
@@ -6326,7 +6327,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6326
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
6327
  WHERE entity_id=".$cat_id;
6328
  $quer=$this->db_do($q);
6329
- $row=mysql_fetch_array($quer);
6330
  while($row['parent_id']){
6331
  $path=$row['parent_id'].'/'.$path;
6332
  $q="SELECT
@@ -6334,7 +6335,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6334
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
6335
  WHERE entity_id=".$row['parent_id'];
6336
  $quer=$this->db_do($q);
6337
- $row=mysql_fetch_array($quer);
6338
 
6339
  }
6340
  if($cat_id){
@@ -6356,13 +6357,13 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6356
  WHERE store_category_id=".$id;
6357
  $quer=$this->db_do($q);
6358
  $level=1;
6359
- $row=mysql_fetch_array($quer);
6360
  while ($row['parent_store_category_id']!=0){
6361
  $q="SELECT parent_store_category_id
6362
  FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
6363
  WHERE store_category_id=".$row['parent_store_category_id'];
6364
  $quer=$this->db_do($q);
6365
- $row=mysql_fetch_array($quer);
6366
  $level++;
6367
  if($level>20){
6368
  break;
@@ -6400,7 +6401,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6400
  $q="SELECT MAX(id) AS id FROM ".$this->import_status_statistic_table;
6401
 
6402
  $quer=$this->db_do($q);
6403
- $row=mysql_fetch_array($quer);
6404
  $this->current_import_status_statistic_id=$row['id'];
6405
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
6406
  SET global_status_import='Failed'
@@ -6416,13 +6417,13 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6416
  #################################################################################################
6417
  function set_import_error_reporting_message($message){
6418
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
6419
- SET error_report_message='".mysql_real_escape_string($message)."'
6420
  WHERE id=".$this->current_import_status_statistic_id);
6421
  }
6422
  #################################################################################################
6423
  function getImportStatusHistory(){
6424
  $res="SELECT COUNT(*) FROM ".$this->import_status_statistic_table;
6425
- $cnt_arr=mysql_fetch_array($this->db_do($res));
6426
  $cnt=$cnt_arr[0];
6427
  $StatusHistory_arr = array();
6428
  if($cnt>0){
@@ -6439,7 +6440,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6439
  FROM ".$this->import_status_statistic_table."
6440
  ORDER BY start_import limit ".$a.", ".$b;
6441
  $result=$this->db_do($q);
6442
- while($row=mysql_fetch_array($result)){
6443
  $StatusHistory_arr[]=$row;
6444
  }
6445
  }
@@ -6451,7 +6452,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6451
  FROM ".$this->import_status_statistic_table."
6452
  WHERE global_status_import='Successful'
6453
  ORDER BY id DESC LIMIT 1";
6454
- $imp_date=mysql_fetch_array($this->db_do($q));
6455
  return $imp_date['start_import'];
6456
  }
6457
  #################################################################################################
@@ -6467,7 +6468,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6467
  error_report_message
6468
  FROM ".$this->import_status_statistic_table."
6469
  ORDER BY id DESC LIMIT 1";
6470
- $imp_status=mysql_fetch_array($this->db_do($q));
6471
  return $imp_status;
6472
  }
6473
 
@@ -6497,7 +6498,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6497
  FROM ".$this->import_status_table."
6498
  ORDER BY id LIMIT 1";
6499
  $quer=$this->db_do($q);
6500
- if($row=mysql_fetch_array($quer)){
6501
  $messages=array('message'=>$row['message'], 'id'=>$row['id'], 'finished'=>$row['finished']);
6502
  $id=$row['id'];
6503
  }
@@ -6517,7 +6518,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6517
  LIMIT 1
6518
  ";
6519
  $result = $this->db_do($sql);
6520
- if ($row = mysql_fetch_assoc($result)) {
6521
  return $row['entity_type_id'];
6522
  }
6523
  return false;
@@ -6541,7 +6542,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6541
  LIMIT 1
6542
  ";
6543
  $result = $this->db_do($sql);
6544
- if ($row = mysql_fetch_assoc($result)) {
6545
 
6546
  $this->defaultAttributeSetId = $row['default_attribute_set_id'];
6547
  }
@@ -6559,7 +6560,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6559
  LIMIT 1
6560
  ";
6561
  $result = $this->db_do($sql);
6562
- if ($row = mysql_fetch_assoc($result)) {
6563
  $this->_categoryEntityTypeId = $row['entity_type_id'];
6564
  $this->_categoryDefault_attribute_set_id = $row['default_attribute_set_id'];
6565
  }
@@ -6583,7 +6584,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6583
  WHERE entity_type_id = '" . $typeId . "'
6584
  ";
6585
  $result = $this->db_do($sql);
6586
- while ($row = mysql_fetch_assoc($result)) {
6587
  $this->_attributeId[$typeCode][$row['attribute_code']] = $row['attribute_id'];
6588
  }
6589
  }
@@ -6624,7 +6625,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6624
  WHERE
6625
  value='default-category'";
6626
  $res=$this->db_do($q);
6627
- $row=mysql_fetch_array($res);
6628
  if($row['entity_id']>0){
6629
  return $row['entity_id'];
6630
  }else{
@@ -6633,7 +6634,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6633
  WHERE parent_id=".$cat_id;
6634
  $quer=$this->db_do($q);
6635
  $count=0;
6636
- while ($row=mysql_fetch_array($quer)){
6637
  $count++;
6638
  $entity_id=$row['entity_id'];
6639
  }
@@ -6651,7 +6652,7 @@ echo("\nparent_id = [$parent_id] ent_id = [$ent_id]\n");
6651
  $q='SHOW TABLES LIKE "'.Mage::getSingleton('core/resource')->getTableName('catalog_product_flat_').'%"';
6652
  $quer=$this->db_do($q);
6653
  $result=false;
6654
- While($row=mysql_fetch_array($quer)){
6655
  if(is_array($row)){
6656
  $catalog_product_flat=array_pop($row);
6657
  $q='DELETE pf1 FROM '.$catalog_product_flat.' pf1
57
  $this->price_breaks_filter=PRICE_BREAKS;
58
  /*$this->db_connect();
59
  $res = $this->db_do("select languages_id from languages where code='".LANG_CODE."'");
60
+ $row = mysqli_fetch_assoc($res);
61
  $this->lang_id = $row['languages_id'];
62
  */
63
  $this->varDir = TEMPORARY_DIRECTORY_FOR_STORING_FILES;
132
  function is_imort_not_run(){
133
  $q="SELECT IS_FREE_LOCK('sinchimport') as getlock";
134
  $quer=$this->db_do($q);
135
+ $row=mysqli_fetch_array($quer);
136
  return $row['getlock'];
137
  }
138
  #################################################################################################
141
  $q='SHOW PROCEDURE STATUS LIKE "'.Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s').'"';
142
  $quer=$this->db_do($q);
143
  $result=false;
144
+ While($row=mysqli_fetch_array($quer)){
145
  if(($row['Name']==Mage::getSingleton('core/resource')->getTableName('filter_sinch_products_s')) && ($row['Db']==$dbConf->dbname)){
146
  $result = true;
147
  }
152
  function check_db_privileges(){
153
  $q='SHOW PRIVILEGES';
154
  $quer=$this->db_do($q);
155
+ while($row=mysqli_fetch_array($quer)){
156
  if($row['Privilege']=='File' && $row['Context']=='File access on server'){
157
  return true;
158
  }
163
  function check_local_infile(){
164
  $q='SHOW VARIABLES LIKE "local_infile"';
165
  $quer=$this->db_do($q);
166
+ $row=mysqli_fetch_array($quer);
167
  if($row['Variable_name']=='local_infile' && $row['Value']=="ON"){
168
  return true;
169
  }else{
176
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_import_status_statistic')."
177
  WHERE import_type='FULL' AND global_status_import='Successful'";
178
  $quer=$this->db_do($q);
179
+ $row=mysqli_fetch_array($quer);
180
  if($row['cnt']>0){
181
  return true;
182
  }else{
528
 
529
  /**if (!$this->check_loaded_data($parse_file, $categories_temp))
530
  {
531
+ $inf = mysqli_info();
532
  $this->set_import_error_reporting_message('The Stock In The Channel data files do not appear to be in the correct format. Check file'.$parse_file. "(LOAD DATA ... ".$inf.")");
533
  exit;
534
  }/**/
764
 
765
 
766
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
767
+ while ($row = mysqli_fetch_array($categories))
768
  {
769
  $parent_id = $row['parent_id'];
770
  $entity_id = $row['entity_id'];
775
  UPDATE $catalog_category_entity
776
  SET path = '$path'
777
  WHERE entity_id = $entity_id");
778
+ } // while ($row = mysqli_fetch_array($categories))
779
 
780
 
781
 
1211
  echo("\n $query\n");
1212
  $root_categories = $this->db_do($query);
1213
 
1214
+ while($root_cat = mysqli_fetch_array($root_categories))
1215
  {
1216
  $root_id = $root_cat['entity_id'];
1217
  $root_name = $root_cat['RootName'];
1282
  AND cce.entity_type_id = ccev.entity_type_id
1283
  AND ccev.attribute_id = 41
1284
  WHERE parent_id = 1"); // 41 - category name
1285
+ while ($row = mysqli_fetch_array($query)) $old_cats[] = $row['category_name'];
1286
 
1287
  //var_dump($old_cats);
1288
 
1289
 
1290
  $query = $this->db_do("SELECT MAX(entity_id) AS max_entity_id FROM $catalog_category_entity");
1291
+ $max_entity_id = mysqli_fetch_array($query);
1292
 
1293
  //var_dump($max_entity_id);
1294
 
1373
  AND ccev.attribute_id = 41
1374
  WHERE parent_id = 1"); // 41 - category name
1375
  $OLD = array();
1376
+ while($root_cat = mysqli_fetch_array($root_categories)) $OLD[] = $root_cat['category_name'];
1377
 
1378
  $new_categories = $this->db_do("SELECT DISTINCT RootName FROM $categories_temp");
1379
  $NEW = array();
1380
+ while($new_root_cat = mysqli_fetch_array($new_categories)) $exists_coincidence[$new_root_cat['RootName']] = TRUE;
1381
 
1382
  /**
1383
  $exists_coincidence = array();
1587
  echo("\n\n$query\n\n");
1588
  $root_categories = $this->db_do($query);
1589
 
1590
+ while($root_cat = mysqli_fetch_array($root_categories))
1591
  {
1592
  $root_id = $root_cat['entity_id'];
1593
  $root_name = $root_cat['RootName'];
1737
 
1738
 
1739
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
1740
+ while ($row = mysqli_fetch_array($categories))
1741
  {
1742
  $parent_id = $row['parent_id'];
1743
  $entity_id = $row['entity_id'];
1748
  UPDATE $catalog_category_entity
1749
  SET path = '$path'
1750
  WHERE entity_id = $entity_id");
1751
+ } // while ($row = mysqli_fetch_array($categories))
1752
 
1753
 
1754
  ///////////////////////////////////////////////////////
2086
  FROM $catalog_category_entity
2087
  WHERE entity_id = $cat_id";
2088
  $quer = $this->db_do($q);
2089
+ $row = mysqli_fetch_array($quer);
2090
  while ($row['parent_id'])
2091
  {
2092
  $path = $row['parent_id'].'/'.$path;
2098
  FROM $catalog_category_entity
2099
  WHERE entity_id = $parent_id";
2100
  $quer = $this->db_do($q);
2101
+ $row = mysqli_fetch_array($quer);
2102
  }
2103
 
2104
  if ($cat_id) $path.=$cat_id."/";
3043
  WHERE parent_store_category_id = 0");
3044
 
3045
  $store_cat_ids = $this->db_do("SELECT store_category_id FROM $categories_temp");
3046
+ while ($row = mysqli_fetch_array($store_cat_ids))
3047
  {
3048
  $store_category_id = $row['store_category_id'];
3049
 
3259
 
3260
 
3261
  $categories = $this->db_do("SELECT entity_id, parent_id FROM $catalog_category_entity ORDER BY parent_id");
3262
+ while ($row = mysqli_fetch_array($categories))
3263
  {
3264
  $parent_id = $row['parent_id'];
3265
  $entity_id = $row['entity_id'];
3752
  WHERE aov.value IS NULL";
3753
  $quer=$this->db_do($q);
3754
 
3755
+ while($row=mysqli_fetch_array($quer)){
3756
  $q0="INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
3757
  (attribute_id)
3758
  VALUES(".$this->attributes['manufacturer'].")";
3764
  )(
3765
  SELECT
3766
  max(option_id) as option_id,
3767
+ "."'".mysqli_real_escape_string($row['manufacturer_name'])."'
3768
  FROM ".Mage::getSingleton('core/resource')->getTableName('eav_attribute_option')."
3769
  WHERE attribute_id=".$this->attributes['manufacturer']."
3770
  )
3906
  if($this->current_import_status_statistic_id){
3907
  $res = $this->db_do("SELECT COUNT(*) AS cnt
3908
  FROM ".Mage::getSingleton('core/resource')->getTableName('products_temp'));
3909
+ $row = mysqli_fetch_assoc($res);
3910
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
3911
  SET number_of_products=".$row['cnt']."
3912
  WHERE id=".$this->current_import_status_statistic_id);
4059
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')." a
4060
  INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stock_and_prices_temp')." b
4061
  ON a.store_product_id=b.store_product_id");
4062
+ $row = mysqli_fetch_assoc($res);
4063
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
4064
  SET number_of_products=".$row['cnt']."
4065
  WHERE id=".$this->current_import_status_statistic_id);
4227
  FROM ".Mage::getSingleton('core/resource')->getTableName('core_store')."
4228
  WHERE code!='admin'
4229
  "); // where code!='admin' was adder for editing Featured products;
4230
+ while ($row = mysqli_fetch_assoc($result)) {
4231
  $sql = "INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('products_website_temp')." (
4232
  store_product_id,
4233
  sinch_product_id,
5314
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_product_link_type')
5315
  );
5316
  $link_type=array();
5317
+ while ($row = mysqli_fetch_array($result)) {
5318
  $link_type[$row['code']]=$row['link_type_id'];
5319
  }
5320
 
5391
  /* $q="select distinct store_product_id from stINch_related_products";
5392
  $quer=$this->db_do($q);
5393
  $prod = Mage::getModel('catalog/product');
5394
+ while ($row = mysqli_fetch_assoc($quer)) {
5395
  $q1="select distinct store_related_product_id store_product_id from stINch_related_products where store_product_id=".$row['store_product_id'].;
5396
  $quer1=$this->db_do($q1);
5397
  $prod->load($row['store_product_id']);
5408
  ###$product->save();
5409
  ###
5410
  $i=1;
5411
+ while ($row1 = mysqli_fetch_assoc($quer1)) {
5412
  $param[$row1['store_related_product_id']]['position']=$i++;
5413
 
5414
  }
5655
  $q="SELECT customer_group_id FROM ".Mage::getSingleton('core/resource')->getTableName('customer_group');
5656
  $quer=$this->db_do($q);
5657
 
5658
+ while ($row = mysqli_fetch_assoc($quer)) {
5659
  $result = $this->db_do("
5660
  INSERT INTO ".Mage::getSingleton('core/resource')->getTableName('catalog_product_index_price')." (
5661
  entity_id,
5785
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products')."
5786
  WHERE store_product_id =".$store_product_id;
5787
  $quer=$this->db_do($q);
5788
+ $product=mysqli_fetch_array($quer);
5789
 
5790
  $this->productDescription = (string) substr($product['description'],50,0);
5791
  $this->fullProductDescription = (string)$product['description'];
5800
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_manufacturers')."
5801
  WHERE sinch_manufacturer_id=".$product['sinch_manufacturer_id'];
5802
  $quer=$this->db_do($q);
5803
+ $manufacturer=mysqli_fetch_array($quer);
5804
  $this->vendor = (string)$manufacturer['manufacturer_name'];
5805
  }
5806
  $q="SELECT DISTINCT ean_code
5809
  ON sec.product_id=sp.sinch_product_id
5810
  WHERE sp.store_product_id=".$store_product_id;
5811
  $quer=$this->db_do($q);
5812
+ while ($row=mysqli_fetch_array($quer)){
5813
  $EANarr[]=$row['ean_code'];
5814
  }
5815
  // $prodEAN = $productTag->EANCode;
5834
  INNER JOIN ".Mage::getSingleton('core/resource')->getTableName('stINch_categories_features')." c
5835
  ON b.category_feature_id = c.category_feature_id
5836
  WHERE a.sinch_product_id = '" .$this->sinchProductId . "'" );
5837
+ while ($features = mysqli_fetch_array($product_info_features)) {
5838
  $descriptionArray[$features['name']] = $features['value'];
5839
  }
5840
 
5871
 
5872
  // echo $q;
5873
  $quer=$this->db_do($q);
5874
+ while($row=mysqli_fetch_array($quer)){
5875
 
5876
  $productArray = array();
5877
  $productArray['name'] = (string)$row['product_name'];
5902
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_pictures_gallery')."
5903
  WHERE store_product_id=".$store_product_id);
5904
 
5905
+ $res=mysqli_fetch_array($q);
5906
  if(!$res || !$res['cnt']){
5907
  return false;
5908
  }
5914
 
5915
  $res=$this->db_do($q);
5916
 
5917
+ while($photo=mysqli_fetch_array($res)){
5918
  $picHeight = (int)500;//$photo["PicHeight"];
5919
  $picWidth = (int)500;//$photo["PicWidth"];
5920
  $thumbUrl = (string)$photo["ThumbPic"];
6044
  $q=$this->db_do("SELECT store_product_id
6045
  FROM ".Mage::getSingleton('core/resource')->getTableName('stINch_products_mapping')."
6046
  WHERE entity_id=".$entity_id);
6047
+ $res=mysqli_fetch_array($q);
6048
  // echo $entity_id."AAAA".$res['store_product_id']; exit;
6049
  return ($res['store_product_id']);
6050
  }
6055
  // $connection = Mage::getModel('core/resource')->getConnection('core_write');
6056
  $dbConf = Mage::getConfig()->getResourceConnectionConfig('core_setup');
6057
 
6058
+ if ($this->db = mysqli_connect($dbConf->host, $dbConf->username, $dbConf->password)) {
6059
+ mysqli_options($this->db, MYSQLI_OPT_LOCAL_INFILE, true);
6060
+ if(mysqli_select_db($this->db, $dbConf->dbname)){
6061
  $this->_LOG("Connected..");
6062
  }else{
6063
+ die("Can't select the database: " . mysqli_error($this->db));
6064
  }
6065
  }else{
6066
+ die("Could not connect: " . mysqli_error($this->db));
6067
 
6068
  }
6069
 
6076
  Mage::log("Query: " . $query, null, $this->_logFile);
6077
  }
6078
  // $result = $this->this->db_do($query);//
6079
+ // $query=mysqli_real_escape_string($query);
6080
+ //mysqli_query('set names utf8');
6081
+ $result = mysqli_query($this->db, $query) or die("Query failed: " . mysqli_error($this->db));
6082
  if (!$result) {
6083
+ throw new Exception("Invalid query: $sql\n" . mysqli_error($this->db));
6084
  } else {
6085
  return $result;
6086
  }
6090
  ##################################################################################################
6091
  function table_rows_count($table){
6092
  $rows_count_res=$this->db_do("select count(*) as cnt from ".$table);
6093
+ $rows_count=mysqli_fetch_array($rows_count_res);
6094
  return ($rows_count['cnt']);
6095
  }
6096
  ##################################################################################################
6146
  WHERE entity_type_id=".$entity_type_id."
6147
  AND attribute_id=".$attribute_id
6148
  );
6149
+ while($row=mysqli_fetch_array($result)){
6150
  $value=$this->valid_char($row['value']);
6151
  if($value!='' and $value!=$row['value']){
6152
  $this->db_do("UPDATE ".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')."
6153
+ SET value='".mysqli_real_escape_string($value)."'
6154
  WHERE entity_id=".$row['entity_id']."
6155
  AND entity_type_id=".$entity_type_id."
6156
  AND attribute_id=".$attribute_id);
6280
  WHERE parent_store_category_id=".$id;
6281
  $quer=$this->db_do($q);
6282
  $count=0;
6283
+ while ($row=mysqli_fetch_array($quer)){
6284
  $count+=$this->count_children($row['store_category_id']);
6285
  $count++;
6286
  }
6327
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
6328
  WHERE entity_id=".$cat_id;
6329
  $quer=$this->db_do($q);
6330
+ $row=mysqli_fetch_array($quer);
6331
  while($row['parent_id']){
6332
  $path=$row['parent_id'].'/'.$path;
6333
  $q="SELECT
6335
  FROM ".Mage::getSingleton('core/resource')->getTableName('catalog_category_entity')."
6336
  WHERE entity_id=".$row['parent_id'];
6337
  $quer=$this->db_do($q);
6338
+ $row=mysqli_fetch_array($quer);
6339
 
6340
  }
6341
  if($cat_id){
6357
  WHERE store_category_id=".$id;
6358
  $quer=$this->db_do($q);
6359
  $level=1;
6360
+ $row=mysqli_fetch_array($quer);
6361
  while ($row['parent_store_category_id']!=0){
6362
  $q="SELECT parent_store_category_id
6363
  FROM ".Mage::getSingleton('core/resource')->getTableName('categories_temp')."
6364
  WHERE store_category_id=".$row['parent_store_category_id'];
6365
  $quer=$this->db_do($q);
6366
+ $row=mysqli_fetch_array($quer);
6367
  $level++;
6368
  if($level>20){
6369
  break;
6401
  $q="SELECT MAX(id) AS id FROM ".$this->import_status_statistic_table;
6402
 
6403
  $quer=$this->db_do($q);
6404
+ $row=mysqli_fetch_array($quer);
6405
  $this->current_import_status_statistic_id=$row['id'];
6406
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
6407
  SET global_status_import='Failed'
6417
  #################################################################################################
6418
  function set_import_error_reporting_message($message){
6419
  $this->db_do("UPDATE ".$this->import_status_statistic_table."
6420
+ SET error_report_message='".mysqli_real_escape_string($message)."'
6421
  WHERE id=".$this->current_import_status_statistic_id);
6422
  }
6423
  #################################################################################################
6424
  function getImportStatusHistory(){
6425
  $res="SELECT COUNT(*) FROM ".$this->import_status_statistic_table;
6426
+ $cnt_arr=mysqli_fetch_array($this->db_do($res));
6427
  $cnt=$cnt_arr[0];
6428
  $StatusHistory_arr = array();
6429
  if($cnt>0){
6440
  FROM ".$this->import_status_statistic_table."
6441
  ORDER BY start_import limit ".$a.", ".$b;
6442
  $result=$this->db_do($q);
6443
+ while($row=mysqli_fetch_array($result)){
6444
  $StatusHistory_arr[]=$row;
6445
  }
6446
  }
6452
  FROM ".$this->import_status_statistic_table."
6453
  WHERE global_status_import='Successful'
6454
  ORDER BY id DESC LIMIT 1";
6455
+ $imp_date=mysqli_fetch_array($this->db_do($q));
6456
  return $imp_date['start_import'];
6457
  }
6458
  #################################################################################################
6468
  error_report_message
6469
  FROM ".$this->import_status_statistic_table."
6470
  ORDER BY id DESC LIMIT 1";
6471
+ $imp_status=mysqli_fetch_array($this->db_do($q));
6472
  return $imp_status;
6473
  }
6474
 
6498
  FROM ".$this->import_status_table."
6499
  ORDER BY id LIMIT 1";
6500
  $quer=$this->db_do($q);
6501
+ if($row=mysqli_fetch_array($quer)){
6502
  $messages=array('message'=>$row['message'], 'id'=>$row['id'], 'finished'=>$row['finished']);
6503
  $id=$row['id'];
6504
  }
6518
  LIMIT 1
6519
  ";
6520
  $result = $this->db_do($sql);
6521
+ if ($row = mysqli_fetch_assoc($result)) {
6522
  return $row['entity_type_id'];
6523
  }
6524
  return false;
6542
  LIMIT 1
6543
  ";
6544
  $result = $this->db_do($sql);
6545
+ if ($row = mysqli_fetch_assoc($result)) {
6546
 
6547
  $this->defaultAttributeSetId = $row['default_attribute_set_id'];
6548
  }
6560
  LIMIT 1
6561
  ";
6562
  $result = $this->db_do($sql);
6563
+ if ($row = mysqli_fetch_assoc($result)) {
6564
  $this->_categoryEntityTypeId = $row['entity_type_id'];
6565
  $this->_categoryDefault_attribute_set_id = $row['default_attribute_set_id'];
6566
  }
6584
  WHERE entity_type_id = '" . $typeId . "'
6585
  ";
6586
  $result = $this->db_do($sql);
6587
+ while ($row = mysqli_fetch_assoc($result)) {
6588
  $this->_attributeId[$typeCode][$row['attribute_code']] = $row['attribute_id'];
6589
  }
6590
  }
6625
  WHERE
6626
  value='default-category'";
6627
  $res=$this->db_do($q);
6628
+ $row=mysqli_fetch_array($res);
6629
  if($row['entity_id']>0){
6630
  return $row['entity_id'];
6631
  }else{
6634
  WHERE parent_id=".$cat_id;
6635
  $quer=$this->db_do($q);
6636
  $count=0;
6637
+ while ($row=mysqli_fetch_array($quer)){
6638
  $count++;
6639
  $entity_id=$row['entity_id'];
6640
  }
6652
  $q='SHOW TABLES LIKE "'.Mage::getSingleton('core/resource')->getTableName('catalog_product_flat_').'%"';
6653
  $quer=$this->db_do($q);
6654
  $result=false;
6655
+ While($row=mysqli_fetch_array($quer)){
6656
  if(is_array($row)){
6657
  $catalog_product_flat=array_pop($row);
6658
  $q='DELETE pf1 FROM '.$catalog_product_flat.' pf1
app/code/local/Bintime/Sinchimport/Model/System/Config/ServerList.php CHANGED
@@ -9,10 +9,13 @@ class Bintime_Sinchimport_Model_System_Config_ServerList
9
  public function toOptionArray()
10
  {
11
  $paramsArray = array(
12
- 'ftp.stockinthechannel.com' => 'UK(ftp.stockinthechannel.com)',
13
- 'ftpus.stockinthechannel.com' => 'USA(ftpus.stockinthechannel.com)',
 
 
 
 
14
  );
15
-
16
  return $paramsArray;
17
  }
18
  }
9
  public function toOptionArray()
10
  {
11
  $paramsArray = array(
12
+ 'ftp.stockinthechannel.com' => 'UK - ftp.stockinthechannel.com',
13
+ 'ftpus.stockinthechannel.com' => 'USA - ftpus.stockinthechannel.com',
14
+ 'ftp.canalstock.es' => 'Spain - ftp.canalstock.es',
15
+ 'ftp.canalstock.mx' => 'Mexico - ftp.canalstock.mx',
16
+ 'ftp.stockradar.be' => 'Belgium - ftp.stockradar.be',
17
+ 'ftpau.stockinthechannel.com' => 'Australia - ftpau.stockinthechannel.com',
18
  );
 
19
  return $paramsArray;
20
  }
21
  }
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-install-0.1.0.php CHANGED
@@ -4,12 +4,12 @@ $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
 
@@ -133,10 +133,10 @@ BEGIN
133
  END
134
  ";
135
 
136
- if (!mysql_query($query, $cnx)) {
137
  throw new Exception("Failed to create stored procedure");
138
  }
139
 
140
- mysql_close($cnx);
141
 
142
  $installer->endSetup();
4
 
5
  //прямое подключение к базе необходимо для добавления хранимки
6
  $config = $installer->getConnection()->getConfig();
7
+ $cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
8
  if (!$cnx) {
9
  throw new Exception('Failed to connect to database.');
10
  }
11
 
12
+ if (!mysqli_select_db($cnx, $config['dbname'])) {
13
  throw new Exception('Failed to select a database.');
14
  }
15
 
133
  END
134
  ";
135
 
136
+ if (!mysqli_query($cnx, $query)) {
137
  throw new Exception("Failed to create stored procedure");
138
  }
139
 
140
+ mysqli_close($cnx);
141
 
142
  $installer->endSetup();
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.1-0.1.2.php CHANGED
@@ -5,20 +5,20 @@ stepan
5
  $installer = $this;
6
 
7
  $config = $installer->getConnection()->getConfig();
8
- $cnx = mysql_connect($config['host'], $config['username'], $config['password']);
9
  if (!$cnx) {
10
  throw new Exception('Failed to connect to database.');
11
  }
12
 
13
- if (!mysql_select_db($config['dbname'])) {
14
  throw new Exception('Failed to select a database.');
15
  }
16
 
17
  $check_store_product_id=1;
18
  $check_sinch_product_id=1;
19
  $q="show columns from catalog_product_entity";
20
- $res=mysql_query($q);
21
- while($row=mysql_fetch_assoc($res)){
22
  if($row['Field']=='store_product_id'){
23
  $check_store_product_id=0;
24
  }elseif($row['Field']=='sinch_product_id'){
5
  $installer = $this;
6
 
7
  $config = $installer->getConnection()->getConfig();
8
+ $cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
9
  if (!$cnx) {
10
  throw new Exception('Failed to connect to database.');
11
  }
12
 
13
+ if (!mysqli_select_db($cnx, $config['dbname'])) {
14
  throw new Exception('Failed to select a database.');
15
  }
16
 
17
  $check_store_product_id=1;
18
  $check_sinch_product_id=1;
19
  $q="show columns from catalog_product_entity";
20
+ $res=mysqli_query($cnx, $q);
21
+ while($row=mysqli_fetch_assoc($res)){
22
  if($row['Field']=='store_product_id'){
23
  $check_store_product_id=0;
24
  }elseif($row['Field']=='sinch_product_id'){
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.2-0.1.3.php CHANGED
@@ -4,12 +4,12 @@ $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
 
@@ -124,10 +124,10 @@ BEGIN
124
  END
125
  ";
126
 
127
- if (!mysql_query($query, $cnx)) {
128
  throw new Exception("Failed to create stored procedure");
129
  }
130
 
131
- mysql_close($cnx);
132
 
133
  $installer->endSetup();
4
 
5
  //прямое подключение к базе необходимо для добавления хранимки
6
  $config = $installer->getConnection()->getConfig();
7
+ $cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
8
  if (!$cnx) {
9
  throw new Exception('Failed to connect to database.');
10
  }
11
 
12
+ if (!mysqli_select_db($cnx, $config['dbname'])) {
13
  throw new Exception('Failed to select a database.');
14
  }
15
 
124
  END
125
  ";
126
 
127
+ if (!mysqli_query($cnx, $query)) {
128
  throw new Exception("Failed to create stored procedure");
129
  }
130
 
131
+ mysqli_close($cnx);
132
 
133
  $installer->endSetup();
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.6-0.1.7.php CHANGED
@@ -4,12 +4,12 @@ $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
 
@@ -19,8 +19,8 @@ $installer->startSetup();
19
  $check_store_category_id=1;
20
  $check_parent_store_category_id=1;
21
  $q="show columns from catalog_category_entity";
22
- $res=mysql_query($q);
23
- while($row=mysql_fetch_assoc($res)){
24
  if($row['Field']=='store_category_id'){
25
  $check_store_category_id=0;
26
  }elseif($row['Field']=='parent_store_category_id'){
@@ -265,10 +265,10 @@ BEGIN
265
  END
266
  ";
267
 
268
- if (!mysql_query($query, $cnx)) {
269
  throw new Exception("Failed to create stored procedure");
270
  }
271
 
272
- mysql_close($cnx);
273
 
274
  $installer->endSetup();
4
 
5
  //прямое подключение к базе необходимо для добавления хранимки
6
  $config = $installer->getConnection()->getConfig();
7
+ $cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
8
  if (!$cnx) {
9
  throw new Exception('Failed to connect to database.');
10
  }
11
 
12
+ if (!mysqli_select_db($cnx, $config['dbname'])) {
13
  throw new Exception('Failed to select a database.');
14
  }
15
 
19
  $check_store_category_id=1;
20
  $check_parent_store_category_id=1;
21
  $q="show columns from catalog_category_entity";
22
+ $res=mysqli_query($cnx, $q);
23
+ while($row=mysqli_fetch_assoc($res)){
24
  if($row['Field']=='store_category_id'){
25
  $check_store_category_id=0;
26
  }elseif($row['Field']=='parent_store_category_id'){
265
  END
266
  ";
267
 
268
+ if (!mysqli_query($cnx, $query)) {
269
  throw new Exception("Failed to create stored procedure");
270
  }
271
 
272
+ mysqli_close($cnx);
273
 
274
  $installer->endSetup();
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.1.7-0.1.8.php CHANGED
@@ -98,7 +98,7 @@ INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code,
98
  'You are missing the MySQL stored procedure ".$installer->getTable('filter_icecat_products_s').".sql', 'You can recreate it by running the script found in [shop dir]/app/code/local/Bintime/Sinchimport/sql/ in PhpMyAdmin');
99
  ");
100
 
101
- mysql_close($cnx);
102
 
103
  $installer->endSetup();
104
 
98
  'You are missing the MySQL stored procedure ".$installer->getTable('filter_icecat_products_s').".sql', 'You can recreate it by running the script found in [shop dir]/app/code/local/Bintime/Sinchimport/sql/ in PhpMyAdmin');
99
  ");
100
 
101
+ mysqli_close($cnx);
102
 
103
  $installer->endSetup();
104
 
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.0-0.2.1.php CHANGED
@@ -98,7 +98,7 @@ INSERT ".$installer->getTable('stINch_sinchcheck')."(caption, descr, check_code,
98
  'You are missing the MySQL stored procedure ".$installer->getTable('filter_sinch_products_s').".sql', 'You can recreate it by running the script found in [shop dir]/app/code/local/Bintime/Sinchimport/sql/ in PhpMyAdmin');
99
  ");
100
 
101
- mysql_close($cnx);
102
 
103
  $installer->endSetup();
104
 
98
  'You are missing the MySQL stored procedure ".$installer->getTable('filter_sinch_products_s').".sql', 'You can recreate it by running the script found in [shop dir]/app/code/local/Bintime/Sinchimport/sql/ in PhpMyAdmin');
99
  ");
100
 
101
+ mysqli_close($cnx);
102
 
103
  $installer->endSetup();
104
 
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-0.2.1-0.2.2.php CHANGED
@@ -4,12 +4,12 @@ $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
 
@@ -221,10 +221,10 @@ BEGIN
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();
4
 
5
  //прямое подключение к базе необходимо для добавления хранимки
6
  $config = $installer->getConnection()->getConfig();
7
+ $cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
8
  if (!$cnx) {
9
  throw new Exception('Failed to connect to database.');
10
  }
11
 
12
+ if (!mysqli_select_db($cnx, $config['dbname'])) {
13
  throw new Exception('Failed to select a database.');
14
  }
15
 
221
  END
222
  ";
223
 
224
+ if (!mysqli_query($cnx, $query)) {
225
  throw new Exception("Failed to create stored procedure");
226
  }
227
 
228
+ mysqli_close($cnx);
229
 
230
  $installer->endSetup();
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.0-3.0.1.php CHANGED
@@ -3,12 +3,12 @@ $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
 
@@ -297,11 +297,11 @@ BEGIN
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();
3
 
4
  //прямое подключение к базе необходимо для добавления хранимки
5
  $config = $installer->getConnection()->getConfig();
6
+ $cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
7
  if (!$cnx) {
8
  throw new Exception('Failed to connect to database.');
9
  }
10
 
11
+ if (!mysqli_select_db($cnx, $config['dbname'])) {
12
  throw new Exception('Failed to select a database.');
13
  }
14
 
297
  END
298
  ";
299
 
300
+ if (!mysqli_query($cnx, $query)) {
301
  throw new Exception("Failed to create stored procedure".$query);
302
  }
303
 
304
 
305
+ mysqli_close($cnx);
306
 
307
  $installer->endSetup();
app/code/local/Bintime/Sinchimport/sql/sinchimport_setup/mysql4-upgrade-3.0.2-3.0.3.php CHANGED
@@ -4,12 +4,12 @@ $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
 
@@ -33,10 +33,10 @@ BEGIN
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();
4
 
5
  //прямое подключение к базе необходимо для добавления хранимки
6
  $config = $installer->getConnection()->getConfig();
7
+ $cnx = mysqli_connect($config['host'], $config['username'], $config['password']);
8
  if (!$cnx) {
9
  throw new Exception('Failed to connect to database.');
10
  }
11
 
12
+ if (!mysqli_select_db($cnx, $config['dbname'])) {
13
  throw new Exception('Failed to select a database.');
14
  }
15
 
33
  END
34
  ";
35
 
36
+ if (!mysqli_query($cnx, $query)) {
37
  throw new Exception("Failed to create stored function");
38
  }
39
 
40
+ mysqli_close($cnx);
41
 
42
  $installer->endSetup();
app/design/adminhtml/default/default/layout/sinchimport.xml CHANGED
@@ -1,57 +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>
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 CHANGED
@@ -1,70 +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; ?>
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 CHANGED
@@ -1,13 +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>
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>
app/design/frontend/default/default/layout/sinchimport.xml CHANGED
@@ -1,110 +1,110 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
-
4
- <sinchimport_product_view>
5
- <!-- <update handle="catalog_product_view" /> -->
6
- <!-- Mage_Catalog -->
7
- <reference name="root">
8
- <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
9
- </reference>
10
- <reference name="head">
11
- <action method="addJs"><script>varien/product.js</script></action>
12
- <action method="addCss"><stylesheet>css/view_table.css</stylesheet></action>
13
- <action method="addItem"><type>skin_js</type><name>js/product_view.js</name></action>
14
- <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_c