Advertisement
Guest User

Untitled

a guest
Jan 10th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.62 KB | None | 0 0
  1. <?php
  2.  
  3.     $servername = "d58093.mysql.zone.ee";
  4.     $username = "d58093sa114985";
  5.     $password = "";
  6.     $dbname = "d58093_bredencom";
  7.      
  8.      $filter_mapping["50/56"] = 144;
  9.      $filter_mapping["62/68"] = 145;
  10.      $filter_mapping["74/80"] = 146;
  11.      $filter_mapping["86/92"] = 147;
  12.      $filter_mapping["98/104"] = 148;
  13.      $filter_mapping["110/116"] = 149;
  14.      $filter_mapping["122/128"] = 150;
  15.      $filter_mapping["134/140"] = 151;
  16.      $filter_mapping["146/152"] = 152;
  17.      $filter_mapping["158/164"] = 153;
  18.      $filter_mapping["S"] = 154;
  19.      $filter_mapping["M"] = 145;
  20.      $filter_mapping["L"] = 156;
  21.      $filter_mapping["XL"] = 157;
  22.      
  23.      
  24.     //Vanuste mapping
  25.     $filter_mapping["0-2 kuud"] = 158;
  26.     $filter_mapping["2-6 kuud"] = 169;
  27.     $filter_mapping["6-12 kuud"] = 160;
  28.     $filter_mapping["1-2 aastat"] = 161;
  29.     $filter_mapping["2-3 aastat"] = 162;
  30.     $filter_mapping["3-4 aastat"] = 163;
  31.     $filter_mapping["4-5 aastat"] = 164;
  32.     $filter_mapping["5-6 aastat"] = 165;
  33.     $filter_mapping["6-8 aastat"] = 166;
  34.     $filter_mapping["8-10 aastat"] = 167;
  35.     $filter_mapping["10-12 aastat"] = 168;
  36.     $filter_mapping["12+ aastat"] = 169;
  37.     $filter_mapping["Täiskasvanud"] = 170;
  38.      
  39.      
  40.     //Peaümbermõõdu mapping
  41.     $filter_mapping["35/38"] = 171;
  42.     $filter_mapping["39/42"] = 172;
  43.     $filter_mapping["43/46"] = 173;
  44.     $filter_mapping["47/50"] = 174;
  45.     $filter_mapping["51/54"] = 175;
  46.     $filter_mapping["55/58"] = 176;
  47.     $filter_mapping["59/62"] = 177;
  48.  
  49.  
  50.     $xml = simplexml_load_file("https://www.bredenkids.com/erply/suurused.php");
  51.     $products = ['121965', '121936'];
  52.     /* käime läbi kõik tooted mis on XMLis */
  53.     foreach ($xml->products->children() as $product)
  54.     {
  55.         if (empty ($products)) exit;
  56.  
  57.         if (in_array($product->product_id, $products))
  58.         {
  59.  
  60.             /* kui kogus on 0 või väiksem siis lähme edasi loopiga */
  61.             if ($product->sizes->size->attributes()->qty <= 0)
  62.             {
  63.                 continue;
  64.             }
  65.             else
  66.             {
  67.                 $product_id = (STRING) $product->sizes->size->attributes()->product_id;
  68.                 $product_name = (STRING) $product->name;
  69.                 foreach ($product->sizes->size as $size_id => $size_name)
  70.                 {
  71.                     $sql = 'INSERT INTO jk2031_product_filter(product_id, filter_id) VALUES("' . $product_id . '", "' . $filter_mapping[(STRING) $size_name] .'")';
  72.                     echo $sql . "\n";
  73.                 }
  74.  
  75.             }
  76.         }
  77.     }
  78.  
  79.  
  80.  
  81.    // mysqli_close($conn);
  82.  
  83. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement