Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "d58093.mysql.zone.ee";
- $username = "d58093sa114985";
- $password = "";
- $dbname = "d58093_bredencom";
- $filter_mapping["50/56"] = 144;
- $filter_mapping["62/68"] = 145;
- $filter_mapping["74/80"] = 146;
- $filter_mapping["86/92"] = 147;
- $filter_mapping["98/104"] = 148;
- $filter_mapping["110/116"] = 149;
- $filter_mapping["122/128"] = 150;
- $filter_mapping["134/140"] = 151;
- $filter_mapping["146/152"] = 152;
- $filter_mapping["158/164"] = 153;
- $filter_mapping["S"] = 154;
- $filter_mapping["M"] = 145;
- $filter_mapping["L"] = 156;
- $filter_mapping["XL"] = 157;
- //Vanuste mapping
- $filter_mapping["0-2 kuud"] = 158;
- $filter_mapping["2-6 kuud"] = 169;
- $filter_mapping["6-12 kuud"] = 160;
- $filter_mapping["1-2 aastat"] = 161;
- $filter_mapping["2-3 aastat"] = 162;
- $filter_mapping["3-4 aastat"] = 163;
- $filter_mapping["4-5 aastat"] = 164;
- $filter_mapping["5-6 aastat"] = 165;
- $filter_mapping["6-8 aastat"] = 166;
- $filter_mapping["8-10 aastat"] = 167;
- $filter_mapping["10-12 aastat"] = 168;
- $filter_mapping["12+ aastat"] = 169;
- $filter_mapping["Täiskasvanud"] = 170;
- //Peaümbermõõdu mapping
- $filter_mapping["35/38"] = 171;
- $filter_mapping["39/42"] = 172;
- $filter_mapping["43/46"] = 173;
- $filter_mapping["47/50"] = 174;
- $filter_mapping["51/54"] = 175;
- $filter_mapping["55/58"] = 176;
- $filter_mapping["59/62"] = 177;
- $xml = simplexml_load_file("https://www.bredenkids.com/erply/suurused.php");
- $products = ['121965', '121936'];
- /* käime läbi kõik tooted mis on XMLis */
- foreach ($xml->products->children() as $product)
- {
- if (empty ($products)) exit;
- if (in_array($product->product_id, $products))
- {
- /* kui kogus on 0 või väiksem siis lähme edasi loopiga */
- if ($product->sizes->size->attributes()->qty <= 0)
- {
- continue;
- }
- else
- {
- $product_id = (STRING) $product->sizes->size->attributes()->product_id;
- $product_name = (STRING) $product->name;
- foreach ($product->sizes->size as $size_id => $size_name)
- {
- $sql = 'INSERT INTO jk2031_product_filter(product_id, filter_id) VALUES("' . $product_id . '", "' . $filter_mapping[(STRING) $size_name] .'")';
- echo $sql . "\n";
- }
- }
- }
- }
- // mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement