Jump to content

System to update CSV File When Order Placed


Recommended Posts

Hi guys,


Not sure if this is possible but thought if it was, someone here would know.


Is it possible so that when a customer makes a purchase on my Prestashop website, that the system would update a CSV file? In short, I would like a CSV file that shows the number of orders placed in that day and then to keep an on going track as and when it happens automatically?


If it helps, I am trying to link some key metrics from my Prestashop website into Cyfe.


Thanks in advance.

Link to comment
Share on other sites



Funnily enough we were talking about this today in order to load orders into our warehousing system.


My thoughts are that you would want to create a batch type program/process that is scheduled to run via crontab at determined times. This batch program would read the orders table and output to a csv file taking care not to output any orders that have been output previously.


In theory this should be fairly simple.


If on the other hand you wanted to write to the CSV file as soon as an order was placed, you would probably have to create an override for the code that creates the order.



Link to comment
Share on other sites

Okay, I have managed to write a php script that should pull data from the MySQL database. In essence its for a Cyfe widget that I want to be able to display the number of orders on each day. I have the following so far however it isn't pulling data through, it says 0 for every day and thats not right. Can you help?


// Connect to the data source
$db_user  = "xxxxx";
$db_password = "xxxxx";
$db_database = "xxxxx";
$db_server = "xxxxx";
mysql_connect($db_server, $db_user, $db_password);
@mysql_select_db($db_database) or die( "Unable to select database");
$query = "SELECT date_add, COUNT(*) as count FROM id_shop GROUP BY date_add ORDER BY date_add ASC";
$result = mysql_query($query);
$incoming_data = array();
while($row = mysql_fetch_array($result))
$incoming_data[str_replace('-', '', $row['date_add'])] = $row['count'];
// Load up the data into an array as follows
$data = array();
$data[] = 'Date,Orders';
if(count($incoming_data) > 0)
for($i=29; $i>=0; $i--)
$date = date('Ymd', strtotime('-'.$i.' day'));
if(array_key_exists($date, $incoming_data))
$data[] = $date.','.$incoming_data[$date];
$data[] = $date.',0';
$data[] = 'Color,#ff7f00';
// Output the data as follows
echo implode("\n", $data);
Link to comment
Share on other sites



Don't know Cyfe at all so don't how to integrate data into it. However, looking at your code above, you would want to pull your data from your PS_ORDERS table so your query would be:


SELECT date_add, COUNT( * ) AS count FROM ps_orders GROUP BY date_add ORDER BY date_add ASC


This should give you data out. If you have access to PHPMyAdmin you will be able to run the query and see your output.



Link to comment
Share on other sites

  • 9 months later...

Hi websitebuilder,


Did you ever have any luck getting this working? I'm looking into doing something similar and would love to get your input.

Edited by Guest (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...