Version Notes
- PHPDoc
- Decrease nesting level to meet Magento ECG standards requirements
Download this release
Release Info
Developer | Digital Pianism |
Extension | DigitalPianism_Abandonedcarts |
Version | 0.1.10 |
Comparing to | |
See all releases |
Code changes from version 0.1.9 to 0.1.10
- app/code/community/DigitalPianism/Abandonedcarts/Block/Adminhtml/System/Config/Form/Button.php +3 -0
- app/code/community/DigitalPianism/Abandonedcarts/Helper/Data.php +24 -9
- app/code/community/DigitalPianism/Abandonedcarts/Model/Observer.php +58 -24
- app/code/community/DigitalPianism/Abandonedcarts/controllers/Adminhtml/AbandonedcartsController.php +3 -0
- app/code/community/DigitalPianism/Abandonedcarts/etc/config.xml +1 -1
- package.xml +6 -5
app/code/community/DigitalPianism/Abandonedcarts/Block/Adminhtml/System/Config/Form/Button.php
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
class DigitalPianism_Abandonedcarts_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
{
|
5 |
/*
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Class DigitalPianism_Abandonedcarts_Block_Adminhtml_System_Config_Form_Button
|
5 |
+
*/
|
6 |
class DigitalPianism_Abandonedcarts_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
{
|
8 |
/*
|
app/code/community/DigitalPianism/Abandonedcarts/Helper/Data.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
4 |
{
|
5 |
protected $logFileName = 'digitalpianism_abandonedcarts.log';
|
6 |
|
@@ -12,23 +15,35 @@ class DigitalPianism_Abandonedcarts_Helper_Data extends Mage_Core_Helper_Abstrac
|
|
12 |
{
|
13 |
Mage::log($data, null, $this->logFileName);
|
14 |
}
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
{
|
18 |
return Mage::getStoreConfig('abandonedcartsconfig/options/enable');
|
19 |
}
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
22 |
{
|
23 |
return Mage::getStoreConfig('abandonedcartsconfig/options/enable_sale');
|
24 |
}
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
{
|
28 |
return Mage::getStoreConfig('abandonedcartsconfig/options/dryrun');
|
29 |
}
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
{
|
33 |
return Mage::getStoreConfig('abandonedcartsconfig/options/testemail');
|
34 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Class DigitalPianism_Abandonedcarts_Helper_Data
|
5 |
+
*/
|
6 |
+
class DigitalPianism_Abandonedcarts_Helper_Data extends Mage_Core_Helper_Abstract
|
7 |
{
|
8 |
protected $logFileName = 'digitalpianism_abandonedcarts.log';
|
9 |
|
15 |
{
|
16 |
Mage::log($data, null, $this->logFileName);
|
17 |
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return mixed
|
21 |
+
*/
|
22 |
+
public function isEnabled()
|
23 |
{
|
24 |
return Mage::getStoreConfig('abandonedcartsconfig/options/enable');
|
25 |
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @return mixed
|
29 |
+
*/
|
30 |
+
public function isSaleEnabled()
|
31 |
{
|
32 |
return Mage::getStoreConfig('abandonedcartsconfig/options/enable_sale');
|
33 |
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return mixed
|
37 |
+
*/
|
38 |
+
public function getDryRun()
|
39 |
{
|
40 |
return Mage::getStoreConfig('abandonedcartsconfig/options/dryrun');
|
41 |
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return mixed
|
45 |
+
*/
|
46 |
+
public function getTestEmail()
|
47 |
{
|
48 |
return Mage::getStoreConfig('abandonedcartsconfig/options/testemail');
|
49 |
}
|
app/code/community/DigitalPianism/Abandonedcarts/Model/Observer.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
4 |
{
|
5 |
|
6 |
protected $recipients = array();
|
@@ -30,13 +33,35 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
30 |
|
31 |
$this->today = $today->toString("Y-MM-dd HH:mm:ss");
|
32 |
}
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
35 |
{
|
36 |
return $this->today;
|
37 |
}
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
{
|
41 |
// Test if the customer is already in the array
|
42 |
if (!array_key_exists($args['row']['customer_email'], $this->recipients))
|
@@ -65,7 +90,10 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
65 |
$this->recipients[$args['row']['customer_email']]['emailTemplateVariables'] = $emailTemplateVariables;
|
66 |
}
|
67 |
|
68 |
-
|
|
|
|
|
|
|
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'])
|
@@ -140,8 +168,12 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
140 |
$this->saleRecipients[$args['row']['customer_email']]['emailTemplateVariables'] = $emailTemplateVariables;
|
141 |
}
|
142 |
}
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
145 |
{
|
146 |
try
|
147 |
{
|
@@ -153,7 +185,7 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
153 |
$sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
|
154 |
|
155 |
// Send the emails via a loop
|
156 |
-
foreach ($this->
|
157 |
{
|
158 |
// Don't send the email if dryrun is set
|
159 |
if ($dryrun)
|
@@ -209,8 +241,12 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
209 |
Mage::helper('abandonedcarts')->log(__METHOD__ . " " . $e->getMessage());
|
210 |
}
|
211 |
}
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
214 |
{
|
215 |
try
|
216 |
{
|
@@ -222,7 +258,7 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
222 |
$sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
|
223 |
|
224 |
// Send the emails via a loop
|
225 |
-
foreach ($this->
|
226 |
{
|
227 |
// Don't send the email if dryrun is set
|
228 |
if ($dryrun)
|
@@ -281,8 +317,8 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
281 |
|
282 |
/**
|
283 |
* Send notification email to customer with abandoned cart containing sale products
|
284 |
-
* @param boolean if dryrun is set to true, it won't send emails and won't alter quotes
|
285 |
-
* @param string email to test
|
286 |
*/
|
287 |
public function sendAbandonedCartsSaleEmail($dryrun = false, $testemail = null)
|
288 |
{
|
@@ -361,10 +397,7 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
361 |
$collection->load();
|
362 |
|
363 |
// Skip the rest of the code if the collection is empty
|
364 |
-
if ($collection->getSize() == 0)
|
365 |
-
{
|
366 |
-
continue;
|
367 |
-
}
|
368 |
|
369 |
// Call iterator walk method with collection query string and callback method as parameters
|
370 |
// Has to be used to handle massive collection instead of foreach
|
@@ -382,12 +415,13 @@ class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstr
|
|
382 |
Mage::helper('abandonedcarts')->log(__METHOD__ . " " . $e->getMessage());
|
383 |
}
|
384 |
}
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
|
|
391 |
public function sendAbandonedCartsEmail($nodate = false, $dryrun = false, $testemail = null)
|
392 |
{
|
393 |
if (Mage::helper('abandonedcarts')->getDryRun()) $dryrun = true;
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Class DigitalPianism_Abandonedcarts_Model_Observer
|
5 |
+
*/
|
6 |
+
class DigitalPianism_Abandonedcarts_Model_Observer extends Mage_Core_Model_Abstract
|
7 |
{
|
8 |
|
9 |
protected $recipients = array();
|
33 |
|
34 |
$this->today = $today->toString("Y-MM-dd HH:mm:ss");
|
35 |
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function getToday()
|
41 |
{
|
42 |
return $this->today;
|
43 |
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
public function getRecipients()
|
49 |
+
{
|
50 |
+
return $this->recipients;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @return array
|
55 |
+
*/
|
56 |
+
public function getSaleRecipients()
|
57 |
+
{
|
58 |
+
return $this->saleRecipients;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @param $args
|
63 |
+
*/
|
64 |
+
public function generateRecipients($args)
|
65 |
{
|
66 |
// Test if the customer is already in the array
|
67 |
if (!array_key_exists($args['row']['customer_email'], $this->recipients))
|
90 |
$this->recipients[$args['row']['customer_email']]['emailTemplateVariables'] = $emailTemplateVariables;
|
91 |
}
|
92 |
|
93 |
+
/**
|
94 |
+
* @param $args
|
95 |
+
*/
|
96 |
+
public function generateSaleRecipients($args)
|
97 |
{
|
98 |
// Double check if the special from date is set
|
99 |
if (!array_key_exists('product_special_from_date',$args['row']) || !$args['row']['product_special_from_date'])
|
168 |
$this->saleRecipients[$args['row']['customer_email']]['emailTemplateVariables'] = $emailTemplateVariables;
|
169 |
}
|
170 |
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* @param $dryrun
|
174 |
+
* @param $testemail
|
175 |
+
*/
|
176 |
+
public function sendSaleEmails($dryrun,$testemail)
|
177 |
{
|
178 |
try
|
179 |
{
|
185 |
$sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
|
186 |
|
187 |
// Send the emails via a loop
|
188 |
+
foreach ($this->getSaleRecipients() as $email => $recipient)
|
189 |
{
|
190 |
// Don't send the email if dryrun is set
|
191 |
if ($dryrun)
|
241 |
Mage::helper('abandonedcarts')->log(__METHOD__ . " " . $e->getMessage());
|
242 |
}
|
243 |
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* @param $dryrun
|
247 |
+
* @param $testemail
|
248 |
+
*/
|
249 |
+
public function sendEmails($dryrun,$testemail)
|
250 |
{
|
251 |
try
|
252 |
{
|
258 |
$sender['name'] = Mage::getStoreConfig('abandonedcartsconfig/options/name');
|
259 |
|
260 |
// Send the emails via a loop
|
261 |
+
foreach ($this->getRecipients() as $email => $recipient)
|
262 |
{
|
263 |
// Don't send the email if dryrun is set
|
264 |
if ($dryrun)
|
317 |
|
318 |
/**
|
319 |
* Send notification email to customer with abandoned cart containing sale products
|
320 |
+
* @param boolean $dryrun if dryrun is set to true, it won't send emails and won't alter quotes
|
321 |
+
* @param string $testemail email to test
|
322 |
*/
|
323 |
public function sendAbandonedCartsSaleEmail($dryrun = false, $testemail = null)
|
324 |
{
|
397 |
$collection->load();
|
398 |
|
399 |
// Skip the rest of the code if the collection is empty
|
400 |
+
if ($collection->getSize() == 0) continue;
|
|
|
|
|
|
|
401 |
|
402 |
// Call iterator walk method with collection query string and callback method as parameters
|
403 |
// Has to be used to handle massive collection instead of foreach
|
415 |
Mage::helper('abandonedcarts')->log(__METHOD__ . " " . $e->getMessage());
|
416 |
}
|
417 |
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Send notification email to customer with abandoned carts after the number of days specified in the config
|
421 |
+
* @param bool $nodate
|
422 |
+
* @param boolean $dryrun if dryrun is set to true, it won't send emails and won't alter quotes
|
423 |
+
* @param string $testemail email to test
|
424 |
+
*/
|
425 |
public function sendAbandonedCartsEmail($nodate = false, $dryrun = false, $testemail = null)
|
426 |
{
|
427 |
if (Mage::helper('abandonedcarts')->getDryRun()) $dryrun = true;
|
app/code/community/DigitalPianism/Abandonedcarts/controllers/Adminhtml/AbandonedcartsController.php
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
class DigitalPianism_Abandonedcarts_Adminhtml_AbandonedcartsController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
/**
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Class DigitalPianism_Abandonedcarts_Adminhtml_AbandonedcartsController
|
5 |
+
*/
|
6 |
class DigitalPianism_Abandonedcarts_Adminhtml_AbandonedcartsController extends Mage_Adminhtml_Controller_Action
|
7 |
{
|
8 |
/**
|
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.10</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,12 @@
|
|
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-12-
|
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="
|
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.10</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>- PHPDoc
|
14 |
+
- Decrease nesting level to meet Magento ECG standards requirements</notes>
|
15 |
<authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
|
16 |
+
<date>2014-12-19</date>
|
17 |
+
<time>11:27:20</time>
|
18 |
+
<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="d5a6f33d47d067fc09a7b7fe8eacd287"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4eda7b865d023206a58a4178f7db81a5"/></dir><dir name="Model"><file name="Observer.php" hash="49baa4ce3a82b6b70c63dcce1c8a5e21"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AbandonedcartsController.php" hash="ca68e31a5e41f036451a409a7eeaaa16"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8ddca513c0ed7e034c476f3e026ceda8"/><file name="config.xml" hash="17ea6d587df418c1210db8278ee16b16"/><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>
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
</package>
|