Skip to main content
deleted 15 characters in body
Source Link
sv3n
  • 11.7k
  • 7
  • 41
  • 73

As @william-oakley suggested and unless you need to stick to the lastRunTime approach for some reason, it would be more robust to read and log which orders have been exported rather than rely on the time.

public function ExportSales()
{
    //A collection of orders
    $orderCollection = Mage::getModel('sales/order')->getCollection();

    $orderCollection
    ->addAttributeToFilter('status', array('in' => array('pending', 'complete')))
 

   // Filter by Non exported
    ->addFieldToFilter('exported', array('eq' => '0'));

    
}

Of course for this to work you will need to create the exported field in the database and update it as exported when you finish exporting the order.

As @william-oakley suggested and unless you need to stick to the lastRunTime approach for some reason, it would be more robust to read and log which orders have been exported rather than rely on the time.

public function ExportSales()
{
    //A collection of orders
    $orderCollection = Mage::getModel('sales/order')->getCollection();

    $orderCollection
    ->addAttributeToFilter('status', array('in' => array('pending', 'complete')))
 

   // Filter by Non exported
    ->addFieldToFilter('exported', array('eq' => '0'));

    
}

Of course for this to work you will need to create the exported field in the database and update it as exported when you finish exporting the order.

As @william-oakley suggested and unless you need to stick to the lastRunTime approach for some reason, it would be more robust to read and log which orders have been exported rather than rely on the time.

public function ExportSales()
{
    //A collection of orders
    $orderCollection = Mage::getModel('sales/order')->getCollection();

    $orderCollection
    ->addAttributeToFilter('status', array('in' => array('pending', 'complete')))

   // Filter by Non exported
    ->addFieldToFilter('exported', array('eq' => '0'));
}

Of course for this to work you will need to create the exported field in the database and update it as exported when you finish exporting the order.

Source Link
diazwatson
  • 2.5k
  • 2
  • 27
  • 39

As @william-oakley suggested and unless you need to stick to the lastRunTime approach for some reason, it would be more robust to read and log which orders have been exported rather than rely on the time.

public function ExportSales()
{
    //A collection of orders
    $orderCollection = Mage::getModel('sales/order')->getCollection();

    $orderCollection
    ->addAttributeToFilter('status', array('in' => array('pending', 'complete')))


   // Filter by Non exported
    ->addFieldToFilter('exported', array('eq' => '0'));

    
}

Of course for this to work you will need to create the exported field in the database and update it as exported when you finish exporting the order.