Skip to content

Commit c057979

Browse files
Merge branch 'develop'
# Conflicts: # modman
2 parents c63586d + a8ea9ad commit c057979

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1134
-293
lines changed

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimperrors/Grid.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ protected function _prepareColumns()
8282
'sortable' => false
8383
)
8484
);
85-
$this->addColumn('action_donwload', array(
85+
$this->addColumn(
86+
'action_donwload', array(
8687
'header' => $this->helper('mailchimp')->__('Download Response'),
8788
'width' => 15,
8889
'sortable' => false,

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mailchimperrors/Link.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function render(Varien_Object $row)
3838
$displayText = $this->__('Something went wrong when retrieving original item.');
3939
break;
4040
}
41+
4142
return $displayText;
4243
}
4344
}

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mergevars/Add.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
* File : Add.php
77
* Module : Ebizmarts_MailChimp
88
*/
9-
class Ebizmarts_Mailchimp_Block_Adminhtml_Mergevars_Add extends Mage_Adminhtml_Block_Widget_Form_Container {
9+
class Ebizmarts_Mailchimp_Block_Adminhtml_Mergevars_Add extends Mage_Adminhtml_Block_Widget_Form_Container
10+
{
1011
protected $_mode = 'add';
11-
public function __construct() {
12+
public function __construct()
13+
{
1214
$this->_controller = 'adminhtml_mergevars';
1315
$this->_blockGroup = 'mailchimp';
1416

@@ -26,7 +28,8 @@ public function getHeaderText()
2628
{
2729
return Mage::helper('mailchimp')->__('New Field Type');
2830
}
29-
public function _prepareForm() {
31+
public function _prepareForm()
32+
{
3033
}
3134

3235
}

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Mergevars/Add/Form.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,41 @@
88
*/
99
class Ebizmarts_Mailchimp_Block_Adminhtml_Mergevars_Add_Form extends Mage_Adminhtml_Block_Widget_Form
1010
{
11-
protected function _prepareForm() {
11+
protected function _prepareForm()
12+
{
1213
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/saveadd'), 'method' => 'post'));
1314
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('mailchimp')->__('Mergevars Data')));
1415

1516

16-
$fieldset->addField('mergevar_label', 'text', array(
17+
$fieldset->addField(
18+
'mergevar_label', 'text', array(
1719
'name' => 'mergevar[label]',
1820
'label' => Mage::helper('mailchimp')->__('MergeVar Name'),
1921
'id' => 'mergevar_label',
2022
'title' => Mage::helper('mailchimp')->__('MergeVar Name'),
2123
'required' => true
22-
));
23-
$fieldset->addField('mergevar_fieldtype','select',array(
24+
)
25+
);
26+
$fieldset->addField(
27+
'mergevar_fieldtype', 'select', array(
2428
'name' => 'mergevar[fieldtype]',
2529
'label' => Mage::helper('mailchimp')->__('Field Type'),
2630
'id' => 'mergevar_fieldtype',
2731
'values' => Mage::getSingleton('mailchimp/system_config_source_fieldtype')->getFieldTypes(),
2832
'required' => true
29-
));
33+
)
34+
);
3035

31-
$fieldset->addField('mergevar_value', 'text', array(
36+
$fieldset->addField(
37+
'mergevar_value', 'text', array(
3238
'name' => 'mergevar[value]',
3339
'label' => Mage::helper('mailchimp')->__('Value for case entry'),
3440
'id' => 'mergevar_value',
3541
'title' => Mage::helper('mailchimp')->__('Value for case entry'),
3642
'note' => 'This value should be added in the case of Data.php file',
3743
'required' => true
38-
));
44+
)
45+
);
3946

4047

4148

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Sales/Order/Grid/Renderer/Mailchimp.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ class Ebizmarts_MailChimp_Block_Adminhtml_Sales_Order_Grid_Renderer_Mailchimp ex
1515
public function render(Varien_Object $row)
1616
{
1717
$order = Mage::getModel('sales/order')->load($row->getData('entity_id'));
18-
if ($order->getMailchimpAbandonedcartFlag() || $order->getMailchimpCampaignId()) {
18+
if ($order->getMailchimpAbandonedcartFlag() || $order->getMailchimpCampaignId() || $order->getMailchimpLandingPage()) {
1919
$result = '<img src="' . $this->getSkinUrl("ebizmarts/mailchimp/images/logo-freddie-monocolor-200.png") . '" width="40" title="hep hep thanks MailChimp" />';
2020
} else {
2121
$result = '';
2222
}
23+
2324
return $result;
2425
}
2526
}

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/Sales/Order/View/Info/Monkey.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function isReferred()
2020
{
2121
$ret = true;
2222
}
23+
2324
return $ret;
2425
}
2526
public function getCampaign()

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/Form/Field/Mapfields.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function __construct()
4343
$this->_customerAttributes[$option['attribute_id']] = $option['frontend_label'];
4444
}
4545
}
46+
4647
$customFieldTypes = unserialize(
4748
Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_CUSTOM_MAP_FIELDS)
4849
);
@@ -53,6 +54,7 @@ public function __construct()
5354
$this->_customerAttributes[$value] = $label;
5455
}
5556
}
57+
5658
ksort($this->_customerAttributes);
5759
}
5860

