DigitalPianism_Abandonedcarts - Version 0.1.8

Version Notes

- Implement coding standards fixes (based on triplecheck.io recommendations).

Download this release

Release Info

Developer Digital Pianism
Extension DigitalPianism_Abandonedcarts
Version 0.1.8
Comparing to
See all releases


Code changes from version 0.1.7 to 0.1.8

app/code/community/DigitalPianism/Abandonedcarts/Model/Observer.php CHANGED
@@ -140,6 +140,150 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
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
@@ -148,8 +292,6 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
148
  */
149
  public function sendAbandonedCartsSaleEmail($dryrun = false, $testemail = null)
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())
@@ -157,7 +299,7 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
157
  $this->setToday();
158
 
159
  // Get the attribute id for the status attribute
160
- $eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
161
  $statusId = $eavAttribute->getIdByCode('catalog_product', 'status');
162
 
163
  // Loop through the stores
@@ -223,7 +365,7 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
223
  $collection->load();
224
 
225
  // Skip the rest of the code if the collection is empty
226
- if (count($collection) == 0)
227
  {
228
  continue;
229
  }
@@ -232,63 +374,8 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
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');
237
- // Get the sender
238
- $sender = array();
239
- $sender['email'] = Mage::getStoreConfig('abandonedcartsconfig/options/email');
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)
247
- {
248
- // Log data when dried run
249
- Mage::helper('abandonedcarts')->log(sprintf("%s->%s", __METHOD__, print_r($recipient['emailTemplateVariables'],true)));
250
- // If the test email is set and found
251
- if (isset($testemail) && $email == $testemail)
252
- {
253
- Mage::helper('abandonedcarts')->log(__METHOD__ . "sendAbandonedCartsSaleEmail test: " . $email);
254
- // Send the test email
255
- Mage::getModel('core/email_template')
256
- ->sendTransactional(
257
- $templateId,
258
- $sender,
259
- $email,
260
- $recipient['emailTemplateVariables']['fullname'] ,
261
- $recipient['emailTemplateVariables'],
262
- null);
263
- }
264
- }
265
- else
266
- {
267
- Mage::helper('abandonedcarts')->log(__METHOD__ . "sendAbandonedCartsSaleEmail: " . $email);
268
-
269
- // Send the email
270
- Mage::getModel('core/email_template')
271
- ->sendTransactional(
272
- $templateId,
273
- $sender,
274
- $email,
275
- $recipient['emailTemplateVariables']['fullname'] ,
276
- $recipient['emailTemplateVariables'],
277
- null);
278
- }
279
-
280
- // Load the quote
281
- $quote = Mage::getModel('sales/quote')->load($recipient['cartId']);
282
-
283
- // We change the notification attribute
284
- $quote->setAbandonedSaleNotified(1);
285
-
286
- // Save only if dryrun is false or if the test email is set and found
287
- if (!$dryrun || (isset($testemail) && $email == $testemail))
288
- {
289
- $quote->save();
290
- }
291
- }
292
  }
293
  }
294
  }
@@ -332,7 +419,7 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
332
  }
333
 
334
  // Get the attribute id for the status attribute
335
- $eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
336
  $statusId = $eavAttribute->getIdByCode('catalog_product', 'status');
337
 
338
  // Loop through the stores
@@ -395,64 +482,6 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
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');
401
- // Get the sender
402
- $sender = array();
403
- $sender['email'] = Mage::getStoreConfig('abandonedcartsconfig/options/email');
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)
411
- {
412
- // Log data when dried run
413
- Mage::helper('abandonedcarts')->log(sprintf("%s->%s", __METHOD__, print_r($recipient['emailTemplateVariables'],true)));
414
- // If the test email is set and found
415
- if (isset($testemail) && $email == $testemail)
416
- {
417
- Mage::helper('abandonedcarts')->log(__METHOD__ . "sendAbandonedCartsEmail test: " . $email);
418
- // Send the test email
419
- Mage::getModel('core/email_template')
420
- ->sendTransactional(
421
- $templateId,
422
- $sender,
423
- $email,
424
- $recipient['emailTemplateVariables']['fullname'] ,
425
- $recipient['emailTemplateVariables'],
426
- null);
427
- }
428
- }
429
- else
430
- {
431
- Mage::helper('abandonedcarts')->log(__METHOD__ . "sendAbandonedCartsEmail: " . $email);
432
-
433
- // Send the email
434
- Mage::getModel('core/email_template')
435
- ->sendTransactional(
436
- $templateId,
437
- $sender,
438
- $email,
439
- $recipient['emailTemplateVariables']['fullname'] ,
440
- $recipient['emailTemplateVariables'],
441
- null);
442
- }
443
-
444
- // Load the quote
445
- $quote = Mage::getModel('sales/quote')->load($recipient['cartId']);
446
-
447
- // We change the notification attribute
448
- $quote->setAbandonedNotified(1);
449
-
450
- // Save only if dryrun is false or if the test email is set and found
451
- if (!$dryrun || (isset($testemail) && $email == $testemail))
452
- {
453
- $quote->save();
454
- }
455
- }
456
  }
