Last active
December 26, 2015 00:39
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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