Automatically emailing supplier when a new order comes in.
I am currently using Zen Cart and when a new order is placed you simply click a button and an email is sent to the supplier notifying them of the new order along with an attached invoice. I haven’t been able to find anything like this in Magento. Am I missing something or is this just not supported?


1MonoMachines posted Mon, June 9, 2008
I am actually looking for the same feature. Any luck with this @mikefifeld? Also, is there any way export this “Purchase Order” information as a CSV?
2barrmy posted Fri, June 27, 2008
For a company I worked with would have a cron job running on 15min intervals that pulled all new orders (since the last report) straight from the db (in magento’s case thats in mag_sales_order) and sent emails with the csv file to the different distributors based on a distributor attribute - very similar to the one below. Technically one could write an intermediary script after purchase confirmation that would trigger a php function that could do the same thing...i’m pretty sure php mail supports sending attachments
monomachines - you can either write a script to do it via SQL or have php handle the export....here’ s a CSV export script:
create a file called export_orders.php, insert the following code:
<?php
$host = ‘localhost’;
$user = ‘ENTER YOUR MYSQL DB USERNAME’;
$pass = ‘ENTER YOUR MYSQL DB PASSWORD’;
$db = ‘ENTER YOUR MAGENTO DB NAME’;
$table = ‘mag_sales_order’;
$file = ‘export’;
$link = mysql_connect($host, $user, $pass) or die("Can not connect.” . mysql_error());
mysql_select_db($db) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM “.$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row[’Field’].”, “;
$i++;
}
}
$csv_output .= “n”;
$values = mysql_query("SELECT * FROM “.$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].”, “;
}
$csv_output .= “n”;
}
$filename = $file."_”.date("Y-m-d_H-i",time());
header("Content-ty
3barrmy posted Fri, June 27, 2008
it cut the code - starting from one line up
$filename = $file."_".date("Y-m-d_H-i",time());header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>
2. run the file by going to http://www.yourwebsite.com/export_orders.php