457
  }
458
  }
140
  $this->saleRecipients[$args['row']['customer_email']]['emailTemplateVariables'] = $emailTemplateVariables;
141
  }
142
  }
143
+
144
+ public function sendSaleEmails()
145
+ {
146
+ try
147
+ {
148
+ if (Mage::helper('abandonedcarts')->getDryRun()) $dryrun = true;
149
+ if (Mage::helper('abandonedcarts')->getTestEmail()) $testemail = Mage::helper('abandonedcarts')->getTestEmail();
150
+
151
+ // Get the transactional email template
152
+ $templateId = Mage::getStoreConfig('abandonedcartsconfig/options/email_template_sale');
153
+ // Get the sender
154
+ $sender = array();
155
+ $sender['email'] = Mage::getStoreConfig('abandonedcartsconfig/options/email');
156
+ $sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
157
+
158
+ // Send the emails via a loop
159
+ foreach ($this->saleRecipients as $email => $recipient)
160
+ {
161
+ // Don't send the email if dryrun is set
162
+ if ($dryrun)
163
+ {
164
+ // Log data when dried run
165
+ Mage::helper('abandonedcarts')->log(__METHOD__);
166
+ Mage::helper('abandonedcarts')->log($recipient['emailTemplateVariables']);
167
+ // If the test email is set and found
168
+ if (isset($testemail) && $email == $testemail)
169
+ {
170
+ Mage::helper('abandonedcarts')->log(__METHOD__ . "sendAbandonedCartsSaleEmail test: " . $email);
171
+ // Send the test email
172
+ Mage::getModel('core/email_template')
173
+ ->sendTransactional(
174
+ $templateId,
175
+ $sender,
176
+ $email,
177
+ $recipient['emailTemplateVariables']['fullname'] ,
178
+ $recipient['emailTemplateVariables'],
179
+ null);
180
+ }
181
+ }
182
+ else
183
+ {
184
+ Mage::helper('abandonedcarts')->log(__METHOD__ . "sendAbandonedCartsSaleEmail: " . $email);
185
+
186
+ // Send the email
187
+ Mage::getModel('core/email_template')
188
+ ->sendTransactional(
189
+ $templateId,
190
+ $sender,
191
+ $email,
192
+ $recipient['emailTemplateVariables']['fullname'] ,
193
+ $recipient['emailTemplateVariables'],
194
+ null);
195
+ }
196
+
197
+ // Load the quote
198
+ $quote = Mage::getModel('sales/quote')->load($recipient['cartId']);
199
+
200
+ // We change the notification attribute
201
+ $quote->setAbandonedSaleNotified(1);
202
+
203
+ // Save only if dryrun is false or if the test email is set and found
204
+ if (!$dryrun || (isset($testemail) && $email == $testemail))
205
+ {
206
+ $quote->save();
207
+ }
208
+ }
209
+ }
210
+ catch (Exception $e)
211
+ {
212
+ Mage::helper('abandonedcarts')->log(__METHOD__ . " " . $e->getMessage());
213
+ }
214
+ }
215
+
216
+ public function sendEmails()
217
+ {
218
+ try
219
+ {
220
+ if (Mage::helper('abandonedcarts')->getDryRun()) $dryrun = true;
221
+ if (Mage::helper('abandonedcarts')->getTestEmail()) $testemail = Mage::helper('abandonedcarts')->getTestEmail();
222
+
223
+ // Get the transactional email template
224
+ $templateId = Mage::getStoreConfig('abandonedcartsconfig/options/email_template');
225
+ // Get the sender
226
+ $sender = array();
227
+ $sender['email'] = Mage::getStoreConfig('abandonedcartsconfig/options/email');
228
+ $sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
229
+
230
+ // Send the emails via a loop
231
+ foreach ($this->recipients as $email => $recipient)
232
+ {
233
+ // Don't send the email if dryrun is set
234
+ if ($dryrun)
235
+ {
236
+ // Log data when dried run
237
+ Mage::helper('abandonedcarts')->log(__METHOD__);
238
+ Mage::helper('abandonedcarts')->log($recipient['emailTemplateVariables']);
239
+ // If the test email is set and found
240
+ if (isset($testemail) && $email == $testemail)
241
+ {
242
+ Mage::helper('abandonedcarts')->log(__METHOD__ . "sendAbandonedCartsEmail test: " . $email);
243
+ // Send the test email
244
+ Mage::getModel('core/email_template')
245
+ ->sendTransactional(
246
+ $templateId,
247
+ $sender,
248
+ $email,
249
+ $recipient['emailTemplateVariables']['fullname'] ,
250
+ $recipient['emailTemplateVariables'],
251
+ null);
252
+ }
253
+ }
254
+ else
255
+ {
256
+ Mage::helper('abandonedcarts')->log(__METHOD__ . "sendAbandonedCartsEmail: " . $email);
257
+
258
+ // Send the email
259
+ Mage::getModel('core/email_template')
260
+ ->sendTransactional(
261
+ $templateId,
262
+ $sender,
263
+ $email,
264
+ $recipient['emailTemplateVariables']['fullname'] ,
265
+ $recipient['emailTemplateVariables'],
266
+ null);
267
+ }
268
+
269
+ // Load the quote
270
+ $quote = Mage::getModel('sales/quote')->load($recipient['cartId']);
271
+
272
+ // We change the notification attribute
273
+ $quote->setAbandonedNotified(1);
274
+
275
+ // Save only if dryrun is false or if the test email is set and found
276
+ if (!$dryrun || (isset($testemail) && $email == $testemail))
277
+ {
278
+ $quote->save();
279
+ }
280
+ }
281
+ }
282
+ catch (Exception $e)
283
+ {
284
+ Mage::helper('abandonedcarts')->log(__METHOD__ . " " . $e->getMessage());
285
+ }
286
+ }
287
 
