Jump to content

Stocks786

Members
  • Posts

    3
  • Joined

  • Last visited

Contact Methods

Profile Information

  • Location
    South Africa

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Stocks786's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thank you for your help. I will try this and get back to you.
  2. This is the code that I've used... // -------------------------------------------------- // quantity_update.php // Change MySql database quantity and prices and other data from csv file // // To run open in your browser. // Example: http://www.mysite.com/secure_folder/update.php // // --------------------------------------------------- //Configuration variables //--------------------------------------------------- // Connect to MySQL change with your data mysql_connect("LOCALHOST", "root", "") or die(mysql_error()); mysql_select_db("presta100") or die(mysql_error()); // If first row of csv file is headings set $row to 1. $row = 0; // TABLE OF PRODUCTS AND VARIATIONS - IN PRESTASHOP IS PREFIX_ $update_table = "ps_product"; // Get the csv file - INSERT THE ADDRESS OF CSV FILE OR UPLOAD IT TO THE SOME FOLDER OF THIS SCRIPT $handle = fopen("update.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 // SET VARIABLES $reference, $price AND $quantity IF YOU ARE NOT UPDATING PRESTASHOP TABLES while (($data = fgetcsv($handle, 100000, ";")) !== FALSE) { $num = count($data); echo "\n"; echo "( $row )\n"; $row++; for ($c=0; $c < $num; $c++) { if ($c = 1) { $reference = $data[($c - 1)]; echo $reference . " - Reference Assigned\n"; } if ($c = 2) { $price = $data[($c - 1)]; mysql_query("UPDATE $update_table SET price='$price' WHERE reference='$reference'") or die(mysql_error()); echo $price . " - Price updated\n"; } if ($c = 3) { $quantity = $data[($c - 1)]; mysql_query("UPDATE $update_table SET quantity='$quantity' WHERE reference='$reference'") or die(mysql_error()); echo $quantity . " - Quantity updated\n"; } if ($c = 4) { $active = $data[($c - 1)]; mysql_query("UPDATE $update_table SET active='$active' WHERE reference='$reference'") or die(mysql_error()); echo $active . " - Activity updated\n"; echo "_____________________________________________________\n"; } } } fclose($handle); echo " \n"; echo " - - - SUCESSFULY COMPLETED - - - "; ?>
  3. Hi I'm really battling to find a way to create a PHP script to update my stock quantities in PS 1.6. What I need it to do is Upload CSV file that has my stock code (Reference) and quantities. Read that csv file and run an sql query to update the stock quantities. My CSV file has the following fields: Reference (Text as per stock code) Quantity (integer) I tried with some PHP Code and an SQL query but failed, miserably. I do know that my stock quantities is stored in the stock_available table and that the master products in the product table. Any assistance is appreciated. Thanks in advance.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More