How can I gene开发者_如何转开发rate a text file for each new order in Magento.
You will need to create a new module (use the Module Creator extension for a headstart) and bind an Observer to the sales_convert_quote_to_order
Event. You can then retrieve the Order
object from the Event and output the values of interest to a text file using standard PHP file functions (or Zend_File if you wish).
If you search stackoverflow or the web in general, you will find a number of tutorials on how to use the Event-Observer model, you will just need to adapt that to the specifics of the Event you are interested in.
HTH, JD
You can also override succesAction in OnepageController from Checkout module in Mage. This action is always called after successed new order in Magento.
You can use code:
$order = Mage::getModel('sales/order')->load($this->getOnepage()->getCheckout()->getLastOrderId())
$ourFileName = "order_".$order->getId().".txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fwrite($ourFileHandle, 'Some text');
fclose($ourFileHandle);
You can put this part of code just before Mage::getSingleton('checkout/session')->clear();
精彩评论