288
  /**
289
  * Send notification email to customer with abandoned cart containing sale products
292
  */
293
  public function sendAbandonedCartsSaleEmail($dryrun = false, $testemail = null)
294
  {
 
 
295
  try
296
  {
297
  if (Mage::helper('abandonedcarts')->isSaleEnabled())
299
  $this->setToday();
300
 
301
  // Get the attribute id for the status attribute
302
+ $eavAttribute = Mage::getModel('eav/entity_attribute');
303
  $statusId = $eavAttribute->getIdByCode('catalog_product', 'status');
304
 
305
  // Loop through the stores
365
  $collection->load();
366
 
367
  // Skip the rest of the code if the collection is empty
368
+ if ($collection->getSize() == 0)
369
  {
370
  continue;
371
  }
374
  // Has to be used to handle massive collection instead of foreach
375
  Mage::getSingleton('core/resource_iterator')->walk($collection->getSelect(), array(array($this, 'generateSaleRecipients')));
376
 
377
+ // Send the emails
378
+ $this->sendSaleEmails();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  }
380
  }
381
  }
419
  }
420
 
421
  // Get the attribute id for the status attribute
422
+ $eavAttribute = Mage::getModel('eav/entity_attribute');
423
  $statusId = $eavAttribute->getIdByCode('catalog_product', 'status');
424
 
425
  // Loop through the stores
482
  // Call iterator walk method with collection query string and callback method as parameters
483
  // Has to be used to handle massive collection instead of foreach
484
  Mage::getSingleton('core/resource_iterator')->walk($collection->getSelect(), array(array($this, 'generateRecipients')));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  }
486
  }
487
  }
app/code/community/DigitalPianism/Abandonedcarts/etc/config.xml CHANGED
@@ -4,7 +4,7 @@
4
 
5
  <modules>
6
  <DigitalPianism_Abandonedcarts>
7
- <version>0.1.7</version>
8
  </DigitalPianism_Abandonedcarts>
9
  </modules>
10
 
4
 
5
  <modules>
6
  <DigitalPianism_Abandonedcarts>
7
+ <version>0.1.8</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.7</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,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.&#xD;
11
  &#xD;
12
  Another email can also be sent if one of the abandoned products goes on sale.</description>
13
- <notes>- Add database prefix to the table in the Observer (thanks to mecaniqueorange for the advice)</notes>
14
  <authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
15
- <date>2014-10-08</date>
16
- <time>12:14:00</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="5d9b5f630388be9659e4f40437e8a8ad"/></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="8d74cc7b72a11d69339e2de87dab9c89"/><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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DigitalPianism_Abandonedcarts</name>
4
+ <version>0.1.8</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.&#xD;
11
  &#xD;
12
  Another email can also be sent if one of the abandoned products goes on sale.</description>
13
+ <notes>- Implement coding standards fixes (based on triplecheck.io recommendations).</notes>
14
  <authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
15
+ <date>2014-12-09</date>
16
+ <time>20:24:05</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="cea8f760acb1a02ff2fb5d6d4665228a"/></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="1d58bd0ebda796b722f509b89d920364"/><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>