@@ -61,6 +63,7 @@ protected function _renderCellTemplate($columnName)
6163
if (empty($this->_columns[$columnName])) {
6264
throw new Exception('Wrong column name specified.');
6365
}
66+
6467
$column = $this->_columns[$columnName];
6568
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
6669

@@ -69,18 +72,22 @@ protected function _renderCellTemplate($columnName)
6972
foreach ($this->_customerAttributes as $att => $name) {
7073
$rendered .= '<option value="' . $att . '">' . $name . '</option>';
7174
}
75+
7276
$rendered .= '</select>';
7377
} else {
7478
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' . ($column['size'] ? 'size="' . $column['size'] . '"' : '') . '/>';
7579
}
80+
7681
return $rendered;
7782
}
7883

79-
protected function _getMailChimpValue(){
84+
protected function _getMailChimpValue()
85+
{
8086
return Mage::getSingleton('core/session')->getMailchimpValue();
8187
}
8288

83-
protected function _getMailChimpLabel(){
89+
protected function _getMailChimpLabel()
90+
{
8491
return Mage::getSingleton('core/session')->getMailchimpLabel();
8592
}
8693
}

app/code/community/Ebizmarts/MailChimp/Block/Adminhtml/System/Config/OauthWizard.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ protected function _prepareLayout()
2121
if (!$this->getTemplate()) {
2222
$this->setTemplate('ebizmarts/mailchimp/system/config/oauth_wizard.phtml');
2323
}
24+
2425
return $this;
2526
}
2627

app/code/community/Ebizmarts/MailChimp/Block/Popup/Emailcatcher.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ protected function _handleCookie()
5252
if (isset($cookieValues[1])) {
5353
$fName = $cookieValues[1];
5454
}
55+
5556
if (isset($cookieValues[2])) {
5657
$lName = $cookieValues[2];
5758
}
59+
5860
if ($subscribeCookie == 'true') {
5961
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
6062
if (!$subscriber->getId()) {
@@ -65,10 +67,12 @@ protected function _handleCookie()
6567
$subscriberFname = filter_var($fName, FILTER_SANITIZE_STRING);
6668
$subscriber->setSubscriberFirstname($subscriberFname);
6769
}
70+
6871
if ($lName) {
6972
$subscriberLname = filter_var($lName, FILTER_SANITIZE_STRING);
7073
$subscriber->setSubscriberLastname($subscriberLname);
7174
}
75+
7276
$subscriber->setStoreId($storeId)
7377
->subscribe($email);
7478
return 'location.reload';

app/code/community/Ebizmarts/MailChimp/Helper/Data.php

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ protected function _getConfigScopeId($storeId = null, $websiteId = null)
3030
$websiteId = Mage::getModel('core/website')->load($code)->getId();
3131
$storeId = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId();
3232
}
33+
3334
$scopeArray['websiteId'] = $websiteId;
3435
$scopeArray['storeId'] = $storeId;
3536
return $scopeArray;
@@ -55,6 +56,7 @@ public function getConfigValue($path, $storeId = null, $returnParentValueIfNull
5556
} else {
5657
$scopeArray['storeId'] = $storeId;
5758
}
59+
5860
if (!$returnParentValueIfNull) {
5961
if (isset($scopeArray['websiteId']) && $scopeArray['websiteId']) {
6062
//Website scope
@@ -73,6 +75,7 @@ public function getConfigValue($path, $storeId = null, $returnParentValueIfNull
7375
}
7476
}
7577
}
78+
7679
return $configValue;
7780
}
7881

