Skip to content

Instantly share code, notes, and snippets.

@yireo
Last active December 26, 2015 00:39
Show Gist options
  • Save yireo/7066256 to your computer and use it in GitHub Desktop.
Save yireo/7066256 to your computer and use it in GitHub Desktop.
Cronjob for Magento to send any invoice-emails that have not been sent yet
<?php
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$from_date = date('Y-m-d', time() - (60*60*24*14));
$invoices = Mage::getModel('sales/order_invoice')->getCollection()
->addAttributeToFilter('created_at', array('from' => $from_date))
->addAttributeToFilter('email_sent', array('null' => true))
;
foreach($invoices as $invoice) {
$order = $invoice->getOrder();
if($order->getStatus() != 'complete') continue;
$invoice->sendEmail(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment