Skip to content
This repository has been archived by the owner on Jun 1, 2018. It is now read-only.

Commit

Permalink
Coding standards changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiagoebizmarts committed Oct 21, 2016
1 parent 350e993 commit 1c0b3f7
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 261 deletions.
57 changes: 32 additions & 25 deletions app/code/community/Ebizmarts/AbandonedCart/Model/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Ebizmarts_AbandonedCart_Model_Cron
protected $_couponlength;
protected $_couponlabel;
protected $_sendcoupondays;
protected $_suffix;
protected $_diff;

/**
*
Expand Down Expand Up @@ -99,17 +101,17 @@ protected function _proccess($storeId)
protected function _processRun($adapter, $run, $storeId)
{
// subtract days from latest run to get difference from the actual abandon date of the cart
$diff = $this->_days[$run];
$this->_diff = $this->_days[$run];
if ($run == 1 && $this->_unit == Ebizmarts_AbandonedCart_Model_Config::IN_HOURS) {
$diff -= $this->_days[0] / 24;
$this->_diff -= $this->_days[0] / 24;
} elseif ($run != 0) {
$diff -= $this->_days[$run - 1];
$this->_diff -= $this->_days[$run - 1];
}

// set the top date of the carts to get
$expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($diff, 'DAY'));
$expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($this->_diff, 'DAY'));
if ($run == 0 && $this->_unit == Ebizmarts_AbandonedCart_Model_Config::IN_HOURS) {
$expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($diff, 'HOUR'));
$expr = sprintf('DATE_SUB(%s, %s)', $adapter->quote(now()), $this->_getIntervalUnitSql($this->_diff, 'HOUR'));
}
$from = new Zend_Db_Expr($expr);

Expand All @@ -136,14 +138,14 @@ protected function _processRun($adapter, $run, $storeId)
->getFirstItem();
if ($item) {
$status = $item->getCurrentStatus();
$suffix = '';
$this->_suffix = '';
if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_ACTIVE, $storeId) && $status == 1) {
$abTesting = true;
$suffix = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_MANDRILL_SUFFIX, $storeId);
$this->_suffix = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_MANDRILL_SUFFIX, $storeId);
}
}
if ($abTesting) {
$this->_mandrillTag .= '_' . $suffix;
$this->_mandrillTag .= '_' . $this->_suffix;
$this->_sendcoupondays = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_COUPON_SENDON, $storeId);
} else {
$this->_sendcoupondays = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_DAYS, $storeId);
Expand All @@ -160,8 +162,28 @@ protected function _processRun($adapter, $run, $storeId)
$ganalytics .= '&utm_campaign='.Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::GANALYTICS_CAMPAIGN, $storeId);
}
}
$this->_proccessQuotes($collection, $storeId, $abTesting, $ganalytics, $run);
if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_ACTIVE, $storeId)) {
$counterCollection = Mage::getModel('ebizmarts_abandonedcart/abtesting')->getCollection();
$defaultStore = Mage::app()->getStore($storeId)->getWebsite()->getDefaultStore();
$normalFilter = array('eq' => $storeId);
if ($storeId == $defaultStore->getId()) {
$newFilter = array('eq' => '0');
$collection->addFieldToFilter('store_id', array($normalFilter, $newFilter));
} else {
$collection->addFieldToFilter('store_id', $normalFilter);
}
$counter = $counterCollection->getFirstItem();
$counter->setCurrentStatus($counter->getCurrentStatus() + 1)
->save();
}
}

protected function _proccessQuotes($collection, $storeId, $abTesting, $ganalytics, $run)
{
// for each cart of the current run
foreach ($collection as $quote) {

$quote = $this->_proccessCollection($quote, $storeId);

if (count($quote->getAllVisibleItems()) < 1) {
Expand Down Expand Up @@ -190,7 +212,7 @@ protected function _processRun($adapter, $run, $storeId)
//srand((double)microtime()*1000000);
$token = md5(rand(0, 9999999));
if ($abTesting) {
$url = Mage::getModel('core/url')->setStore($storeId)->getUrl('', array('_nosid' => true)) . 'ebizmarts_abandonedcart/abandoned/loadquote?id=' . $quote->getEntityId() . '&token=' . $token . '&' . $suffix;
$url = Mage::getModel('core/url')->setStore($storeId)->getUrl('', array('_nosid' => true)) . 'ebizmarts_abandonedcart/abandoned/loadquote?id=' . $quote->getEntityId() . '&token=' . $token . '&' . $this->_suffix;
} else {
$url = Mage::getModel('core/url')->setStore($storeId)->getUrl('', array('_nosid' => true)) . 'ebizmarts_abandonedcart/abandoned/loadquote?id=' . $quote->getEntityId() . '&token=' . $token;
}
Expand Down Expand Up @@ -218,7 +240,7 @@ protected function _processRun($adapter, $run, $storeId)
}

// if days have passed proceed to send mail
if ($updatedAtDiff >= $diff) {
if ($updatedAtDiff >= $this->_diff) {
$mailsubject = $this->_getMailSubject($run, $storeId, $abTesting);
$templateId = $this->_getTemplateId($run, $storeId, $abTesting);
if ($this->_sendcoupon && $run + 1 == $this->_sendcoupondays) {
Expand Down Expand Up @@ -273,21 +295,6 @@ protected function _processRun($adapter, $run, $storeId)
}
}
}
if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_ACTIVE, $storeId)) {
$counterCollection = Mage::getModel('ebizmarts_abandonedcart/abtesting')->getCollection();
$defaultStore = Mage::app()->getStore($storeId)->getWebsite()->getDefaultStore();
$normalFilter = array('eq' => $storeId);
if ($storeId == $defaultStore->getId()) {
$newFilter = array('eq' => '0');
$collection->addFieldToFilter('store_id', array($normalFilter, $newFilter));
} else {
$collection->addFieldToFilter('store_id', $normalFilter);
}
$counter = $counterCollection->getFirstItem();
$counter->setCurrentStatus($counter->getCurrentStatus() + 1)
->save();
}

}
protected function _proccessCollection($quote, $storeId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/
class Ebizmarts_MageMonkey_Block_Customer_Account_Lists extends Ebizmarts_MageMonkey_Block_Lists
{

private $_lists;
}
2 changes: 1 addition & 1 deletion app/code/community/Ebizmarts/MageMonkey/Block/Signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
*/
class Ebizmarts_MageMonkey_Block_Signup extends Ebizmarts_MageMonkey_Block_Lists
{

private $_signup;
}
Loading

0 comments on commit 1c0b3f7

Please sign in to comment.