@@ -83,7 +86,8 @@ public function getConfigValue($path, $storeId = null, $returnParentValueIfNull
8386
*/
8487
public function getMCStoreName()
8588
{
86-
return parse_url(Mage::getBaseUrl(), PHP_URL_HOST);
89+
$storeView = Mage::app()->getDefaultStoreView();
90+
return $storeView->getWebsite()->getDefaultStore()->getFrontendName();
8791
}
8892

8993
/**
@@ -133,12 +137,15 @@ public function resetMCEcommerceData($deleteDataInMailchimp=false)
133137
} catch(Mailchimp_Error $e) {
134138
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
135139
}
140+
136141
//clear store config values
137142
Mage::getConfig()->deleteConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCSTOREID);
138143
}
144+
139145
if ($ecommerceEnabled && $apikey && $listId) {
140146
$this->createStore($listId);
141147
}
148+
142149
//reset mailchimp minimum date to sync flag
143150
Mage::getConfig()->saveConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCMINSYNCDATEFLAG, Varien_Date::now());
144151
Mage::getConfig()->saveConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCSTORE_RESETED, 1);
@@ -185,7 +192,7 @@ public function logRequest($message, $batchId=null)
185192
} else {
186193
$logDir = Mage::getBaseDir('var') . DS . 'log';
187194
$fileName = $logDir.DS.$batchId.'.Request.log';
188-
file_put_contents($fileName,$message);
195+
file_put_contents($fileName, $message);
189196
}
190197
}
191198
}
@@ -216,8 +223,11 @@ public function resetErrors()
216223
foreach ($collection as $product) {
217224
$product->setData("mailchimp_sync_delta", null);
218225
$product->setData("mailchimp_sync_error", '');
219-
$product->setMailchimpUpdateObserverRan(true);
220-
$product->save();
226+
$resource = $product->getResource();
227+
$resource->saveAttribute($product, 'mailchimp_sync_delta');
228+
$resource->saveAttribute($product, 'mailchimp_sync_error');
229+
// $product->setMailchimpUpdateObserverRan(true);
230+
// $product->save();
221231
}
222232

223233
// reset subscribers with errors
@@ -240,8 +250,11 @@ public function resetErrors()
240250
foreach ($collection as $customer) {
241251
$customer->setData("mailchimp_sync_delta", '0000-00-00 00:00:00');
242252
$customer->setData("mailchimp_sync_error", '');
243-
$customer->setMailchimpUpdateObserverRan(true);
244-
$customer->save();
253+
$resource = $customer->getResource();
254+
$resource->saveAttribute($customer, 'mailchimp_sync_delta');
255+
$resource->saveAttribute($customer, 'mailchimp_sync_error');
256+
// $customer->setMailchimpUpdateObserverRan(true);
257+
// $customer->save();
245258
}
246259

247260
// reset orders with errors
@@ -301,6 +314,7 @@ public function deleteStore()
301314
} catch (Mailchimp_Error $e) {
302315
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
303316
}
317+
304318
//clear store config values
305319
Mage::getConfig()->deleteConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCSTOREID);
306320
}
@@ -320,6 +334,7 @@ public function createMergeFields()
320334
} catch (Mailchimp_Error $e) {
321335
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
322336
}
337+
323338
if (count($mailchimpFields) > 0) {
324339
foreach ($maps as $map) {
325340
$customAtt = $map['magento'];
@@ -331,6 +346,7 @@ public function createMergeFields()
331346
$alreadyExists = true;
332347
}
333348
}
349+
334350
if (!$alreadyExists) {
335351
foreach ($customFieldTypes as $customFieldType) {
336352
if ($customFieldType['value'] == $chimpTag) {
@@ -339,9 +355,11 @@ public function createMergeFields()
339355
} catch (Mailchimp_Error $e) {
340356
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
341357
}
358+
342359
$created = true;
343360
}
344361
}
362+
345363
if (!$created) {
346364
$attrSetId = Mage::getResourceModel('eav/entity_attribute_collection')
347365
->setEntityTypeFilter(1)
@@ -353,6 +371,7 @@ public function createMergeFields()
353371
$label = $option['frontend_label'];
354372
}
355373
}
374+
356375
try {
357376
if ($label) {
358377
//Shipping and Billing Address
@@ -391,6 +410,17 @@ public function getApi()
391410
if ($apiKey != null && $apiKey != "") {
392411
$api = new Ebizmarts_Mailchimp($apiKey, null, 'Mailchimp4Magento' . (string)Mage::getConfig()->getNode('modules/Ebizmarts_MailChimp/version'));
393412
}
413+
394414
return $api;
395415
}
416+
public function changeName($name)
417+
{
418+
if (Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_ACTIVE)) {
419+
try {
420+
Mage::getModel('mailchimp/api_stores')->modifyName($name);
421+
} catch (Mailchimp_Error $e) {
422+
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
423+
}
424+
}
425+
}
396426
}

0 commit comments

Comments
 (0)