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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiagoebizmarts committed Jun 16, 2016
2 parents 3ab5294 + be98958 commit e3c4579
Show file tree
Hide file tree
Showing 42 changed files with 320 additions and 132 deletions.
Empty file modified .gitignore
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function getImage($_item)
{
$product = Mage::getModel('catalog/product')
->load($_item->getProductId());
$imageUrl = $product->getThumbnailUrl();
if ($product->getImage() == "no_selection" && $product->getTypeId() == "configurable") {
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($product);
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
Expand All @@ -38,8 +39,6 @@ public function getImage($_item)
$imageUrl = $simple_product->getThumbnailUrl();
}
}
} else {
$imageUrl = $product->getThumbnailUrl();
}
return $imageUrl;
}
Expand Down
3 changes: 3 additions & 0 deletions app/code/community/Ebizmarts/AbandonedCart/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public function saveMail($mailType, $mail, $name, $couponCode, $storeId)
case 'by_percent':
$couponType = 2;
break;
default:
$couponType = 0;
break;
}
} else {
$couponType = 0;
Expand Down
5 changes: 5 additions & 0 deletions app/code/community/Ebizmarts/AbandonedCart/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ class Ebizmarts_AbandonedCart_Model_Config
const POPUP_COUPON_DISCOUNT = 'ebizmarts_abandonedcart/emailcatcher/popup_discount';
const POPUP_COUPON_LABEL = 'ebizmarts_abandonedcart/emailcatcher/popup_couponlabel';

const GANALYTICS_ACTIVE = 'ebizmarts_abandonedcart/ganalytics/analytics_active';
const GANALYTICS_SOURCE = 'ebizmarts_abandonedcart/ganalytics/analytics_source';
const GANALYTICS_MEDIUM = 'ebizmarts_abandonedcart/ganalytics/analytics_medium';
const GANALYTICS_CAMPAIGN = 'ebizmarts_abandonedcart/ganalytics/analytics_campaign';

}
36 changes: 27 additions & 9 deletions app/code/community/Ebizmarts/AbandonedCart/Model/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,18 @@ protected function _processRun($adapter, $run, $storeId)
} else {
$this->sendcoupondays = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::COUPON_DAYS, $storeId);
}

$ganalytics='';
if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::GANALYTICS_ACTIVE, $storeId)) {
if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::GANALYTICS_SOURCE, $storeId)!='') {
$ganalytics .= '&utm_source='.Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::GANALYTICS_SOURCE, $storeId);
}
if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::GANALYTICS_MEDIUM, $storeId)!='') {
$ganalytics .= '&utm_medium='.Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::GANALYTICS_MEDIUM, $storeId);
}
if(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::GANALYTICS_CAMPAIGN, $storeId)!='') {
$ganalytics .= '&utm_campaign='.Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::GANALYTICS_CAMPAIGN, $storeId);
}
}
// for each cart of the current run
foreach ($collection as $quote) {
$this->_proccessCollection($quote, $storeId);
Expand Down Expand Up @@ -179,11 +190,11 @@ 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 . '&' . $suffix;
} else {
$url = Mage::getModel('core/url')->setStore($storeId)->getUrl('', array('_nosid' => true)) . 'ebizmarts_abandonedcart/abandoned/loadquote?id=' . $quote->getEntityId() . '&token=' . $token;
}

$url .= $ganalytics;
$data = array('AbandonedURL' => $url, 'AbandonedDate' => $quote->getUpdatedAt());

// send email
Expand All @@ -200,7 +211,7 @@ protected function _processRun($adapter, $run, $storeId)

