Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	modman
  • Loading branch information
Santiagoebizmarts committed Feb 8, 2017
2 parents c63586d + a8ea9ad commit c057979
Show file tree
Hide file tree
Showing 49 changed files with 1,134 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ protected function _prepareColumns()
'sortable' => false
)
);
$this->addColumn('action_donwload', array(
$this->addColumn(
'action_donwload', array(
'header' => $this->helper('mailchimp')->__('Download Response'),
'width' => 15,
'sortable' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function render(Varien_Object $row)
$displayText = $this->__('Something went wrong when retrieving original item.');
break;
}

return $displayText;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
* File : Add.php
* Module : Ebizmarts_MailChimp
*/
class Ebizmarts_Mailchimp_Block_Adminhtml_Mergevars_Add extends Mage_Adminhtml_Block_Widget_Form_Container {
class Ebizmarts_Mailchimp_Block_Adminhtml_Mergevars_Add extends Mage_Adminhtml_Block_Widget_Form_Container
{
protected $_mode = 'add';
public function __construct() {
public function __construct()
{
$this->_controller = 'adminhtml_mergevars';
$this->_blockGroup = 'mailchimp';

Expand All @@ -26,7 +28,8 @@ public function getHeaderText()
{
return Mage::helper('mailchimp')->__('New Field Type');
}
public function _prepareForm() {
public function _prepareForm()
{
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,41 @@
*/
class Ebizmarts_Mailchimp_Block_Adminhtml_Mergevars_Add_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm() {
protected function _prepareForm()
{
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/saveadd'), 'method' => 'post'));
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('mailchimp')->__('Mergevars Data')));


$fieldset->addField('mergevar_label', 'text', array(
$fieldset->addField(
'mergevar_label', 'text', array(
'name' => 'mergevar[label]',
'label' => Mage::helper('mailchimp')->__('MergeVar Name'),
'id' => 'mergevar_label',
'title' => Mage::helper('mailchimp')->__('MergeVar Name'),
'required' => true
));
$fieldset->addField('mergevar_fieldtype','select',array(
)
);
$fieldset->addField(
'mergevar_fieldtype', 'select', array(
'name' => 'mergevar[fieldtype]',
'label' => Mage::helper('mailchimp')->__('Field Type'),
'id' => 'mergevar_fieldtype',
'values' => Mage::getSingleton('mailchimp/system_config_source_fieldtype')->getFieldTypes(),
'required' => true
));
)
);

$fieldset->addField('mergevar_value', 'text', array(
$fieldset->addField(
'mergevar_value', 'text', array(
'name' => 'mergevar[value]',
'label' => Mage::helper('mailchimp')->__('Value for case entry'),
'id' => 'mergevar_value',
'title' => Mage::helper('mailchimp')->__('Value for case entry'),
'note' => 'This value should be added in the case of Data.php file',
'required' => true
));
)
);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ class Ebizmarts_MailChimp_Block_Adminhtml_Sales_Order_Grid_Renderer_Mailchimp ex
public function render(Varien_Object $row)
{
$order = Mage::getModel('sales/order')->load($row->getData('entity_id'));
if ($order->getMailchimpAbandonedcartFlag() || $order->getMailchimpCampaignId()) {
if ($order->getMailchimpAbandonedcartFlag() || $order->getMailchimpCampaignId() || $order->getMailchimpLandingPage()) {
$result = '<img src="' . $this->getSkinUrl("ebizmarts/mailchimp/images/logo-freddie-monocolor-200.png") . '" width="40" title="hep hep thanks MailChimp" />';
} else {
$result = '';
}

return $result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function isReferred()
{
$ret = true;
}

return $ret;
}
public function getCampaign()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function __construct()
$this->_customerAttributes[$option['attribute_id']] = $option['frontend_label'];
}
}

$customFieldTypes = unserialize(
Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_CUSTOM_MAP_FIELDS)
);
Expand All @@ -53,6 +54,7 @@ public function __construct()
$this->_customerAttributes[$value] = $label;
}
}

ksort($this->_customerAttributes);
}

Expand All @@ -61,6 +63,7 @@ protected function _renderCellTemplate($columnName)
if (empty($this->_columns[$columnName])) {
throw new Exception('Wrong column name specified.');
}

$column = $this->_columns[$columnName];
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';

Expand All @@ -69,18 +72,22 @@ protected function _renderCellTemplate($columnName)
foreach ($this->_customerAttributes as $att => $name) {
$rendered .= '<option value="' . $att . '">' . $name . '</option>';
}

$rendered .= '</select>';
} else {
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' . ($column['size'] ? 'size="' . $column['size'] . '"' : '') . '/>';
}

return $rendered;
}

protected function _getMailChimpValue(){
protected function _getMailChimpValue()
{
return Mage::getSingleton('core/session')->getMailchimpValue();
}

protected function _getMailChimpLabel(){
protected function _getMailChimpLabel()
{
return Mage::getSingleton('core/session')->getMailchimpLabel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected function _prepareLayout()
if (!$this->getTemplate()) {
$this->setTemplate('ebizmarts/mailchimp/system/config/oauth_wizard.phtml');
}

return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ protected function _handleCookie()
if (isset($cookieValues[1])) {
$fName = $cookieValues[1];
}

if (isset($cookieValues[2])) {
$lName = $cookieValues[2];
}

if ($subscribeCookie == 'true') {
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
if (!$subscriber->getId()) {
Expand All @@ -65,10 +67,12 @@ protected function _handleCookie()
$subscriberFname = filter_var($fName, FILTER_SANITIZE_STRING);
$subscriber->setSubscriberFirstname($subscriberFname);
}

if ($lName) {
$subscriberLname = filter_var($lName, FILTER_SANITIZE_STRING);
$subscriber->setSubscriberLastname($subscriberLname);
}

$subscriber->setStoreId($storeId)
->subscribe($email);
return 'location.reload';
Expand Down
42 changes: 36 additions & 6 deletions app/code/community/Ebizmarts/MailChimp/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected function _getConfigScopeId($storeId = null, $websiteId = null)
$websiteId = Mage::getModel('core/website')->load($code)->getId();
$storeId = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId();
}

$scopeArray['websiteId'] = $websiteId;
$scopeArray['storeId'] = $storeId;
return $scopeArray;
Expand All @@ -55,6 +56,7 @@ public function getConfigValue($path, $storeId = null, $returnParentValueIfNull
} else {
$scopeArray['storeId'] = $storeId;
}

if (!$returnParentValueIfNull) {
if (isset($scopeArray['websiteId']) && $scopeArray['websiteId']) {
//Website scope
Expand All @@ -73,6 +75,7 @@ public function getConfigValue($path, $storeId = null, $returnParentValueIfNull
}
}
}

return $configValue;
}

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

/**
Expand Down Expand Up @@ -133,12 +137,15 @@ public function resetMCEcommerceData($deleteDataInMailchimp=false)
} catch(Mailchimp_Error $e) {
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
}

//clear store config values
Mage::getConfig()->deleteConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCSTOREID);
}

if ($ecommerceEnabled && $apikey && $listId) {
$this->createStore($listId);
}

//reset mailchimp minimum date to sync flag
Mage::getConfig()->saveConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCMINSYNCDATEFLAG, Varien_Date::now());
Mage::getConfig()->saveConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCSTORE_RESETED, 1);
Expand Down Expand Up @@ -185,7 +192,7 @@ public function logRequest($message, $batchId=null)
} else {
$logDir = Mage::getBaseDir('var') . DS . 'log';
$fileName = $logDir.DS.$batchId.'.Request.log';
file_put_contents($fileName,$message);
file_put_contents($fileName, $message);
}
}
}
Expand Down Expand Up @@ -216,8 +223,11 @@ public function resetErrors()
foreach ($collection as $product) {
$product->setData("mailchimp_sync_delta", null);
$product->setData("mailchimp_sync_error", '');
$product->setMailchimpUpdateObserverRan(true);
$product->save();
$resource = $product->getResource();
$resource->saveAttribute($product, 'mailchimp_sync_delta');
$resource->saveAttribute($product, 'mailchimp_sync_error');
// $product->setMailchimpUpdateObserverRan(true);
// $product->save();
}

// reset subscribers with errors
Expand All @@ -240,8 +250,11 @@ public function resetErrors()
foreach ($collection as $customer) {
$customer->setData("mailchimp_sync_delta", '0000-00-00 00:00:00');
$customer->setData("mailchimp_sync_error", '');
$customer->setMailchimpUpdateObserverRan(true);
$customer->save();
$resource = $customer->getResource();
$resource->saveAttribute($customer, 'mailchimp_sync_delta');
$resource->saveAttribute($customer, 'mailchimp_sync_error');
// $customer->setMailchimpUpdateObserverRan(true);
// $customer->save();
}

// reset orders with errors
Expand Down Expand Up @@ -301,6 +314,7 @@ public function deleteStore()
} catch (Mailchimp_Error $e) {
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
}

//clear store config values
Mage::getConfig()->deleteConfig(Ebizmarts_MailChimp_Model_Config::GENERAL_MCSTOREID);
}
Expand All @@ -320,6 +334,7 @@ public function createMergeFields()
} catch (Mailchimp_Error $e) {
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
}

if (count($mailchimpFields) > 0) {
foreach ($maps as $map) {
$customAtt = $map['magento'];
Expand All @@ -331,6 +346,7 @@ public function createMergeFields()
$alreadyExists = true;
}
}

if (!$alreadyExists) {
foreach ($customFieldTypes as $customFieldType) {
if ($customFieldType['value'] == $chimpTag) {
Expand All @@ -339,9 +355,11 @@ public function createMergeFields()
} catch (Mailchimp_Error $e) {
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
}

$created = true;
}
}

if (!$created) {
$attrSetId = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter(1)
Expand All @@ -353,6 +371,7 @@ public function createMergeFields()
$label = $option['frontend_label'];
}
}

try {
if ($label) {
//Shipping and Billing Address
Expand Down Expand Up @@ -391,6 +410,17 @@ public function getApi()
if ($apiKey != null && $apiKey != "") {
$api = new Ebizmarts_Mailchimp($apiKey, null, 'Mailchimp4Magento' . (string)Mage::getConfig()->getNode('modules/Ebizmarts_MailChimp/version'));
}

return $api;
}
public function changeName($name)
{
if (Mage::helper('mailchimp')->getConfigValue(Ebizmarts_MailChimp_Model_Config::GENERAL_ACTIVE)) {
try {
Mage::getModel('mailchimp/api_stores')->modifyName($name);
} catch (Mailchimp_Error $e) {
Mage::helper('mailchimp')->logError($e->getFriendlyMessage());
}
}
}
}
Loading

0 comments on commit c057979

Please sign in to comment.