stefano7 Posted May 2, 2015 Share Posted May 2, 2015 (edited) Hi, sorry for my english i need to ugrade quantity combination. I use this in mysql with csv file and it work's for me: but: - with this file prestashop doesn't change total quantity of the product but only the single combination. - there is another simple way to bulk upgrade quantity of combination in mysql or not? <?php // -------------------------------------------------- // quantity_update.php // Change MySql database quantity and prices and other data from csv file // Standalone script - run it by web browser // Last Updated: May 27 2009 // Author: Mozack // // Instructions // // Backup your database. // Define the veriables below. // Upload this file to your server. // quantity_update.php // // To run open in your browser. // Example: http://www.mysite.com/protected_folder/quantity_update.php // // That's it!!! Check that everything is changed properly and make neccessary corrections. // // WHEN DONE REMOVE THIS FILE FROM YOUR SERVER OR KEEP WITH THIS FILE ONE INDEX.PHP REDIRECTING !!!!! // --------------------------------------------------- //Configuration variables //--------------------------------------------------- // Connect to MySQL change with your data mysql_connect("LOCALHOST", "stanem_pres678", "92S.7G56P.") or die(mysql_error()); mysql_select_db("stanem_pres678") or die(mysql_error()); // If first row of csv file is headings set $row to 1. $row = 1; // TABLE OF PRODUCTS AND VARIATIONS - IN PRESTASHOP IS PREFIX_product_attribute $update_table = "ps_stock_available"; // Get the csv file - INSERT THE ADDRESS OF CSV FILE OR UPLOAD IT TO THE SOME FOLDER OF THIS SCRIPT $handle = fopen("http://shop.stanem.it/csv/INVENTARIO.csv", "r"); // Go through the csv file and print each row with fields to the screen. // And import them into the database updating only the price and quantity // YOU MUST SET THE VARIABLES $ean13, $price AND $quantity IF YOU ARE NOT UPDATING PRESTASHOP TABLES // IF YOU WANT TO UPDATE OTHER DATA IN THE SOME TABLE LIKE SUPPLIER_REFERENCE, LOCATION, ECOTAX, ETC YOU MAST HAVE // ALL THE DATA IN THE SOME CSV FILE AND THE COLLUMS IN THE SOME ORDER OF THIS CODE. YOU MUST ADD MORE IF STATEMENTS TO ADD // ADITIONAL DATA TO IMPORT while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) { $num = $c=2; echo "<p> $num fields to update in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { if ($c = 1) { $idpa = $data[($c - 1)]; echo $idpa . " ID Assigned <br />\n"; } if ($c = 2) { $quantity = $data[($c - 1)]; mysql_query("UPDATE $update_table SET quantity='$quantity' WHERE id_product_attribute = '$idpa'") or die(mysql_error()); echo $product_quantity . " Imported to <b>$row</b> in product <b>$ID</b> <br />\n"; } // ADD ADITIONAL IF STATEMENTS FOR EACH FIELD YOU WANT UPDATE IN THE SOME ORDER OF YOUR CSV FILE } } fclose($handle); echo "<h1>COMPLETED.</h1>"; ?> Edited May 2, 2015 by stefano7 (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted May 5, 2015 Share Posted May 5, 2015 Try CSV import - Combinations. Link to comment Share on other sites More sharing options...
stefano7 Posted May 8, 2015 Author Share Posted May 8, 2015 thank's for your reply but if i re-import combination with csv, prestashop re-create other combination doesn't update existing Link to comment Share on other sites More sharing options...
tuk66 Posted May 11, 2015 Share Posted May 11, 2015 Another way is to use SQL queries. But which one, it needs a little thought and testing. Link to comment Share on other sites More sharing options...
musicmaster Posted May 12, 2015 Share Posted May 12, 2015 You could try my free script Triple Edit. It is not exactly mass update for combinations but you can handle everything on one screen what makes it much faster than Prestashop. Link to comment Share on other sites More sharing options...
stefano7 Posted May 12, 2015 Author Share Posted May 12, 2015 thank's a lot to all. #musicmaster i search a metod a little bit auto #tuk i use mysql query but i need something fast that mine Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now