Skip to content

Commit

Permalink
fix #7 and #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Petrini committed Nov 9, 2016
1 parent e580290 commit 9dce7a7
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class DigitalPianism_Abandonedcarts_Model_Notifier extends Mage_Core_Model_Abstr
*/
protected $_currentStoreId;

/**
* @var
*/
protected $_originalArea;

/**
* @var
*/
Expand Down Expand Up @@ -273,6 +278,12 @@ protected function _sendSaleEmails($dryrun, $testemail)

// Store Id
Mage::app()->setCurrentStore($recipient['store_id']);
// Area
if ($recipient['store_id'] === 0) {
Mage::app()->getDesign()->setArea('adminhtml');
} else {
Mage::app()->getDesign()->setArea('frontend');
}
// Get the transactional email template
$templateId = Mage::getStoreConfig('abandonedcartsconfig/email/email_template_sale');
// Get the sender
Expand Down Expand Up @@ -360,6 +371,16 @@ protected function _sendEmails($dryrun, $testemail)

// Store ID
Mage::app()->setCurrentStore($recipient['store_id']);
// Area
if ($recipient['store_id'] === 0) {
Mage::app()->getDesign()->setArea('adminhtml');
} else {
Mage::app()->getDesign()->setArea('frontend');
}

if ($recipient['store_id']) {
Mage::app()->set
}
// Get the transactional email template
$templateId = Mage::getStoreConfig('abandonedcartsconfig/email/email_template');
// Get the sender
Expand Down Expand Up @@ -449,6 +470,8 @@ public function sendAbandonedCartsSaleEmail($dryrun = false, $testemail = null,
$this->_customerGroups = $this->_customerGroups ? $this->_customerGroups : Mage::helper('abandonedcarts')->getCustomerGroupsLimitation();
// Original store id
$this->_originalStoreId = Mage::app()->getStore()->getId();
// Original area
$this->_originalArea = Mage::app()->getDesign()->getArea();
try
{
if (Mage::helper('abandonedcarts')->isSaleEnabled()) {
Expand Down Expand Up @@ -489,12 +512,14 @@ public function sendAbandonedCartsSaleEmail($dryrun = false, $testemail = null,
}
$this->_sendSaleEmails($dryrun, $testemail);
}
Mage::app()->getDesign()->setArea($this->_originalArea);
Mage::app()->setCurrentStore($this->_originalStoreId);

return count($this->_getSaleRecipients());
}
catch (Exception $e)
{
Mage::app()->getDesign()->setArea($this->_originalArea);
Mage::app()->setCurrentStore($this->_originalStoreId);
Mage::helper('abandonedcarts')->log(sprintf("%s->Error: %s", __METHOD__, $e->getMessage()));
return 0;
Expand Down Expand Up @@ -522,6 +547,8 @@ public function sendAbandonedCartsEmail($nodate = false, $dryrun = false, $teste
$this->_customerGroups = $this->_customerGroups ? $this->_customerGroups : Mage::helper('abandonedcarts')->getCustomerGroupsLimitation();
// Original store id
$this->_originalStoreId = Mage::app()->getStore()->getId();
// Original area
$this->_originalArea = Mage::app()->getDesign()->getArea();
try
{
if (Mage::helper('abandonedcarts')->isEnabled()) {
Expand Down Expand Up @@ -575,12 +602,14 @@ public function sendAbandonedCartsEmail($nodate = false, $dryrun = false, $teste
// Send the emails
$this->_sendEmails($dryrun, $testemail);
}
Mage::app()->getDesign()->setArea($this->_originalArea);
Mage::app()->setCurrentStore($this->_originalStoreId);

return count($this->_getRecipients());
}
catch (Exception $e)
{
Mage::app()->getDesign()->setArea($this->_originalArea);
Mage::app()->setCurrentStore($this->_originalStoreId);
Mage::helper('abandonedcarts')->log(sprintf("%s->Error: %s", __METHOD__, $e->getMessage()));
return 0;
Expand Down

0 comments on commit 9dce7a7

Please sign in to comment.