Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

Vous parlez français ? par ici !
[[SOLVED]]Automatic update product quantities
#1
Posted 27 May 2009 - 03:13 PM
I'm newbie with prestashop, i've created new products with variation (sizes), each size of products have different EAN and different quantities. How can i update that quantities from one external php file protected by password?
I want something like cronjob to do the task and keep my available quantities updated.
The external php file (from other store) have on first collum the EAN of related size, on second collum (dont need to connect) have the name of product and 3rd collum have the available quantites...
Is that possible to do? Maybe one script like other shopping carts uses to update currencies... I dont know...
Can someone help me?
Thanls thanks thanks...
Biquini Moda Praia Blog - http://www.biquinimo...og-loja-online/
Bikini Perfeito - http://www.bikiniperfeito.com
Bikinis Brasileiros Online - http://www.bikinisbr...eirosonline.com
4everus.net - http://www.4everus.net - Social Life
Mozack Blog - http://www.mozack.net
#3
Posted 27 May 2009 - 03:36 PM
Thanks... If i solve this i share it
Biquini Moda Praia Blog - http://www.biquinimo...og-loja-online/
Bikini Perfeito - http://www.bikiniperfeito.com
Bikinis Brasileiros Online - http://www.bikinisbr...eirosonline.com
4everus.net - http://www.4everus.net - Social Life
Mozack Blog - http://www.mozack.net
#4
Posted 27 May 2009 - 07:44 PM
From 1243434625:
Theres a lot of people needing some kind of module that can do update of products prices, quantities and availability but so far nothing can do that.
If you figure out how to do that please share with us.
Hi, the problem of quantities update is solved...
I can share it but i'm new here...
I dont know how to share it....
Is a basic script but maybe can help someone...
Biquini Moda Praia Blog - http://www.biquinimo...og-loja-online/
Bikini Perfeito - http://www.bikiniperfeito.com
Bikinis Brasileiros Online - http://www.bikinisbr...eirosonline.com
4everus.net - http://www.4everus.net - Social Life
Mozack Blog - http://www.mozack.net
#5
Posted 27 May 2009 - 08:25 PM
welcome too
just post it right here and mark your threat as solved
just attach the files you changed
thanks for sharing
sd
#7
Posted 27 May 2009 - 09:15 PM
is it possible if you have all the data in the same csv
Biquini Moda Praia Blog - http://www.biquinimo...og-loja-online/
Bikini Perfeito - http://www.bikiniperfeito.com
Bikinis Brasileiros Online - http://www.bikinisbr...eirosonline.com
4everus.net - http://www.4everus.net - Social Life
Mozack Blog - http://www.mozack.net
#9
Posted 27 May 2009 - 09:49 PM
Here is the solution. PLEASE BACKUP YOUR DATABASE FIRST. I'VE FINISHED IT TODAY, I TRY AND IT WORKS, BUT IT COULD BE A PROBLEM.
Follow the steps you will find in php file.
Best regards...
I'm waiting for your replay
Attached File(s)
quantity_update.zip (2bytes)
Number of downloads: 1116
Biquini Moda Praia Blog - http://www.biquinimo...og-loja-online/
Bikini Perfeito - http://www.bikiniperfeito.com
Bikinis Brasileiros Online - http://www.bikinisbr...eirosonline.com
4everus.net - http://www.4everus.net - Social Life
Mozack Blog - http://www.mozack.net
#10
Posted 27 May 2009 - 09:53 PM
i don´t need it right now
will give it a try soon i get time
sd
#11
Posted 28 May 2009 - 08:34 AM
One update to the file, on line 44, you can change the "," to ";" if your csv use other type of separator...
Biquini Moda Praia Blog - http://www.biquinimo...og-loja-online/
Bikini Perfeito - http://www.bikiniperfeito.com
Bikinis Brasileiros Online - http://www.bikinisbr...eirosonline.com
4everus.net - http://www.4everus.net - Social Life
Mozack Blog - http://www.mozack.net
#14
Posted 28 May 2009 - 10:21 AM
reference - supplier_reference - location - ean13 - wholesale_price - price (...)
your csv must have this fields or not, but with the some order.
You can only update one table. In this case is the table of product_attribute.
You have to change as well the line 44 to the symbol that separate each collum of csv, set it in php file like: , or ; (..)
In my csv i just have 2 fileds ean13 and quantity (in this order)
Hope can help you, best regards.
Biquini Moda Praia Blog - http://www.biquinimo...og-loja-online/
Bikini Perfeito - http://www.bikiniperfeito.com
Bikinis Brasileiros Online - http://www.bikinisbr...eirosonline.com
4everus.net - http://www.4everus.net - Social Life
Mozack Blog - http://www.mozack.net
#15
Posted 28 May 2009 - 10:22 AM
Thanks.
Biquini Moda Praia Blog - http://www.biquinimo...og-loja-online/
Bikini Perfeito - http://www.bikiniperfeito.com
Bikinis Brasileiros Online - http://www.bikinisbr...eirosonline.com
4everus.net - http://www.4everus.net - Social Life
Mozack Blog - http://www.mozack.net
#17
Posted 13 June 2009 - 01:39 PM
#18
Posted 15 July 2009 - 05:43 PM
<?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.
// update.php
//
// To run open in your browser.
// Example: http://www.mysite.com/secure_folder/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", "here goes your login", "here goes your password") or die(mysql_error());
mysql_select_db("heregoes your database name") 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_product_attribute
$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
// YOU MUST SET THE VARIABLES $reference, $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 = count($data);
echo "n";
echo "( $row )n";
$row++;
for ($c=0; $c < $num; $c++) {
if ($c = 1) {
$reference = $data[($c - 1)];
echo $reference . " - Reference Assignedn";
}
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 updatedn";
}
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 updatedn";
}
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 updatedn";
echo "_____________________________________________________n";
}
// ADD ADITIONAL IF STATEMENTS FOR EACH FIELD YOU WANT UPDATE IN THE SOME ORDER OF YOUR CSV FILE
}
}
fclose($handle);
echo " n";
echo " - - - SUCESSFULY COMPLETED - - - ";
?>
NOTICE, code does not report any mistakes (eg. not found reference) so if anyone knows how to improve this code please share here...
file update.csv
(columns in excel) reference, price, quantity, activity
PCDE-OP360MTE2200 8.853,000000 100 1
PCDE-OP360MTE2500 8.853,000000 100 1
PCDE-OP360MTE5300 132,000000 600 1
PCDE-OP360MTE7400 4.755,000000 600 1
PCDE-OP360MTE2240 8.853,000000 605 1
#19
Posted 31 July 2009 - 03:43 AM
1 fields to update in line 0:
1;"1";"1";"1";"1";"1" EAN13 Assigned
Undefined offset: 1 in C:\wamp\www\prestashop\Protected_folder\quantity_update.php on line 54
Table 'bla bla bla ' doesn't exist
how can i know what is my table?
#20
Posted 11 August 2009 - 10:46 AM
this file update catalog with import csv, okay?
no apply in store.
have a problem.
see screenshot.
Attached File(s)
screen.png (49bytes)
Number of downloads: 2493
CCampea Twitter- http://twitter.com/ccampealoja
CCampea Facebook - CCampea Facebook - Store Online Motos, Bikes and Accessories
CCampea ThisNext - CCampea This
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