//if hour is set for first run calculates hours since cart was created else calculates days
$today = idate('U', strtotime(now()));
$updatedAt = idate('U', strtotime($quote2->getUpdatedAt()));
$updatedAt = idate('U', strtotime($quote->getUpdatedAt()));
$updatedAtDiff = ($today - $updatedAt) / 60 / 60 / 24;
if ($this->unit == Ebizmarts_AbandonedCart_Model_Config::IN_HOURS && $run == 0) {
$updatedAtDiff = ($today - $updatedAt) / 60 / 60;
Expand Down Expand Up @@ -263,8 +274,15 @@ protected function _processRun($adapter, $run, $storeId)
}
}
if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AB_TESTING_ACTIVE, $storeId)) {
$counterCollection = Mage::getModel('ebizmarts_abandonedcart/abtesting')->getCollection()
->addFieldToFilter('store_id', array('eq' => $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();
Expand Down Expand Up @@ -374,12 +392,12 @@ protected function _sendPopupCoupon($storeId)
*/
protected function _createNewCoupon($store, $email)
{
$websiteid = Mage::getModel('core/store')->load($store)->getWebsiteId();
$collection = Mage::getModel('salesrule/rule')->getCollection()
->addFieldToFilter('name', array('like' => 'Abandoned coupon ' . $email));
->addFieldToFilter('name', array('like' => 'Abandoned coupon ' . $email))
->addFieldToFilter('website_ids', array('eq' => $websiteid));
if (!count($collection)) {

$websiteid = Mage::getModel('core/store')->load($store)->getWebsiteId();

$fromDate = date("Y-m-d");
$toDate = date('Y-m-d', strtotime($fromDate . " + $this->couponexpiredays day"));
if ($this->coupontype == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function saveConfig(Varien_Event_Observer $observer)

$cleanCache = false;
$store = is_null($observer->getEvent()->getStore()) ? Mage::app()->getDefaultStoreView()->getCode() : $observer->getEvent()->getStore();
$config = null;
if (!Mage::helper('ebizmarts_mandrill')->useTransactionalService()) {
$config = new Mage_Core_Model_Config();
$config->saveConfig(Ebizmarts_AbandonedCart_Model_Config::ACTIVE, false, $scope, $store);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,29 @@ public function loadquoteAction()
if (isset($params['id'])) {
//restore the quote
// Mage::log($params['id']);

$analytics = array();
if(isset($params['utm_source'])) {
$analytics['utm_source'] = $params['utm_source'];
}
if(isset($params['utm_medium'])) {
$analytics['utm_medium'] = $params['utm_medium'];
}
if(isset($params['utm_campaign'])) {
$analytics['utm_campaign'] = $params['utm_campaign'];
}
$quote = Mage::getModel('sales/quote')->load($params['id']);
$url = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::PAGE, $quote->getStoreId());
$url = Mage::getUrl(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::PAGE, $quote->getStoreId()));
$first = true;
foreach($analytics as $key => $value) {
if($first) {
$char = '?';
$first = false;
}
else {
$char = '&';
}
$url .= "$char$key=$value";
}
if (isset($params['coupon'])) {
$quote->setCouponCode($params['coupon']);
$quote->save();
Expand All @@ -32,22 +52,36 @@ public function loadquoteAction()
Mage::getSingleton('customer/session')->addNotice("Your token cart is incorrect");
$this->_redirect($url);
} else {
$url = Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::PAGE, $quote->getStoreId());
$url = Mage::getUrl(Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::PAGE, $quote->getStoreId()));
$first = true;
foreach($analytics as $key => $value) {
if($first) {
$char = '?';
$first = false;
}
else {
$char = '&';
}
$url .= "$char$key=$value";
}
$quote->setEbizmartsAbandonedcartFlag(1);
$quote->save();
if (!$quote->getCustomerId()) {
$this->_getSession()->setQuoteId($quote->getId());
$this->_redirect($url);
$this->getResponse()
->setRedirect($url, 301);
} else {
if (Mage::getStoreConfig(Ebizmarts_AbandonedCart_Model_Config::AUTOLOGIN, $quote->getStoreId())) {
$customer = Mage::getModel('customer/customer')->load($quote->getCustomerId());
if ($customer->getId()) {
Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
}
$this->_redirect($url);
$this->getResponse()
->setRedirect($url, 301);
} else {
if (Mage::helper('customer')->isLoggedIn()) {
$this->_redirect($url);
$this->getResponse()
->setRedirect($url, 301);
} else {
Mage::getSingleton('customer/session')->addNotice("Login to complete your order");
$this->_redirect('customer/account');
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Ebizmarts/AbandonedCart/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<config>
<modules>
<Ebizmarts_AbandonedCart>
<version>1.2.1</version>
<version>1.2.2.1</version>
</Ebizmarts_AbandonedCart>
</modules>
<global>
Expand Down
52 changes: 52 additions & 0 deletions app/code/community/Ebizmarts/AbandonedCart/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,58 @@
</popup_couponlabel>
</fields>
</emailcatcher>
<ganalytics>
<label>Google Analytics</label>
<sort_order>500</sort_order>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<analytics_active translate="label comment">
<label>Active</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>510</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</analytics_active>
<analytics_source>
<label>Source</label>
<frontend_type>text</frontend_type>
<sort_order>520</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<analytics_active>1</analytics_active>
</depends>
</analytics_source>
<analytics_medium>
<label>Medium</label>
<frontend_type>text</frontend_type>
<sort_order>530</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<analytics_active>1</analytics_active>
</depends>
</analytics_medium>
<analytics_campaign>
<label>Campaing</label>
<frontend_type>text</frontend_type>
<sort_order>540</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<analytics_active>1</analytics_active>
</depends>
</analytics_campaign>
</fields>
</ganalytics>
</groups>
</ebizmarts_abandonedcart>
</sections>
Expand Down
30 changes: 23 additions & 7 deletions app/code/community/Ebizmarts/Autoresponder/Model/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,16 @@ protected function _processBirthday($storeId)
$moreselect = "MONTH(at_dob.value) = $month AND DAY(at_dob.value) = $day";


$collection->addAttributeToFilter('dob', array('neq' => 'null'))
->addFieldToFilter('store_id', array('eq' => $storeId));
$collection->addAttributeToFilter('dob', array('neq' => 'null'));
$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);
}

if (count($customerGroups)) {
$collection->addFieldToFilter('group_id', array('in' => $customerGroups));
}
Expand Down Expand Up @@ -203,7 +211,14 @@ protected function _processNoActivity($storeId)
if (count($customerGroups)) {
$collection->addFieldToFilter('group_id', array('in' => $customerGroups));
}
$collection->addFieldToFilter('store_id', array('eq' => $storeId));
$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);
}

foreach ($collection as $customer) {
$customerId = $customer->getEntityId();
Expand Down Expand Up @@ -439,9 +454,9 @@ protected function _processWishlist($storeId)
->addFieldToFilter('main_table.store_id', array('eq' => $storeId))
->setOrder('main_table.wishlist_id');
$wishlist_ant = -1;
$wishlistId = $collection->getFirstItem()->getWishlistId();
$products = array();
foreach ($collection as $item) {
$wishlistId = $item->getWishlistId();
if ($wishlistId != $wishlist_ant) {
if ($wishlist_ant != -1 && count($products) > 0) {
$translate = Mage::getSingleton('core/translate');
Expand Down Expand Up @@ -474,7 +489,6 @@ protected function _processWishlist($storeId)

}
$wishlist_ant = $wishlistId;
$wishlistId = $item->getWishlistId();
$wishlist = Mage::getModel('wishlist/wishlist')->load($wishlistId);
$customer = Mage::getModel('customer/customer')->load($wishlist->getCustomerId());
$products = array();
Expand Down Expand Up @@ -862,15 +876,17 @@ public function cleanupBackToStock()

protected function _createNewCoupon($store, $email, $string)
{
$websiteid = Mage::getModel('core/store')->load($store)->getWebsiteId();
$collection = Mage::getModel('salesrule/rule')->getCollection()
->addFieldToFilter('name', array('like' => $string . $email));
->addFieldToFilter('name', array('like' => $string . $email))
->addFieldToFilter('website_ids', array('eq' => $websiteid));

if (!count($collection)) {
$couponamount = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_DISCOUNT, $store);
$couponexpiredays = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_EXPIRE, $store);
$coupontype = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_DISCOUNT_TYPE, $store);
$couponlength = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_LENGTH, $store);
$couponlabel = Mage::getStoreConfig(Ebizmarts_Autoresponder_Model_Config::BIRTHDAY_COUPON_LABEL, $store);
$websiteid = Mage::getModel('core/store')->load($store)->getWebsiteId();

$fromDate = date("Y-m-d");
$toDate = date('Y-m-d', strtotime($fromDate . " + $couponexpiredays day"));
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Ebizmarts/Autoresponder/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<config>
<modules>
<Ebizmarts_Autoresponder>
<version>1.2.1</version>
<version>1.2.1.1</version>
</Ebizmarts_Autoresponder>
</modules>
<global>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");

$installer->run("
try {
$installer->run("
ALTER TABLE `{$this->getTable('magemonkey_mails_sent')}`
CHANGE `mail_type` `mail_type` ENUM( 'abandoned cart', 'happy birthday', 'new order', 'related products', 'product review', 'no activity', 'wishlist', 'review coupon' )
CHARACTER SET utf8 NOT NULL;
");
}catch (Exception $e){

}

$installer->addAttribute(
'customer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ protected function tableExists(){
}else{
$pre = '';
}
$resource = Mage::getSingleton('core/resource');
$resource = Mage::getSingleton('core/resource')
->getConnection('core_write');

$table = $resource->getTableName($pre.'permission_block');
$tableExists = (bool)$resource->getConnection()->showTableStatus($table);
$tableExists = (bool)$resource->showTableStatus($table);
return $tableExists;
}
}
Loading

0 comments on commit e3c4579

Please sign in to comment.