Noudata näitä ohjeita, jos haluat siirtää tuotteet OpenCart-verkkokauppaohjelmiston versiosta 1.5 Clover Shop -verkkokauppaohjelmistoon. Toimenpide ei vaikuta OpenCart-verkkokaupan toimintaan.
Tässä työssä tarvitaan
<?php /* -----------------------------------------------------UTF-8---❤----- csx4_export.php (model example) Clover Shop(r) X4 Copyright (c) 2013- Clover Shop Oy. All rights reserved. This is commercial software. Unauthorized use, reproduction, reverse engineering and/or distribution is strictly prohibited. For more information, please visit http://www.clovershop.com -------------------------------------------------------------------- */ /* Lets set the software configurations. */ $config['mysql5_database'] = "testitietokanta"; // MySQL-tietokannan nimi $config['mysql5_server'] = "localhost"; // MySQL-tietokantapalvelimen osoite $config['mysql5_read_username'] = "testitunnus"; // MySQL-käyttäjätunnus lukuoikeuksilla SELECT $config['mysql5_read_password'] = "testisalasana"; // MySQL-salasana yllä olevalle käyttäjätunnukselle $config['mysql5_set_charset'] = "utf8"; $config['mysql5_set_names'] = "utf8"; /* Lets set the PHP configurations. */ error_reporting (E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED); ini_set ("display_errors", "1"); ini_set ("display_startup_errors", "0"); ini_set ("default_charset", "UTF-8"); if (function_exists('mb_internal_encoding')) mb_internal_encoding ("UTF-8"); //ini_set ("memory_limit", "1024M"); //ini_set ("max_execution_time", "1500"); /* Lets start a MySQL connection. */ $dblink = @mysqli_connect ($config['mysql5_server'], $config['mysql5_read_username'], $config['mysql5_read_password'], $config['mysql5_database']); if (!$dblink) { echo "Tietokantayhteys ei toimi, MySQL-virhe: ". mysqli_connect_error(); exit; } if (version_compare (PHP_VERSION, "5.2.3", ">=")) { if ($config['mysql5_set_charset']) mysqli_set_charset ($dblink, $config['mysql5_set_charset']); } else { if ($config['mysql5_set_names']) mysqli_query ($dblink, "SET NAMES '". $config['mysql5_set_names'] ."'"); // Do not use real escaping here } /* Lets output the file. */ ob_start(); $result = mysqli_query ($dblink, "SHOW COLUMNS FROM product"); if (is_object ($result) && mysqli_num_rows ($result)) { echo "category_id (product_to_category)|"; echo "name (category_description)|"; echo "name (product_description)|"; echo "description (product_description)|"; echo "meta_description (product_description)|"; echo "meta_keyword (product_description)|"; echo "tag (product_description)|"; echo "name (manufacturer)|"; echo "image (manufacturer)|"; echo "image (product_image 2)|"; echo "image (product_image 3)|"; echo "image (product_image 4)|"; echo "image (product_image 5)|"; echo "image (product_image 6)|"; echo "price (product_discount)|"; echo "date_start (product_discount)|"; echo "date_end (product_discount)|"; echo "price (product_special)|"; echo "date_start (product_special)|"; echo "date_end (product_special)|"; while ($s = mysqli_fetch_array ($result)) { echo $s['Field'] ."|"; } echo "\n"; } $result = mysqli_query ($dblink, "SELECT * FROM product LIMIT 100000"); if (is_object ($result) && mysqli_num_rows ($result)) { while ($s = mysqli_fetch_array ($result)) { $other_result = mysqli_query ($dblink, "SELECT category_id FROM product_to_category WHERE product_id='". mysqli_real_escape_string ($dblink, $s['product_id']) ."' LIMIT 1"); if (is_object ($other_result) && mysqli_num_rows ($other_result)) { $r = mysqli_fetch_array ($other_result); $other_other_result = mysqli_query ($dblink, "SELECT name FROM category_description WHERE category_id='". mysqli_real_escape_string ($dblink, $r['category_id']) ."' LIMIT 1"); if (is_object ($other_other_result) && mysqli_num_rows ($other_other_result)) { $q = mysqli_fetch_array ($other_other_result); } echo "\"". $r['category_id'] ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", htmlspecialchars_decode ($q['name'], ENT_QUOTES)) ."\"|"; } else { echo "\"\"|"; echo "\"\"|"; } $other_result = mysqli_query ($dblink, "SELECT * FROM product_description WHERE product_id='". mysqli_real_escape_string ($dblink, $s['product_id']) ."' LIMIT 1"); if (is_object ($other_result) && mysqli_num_rows ($other_result)) { $r = mysqli_fetch_array ($other_result); echo "\"". str_replace (array ("\r", "\n"), "", htmlspecialchars_decode ($r['name'], ENT_QUOTES)) ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", htmlspecialchars_decode ($r['description'], ENT_QUOTES)) ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", htmlspecialchars_decode ($r['meta_description'], ENT_QUOTES)) ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", htmlspecialchars_decode ($r['meta_keyword'], ENT_QUOTES)) ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", htmlspecialchars_decode ($r['tag'], ENT_QUOTES)) ."\"|"; } else { echo "\"\"|"; echo "\"\"|"; echo "\"\"|"; echo "\"\"|"; echo "\"\"|"; } $other_result = mysqli_query ($dblink, "SELECT * FROM manufacturer WHERE manufacturer_id='". mysqli_real_escape_string ($dblink, $s['manufacturer_id']) ."' ORDER BY sort_order asc LIMIT 1"); if (is_object ($other_result) && mysqli_num_rows ($other_result)) { $r = mysqli_fetch_array ($other_result); echo "\"". str_replace (array ("\r", "\n"), "", htmlspecialchars_decode ($r['name'], ENT_QUOTES)) ."\"|"; echo "\"". $r['image'] ."\"|"; } else { echo "\"\"|"; echo "\"\"|"; } unset ($extra_images); $extra_images = 0; $other_result = mysqli_query ($dblink, "SELECT * FROM product_image WHERE product_id='". mysqli_real_escape_string ($dblink, $s['product_id']) ."' ORDER BY sort_order asc LIMIT 5"); if (is_object ($other_result) && mysqli_num_rows ($other_result)) { while ($r = mysqli_fetch_array ($other_result)) { echo "\"". $r['image'] ."\"|"; $extra_images++; } } $fill_images = (5 - $extra_images); for ($i = 1; $i <= $fill_images; $i++) { echo "\"\"|"; } $other_result = mysqli_query ($dblink, "SELECT * FROM product_discount WHERE product_id='". mysqli_real_escape_string ($dblink, $s['product_id']) ."' LIMIT 1"); if (is_object ($other_result) && mysqli_num_rows ($other_result)) { $r = mysqli_fetch_array ($other_result); echo "\"". str_replace (array ("\r", "\n"), "", $r['price']) ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", $r['date_start']) ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", $r['date_end']) ."\"|"; } else { echo "\"\"|"; echo "\"\"|"; echo "\"\"|"; } $other_result = mysqli_query ($dblink, "SELECT * FROM product_special WHERE product_id='". mysqli_real_escape_string ($dblink, $s['product_id']) ."' LIMIT 1"); if (is_object ($other_result) && mysqli_num_rows ($other_result)) { $r = mysqli_fetch_array ($other_result); echo "\"". str_replace (array ("\r", "\n"), "", $r['price']) ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", $r['date_start']) ."\"|"; echo "\"". str_replace (array ("\r", "\n"), "", $r['date_end']) ."\"|"; } else { echo "\"\"|"; echo "\"\"|"; echo "\"\"|"; } for ($j = 0; $j < 31; $j++) { echo "\"". str_replace (array ("\r", "\n"), "", htmlspecialchars_decode ($s[$j], ENT_QUOTES)) ."\"|"; } echo "\n"; } } header ("Content-type: text/html; charset=utf-8"); header ("Content-Disposition: attachment; filename=\"". date ("YmdHis") ."products.csv\""); echo ob_get_clean(); /* Lets close MySQL connection. */ mysqli_close ($dblink); ?>
Jos tuotujen tuotteiden hinnat ovat arvonlisäveron verran väärin, korjaa niitä saman verran.
Toimi seuraavasti, jos tuotteiden hinnoissa on liikaa desimaaleja haluamaasi määrään nähden, etkä halua korjata niitä yksitellen. Tässä koodiesimerkissä hinnat pyöristetaan kahden desimaalin tarkkuuteen.
<?php /* -----------------------------------------------------UTF-8---❤----- cat/oma_hintojen_pyoristys.php (model example) Clover Shop(r) X4 Copyright (c) 2013- Clover Shop Oy. All rights reserved. This is commercial software. Unauthorized use, reproduction, reverse engineering and/or distribution is strictly prohibited. For more information, please visit http://www.clovershop.com -------------------------------------------------------------------- */ // Säädetään virheilmoitusherkkyyttä error_reporting (0); // Luetaan asetukset include "config/config_inc.php"; // Avataan MySQL-yhteys $mysql_link = @mysqli_connect ($config['mysql5_server'], $config['mysql5_readwrite_username'], $config['mysql5_readwrite_password'], $config['mysql5_database']); if (!$mysql_link) { echo "Tietokantayhteys ei toimi, MySQL-virhe: ". mysqli_connect_error(); exit; } if (version_compare (PHP_VERSION, "5.2.3", ">=")) { mysqli_set_charset ($mysql_link, "utf8"); } else { mysqli_query ($mysql_link, "SET NAMES 'utf8'"); } // Pyöristetään hinnat $result = mysqli_query ($dblink, "SELECT * FROM csx4_products LIMIT 1000000"); if (is_object ($result) && mysqli_num_rows ($result)) { while ($s = mysqli_fetch_array ($result)) { if ($s['cs_product_price1_normal']) { $s['cs_product_price1_normal'] = round ($s['cs_product_price1_normal'], 2); mysqli_query ($dblink, "UPDATE csx4_products SET cs_product_price1_normal='". mysqli_real_escape_string ($dblink, $s['cs_product_price1_normal']) ."' WHERE cs_product_id='". mysqli_real_escape_string ($dblink, $s['cs_product_id']) ."'"); } if ($s['cs_product_price1_sale']) { $s['cs_product_price1_sale'] = round ($s['cs_product_price1_sale'], 2); mysqli_query ($dblink, "UPDATE csx4_products SET cs_product_price1_sale='". mysqli_real_escape_string ($dblink, $s['cs_product_price1_sale']) ."' WHERE cs_product_id='". mysqli_real_escape_string ($dblink, $s['cs_product_id']) ."'"); } } echo "Hintojen pyöristys tehty."; } // Suljetaan MySQL-yhteys mysqli_close ($mysql_link); ?>
Näillä ohjeilla ei voida siirtää tuoteoptioita, kuten esimerkiksi T-paidan värioptioita. Tuonti tapahtuu ensimmäiseen asiakasryhmään.
Näillä ohjeilla ja koodiesimerkeillä ei ole minkäänlaista toimivuustakuuta. Emme vastaa välittömistä, välillisistä, satunnaisista tai epäsuorista vahingoista, menetyksistä, korvauksista, tai kolmannen osapuolen esittämistä vaatimuksista, jotka johtuvat näiden ohjeiden tai koodiesimerkkien noudattamisesta.
Asenna ohjelmisto tai tilaa meiltä maksuton asennustyö. Maksuton asiakaspalvelumme ja tekninen tukemme neuvoo tarvittaessa kummassakin tapauksessa.
Kirjaudu selaimella verkkokaupan hallintaliittymään ja perusta verkkokauppa. Tarjoamme maksuttomat Maxi-ominaisuudet verkkokaupan perustamisen ajaksi.
Tilaa lisenssi vasta, kun olet perustanut verkkokaupan, eli verkkokauppa on ns. laitettu tulille. Voit myös olla tilaamatta lisenssiä ja luopua hankkeesta.