So I have this script:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require('app/Mage.php');
umask(0);
Mage::app();
/* Set our dates */
$fromDate = '2016-05-30 00:00:00';
$toDate = '2019-05-31 00:00:00';
/* Get the collection. Here we set a date range, and ignore cancelled orders.
You can filter the collection however you prefer */
$orders = Mage::getModel('sales/order')->getCollection()
->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate))
->addFieldToFilter('status', array('nin' => array('canceled')));
/* Here you can build an array, write to a CSV etc */
foreach($orders as $order){
/* get order details (e.g. ID) like this: */
echo $order->getIncrementId().'<br/>';
$id = $order->getIncrementId()
/* you can load the order items, if you need them */
$items = $order->getAllVisibleItems();
}
I am trying to place this in the root of my server so I can run it and print orders to the screen. What should the file extension be .js .php .sh? Also once it's on the root of the server, how can I run it?