Version Notes
- Improve memory management (30% memory use decrease)
Download this release
Release Info
| Developer | Digital Pianism |
| Extension | DigitalPianism_Abandonedcarts |
| Version | 0.1.6 |
| Comparing to | |
| See all releases | |
Code changes from version 0.1.5 to 0.1.6
app/code/community/DigitalPianism/Abandonedcarts/Model/Observer.php
CHANGED
|
@@ -3,6 +3,144 @@
|
|
| 3 |
class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstract
|
| 4 |
{
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
/**
|
| 7 |
* Send notification email to customer with abandoned cart containing sale products
|
| 8 |
* @param boolean if dryrun is set to true, it won't send emails and won't alter quotes
|
|
@@ -12,31 +150,11 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
| 12 |
{
|
| 13 |
if (Mage::helper('abandonedcarts')->getDryRun()) $dryrun = true;
|
| 14 |
if (Mage::helper('abandonedcarts')->getTestEmail()) $testemail = Mage::helper('abandonedcarts')->getTestEmail();
|
| 15 |
-
|
| 16 |
try
|
| 17 |
{
|
| 18 |
if (Mage::helper('abandonedcarts')->isSaleEnabled())
|
| 19 |
{
|
| 20 |
-
|
| 21 |
-
$store = Mage_Core_Model_App::ADMIN_STORE_ID;
|
| 22 |
-
$timezone = Mage::app()->getStore($store)->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
| 23 |
-
date_default_timezone_set($timezone);
|
| 24 |
-
|
| 25 |
-
// Current date
|
| 26 |
-
$currentdate = date("Ymd");
|
| 27 |
-
|
| 28 |
-
$day = (int)substr($currentdate,-2);
|
| 29 |
-
$month = (int)substr($currentdate,4,2);
|
| 30 |
-
$year = (int)substr($currentdate,0,4);
|
| 31 |
-
|
| 32 |
-
$date = array('year' => $year,'month' => $month,'day' => $day,'hour' => 23,'minute' => 59,'second' => 59);
|
| 33 |
-
|
| 34 |
-
$today = new Zend_Date($date);
|
| 35 |
-
$today->setTimeZone("UTC");
|
| 36 |
-
|
| 37 |
-
date_default_timezone_set($timezone);
|
| 38 |
-
|
| 39 |
-
$todayString = $today->toString("Y-MM-dd HH:mm:ss");
|
| 40 |
|
| 41 |
// Get the attribute id for the status attribute
|
| 42 |
$eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
|
|
@@ -110,84 +228,9 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
| 110 |
continue;
|
| 111 |
}
|
| 112 |
|
| 113 |
-
//
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
foreach($collection as $entry)
|
| 117 |
-
{
|
| 118 |
-
// Double check if the special from date is set
|
| 119 |
-
if (!$entry->getProductSpecialFromDate())
|
| 120 |
-
{
|
| 121 |
-
// If not we use today for the comparison
|
| 122 |
-
$fromDate = $todayString;
|
| 123 |
-
}
|
| 124 |
-
else $fromDate = $entry->getProductSpecialFromDate();
|
| 125 |
-
|
| 126 |
-
// Do the same for the special to date
|
| 127 |
-
if (!$entry->getProductSpecialToDate())
|
| 128 |
-
{
|
| 129 |
-
$toDate = $todayString;
|
| 130 |
-
}
|
| 131 |
-
else $toDate = $entry->getProductSpecialToDate();
|
| 132 |
-
|
| 133 |
-
// We need to ensure that the price in cart is higher than the new special price
|
| 134 |
-
// As well as the date comparison in case the sale is over or hasn't started
|
| 135 |
-
if ($entry->getProductPriceInCart() > 0.00
|
| 136 |
-
&& $entry->getProductSpecialPrice() > 0.00
|
| 137 |
-
&& ($entry->getProductPriceInCart() > $entry->getProductSpecialPrice())
|
| 138 |
-
&& ($fromDate <= $todayString)
|
| 139 |
-
&& ($toDate >= $todayString))
|
| 140 |
-
{
|
| 141 |
-
|
| 142 |
-
// Test if the customer is already in the array
|
| 143 |
-
if (!array_key_exists($entry->getCustomerEmail(), $recipients))
|
| 144 |
-
{
|
| 145 |
-
// Create an array of variables to assign to template
|
| 146 |
-
$emailTemplateVariables = array();
|
| 147 |
-
|
| 148 |
-
// Array that contains the data which will be used inside the template
|
| 149 |
-
$emailTemplateVariables['fullname'] = $entry->getCustomerFirstname().' '.$entry->getCustomerLastname();
|
| 150 |
-
$emailTemplateVariables['firstname'] = $entry->getCustomerFirstname();
|
| 151 |
-
$emailTemplateVariables['productname'] = $entry->getProductName();
|
| 152 |
-
$emailTemplateVariables['cartprice'] = number_format($entry->getProductPriceInCart(),2);
|
| 153 |
-
$emailTemplateVariables['specialprice'] = number_format($entry->getProductSpecialPrice(),2);
|
| 154 |
-
|
| 155 |
-
// Assign the values to the array of recipients
|
| 156 |
-
$recipients[$entry->getCustomerEmail()]['cartId'] = $entry->getCartId();
|
| 157 |
-
}
|
| 158 |
-
else
|
| 159 |
-
{
|
| 160 |
-
// We create some extra variables if there is several products in the cart
|
| 161 |
-
$emailTemplateVariables = $recipients[$entry->getCustomerEmail()]['emailTemplateVariables'];
|
| 162 |
-
// Discount amount
|
| 163 |
-
// If one product before
|
| 164 |
-
if (!array_key_exists('discount',$emailTemplateVariables))
|
| 165 |
-
{
|
| 166 |
-
$emailTemplateVariables['discount'] = $emailTemplateVariables['cartprice'] - $emailTemplateVariables['specialprice'];
|
| 167 |
-
}
|
| 168 |
-
// We add the discount on the second product
|
| 169 |
-
$moreDiscount = number_format($entry->getProductPriceInCart(),2) - number_format($entry->getProductSpecialPrice(),2);
|
| 170 |
-
$emailTemplateVariables['discount'] += $moreDiscount;
|
| 171 |
-
// We increase the product count
|
| 172 |
-
if (!array_key_exists('extraproductcount',$emailTemplateVariables))
|
| 173 |
-
{
|
| 174 |
-
$emailTemplateVariables['extraproductcount'] = 0;
|
| 175 |
-
}
|
| 176 |
-
$emailTemplateVariables['extraproductcount'] += 1;
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
// Add currency codes to prices
|
| 180 |
-
$emailTemplateVariables['cartprice'] = Mage::helper('core')->currency($emailTemplateVariables['cartprice'], true, false);
|
| 181 |
-
$emailTemplateVariables['specialprice'] = Mage::helper('core')->currency($emailTemplateVariables['specialprice'], true, false);
|
| 182 |
-
if (array_key_exists('discount',$emailTemplateVariables))
|
| 183 |
-
{
|
| 184 |
-
$emailTemplateVariables['discount'] = Mage::helper('core')->currency($emailTemplateVariables['discount'], true, false);
|
| 185 |
-
}
|
| 186 |
-
|
| 187 |
-
// Assign the array of template variables
|
| 188 |
-
$recipients[$entry->getCustomerEmail()]['emailTemplateVariables'] = $emailTemplateVariables;
|
| 189 |
-
}
|
| 190 |
-
}
|
| 191 |
|
| 192 |
// Get the transactional email template
|
| 193 |
$templateId = Mage::getStoreConfig('abandonedcartsconfig/options/email_template_sale');
|
|
@@ -197,7 +240,7 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
| 197 |
$sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
|
| 198 |
|
| 199 |
// Send the emails via a loop
|
| 200 |
-
foreach ($
|
| 201 |
{
|
| 202 |
// Don't send the email if dryrun is set
|
| 203 |
if ($dryrun)
|
|
@@ -266,7 +309,6 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
| 266 |
{
|
| 267 |
if (Mage::helper('abandonedcarts')->getDryRun()) $dryrun = true;
|
| 268 |
if (Mage::helper('abandonedcarts')->getTestEmail()) $testemail = Mage::helper('abandonedcarts')->getTestEmail();
|
| 269 |
-
|
| 270 |
try
|
| 271 |
{
|
| 272 |
if (Mage::helper('abandonedcarts')->isEnabled())
|
|
@@ -350,37 +392,9 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
| 350 |
// echo $collection->printlogquery(true);
|
| 351 |
$collection->load();
|
| 352 |
|
| 353 |
-
//
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
foreach($collection as $entry)
|
| 357 |
-
{
|
| 358 |
-
// Test if the customer is already in the array
|
| 359 |
-
if (!array_key_exists($entry->getCustomerEmail(), $recipients))
|
| 360 |
-
{
|
| 361 |
-
// Create an array of variables to assign to template
|
| 362 |
-
$emailTemplateVariables = array();
|
| 363 |
-
|
| 364 |
-
// Array that contains the data which will be used inside the template
|
| 365 |
-
$emailTemplateVariables['fullname'] = $entry->getCustomerFirstname().' '.$entry->getCustomerLastname();
|
| 366 |
-
$emailTemplateVariables['firstname'] = $entry->getCustomerFirstname();
|
| 367 |
-
$emailTemplateVariables['productname'] = $entry->getProductName();
|
| 368 |
-
|
| 369 |
-
// Assign the values to the array of recipients
|
| 370 |
-
$recipients[$entry->getCustomerEmail()]['cartId'] = $entry->getCartId();
|
| 371 |
-
|
| 372 |
-
$emailTemplateVariables['extraproductcount'] = 0;
|
| 373 |
-
}
|
| 374 |
-
else
|
| 375 |
-
{
|
| 376 |
-
// We create some extra variables if there is several products in the cart
|
| 377 |
-
$emailTemplateVariables = $recipients[$entry->getCustomerEmail()]['emailTemplateVariables'];
|
| 378 |
-
// We increase the product count
|
| 379 |
-
$emailTemplateVariables['extraproductcount'] += 1;
|
| 380 |
-
}
|
| 381 |
-
// Assign the array of template variables
|
| 382 |
-
$recipients[$entry->getCustomerEmail()]['emailTemplateVariables'] = $emailTemplateVariables;
|
| 383 |
-
}
|
| 384 |
|
| 385 |
// Get the transactional email template
|
| 386 |
$templateId = Mage::getStoreConfig('abandonedcartsconfig/options/email_template');
|
|
@@ -390,7 +404,7 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
| 390 |
$sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
|
| 391 |
|
| 392 |
// Send the emails via a loop
|
| 393 |
-
foreach ($recipients as $email => $recipient)
|
| 394 |
{
|
| 395 |
// Don't send the email if dryrun is set
|
| 396 |
if ($dryrun)
|
| 3 |
class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstract
|
| 4 |
{
|
| 5 |
|
| 6 |
+
protected $recipients = array();
|
| 7 |
+
protected $saleRecipients = array();
|
| 8 |
+
protected $today = "";
|
| 9 |
+
|
| 10 |
+
public function setToday()
|
| 11 |
+
{
|
| 12 |
+
// Date handling
|
| 13 |
+
$store = Mage_Core_Model_App::ADMIN_STORE_ID;
|
| 14 |
+
$timezone = Mage::app()->getStore($store)->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
| 15 |
+
date_default_timezone_set($timezone);
|
| 16 |
+
|
| 17 |
+
// Current date
|
| 18 |
+
$currentdate = date("Ymd");
|
| 19 |
+
|
| 20 |
+
$day = (int)substr($currentdate,-2);
|
| 21 |
+
$month = (int)substr($currentdate,4,2);
|
| 22 |
+
$year = (int)substr($currentdate,0,4);
|
| 23 |
+
|
| 24 |
+
$date = array('year' => $year,'month' => $month,'day' => $day,'hour' => 23,'minute' => 59,'second' => 59);
|
| 25 |
+
|
| 26 |
+
$today = new Zend_Date($date);
|
| 27 |
+
$today->setTimeZone("UTC");
|
| 28 |
+
|
| 29 |
+
date_default_timezone_set($timezone);
|
| 30 |
+
|
| 31 |
+
$this->today = $today->toString("Y-MM-dd HH:mm:ss");
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
public function getToday()
|
| 35 |
+
{
|
| 36 |
+
return $this->today;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
public function generateRecipients($args)
|
| 40 |
+
{
|
| 41 |
+
// Test if the customer is already in the array
|
| 42 |
+
if (!array_key_exists($args['row']['customer_email'], $this->recipients))
|
| 43 |
+
{
|
| 44 |
+
// Create an array of variables to assign to template
|
| 45 |
+
$emailTemplateVariables = array();
|
| 46 |
+
|
| 47 |
+
// Array that contains the data which will be used inside the template
|
| 48 |
+
$emailTemplateVariables['fullname'] = $args['row']['customer_firstname'].' '.$args['row']['customer_lastname'];
|
| 49 |
+
$emailTemplateVariables['firstname'] = $args['row']['customer_firstname'];
|
| 50 |
+
$emailTemplateVariables['productname'] = $args['row']['product_name'];
|
| 51 |
+
|
| 52 |
+
// Assign the values to the array of recipients
|
| 53 |
+
$this->recipients[$args['row']['customer_email']]['cartId'] = $args['row']['cart_id'];
|
| 54 |
+
|
| 55 |
+
$emailTemplateVariables['extraproductcount'] = 0;
|
| 56 |
+
}
|
| 57 |
+
else
|
| 58 |
+
{
|
| 59 |
+
// We create some extra variables if there is several products in the cart
|
| 60 |
+
$emailTemplateVariables = $this->recipients[$args['row']['customer_email']]['emailTemplateVariables'];
|
| 61 |
+
// We increase the product count
|
| 62 |
+
$emailTemplateVariables['extraproductcount'] += 1;
|
| 63 |
+
}
|
| 64 |
+
// Assign the array of template variables
|
| 65 |
+
$this->recipients[$args['row']['customer_email']]['emailTemplateVariables'] = $emailTemplateVariables;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
public function generateSaleRecipients($args)
|
| 69 |
+
{
|
| 70 |
+
// Double check if the special from date is set
|
| 71 |
+
if (!array_key_exists('product_special_from_date',$args['row']) || !$args['row']['product_special_from_date'])
|
| 72 |
+
{
|
| 73 |
+
// If not we use today for the comparison
|
| 74 |
+
$fromDate = $this->getToday();
|
| 75 |
+
}
|
| 76 |
+
else $fromDate = $args['row']['product_special_from_date'];
|
| 77 |
+
|
| 78 |
+
// Do the same for the special to date
|
| 79 |
+
if (!array_key_exists('product_special_to_date',$args['row']) || !$args['row']['product_special_to_date'])
|
| 80 |
+
{
|
| 81 |
+
$toDate = $this->getToday();
|
| 82 |
+
}
|
| 83 |
+
else $toDate = $args['row']['product_special_to_date'];
|
| 84 |
+
|
| 85 |
+
// We need to ensure that the price in cart is higher than the new special price
|
| 86 |
+
// As well as the date comparison in case the sale is over or hasn't started
|
| 87 |
+
if ($args['row']['product_price_in_cart'] > 0.00
|
| 88 |
+
&& $args['row']['product_special_price'] > 0.00
|
| 89 |
+
&& ($args['row']['product_price_in_cart'] > $args['row']['product_special_price'])
|
| 90 |
+
&& ($fromDate <= $this->getToday())
|
| 91 |
+
&& ($toDate >= $this->getToday()))
|
| 92 |
+
{
|
| 93 |
+
|
| 94 |
+
// Test if the customer is already in the array
|
| 95 |
+
if (!array_key_exists($args['row']['customer_email'], $this->saleRecipients))
|
| 96 |
+
{
|
| 97 |
+
// Create an array of variables to assign to template
|
| 98 |
+
$emailTemplateVariables = array();
|
| 99 |
+
|
| 100 |
+
// Array that contains the data which will be used inside the template
|
| 101 |
+
$emailTemplateVariables['fullname'] = $args['row']['customer_firstname'].' '.$args['row']['customer_lastname'];
|
| 102 |
+
$emailTemplateVariables['firstname'] = $args['row']['customer_firstname'];
|
| 103 |
+
$emailTemplateVariables['productname'] = $args['row']['product_name'];
|
| 104 |
+
$emailTemplateVariables['cartprice'] = number_format($args['row']['product_price_in_cart'],2);
|
| 105 |
+
$emailTemplateVariables['specialprice'] = number_format($args['row']['product_special_price'],2);
|
| 106 |
+
|
| 107 |
+
// Assign the values to the array of recipients
|
| 108 |
+
$this->saleRecipients[$args['row']['customer_email']]['cartId'] = $args['row']['cart_id'];
|
| 109 |
+
}
|
| 110 |
+
else
|
| 111 |
+
{
|
| 112 |
+
// We create some extra variables if there is several products in the cart
|
| 113 |
+
$emailTemplateVariables = $this->saleRecipients[$args['row']['customer_email']]['emailTemplateVariables'];
|
| 114 |
+
// Discount amount
|
| 115 |
+
// If one product before
|
| 116 |
+
if (!array_key_exists('discount',$emailTemplateVariables))
|
| 117 |
+
{
|
| 118 |
+
$emailTemplateVariables['discount'] = $emailTemplateVariables['cartprice'] - $emailTemplateVariables['specialprice'];
|
| 119 |
+
}
|
| 120 |
+
// We add the discount on the second product
|
| 121 |
+
$moreDiscount = number_format($args['row']['product_price_in_cart'],2) - number_format($args['row']['product_special_price'],2);
|
| 122 |
+
$emailTemplateVariables['discount'] += $moreDiscount;
|
| 123 |
+
// We increase the product count
|
| 124 |
+
if (!array_key_exists('extraproductcount',$emailTemplateVariables))
|
| 125 |
+
{
|
| 126 |
+
$emailTemplateVariables['extraproductcount'] = 0;
|
| 127 |
+
}
|
| 128 |
+
$emailTemplateVariables['extraproductcount'] += 1;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
// Add currency codes to prices
|
| 132 |
+
$emailTemplateVariables['cartprice'] = Mage::helper('core')->currency($emailTemplateVariables['cartprice'], true, false);
|
| 133 |
+
$emailTemplateVariables['specialprice'] = Mage::helper('core')->currency($emailTemplateVariables['specialprice'], true, false);
|
| 134 |
+
if (array_key_exists('discount',$emailTemplateVariables))
|
| 135 |
+
{
|
| 136 |
+
$emailTemplateVariables['discount'] = Mage::helper('core')->currency($emailTemplateVariables['discount'], true, false);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
// Assign the array of template variables
|
| 140 |
+
$this->saleRecipients[$args['row']['customer_email']]['emailTemplateVariables'] = $emailTemplateVariables;
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
/**
|
| 145 |
* Send notification email to customer with abandoned cart containing sale products
|
| 146 |
* @param boolean if dryrun is set to true, it won't send emails and won't alter quotes
|
| 150 |
{
|
| 151 |
if (Mage::helper('abandonedcarts')->getDryRun()) $dryrun = true;
|
| 152 |
if (Mage::helper('abandonedcarts')->getTestEmail()) $testemail = Mage::helper('abandonedcarts')->getTestEmail();
|
|
|
|
| 153 |
try
|
| 154 |
{
|
| 155 |
if (Mage::helper('abandonedcarts')->isSaleEnabled())
|
| 156 |
{
|
| 157 |
+
$this->setToday();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
// Get the attribute id for the status attribute
|
| 160 |
$eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
|
| 228 |
continue;
|
| 229 |
}
|
| 230 |
|
| 231 |
+
// Call iterator walk method with collection query string and callback method as parameters
|
| 232 |
+
// Has to be used to handle massive collection instead of foreach
|
| 233 |
+
Mage::getSingleton('core/resource_iterator')->walk($collection->getSelect(), array(array($this, 'generateSaleRecipients')));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
// Get the transactional email template
|
| 236 |
$templateId = Mage::getStoreConfig('abandonedcartsconfig/options/email_template_sale');
|
| 240 |
$sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
|
| 241 |
|
| 242 |
// Send the emails via a loop
|
| 243 |
+
foreach ($this->saleRecipients as $email => $recipient)
|
| 244 |
{
|
| 245 |
// Don't send the email if dryrun is set
|
| 246 |
if ($dryrun)
|
| 309 |
{
|
| 310 |
if (Mage::helper('abandonedcarts')->getDryRun()) $dryrun = true;
|
| 311 |
if (Mage::helper('abandonedcarts')->getTestEmail()) $testemail = Mage::helper('abandonedcarts')->getTestEmail();
|
|
|
|
| 312 |
try
|
| 313 |
{
|
| 314 |
if (Mage::helper('abandonedcarts')->isEnabled())
|
| 392 |
// echo $collection->printlogquery(true);
|
| 393 |
$collection->load();
|
| 394 |
|
| 395 |
+
// Call iterator walk method with collection query string and callback method as parameters
|
| 396 |
+
// Has to be used to handle massive collection instead of foreach
|
| 397 |
+
Mage::getSingleton('core/resource_iterator')->walk($collection->getSelect(), array(array($this, 'generateRecipients')));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
|
| 399 |
// Get the transactional email template
|
| 400 |
$templateId = Mage::getStoreConfig('abandonedcartsconfig/options/email_template');
|
| 404 |
$sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
|
| 405 |
|
| 406 |
// Send the emails via a loop
|
| 407 |
+
foreach ($this->recipients as $email => $recipient)
|
| 408 |
{
|
| 409 |
// Don't send the email if dryrun is set
|
| 410 |
if ($dryrun)
|
app/code/community/DigitalPianism/Abandonedcarts/etc/config.xml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
|
| 5 |
<modules>
|
| 6 |
<DigitalPianism_Abandonedcarts>
|
| 7 |
-
<version>0.1.
|
| 8 |
</DigitalPianism_Abandonedcarts>
|
| 9 |
</modules>
|
| 10 |
|
| 4 |
|
| 5 |
<modules>
|
| 6 |
<DigitalPianism_Abandonedcarts>
|
| 7 |
+
<version>0.1.6</version>
|
| 8 |
</DigitalPianism_Abandonedcarts>
|
| 9 |
</modules>
|
| 10 |
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>DigitalPianism_Abandonedcarts</name>
|
| 4 |
-
<version>0.1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -10,11 +10,11 @@
|
|
| 10 |
<description>This extension allows store managers to automatically notice customers with abandoned carts after a customizable number of days via email.
|
| 11 |

|
| 12 |
Another email can also be sent if one of the abandoned products goes on sale.</description>
|
| 13 |
-
<notes>-
|
| 14 |
<authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
|
| 15 |
-
<date>2014-
|
| 16 |
-
<time>
|
| 17 |
-
<contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="Abandonedcarts"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="a27ec4c5bc4cb4e954ebdfebc71cbfd2"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="c76d4abfe24cdad55badea279e13a9a1"/></dir><dir name="Model"><file name="Observer.php" hash="
|
| 18 |
<compatible/>
|
| 19 |
<dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>DigitalPianism_Abandonedcarts</name>
|
| 4 |
+
<version>0.1.6</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 10 |
<description>This extension allows store managers to automatically notice customers with abandoned carts after a customizable number of days via email.
|
| 11 |

|
| 12 |
Another email can also be sent if one of the abandoned products goes on sale.</description>
|
| 13 |
+
<notes>- Improve memory management (30% memory use decrease)</notes>
|
| 14 |
<authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
|
| 15 |
+
<date>2014-09-19</date>
|
| 16 |
+
<time>10:43:32</time>
|
| 17 |
+
<contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="Abandonedcarts"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="a27ec4c5bc4cb4e954ebdfebc71cbfd2"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="c76d4abfe24cdad55badea279e13a9a1"/></dir><dir name="Model"><file name="Observer.php" hash="7c48610df3eae72c357d3441620edd4d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AbandonedcartsController.php" hash="dc840a6de8c229175000df65b0d85289"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8ddca513c0ed7e034c476f3e026ceda8"/><file name="config.xml" hash="1e23c46b57c201de94becbf213848d44"/><file name="system.xml" hash="793efac0feb3c123a1c8869b21f302f1"/></dir><dir name="sql"><dir name="abandonedcarts_setup"><file name="install-0.0.1.php" hash="851338e4a710b5d94fead688b065f4b5"/><file name="upgrade-0.0.1-0.0.2.php" hash="0227c009e49b97bcf3f34f84c49f0927"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DigitalPianism_Abandonedcarts.xml" hash="8a7657855486c68d548db4ba48e083d2"/></dir></target><target name="magelocale"><dir name="en_US"><file name="DigitalPianism_AbandonedCarts.csv" hash="4e17b6cae58dd1cdcd43b1113e2e09f4"/><dir name="template"><dir name="email"><dir name="digitalpianism"><file name="sales_abandonedcarts.html" hash="30565f91c47913465fd184a214c14b23"/><file name="sales_abandonedcarts_sale.html" hash="3cdee557727cb0166741062e5fdcf06f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="digitalpianism"><dir name="abandonedcarts"><dir name="system"><dir name="config"><file name="button.phtml" hash="8f7e673ea52cd81b616cac01b1022990"/></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
| 18 |
<compatible/>
|
| 19 |
<dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
</package>
|
