Version Notes
First Stable Extension Release
Download this release
Release Info
| Developer | mailingwork GmbH |
| Extension | Mailingwork_Sync |
| Version | 1.0.2 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.1 to 1.0.2
- app/code/community/Mailingwork/Sync/Block/Adminhtml/System/Config/Fieldset/Hint.php +59 -0
- app/code/community/Mailingwork/Sync/Block/Adminhtml/System/Config/Form/Field/Customermap.php +166 -0
- app/code/community/Mailingwork/Sync/Block/Adminhtml/System/Config/Initialimport.php +127 -0
- app/code/community/Mailingwork/Sync/Helper/Data.php +100 -0
- app/code/community/Mailingwork/Sync/Model/Abandonedcartcheckoutstatus.php +88 -0
- app/code/community/Mailingwork/Sync/Model/Api.php +82 -0
- app/code/community/Mailingwork/Sync/Model/Api/V2.php +24 -0
- app/code/community/Mailingwork/Sync/Model/InitialImport.php +57 -0
- app/code/community/Mailingwork/Sync/Model/Logger.php +112 -0
- app/code/community/Mailingwork/Sync/Model/MwApi.php +500 -0
- app/code/community/Mailingwork/Sync/Model/Observer.php +114 -0
- app/code/community/Mailingwork/Sync/Model/Resource/Abandonedcartcheckoutstatus.php +58 -0
- app/code/community/Mailingwork/Sync/Model/Resource/Subscriber.php +60 -0
- app/code/community/Mailingwork/Sync/Model/Subscriber.php +240 -0
- app/code/community/Mailingwork/Sync/Model/System/Config/Source/Lists.php +80 -0
- app/code/community/Mailingwork/Sync/Model/System/Config/Source/Optinsetups.php +80 -0
- app/code/community/Mailingwork/Sync/Model/System/Config/Source/Optoutsetups.php +80 -0
- app/code/community/Mailingwork/Sync/controllers/Adminhtml/InitialimportController.php +52 -0
- app/code/community/Mailingwork/Sync/controllers/OnepageController.php +85 -0
- app/code/community/Mailingwork/Sync/etc/api.xml +62 -0
- app/code/community/Mailingwork/Sync/etc/config.xml +148 -0
- app/code/community/Mailingwork/Sync/etc/system.xml +144 -0
- app/code/community/Mailingwork/Sync/etc/wsdl.xml +98 -0
- app/code/community/Mailingwork/Sync/sql/mailingwork_sync_setup/install-1.0.1.php +37 -0
- package.xml +4 -4
app/code/community/Mailingwork/Sync/Block/Adminhtml/System/Config/Fieldset/Hint.php
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Block_Adminhtml_System_Config_Fieldset_Hint extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
| 22 |
+
{
|
| 23 |
+
public function __construct()
|
| 24 |
+
{
|
| 25 |
+
$this->setTemplate('mailingwork/hint.phtml');
|
| 26 |
+
parent::__construct();
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Render fieldset html
|
| 31 |
+
*
|
| 32 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
| 33 |
+
* @return string
|
| 34 |
+
*/
|
| 35 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 36 |
+
|
| 37 |
+
{
|
| 38 |
+
return $this->toHtml();
|
| 39 |
+
}
|
| 40 |
+
/**
|
| 41 |
+
* @return bool
|
| 42 |
+
*/
|
| 43 |
+
public function mailingworkEnabled()
|
| 44 |
+
{
|
| 45 |
+
return false;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function getVersion()
|
| 49 |
+
{
|
| 50 |
+
$modules = $modules = Mage::getConfig()->getNode()->modules;
|
| 51 |
+
|
| 52 |
+
$v = "";
|
| 53 |
+
if(isset($modules->Mailingwork_Sync))
|
| 54 |
+
{
|
| 55 |
+
$v =$modules->Mailingwork_Sync->version;
|
| 56 |
+
}
|
| 57 |
+
return $v;
|
| 58 |
+
}
|
| 59 |
+
}
|
app/code/community/Mailingwork/Sync/Block/Adminhtml/System/Config/Form/Field/Customermap.php
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Block_Adminhtml_System_Config_Form_Field_Customermap
|
| 22 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
| 23 |
+
{
|
| 24 |
+
|
| 25 |
+
protected $_message = array();
|
| 26 |
+
protected $mwFields = null;
|
| 27 |
+
|
| 28 |
+
protected $magentoCustomerFields = array('subscriberdata' => array('email', 'store_id', 'is_customer'),
|
| 29 |
+
'customerdata' => array('prefix', 'firstname', 'lastname', 'last_login_at', 'group'),
|
| 30 |
+
'billingaddress' => array('company', 'prefix', 'firstname', 'lastname',
|
| 31 |
+
'street', 'postcode', 'city', 'country', 'telephone'),
|
| 32 |
+
'shippingaddress' => array('company', 'prefix', 'firstname', 'lastname',
|
| 33 |
+
'street', 'postcode', 'city', 'country', 'telephone'),
|
| 34 |
+
'orderdata' => array('count_orders', 'last_order_at', 'last_order_amount',
|
| 35 |
+
'all_order_amount', 'average_order_amount', 'last_abandoned_cart')
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
public function __construct()
|
| 39 |
+
{
|
| 40 |
+
$this->setTemplate('mailingwork/customermap.phtml');
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
$this->addColumn('magento', array(
|
| 44 |
+
'label' => Mage::helper('adminhtml')->__('Magento'),
|
| 45 |
+
'style' => 'width:200px;',
|
| 46 |
+
));
|
| 47 |
+
$this->addColumn('mailingwork', array(
|
| 48 |
+
'label' => Mage::helper('adminhtml')->__('Mailingwork'),
|
| 49 |
+
'style' => 'width:200px;',
|
| 50 |
+
));
|
| 51 |
+
$this->_addAfter = false;
|
| 52 |
+
|
| 53 |
+
$helper = new Mailingwork_Sync_Helper_Data();
|
| 54 |
+
|
| 55 |
+
if ($helper->isMailingworkEnabled()) {
|
| 56 |
+
if ($helper->getUser()) {
|
| 57 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 58 |
+
$result = $mwApi->getFields();
|
| 59 |
+
if (!empty($result['error'])) {
|
| 60 |
+
$this->_message = array('type' => 'error',
|
| 61 |
+
'message' => __($result['message'])
|
| 62 |
+
);
|
| 63 |
+
} else {
|
| 64 |
+
$this->mwFields = $result['result'];
|
| 65 |
+
}
|
| 66 |
+
} else {
|
| 67 |
+
$this->_message = array('type' => 'error',
|
| 68 |
+
'message' => __('Kein User und Passwort hinterlegt!')
|
| 69 |
+
);
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
parent::__construct();
|
| 74 |
+
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
public function getFieldsForMapping() {
|
| 78 |
+
return $this->magentoCustomerFields;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Render array cell for prototypeJS template
|
| 83 |
+
*
|
| 84 |
+
* @param string $columnName
|
| 85 |
+
* @return string
|
| 86 |
+
* @throws \Exception
|
| 87 |
+
*/
|
| 88 |
+
public function renderMwCellTemplate($columnName, $inputName, $inputGroup)
|
| 89 |
+
{
|
| 90 |
+
if (empty($this->_columns[$columnName])) {
|
| 91 |
+
throw new \Exception('Wrong column name specified.');
|
| 92 |
+
}
|
| 93 |
+
$column = $this->_columns[$columnName];
|
| 94 |
+
$inputNameTmp = $this->_getCellInputElementNameByGroup($inputName, $inputGroup);
|
| 95 |
+
|
| 96 |
+
if ($column['renderer']) {
|
| 97 |
+
return $column['renderer']->setInputName($inputNameTmp)->setColumnName($columnName)->setColumn($column)->toHtml();
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
$field = '';
|
| 101 |
+
$field .= '<select name="' . $inputNameTmp .
|
| 102 |
+
($column['size'] ? 'size="' . $column['size'] . '"' : '') .
|
| 103 |
+
' class="' . (isset($column['class'])
|
| 104 |
+
? $column['class']
|
| 105 |
+
: 'input-text') .
|
| 106 |
+
'"' . (isset($column['style']) ? ' style="' . $column['style'] . '"' : '') .
|
| 107 |
+
'>';
|
| 108 |
+
$field .= '<option value=""> </option>';
|
| 109 |
+
|
| 110 |
+
if (!empty($this->mwFields)
|
| 111 |
+
&& is_array($this->mwFields)
|
| 112 |
+
) {
|
| 113 |
+
foreach($this->mwFields as $mwField) {
|
| 114 |
+
$field .= '<option value="'.$mwField['id'] .'"';
|
| 115 |
+
if ($mwField['id'] == $this->getValueByInputName($inputName, $inputGroup)) {
|
| 116 |
+
$field .= ' selected="selected"';
|
| 117 |
+
}
|
| 118 |
+
$field .= '>'.$mwField['name'].'</option>';
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
}
|
| 122 |
+
$field .= '</select>';
|
| 123 |
+
|
| 124 |
+
return $field;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* Get id for cell element
|
| 129 |
+
*
|
| 130 |
+
* @param string $columnName
|
| 131 |
+
* @return string
|
| 132 |
+
*/
|
| 133 |
+
protected function _getCellInputElementNameByGroup($inputName, $inputGroup)
|
| 134 |
+
{
|
| 135 |
+
return $this->getElement()->getName() . '[' . $inputGroup . '][' . $inputName . ']';
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
protected function getValueByInputName($inputName, $inputGroup) {
|
| 139 |
+
$element = $this->getElement();
|
| 140 |
+
$values = $element->getValue();
|
| 141 |
+
if (!empty($values[$inputGroup][$inputName])) {
|
| 142 |
+
return $values[$inputGroup][$inputName];
|
| 143 |
+
} else {
|
| 144 |
+
return false;
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* get Messagetype
|
| 150 |
+
* @return string
|
| 151 |
+
*/
|
| 152 |
+
public function getMessageType()
|
| 153 |
+
{
|
| 154 |
+
return (!empty($this->_message['type']) ? $this->_message['type'] : false);
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* get Message
|
| 159 |
+
* @return string
|
| 160 |
+
*/
|
| 161 |
+
public function getMessage()
|
| 162 |
+
{
|
| 163 |
+
return (!empty($this->_message['message']) ? $this->_message['message'] : false);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
}
|
app/code/community/Mailingwork/Sync/Block/Adminhtml/System/Config/Initialimport.php
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Synchronize button renderer
|
| 23 |
+
*/
|
| 24 |
+
class Mailingwork_Sync_Block_Adminhtml_System_Config_Initialimport
|
| 25 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 26 |
+
{
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @var string
|
| 30 |
+
*/
|
| 31 |
+
protected $_importList = 'newsletter_mailingwork_syncimport_initialimport_list';
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Initialimport Button Label
|
| 35 |
+
*
|
| 36 |
+
* @var string
|
| 37 |
+
*/
|
| 38 |
+
protected $_initButtonLabel = "Initiale Datenübertragung (Kundendaten) zu Mailingwork starten";
|
| 39 |
+
|
| 40 |
+
/*
|
| 41 |
+
* Set template
|
| 42 |
+
*/
|
| 43 |
+
protected function _construct()
|
| 44 |
+
{
|
| 45 |
+
parent::_construct();
|
| 46 |
+
$this->setTemplate('mailingwork/initialimport.phtml');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
public function getStoreId() {
|
| 51 |
+
$helper = new Mailingwork_Sync_Helper_Data();
|
| 52 |
+
return $helper->_getConfigScopeStoreId();
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Get Importlist Field Name
|
| 57 |
+
*
|
| 58 |
+
* @return string
|
| 59 |
+
*/
|
| 60 |
+
public function getImportListField() {
|
| 61 |
+
return $this->_importList;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Remove scope label
|
| 66 |
+
*
|
| 67 |
+
* @param $element
|
| 68 |
+
* @return string
|
| 69 |
+
*/
|
| 70 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
| 71 |
+
{
|
| 72 |
+
//$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
| 73 |
+
return parent::render($element);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Set Validate VAT Button Label
|
| 78 |
+
*
|
| 79 |
+
* @param string $initButtonLabel
|
| 80 |
+
* @return Mailingwork\Sync\Block\Adminhtml\System\Config\InitialImport
|
| 81 |
+
*/
|
| 82 |
+
public function setInitButtonLabel($initButtonLabel)
|
| 83 |
+
{
|
| 84 |
+
$this->_initButtonLabel = $initButtonLabel;
|
| 85 |
+
return $this;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Get the button and scripts contents
|
| 90 |
+
*
|
| 91 |
+
* @param $element
|
| 92 |
+
* @return string
|
| 93 |
+
*/
|
| 94 |
+
protected function _getElementHtml($element)
|
| 95 |
+
{
|
| 96 |
+
$originalData = $element->getOriginalData();
|
| 97 |
+
$buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->_initButtonLabel;
|
| 98 |
+
$this->addData(
|
| 99 |
+
[
|
| 100 |
+
'button_label' => __($buttonLabel),
|
| 101 |
+
'html_id' => $element->getHtmlId(),
|
| 102 |
+
'ajax_url' => Mage::helper('adminhtml')->getUrl('adminhtml/initialimport/index'),
|
| 103 |
+
]
|
| 104 |
+
);
|
| 105 |
+
|
| 106 |
+
return $this->_toHtml();
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* Generate synchronize button html
|
| 111 |
+
*
|
| 112 |
+
* @return string
|
| 113 |
+
*/
|
| 114 |
+
public function getButtonHtml()
|
| 115 |
+
{
|
| 116 |
+
//$originalData = $element->getOriginalData();
|
| 117 |
+
$buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->_initButtonLabel;
|
| 118 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
| 119 |
+
->setData(array(
|
| 120 |
+
'id' => 'mailingworkinitialimport',
|
| 121 |
+
'label' => $this->helper('adminhtml')->__($buttonLabel),
|
| 122 |
+
'onclick' => 'javascript:startInitialImport(); return false;'
|
| 123 |
+
));
|
| 124 |
+
|
| 125 |
+
return $button->toHtml();
|
| 126 |
+
}
|
| 127 |
+
}
|
app/code/community/Mailingwork/Sync/Helper/Data.php
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Helper_Data extends Mage_Core_Helper_Abstract
|
| 22 |
+
{
|
| 23 |
+
const PATH_ACTIVE = 'newsletter/mailingwork_sync/active';
|
| 24 |
+
const PATH_USER = 'newsletter/mailingwork_sync/username';
|
| 25 |
+
const PATH_PASSWORD = 'newsletter/mailingwork_sync/password';
|
| 26 |
+
const PATH_MAPPING = 'newsletter/mailingwork_sync/mapping';
|
| 27 |
+
const PATH_LISTID = 'newsletter/mailingwork_sync/list_id';
|
| 28 |
+
const PATH_OPTINSETUPNEWCUSTOMER = 'newsletter/mailingwork_sync/optin_setup_new';
|
| 29 |
+
const PATH_OPTINSETUPCUSTOMER = 'newsletter/mailingwork_sync/optin_setup';
|
| 30 |
+
const PATH_OPTOUTSETUPWITHOUTCUSTOMER = 'newsletter/mailingwork_sync/optout_setup_without_customer';
|
| 31 |
+
const PATH_OPTOUTSETUPCUSTOMER = 'newsletter/mailingwork_sync/optout_setup';
|
| 32 |
+
|
| 33 |
+
public function isMailingworkEnabled()
|
| 34 |
+
{
|
| 35 |
+
return Mage::getStoreConfig(self::PATH_ACTIVE, $this->_getConfigScopeStoreId());
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
public function getUser()
|
| 39 |
+
{
|
| 40 |
+
return Mage::getStoreConfig(self::PATH_USER, $this->_getConfigScopeStoreId());
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
public function getPassword()
|
| 44 |
+
{
|
| 45 |
+
return Mage::helper('core')->decrypt(Mage::getStoreConfig(self::PATH_PASSWORD, $this->_getConfigScopeStoreId()));
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function getListId()
|
| 49 |
+
{
|
| 50 |
+
return Mage::getStoreConfig(self::PATH_LISTID, $this->_getConfigScopeStoreId());
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
public function getOptinSetupNewCustomer()
|
| 54 |
+
{
|
| 55 |
+
return Mage::getStoreConfig(self::PATH_OPTINSETUPNEWCUSTOMER, $this->_getConfigScopeStoreId());
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
public function getOptinSetupCustomer()
|
| 59 |
+
{
|
| 60 |
+
return Mage::getStoreConfig(self::PATH_OPTINSETUPCUSTOMER, $this->_getConfigScopeStoreId());
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
public function getOptoutSetupWithoutCustomer()
|
| 64 |
+
{
|
| 65 |
+
return Mage::getStoreConfig(self::PATH_OPTOUTSETUPWITHOUTCUSTOMER, $this->_getConfigScopeStoreId());
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
public function getOptoutSetupCustomer()
|
| 69 |
+
{
|
| 70 |
+
return Mage::getStoreConfig(self::PATH_OPTOUTSETUPCUSTOMER, $this->_getConfigScopeStoreId());
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
public function getMapping()
|
| 74 |
+
{
|
| 75 |
+
return Mage::getStoreConfig(self::PATH_MAPPING, $this->_getConfigScopeStoreId());
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public function _getConfigScopeStoreId()
|
| 79 |
+
{
|
| 80 |
+
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
| 81 |
+
$storeCode = (string)Mage::getSingleton('adminhtml/config_data')->getStore();
|
| 82 |
+
$websiteCode = (string)Mage::getSingleton('adminhtml/config_data')->getWebsite();
|
| 83 |
+
if ('' !== $storeCode) { // store level
|
| 84 |
+
try {
|
| 85 |
+
$storeId = Mage::getModel('core/store')->load( $storeCode )->getId();
|
| 86 |
+
} catch (Exception $ex) { }
|
| 87 |
+
} elseif ('' !== $websiteCode) { // website level
|
| 88 |
+
try {
|
| 89 |
+
$storeId = Mage::getModel('core/website')->load( $websiteCode )->getDefaultStore()->getId();
|
| 90 |
+
} catch (Exception $ex) { }
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
if (empty($storeId) && !empty(Mage::app()->getStore()->getId())) {
|
| 94 |
+
$storeId = Mage::app()->getStore()->getId();
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
return $storeId;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
}
|
app/code/community/Mailingwork/Sync/Model/Abandonedcartcheckoutstatus.php
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_Abandonedcartcheckoutstatus extends Mage_Core_Model_Abstract
|
| 22 |
+
{
|
| 23 |
+
protected $arrCheckoutStepMapping= array('index' => 'Index',
|
| 24 |
+
'billing' => 'Shipping',
|
| 25 |
+
'shipping' => 'Shipping Method',
|
| 26 |
+
'shipping_method' => 'Payment',
|
| 27 |
+
'payment' => 'Review',
|
| 28 |
+
'success' => 'Success',
|
| 29 |
+
'failure' => 'Failure'
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
protected $arrCheckoutSteps = array('Index' => 0,
|
| 33 |
+
'Shipping' => 1,
|
| 34 |
+
'Shipping Method' => 2,
|
| 35 |
+
'Payment' => 3,
|
| 36 |
+
'Review' => 4,
|
| 37 |
+
'Success' => 5,
|
| 38 |
+
'Failure' => 99
|
| 39 |
+
);
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Initialize resource model
|
| 43 |
+
*/
|
| 44 |
+
protected function _construct()
|
| 45 |
+
{
|
| 46 |
+
$this->_init('mailingwork_sync/abandonedcartcheckoutstatus');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Load by quote id
|
| 51 |
+
*
|
| 52 |
+
* @param int $quote_id
|
| 53 |
+
*/
|
| 54 |
+
public function loadByQuoteId($quote_id)
|
| 55 |
+
{
|
| 56 |
+
$this->addData($this->getResource()->loadByQuoteId($quote_id));
|
| 57 |
+
return $this;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
public function updateStatus($quote_id, $status) {
|
| 61 |
+
|
| 62 |
+
$bSave = true;
|
| 63 |
+
$this->loadByQuoteId($quote_id);
|
| 64 |
+
|
| 65 |
+
if (empty($this->getQuoteId())) {
|
| 66 |
+
$this->setData('quote_id', $quote_id);
|
| 67 |
+
} else {
|
| 68 |
+
if (!empty($this->arrCheckoutStepMapping[$status])
|
| 69 |
+
&& $this->arrCheckoutSteps[$this->arrCheckoutStepMapping[$status]] < $this->arrCheckoutSteps[$this->getData('status')]
|
| 70 |
+
) {
|
| 71 |
+
$bSave = false;
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
if (!empty($this->arrCheckoutStepMapping[$status])) {
|
| 76 |
+
$this->setData('status', $this->arrCheckoutStepMapping[$status]);
|
| 77 |
+
} else {
|
| 78 |
+
$this->setData('status', $status);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
if ($bSave) {
|
| 82 |
+
$this->save();
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
return $this;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
}
|
app/code/community/Mailingwork/Sync/Model/Api.php
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_Api extends Mage_Api_Model_Resource_Abstract
|
| 22 |
+
{
|
| 23 |
+
public function getAbandonedCarts($secondsUntilLastUpdate)
|
| 24 |
+
{
|
| 25 |
+
|
| 26 |
+
$aReturn = array();
|
| 27 |
+
$quotes = Mage::getModel('sales/quote')->getCollection();
|
| 28 |
+
/* @var $quotes Mage_Sales_Model_Mysql4_Quote_Collection */
|
| 29 |
+
|
| 30 |
+
//aktualisiert immer die letzten 24h
|
| 31 |
+
$quotes->addFieldToFilter('updated_at', array('to'=>date("Y-m-d H:i:s", time()-$secondsUntilLastUpdate)));
|
| 32 |
+
$quotes->addFieldToFilter('updated_at', array('from'=>date("Y-m-d H:i:s", time()-$secondsUntilLastUpdate-(24*3600))));
|
| 33 |
+
$quotes->addFieldToFilter('is_active', 1);
|
| 34 |
+
|
| 35 |
+
foreach($quotes as $quote) {
|
| 36 |
+
$order = null;
|
| 37 |
+
//zur Sicherheit prüfen ob es zum quote eine order gibt.
|
| 38 |
+
$order = Mage::getModel('sales/order')->loadByAttribute('quote_id');
|
| 39 |
+
|
| 40 |
+
if ($order->isObjectNew()) {
|
| 41 |
+
$customer = $quote->getCustomer();
|
| 42 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
|
| 43 |
+
|
| 44 |
+
if (!empty($subscriber)
|
| 45 |
+
&& $subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED
|
| 46 |
+
) {
|
| 47 |
+
$abandonedCartCheckoutStatus = Mage::getModel('mailingwork_sync/abandonedcartcheckoutstatus')->loadByQuoteId($quote->getId());
|
| 48 |
+
$checkoutStatus = null;
|
| 49 |
+
if (!empty($abandonedCartCheckoutStatus->getQuoteId())) {
|
| 50 |
+
$checkoutStatus = $abandonedCartCheckoutStatus->getData('status');
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
$aReturn[] = array('email' => $subscriber->getEmail(),
|
| 54 |
+
'quote_id' => $quote->getId(),
|
| 55 |
+
'updated_at' => $quote->getUpdatedAt(),
|
| 56 |
+
'store_id' => $quote->getStoreId(),
|
| 57 |
+
'checkout_status' => $checkoutStatus
|
| 58 |
+
);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
return $aReturn;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
public function unsubscribeSubscriber($email) {
|
| 67 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
| 68 |
+
|
| 69 |
+
if ($subscriber->getId()) {
|
| 70 |
+
$subscriber->unsubscribeMagentoOnly();
|
| 71 |
+
return true;
|
| 72 |
+
} else {
|
| 73 |
+
return false;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public function getMailingworkLog() {
|
| 79 |
+
$logger = new Mailingwork_Sync_Model_Logger();
|
| 80 |
+
return $logger->getLast50Lines();
|
| 81 |
+
}
|
| 82 |
+
}
|
app/code/community/Mailingwork/Sync/Model/Api/V2.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_Api_V2 extends Mailingwork_Sync_Model_Api
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
}
|
app/code/community/Mailingwork/Sync/Model/InitialImport.php
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_InitialImport
|
| 22 |
+
{
|
| 23 |
+
/**
|
| 24 |
+
* Mailingwork Api
|
| 25 |
+
*
|
| 26 |
+
* @var \Mailingwork\Sync\Model\MwApi
|
| 27 |
+
*/
|
| 28 |
+
protected $mwApi;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Helper
|
| 32 |
+
* @var \Mailingwork\Sync\Helper\Data
|
| 33 |
+
*/
|
| 34 |
+
protected $helper;
|
| 35 |
+
|
| 36 |
+
public function __construct() {
|
| 37 |
+
$this->mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 38 |
+
$this->helper = new Mailingwork_Sync_Helper_Data();
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
public function mwInitialImport($listId) {
|
| 42 |
+
$storeId = $this->helper->_getConfigScopeStoreId();
|
| 43 |
+
$resourceSubscriber = new Mailingwork_Sync_Model_Resource_Subscriber();
|
| 44 |
+
$arrSubscriber = $resourceSubscriber->loadByStoreId($storeId);
|
| 45 |
+
|
| 46 |
+
if (!empty($arrSubscriber)) {
|
| 47 |
+
$result = $this->mwApi->initialImport($arrSubscriber, $listId);
|
| 48 |
+
} else {
|
| 49 |
+
$result = array('error' => true,
|
| 50 |
+
'message' => 'no subscriber for import found'
|
| 51 |
+
);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
return $result;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
}
|
app/code/community/Mailingwork/Sync/Model/Logger.php
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_Logger
|
| 22 |
+
{
|
| 23 |
+
protected static $logFile = 'mailingwork_sync.log';
|
| 24 |
+
|
| 25 |
+
public static function log_debug($message) {
|
| 26 |
+
self::log($message, Zend_Log::DEBUG, self::$logFile);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public static function log_info($message) {
|
| 30 |
+
self::log($message, Zend_Log::INFO, self::$logFile);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
public static function log_error($message) {
|
| 34 |
+
self::log($message, Zend_Log::ERR, self::$logFile);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* log facility (??)
|
| 39 |
+
*
|
| 40 |
+
* @param string $message
|
| 41 |
+
* @param integer $level
|
| 42 |
+
* @param string $file
|
| 43 |
+
* @param bool $forceLog
|
| 44 |
+
*/
|
| 45 |
+
public static function log($message, $level = null, $file = '', $forceLog = false)
|
| 46 |
+
{
|
| 47 |
+
static $loggers = array();
|
| 48 |
+
|
| 49 |
+
$level = is_null($level) ? Zend_Log::DEBUG : $level;
|
| 50 |
+
|
| 51 |
+
try {
|
| 52 |
+
if (!isset($loggers[$file])) {
|
| 53 |
+
$logDir = Mage::getBaseDir('var') . DS . 'log';
|
| 54 |
+
$logFile = $logDir . DS . $file;
|
| 55 |
+
|
| 56 |
+
if (!is_dir($logDir)) {
|
| 57 |
+
mkdir($logDir);
|
| 58 |
+
chmod($logDir, 0750);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
if (!file_exists($logFile)) {
|
| 62 |
+
file_put_contents($logFile, '');
|
| 63 |
+
chmod($logFile, 0640);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
$format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
|
| 67 |
+
$formatter = new Zend_Log_Formatter_Simple($format);
|
| 68 |
+
$writerModel = (string)Mage::getConfig()->getNode('global/log/core/writer_model');
|
| 69 |
+
if (!Mage::app() || !$writerModel) {
|
| 70 |
+
$writer = new Zend_Log_Writer_Stream($logFile);
|
| 71 |
+
}
|
| 72 |
+
else {
|
| 73 |
+
$writer = new $writerModel($logFile);
|
| 74 |
+
}
|
| 75 |
+
$writer->setFormatter($formatter);
|
| 76 |
+
$loggers[$file] = new Zend_Log($writer);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
if (is_array($message) || is_object($message)) {
|
| 80 |
+
$message = print_r($message, true);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
$loggers[$file]->log($message, $level);
|
| 84 |
+
}
|
| 85 |
+
catch (Exception $e) {
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
public function getLast50Lines() {
|
| 90 |
+
$logFile = Mage::getBaseDir('var') . DS . 'log' . DS . self::$logFile;
|
| 91 |
+
$lines = 50;
|
| 92 |
+
|
| 93 |
+
$f = @fopen($logFile, "r");
|
| 94 |
+
if ($f === false) return false;
|
| 95 |
+
fseek($f, -1, SEEK_END);
|
| 96 |
+
if (fread($f, 1) != "\n") $lines -= 1;
|
| 97 |
+
$output = '';
|
| 98 |
+
$chunk = '';
|
| 99 |
+
while (ftell($f) > 0 && $lines >= 0) {
|
| 100 |
+
$seek = min(ftell($f), 4096);
|
| 101 |
+
fseek($f, -$seek, SEEK_CUR);
|
| 102 |
+
$output = ($chunk = fread($f, $seek)) . $output;
|
| 103 |
+
fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
|
| 104 |
+
$lines -= substr_count($chunk, "\n");
|
| 105 |
+
}
|
| 106 |
+
while ($lines++ < 0) {
|
| 107 |
+
$output = substr($output, strpos($output, "\n") + 1);
|
| 108 |
+
}
|
| 109 |
+
fclose($f);
|
| 110 |
+
return trim($output);
|
| 111 |
+
}
|
| 112 |
+
}
|
app/code/community/Mailingwork/Sync/Model/MwApi.php
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_MwApi
|
| 22 |
+
{
|
| 23 |
+
protected $soapClient = null;
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Logger
|
| 27 |
+
* @var \Mailingwork\Sync\Model\Logger
|
| 28 |
+
*/
|
| 29 |
+
protected $logger;
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Helper
|
| 33 |
+
* @var \Mailingwork\Sync\Helper\Data
|
| 34 |
+
*/
|
| 35 |
+
protected $helper;
|
| 36 |
+
|
| 37 |
+
public function __construct() {
|
| 38 |
+
$this->logger = new Mailingwork_Sync_Model_Logger();
|
| 39 |
+
$this->helper = new Mailingwork_Sync_Helper_Data();
|
| 40 |
+
|
| 41 |
+
$webserviceUrl = Mage::getStoreConfig('mailingwork_sync/mailingwork_sync_configuration/wsdl_url');
|
| 42 |
+
$webserviceTyp = Mage::getStoreConfig('mailingwork_sync/mailingwork_sync_configuration/ws_type');
|
| 43 |
+
$webserviceParam = Mage::getStoreConfig('mailingwork_sync/mailingwork_sync_configuration/ws_param');
|
| 44 |
+
$webserviceLocation = Mage::getStoreConfig('mailingwork_sync/mailingwork_sync_configuration/ws_location');
|
| 45 |
+
|
| 46 |
+
$config = array('soap_version' => SOAP_1_1,'cache_wsdl'=>WSDL_CACHE_NONE);
|
| 47 |
+
if (!empty($webserviceLocation)) {
|
| 48 |
+
$config['location'] = $webserviceLocation;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
$this->soapClient = new \SoapClient($webserviceUrl.$webserviceTyp.'?'.$webserviceParam, $config);
|
| 52 |
+
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Retrieves customer log model
|
| 57 |
+
*
|
| 58 |
+
* @param integer $customerId
|
| 59 |
+
* @return \Magento\Customer\Model\Log
|
| 60 |
+
*/
|
| 61 |
+
protected function getCustomerLogByCustomerId($customerId)
|
| 62 |
+
{
|
| 63 |
+
return Mage::getModel('log/customer')->loadByCustomer($customerId);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* @param integer $customerId
|
| 68 |
+
* @return array
|
| 69 |
+
*/
|
| 70 |
+
protected function getOrdersByCustomerId($customerId) {
|
| 71 |
+
if ($this->isCustomerHasOrders($customerId)) {
|
| 72 |
+
return $this->getCustomerOrderCollection($customerId);
|
| 73 |
+
}
|
| 74 |
+
return [];
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* @param int $customerId
|
| 79 |
+
* @param null|float $grandTotal
|
| 80 |
+
*
|
| 81 |
+
* @return bool
|
| 82 |
+
*/
|
| 83 |
+
public function isCustomerHasOrders($customerId, $grandTotal = null)
|
| 84 |
+
{
|
| 85 |
+
$orderCollection = $this->getCustomerOrderCollection($customerId, $grandTotal);
|
| 86 |
+
return (bool)$orderCollection->getSize();
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* @param int $customerId
|
| 91 |
+
* @param null $grandTotal
|
| 92 |
+
*
|
| 93 |
+
* @return Mage_Sales_Model_Resource_Order_Collection
|
| 94 |
+
*/
|
| 95 |
+
public function getCustomerOrderCollection($customerId, $grandTotal = null)
|
| 96 |
+
{
|
| 97 |
+
$orderCollection = Mage::getResourceModel('sales/order_collection')
|
| 98 |
+
->addFieldToSelect('*')
|
| 99 |
+
->addFieldToFilter('customer_id', $customerId)
|
| 100 |
+
->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
|
| 101 |
+
->setOrder('created_at', 'desc')
|
| 102 |
+
;
|
| 103 |
+
return $orderCollection;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* @param string $email
|
| 108 |
+
* @throws \Exception
|
| 109 |
+
* @return integer
|
| 110 |
+
*/
|
| 111 |
+
protected function getRecipientIdsByEmail($email) {
|
| 112 |
+
$aAdvanced = array('listId' => $this->helper->getPassword());
|
| 113 |
+
|
| 114 |
+
$result = $this->soapClient->getRecipientIdsByEmail($this->helper->getUser(),
|
| 115 |
+
$this->helper->getPassword(),
|
| 116 |
+
$email,
|
| 117 |
+
$this->helper->getListId()
|
| 118 |
+
);
|
| 119 |
+
|
| 120 |
+
if (empty($result['error']) && !empty($result['result'])) {
|
| 121 |
+
return $result['result'];
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
if (!empty($result['error'])) {
|
| 125 |
+
$this->logger->log_error(__METHOD__ . 'StoreId: '.$this->helper->_getConfigScopeStoreId().' ' . $result['message'] . ' (email: ' . $email . ')');
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
if (empty($result['result'])) {
|
| 129 |
+
$this->logger->log_error(__METHOD__ . 'StoreId: '.$this->helper->_getConfigScopeStoreId(). ' empty result (email: ' . $email . ')');
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
return false;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* @param $subscriber
|
| 137 |
+
* @return array
|
| 138 |
+
*/
|
| 139 |
+
protected function getFieldArrayForMw($subscriber) {
|
| 140 |
+
$aFields = array();
|
| 141 |
+
$sMappingFields = $this->helper->getMapping();
|
| 142 |
+
if (!empty($sMappingFields)) {
|
| 143 |
+
$aMappingFields = unserialize($sMappingFields);
|
| 144 |
+
if (!empty($aMappingFields['subscriberdata']['email'])) {
|
| 145 |
+
if (is_array($subscriber)) {
|
| 146 |
+
$aFields[$aMappingFields['subscriberdata']['email']] = $subscriber['subscriber_email'];
|
| 147 |
+
} else {
|
| 148 |
+
$aFields[$aMappingFields['subscriberdata']['email']] = $subscriber->getEmail();
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
if (!empty($aMappingFields['subscriberdata']['store_id'])) {
|
| 152 |
+
if (is_array($subscriber)) {
|
| 153 |
+
$aFields[$aMappingFields['subscriberdata']['store_id']] = $subscriber['store_id'];
|
| 154 |
+
} else {
|
| 155 |
+
$aFields[$aMappingFields['subscriberdata']['store_id']] = $subscriber->getStoreId();
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
$customerId = null;
|
| 159 |
+
if (is_array($subscriber)) {
|
| 160 |
+
$customerId = $subscriber['customer_id'];
|
| 161 |
+
} else {
|
| 162 |
+
$customerId = $subscriber->getCustomerId();
|
| 163 |
+
}
|
| 164 |
+
if (!empty($aMappingFields['subscriberdata']['is_customer'])) {
|
| 165 |
+
$aFields[$aMappingFields['subscriberdata']['is_customer']] = 0;
|
| 166 |
+
if ($customerId) {
|
| 167 |
+
$aFields[$aMappingFields['subscriberdata']['is_customer']] = 1;
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
if ($customerId) {
|
| 171 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
| 172 |
+
if (!empty($customer)) {
|
| 173 |
+
$billingAddress = $customer->getPrimaryBillingAddress();
|
| 174 |
+
$shippingAddress = $customer->getPrimaryShippingAddress();
|
| 175 |
+
$customerLog = $this->getCustomerLogByCustomerId($customer);
|
| 176 |
+
$orders = $this->getOrdersByCustomerId($customer->getId());
|
| 177 |
+
if (!empty($orders)) {
|
| 178 |
+
$countOrders = 0;
|
| 179 |
+
$allOrderAmount = 0;
|
| 180 |
+
$averageOrderAmount = 0;
|
| 181 |
+
foreach($orders as $order) {
|
| 182 |
+
if (empty($lastOrderAt) || $lastOrderAt < $order->getCreatedAt()) {
|
| 183 |
+
$lastOrderAt = $order->getCreatedAt();
|
| 184 |
+
$lastOrderAmount = $order->getGrandTotal();
|
| 185 |
+
}
|
| 186 |
+
$countOrders++;
|
| 187 |
+
$allOrderAmount += $order->getGrandTotal();
|
| 188 |
+
}
|
| 189 |
+
if ($countOrders && $allOrderAmount) {
|
| 190 |
+
$averageOrderAmount = round($allOrderAmount / $countOrders, 2);
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
foreach($aMappingFields as $mappingFieldGroup => $mappingFields) {
|
| 196 |
+
foreach($mappingFields as $customerField => $mwFieldId) {
|
| 197 |
+
if (!empty($mwFieldId)) {
|
| 198 |
+
switch ($mappingFieldGroup) {
|
| 199 |
+
case 'customerdata':
|
| 200 |
+
if ($customerField == 'last_login_at') {
|
| 201 |
+
if (!empty($customerLog)) {
|
| 202 |
+
$aFields[$mwFieldId] = $customerLog->getLoginAt();
|
| 203 |
+
}
|
| 204 |
+
continue;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
if ($customerField == 'group') {
|
| 208 |
+
$aFields[$mwFieldId] = $customer->getGroupId();
|
| 209 |
+
continue;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
$tmpGetFunction = 'get' . ucfirst($customerField);
|
| 213 |
+
if ($customer->$tmpGetFunction()) {
|
| 214 |
+
$aFields[$mwFieldId] = $customer->$tmpGetFunction();
|
| 215 |
+
}
|
| 216 |
+
break;
|
| 217 |
+
|
| 218 |
+
case 'billingaddress':
|
| 219 |
+
if (!empty($billingAddress)) {
|
| 220 |
+
if ($customerField == 'country') {
|
| 221 |
+
$aFields[$mwFieldId] = $billingAddress->getCountryId();
|
| 222 |
+
} else {
|
| 223 |
+
$tmpGetFunction = 'get' . ucfirst($customerField);
|
| 224 |
+
if ($billingAddress->$tmpGetFunction()) {
|
| 225 |
+
if (is_array($billingAddress->$tmpGetFunction())) {
|
| 226 |
+
$value = '';
|
| 227 |
+
foreach($billingAddress->$tmpGetFunction() as $tmpValue) {
|
| 228 |
+
$value .= (!empty($value) ? ', ' : '') . $tmpValue;
|
| 229 |
+
}
|
| 230 |
+
$aFields[$mwFieldId] = $value;
|
| 231 |
+
} else {
|
| 232 |
+
$aFields[$mwFieldId] = $billingAddress->$tmpGetFunction();
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
break;
|
| 238 |
+
|
| 239 |
+
case 'shippingaddress':
|
| 240 |
+
if (!empty($shippingAddress)) {
|
| 241 |
+
if ($customerField == 'country') {
|
| 242 |
+
$aFields[$mwFieldId] = $shippingAddress->getCountryId();
|
| 243 |
+
} else {
|
| 244 |
+
$tmpGetFunction = 'get' . ucfirst($customerField);
|
| 245 |
+
if ($shippingAddress->$tmpGetFunction()) {
|
| 246 |
+
if (is_array($shippingAddress->$tmpGetFunction())) {
|
| 247 |
+
$value = '';
|
| 248 |
+
foreach($shippingAddress->$tmpGetFunction() as $tmpValue) {
|
| 249 |
+
$value .= (!empty($value) ? ', ' : '') . $tmpValue;
|
| 250 |
+
}
|
| 251 |
+
$aFields[$mwFieldId] = $value;
|
| 252 |
+
} else {
|
| 253 |
+
$aFields[$mwFieldId] = $shippingAddress->$tmpGetFunction();
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
break;
|
| 259 |
+
|
| 260 |
+
case 'orderdata':
|
| 261 |
+
if ($customerField == 'count_orders') { $aFields[$mwFieldId] = (!empty($countOrders) ? $countOrders : 0); }
|
| 262 |
+
if ($customerField == 'last_order_at') { $aFields[$mwFieldId] = (!empty($lastOrderAt) ? $lastOrderAt : ''); }
|
| 263 |
+
if ($customerField == 'last_order_amount') { $aFields[$mwFieldId] = (!empty($lastOrderAmount) ? $lastOrderAmount : 0); }
|
| 264 |
+
if ($customerField == 'all_order_amount') { $aFields[$mwFieldId] = (!empty($allOrderAmount) ? $allOrderAmount : 0); }
|
| 265 |
+
if ($customerField == 'average_order_amount') { $aFields[$mwFieldId] = (!empty($averageOrderAmount) ? $averageOrderAmount : 0); }
|
| 266 |
+
break;
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
return $aFields;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
public function getFields() {
|
| 277 |
+
try {
|
| 278 |
+
$result = $this->soapClient->getFields($this->helper->getUser(), $this->helper->getPassword());
|
| 279 |
+
if (!empty($result['error'])) {
|
| 280 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$result['message']);
|
| 281 |
+
}
|
| 282 |
+
return $result;
|
| 283 |
+
} catch (SoapFault $exception) {
|
| 284 |
+
$result = array('error' => 1, 'message' => $exception->getMessage());
|
| 285 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$exception->getMessage());
|
| 286 |
+
return $result;
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
public function getLists() {
|
| 291 |
+
try {
|
| 292 |
+
$result = $this->soapClient->getLists($this->helper->getUser(), $this->helper->getPassword());
|
| 293 |
+
if (!empty($result['error'])) {
|
| 294 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$result['message']);
|
| 295 |
+
}
|
| 296 |
+
return $result;
|
| 297 |
+
} catch (SoapFault $exception) {
|
| 298 |
+
$result = array('error' => 1, 'message' => $exception->getMessage());
|
| 299 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$exception->getMessage());
|
| 300 |
+
return $result;
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
public function getOptinsetups() {
|
| 305 |
+
try {
|
| 306 |
+
$result = $this->soapClient->getOptinsetups($this->helper->getUser(), $this->helper->getPassword());
|
| 307 |
+
if (!empty($result['error'])) {
|
| 308 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$result['message']);
|
| 309 |
+
}
|
| 310 |
+
return $result;
|
| 311 |
+
} catch (SoapFault $exception) {
|
| 312 |
+
$result = array('error' => 1, 'message' => $exception->getMessage());
|
| 313 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$exception->getMessage());
|
| 314 |
+
return $result;
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
public function getOptoutsetups() {
|
| 319 |
+
try {
|
| 320 |
+
$result = $this->soapClient->getOptoutsetups($this->helper->getUser(), $this->helper->getPassword());
|
| 321 |
+
if (!empty($result['error'])) {
|
| 322 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$result['message']);
|
| 323 |
+
}
|
| 324 |
+
return $result;
|
| 325 |
+
} catch (SoapFault $exception) {
|
| 326 |
+
$result = array('error' => 1, 'message' => $exception->getMessage());
|
| 327 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$exception->getMessage());
|
| 328 |
+
return $result;
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
/**
|
| 333 |
+
* @param $subscriber
|
| 334 |
+
* @param boolean $hasCustomer
|
| 335 |
+
* @throws \Exception
|
| 336 |
+
* @return array
|
| 337 |
+
*/
|
| 338 |
+
public function optinRecipient($subscriber, $hasCustomer = false) {
|
| 339 |
+
|
| 340 |
+
if ($hasCustomer) {
|
| 341 |
+
$optinSetupId = $this->helper->getOptinSetupCustomer();
|
| 342 |
+
} else {
|
| 343 |
+
$optinSetupId = $this->helper->getOptinSetupNewCustomer();
|
| 344 |
+
}
|
| 345 |
+
if (empty($optinSetupId)) {
|
| 346 |
+
$this->logger->log_info(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId() .' No OptinSetup Id configured (hasCustomer: '.$hasCustomer.')');
|
| 347 |
+
return false;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
$aFields = $this->getFieldArrayForMw($subscriber);
|
| 351 |
+
|
| 352 |
+
$aAdvanced = array('ip' => Mage::helper('core/http')->getRemoteAddr(),
|
| 353 |
+
'referer' => Mage::helper('core/http')->getHttpReferer()
|
| 354 |
+
);
|
| 355 |
+
$this->logger->log_debug(__METHOD__ .' OptinSetupId '.$optinSetupId.' values:'.json_encode($aFields).' advanced:'.json_encode($aAdvanced));
|
| 356 |
+
$result = $this->soapClient->optinRecipient($this->helper->getUser(),
|
| 357 |
+
$this->helper->getPassword(),
|
| 358 |
+
$optinSetupId,
|
| 359 |
+
$aFields,
|
| 360 |
+
$aAdvanced
|
| 361 |
+
);
|
| 362 |
+
|
| 363 |
+
if (!empty($result['error'])) {
|
| 364 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$result['message']);
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
return $result;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
/**
|
| 371 |
+
* @param $subscriber
|
| 372 |
+
* @param boolean $hasCustomer
|
| 373 |
+
* @throws \Exception
|
| 374 |
+
* @return array
|
| 375 |
+
*/
|
| 376 |
+
public function updateRecipient($subscriber) {
|
| 377 |
+
$aFields = $this->getFieldArrayForMw($subscriber);
|
| 378 |
+
|
| 379 |
+
$recipientIds = $this->getRecipientIdsByEmail($subscriber->getEmail());
|
| 380 |
+
|
| 381 |
+
if (!empty($recipientIds)) {
|
| 382 |
+
$blError = false;
|
| 383 |
+
foreach ($recipientIds as $recipientId) {
|
| 384 |
+
$this->logger->log_debug(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' Recipient Id '.$recipientId.' values: '.json_encode($aFields));
|
| 385 |
+
$result = $this->soapClient->updateRecipientById($this->helper->getUser(),
|
| 386 |
+
$this->helper->getPassword(),
|
| 387 |
+
$recipientId,
|
| 388 |
+
$aFields
|
| 389 |
+
);
|
| 390 |
+
|
| 391 |
+
if (!empty($result['error'])) {
|
| 392 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$result['message']);
|
| 393 |
+
$blError = true;
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
return $blError;
|
| 399 |
+
} else {
|
| 400 |
+
$this->logger->log_info(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' No Recipient Id for '.$subscriber->getEmail());
|
| 401 |
+
return false;
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
/**
|
| 406 |
+
* @param $subscriber
|
| 407 |
+
* @param boolean $hasCustomer
|
| 408 |
+
* @throws \Exception
|
| 409 |
+
* @return array
|
| 410 |
+
*/
|
| 411 |
+
public function optoutRecipient($subscriber, $hasCustomer = false) {
|
| 412 |
+
if ($hasCustomer) {
|
| 413 |
+
$optoutSetupId = $this->helper->getOptoutSetupCustomer();
|
| 414 |
+
} else {
|
| 415 |
+
//$optoutSetupId = $this->_helper->getOptoutSetupWithoutCustomer();
|
| 416 |
+
$optoutSetupId = $this->helper->getOptoutSetupCustomer();
|
| 417 |
+
}
|
| 418 |
+
if (empty($optoutSetupId)) {
|
| 419 |
+
$this->logger->log_info(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' No Optoutsetup Id configured (hasCustomer: '.$hasCustomer.')');
|
| 420 |
+
return false;
|
| 421 |
+
}
|
| 422 |
+
$recipientIds = $this->getRecipientIdsByEmail($subscriber->getEmail());
|
| 423 |
+
$blError = false;
|
| 424 |
+
if (!empty($recipientIds)) {
|
| 425 |
+
foreach ($recipientIds as $recipientId) {
|
| 426 |
+
$this->logger->log_info(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' Optout Recipient-Id '.$recipientId);
|
| 427 |
+
$result = $this->soapClient->optoutRecipientById($this->helper->getUser(),
|
| 428 |
+
$this->helper->getPassword(),
|
| 429 |
+
$optoutSetupId,
|
| 430 |
+
$recipientId
|
| 431 |
+
);
|
| 432 |
+
if (!empty($result['error'])) {
|
| 433 |
+
$blError = true;
|
| 434 |
+
$this->logger->log_error(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' '.$result['message']);
|
| 435 |
+
}
|
| 436 |
+
}
|
| 437 |
+
} else {
|
| 438 |
+
$this->logger->log_info(__METHOD__ .' StoreId: '.$this->helper->_getConfigScopeStoreId().' No Recipient Id for '.$subscriber->getEmail());
|
| 439 |
+
return false;
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
return $blError;
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
/**
|
| 446 |
+
* @param array $arrSubscriber
|
| 447 |
+
* @param integer $listId
|
| 448 |
+
* @return array
|
| 449 |
+
*/
|
| 450 |
+
public function initialImport($arrSubscriber, $listId) {
|
| 451 |
+
if (!empty($arrSubscriber)) {
|
| 452 |
+
$arrSubscriberForImport = array();
|
| 453 |
+
$arrResultImport = array();
|
| 454 |
+
foreach ($arrSubscriber as $subscriber) {
|
| 455 |
+
$arrSubscriberForImport[] = $this->getFieldArrayForMw($subscriber);
|
| 456 |
+
if (count($arrSubscriberForImport) == 2500) {
|
| 457 |
+
$arrResultImport[] = $this->importRecipients($arrSubscriberForImport, $listId);
|
| 458 |
+
$arrSubscriberForImport = array();
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
if (!empty($arrSubscriberForImport)) {
|
| 462 |
+
$arrResultImport[] = $this->importRecipients($arrSubscriberForImport, $listId);
|
| 463 |
+
}
|
| 464 |
+
}
|
| 465 |
+
$sMessage = '';
|
| 466 |
+
$bError = false;
|
| 467 |
+
if (!empty($arrResultImport)) {
|
| 468 |
+
foreach($arrResultImport as $arrResultTmp) {
|
| 469 |
+
if (!empty($arrResultTmp['error'])) {
|
| 470 |
+
$bError = true;
|
| 471 |
+
$sMessage .= (!empty($sMessage) ? ' | ' : '') . $arrResultTmp['message'];
|
| 472 |
+
}
|
| 473 |
+
}
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
$arrResult = array('error' => $bError,
|
| 477 |
+
'message' => ($bError ? $sMessage : 'import successful ' . count($arrSubscriber) . ' subscriber imported')
|
| 478 |
+
);
|
| 479 |
+
|
| 480 |
+
|
| 481 |
+
return $arrResult;
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
/**
|
| 485 |
+
* @param array $arrSubscriber
|
| 486 |
+
* @param integer $listId
|
| 487 |
+
* @return array
|
| 488 |
+
*/
|
| 489 |
+
protected function importRecipients($arrSubscriber, $listId) {
|
| 490 |
+
$result = $this->soapClient->importRecipients($this->helper->getUser(),
|
| 491 |
+
$this->helper->getPassword(),
|
| 492 |
+
$listId,
|
| 493 |
+
$arrSubscriber,
|
| 494 |
+
'add'
|
| 495 |
+
);
|
| 496 |
+
|
| 497 |
+
return $result;
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
}
|
app/code/community/Mailingwork/Sync/Model/Observer.php
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_Observer
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
protected $fieldsToCheck = array('customerdata' => array('prefix', 'firstname', 'lastname', 'group_id'),
|
| 25 |
+
'addressdata' => array('company', 'prefix', 'firstname', 'lastname', 'street', 'postcode', 'city', 'country_id', 'telephone')
|
| 26 |
+
);
|
| 27 |
+
|
| 28 |
+
public function customer_save_after($observer) {
|
| 29 |
+
//prüfen ob Magento Plugin aktiviert ist.
|
| 30 |
+
$helper = new Mailingwork_Sync_Helper_Data();
|
| 31 |
+
if (!$helper->isMailingworkEnabled()) {
|
| 32 |
+
return;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
$bChanged = false;
|
| 36 |
+
$customer = $observer->getCustomer();
|
| 37 |
+
$bChanged = $this->checkCustomerForChange($customer);
|
| 38 |
+
|
| 39 |
+
if ($bChanged) {
|
| 40 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
|
| 41 |
+
if (!empty($subscriber)) {
|
| 42 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 43 |
+
$mwApi->updateRecipient($subscriber);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function customer_address_save_after($observer) {
|
| 49 |
+
//prüfen ob Magento Plugin aktiviert ist.
|
| 50 |
+
$helper = new Mailingwork_Sync_Helper_Data();
|
| 51 |
+
if (!$helper->isMailingworkEnabled()) {
|
| 52 |
+
return;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
$bChanged = false;
|
| 56 |
+
$address = $observer->getCustomerAddress();
|
| 57 |
+
$customer = $address->getCustomer();
|
| 58 |
+
|
| 59 |
+
$addressIds = $customer->getPrimaryAddressIds();
|
| 60 |
+
if (!empty($addressIds) && in_array($address->getId(), $addressIds)) {
|
| 61 |
+
$bChanged = $this->checkAddressForChange($address);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
if ($bChanged) {
|
| 65 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
|
| 66 |
+
if (!empty($subscriber)) {
|
| 67 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 68 |
+
$mwApi->updateRecipient($subscriber);
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
public function sales_order_save_after($observer) {
|
| 74 |
+
//prüfen ob Magento Plugin aktiviert ist.
|
| 75 |
+
$helper = new Mailingwork_Sync_Helper_Data();
|
| 76 |
+
if (!$helper->isMailingworkEnabled()) {
|
| 77 |
+
return;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
$order = $observer->getOrder();
|
| 81 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
| 82 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
|
| 83 |
+
if (!empty($subscriber)) {
|
| 84 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 85 |
+
$mwApi->updateRecipient($subscriber);
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
protected function checkCustomerForChange($customer) {
|
| 91 |
+
$bChanged = false;
|
| 92 |
+
foreach ($this->fieldsToCheck['customerdata'] as $value) {
|
| 93 |
+
$bChanged = $customer->dataHasChangedFor($value);
|
| 94 |
+
if ($bChanged) {
|
| 95 |
+
return $bChanged;
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
return $bChanged;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
protected function checkAddressForChange($address) {
|
| 103 |
+
$bChanged = false;
|
| 104 |
+
foreach ($this->fieldsToCheck['addressdata'] as $value) {
|
| 105 |
+
$bChanged = $address->dataHasChangedFor($value);
|
| 106 |
+
if ($bChanged) {
|
| 107 |
+
return $bChanged;
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
return $bChanged;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
}
|
app/code/community/Mailingwork/Sync/Model/Resource/Abandonedcartcheckoutstatus.php
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_Resource_Abandonedcartcheckoutstatus extends Mage_Core_Model_Resource_Db_Abstract
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* DB read connection
|
| 26 |
+
*
|
| 27 |
+
* @var Zend_Db_Adapter_Abstract
|
| 28 |
+
*/
|
| 29 |
+
protected $_read;
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
protected function _construct() {
|
| 33 |
+
$this->_init('mailingwork_sync/abandonedcartcheckoutstatus', 'quote_id');
|
| 34 |
+
$this->_isPkAutoIncrement = false;
|
| 35 |
+
$this->_read = $this->_getReadAdapter();
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Load by quote_id
|
| 40 |
+
*
|
| 41 |
+
* @param int $quote_id
|
| 42 |
+
* @return array
|
| 43 |
+
*/
|
| 44 |
+
public function loadByQuoteId($quote_id)
|
| 45 |
+
{
|
| 46 |
+
$select = $this->_read->select()
|
| 47 |
+
->from($this->getMainTable())
|
| 48 |
+
->where('quote_id=:quote_id');
|
| 49 |
+
|
| 50 |
+
$result = $this->_read->fetchRow($select, array('quote_id'=>$quote_id));
|
| 51 |
+
|
| 52 |
+
if (!$result) {
|
| 53 |
+
return array();
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
return $result;
|
| 57 |
+
}
|
| 58 |
+
}
|
app/code/community/Mailingwork/Sync/Model/Resource/Subscriber.php
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_Resource_Subscriber extends Mage_Newsletter_Model_Resource_Subscriber
|
| 22 |
+
{
|
| 23 |
+
/**
|
| 24 |
+
* Initialize resource model
|
| 25 |
+
* Get tablename from config
|
| 26 |
+
*
|
| 27 |
+
*/
|
| 28 |
+
protected function _construct()
|
| 29 |
+
{
|
| 30 |
+
parent::_construct();
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Load subscriber from DB by email
|
| 35 |
+
*
|
| 36 |
+
* @param integer $storeId
|
| 37 |
+
* @return array
|
| 38 |
+
*/
|
| 39 |
+
public function loadByStoreId($storeId = null)
|
| 40 |
+
{
|
| 41 |
+
if (!empty($storeId)) {
|
| 42 |
+
$select = $this->_read->select()
|
| 43 |
+
->from($this->getMainTable())
|
| 44 |
+
->where('store_id=:store_id')
|
| 45 |
+
->where('subscriber_status=:subscriber_status');
|
| 46 |
+
$result = $this->_read->fetchAll($select, array('store_id' => $storeId, 'subscriber_status' => Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED));
|
| 47 |
+
} else {
|
| 48 |
+
$select = $this->_read->select()
|
| 49 |
+
->from($this->getMainTable())
|
| 50 |
+
->where('subscriber_status=:subscriber_status');
|
| 51 |
+
$result = $this->_read->fetchAll($select, array('subscriber_status' => Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED));
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
if (!$result) {
|
| 55 |
+
return array();
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
return $result;
|
| 59 |
+
}
|
| 60 |
+
}
|
app/code/community/Mailingwork/Sync/Model/Subscriber.php
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Model_Subscriber extends Mage_Newsletter_Model_Subscriber
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
protected $helper;
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Initialize resource model
|
| 28 |
+
*/
|
| 29 |
+
protected function _construct()
|
| 30 |
+
{
|
| 31 |
+
$this->helper = new Mailingwork_Sync_Helper_Data();
|
| 32 |
+
parent::_construct();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Subscribes by email
|
| 37 |
+
*
|
| 38 |
+
* @param string $email
|
| 39 |
+
* @throws Exception
|
| 40 |
+
* @return int
|
| 41 |
+
*/
|
| 42 |
+
public function subscribe($email)
|
| 43 |
+
{
|
| 44 |
+
//prüfen ob Magento Plugin aktiviert ist.
|
| 45 |
+
if (!$this->helper->isMailingworkEnabled()) {
|
| 46 |
+
return parent::subscribe($email);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
$this->loadByEmail($email);
|
| 50 |
+
$customerSession = Mage::getSingleton('customer/session');
|
| 51 |
+
|
| 52 |
+
if(!$this->getId()) {
|
| 53 |
+
$this->setSubscriberConfirmCode($this->randomSequence());
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
$isConfirmNeed = (Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1) ? true : false;
|
| 57 |
+
$isOwnSubscribes = false;
|
| 58 |
+
$ownerId = Mage::getModel('customer/customer')
|
| 59 |
+
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
|
| 60 |
+
->loadByEmail($email)
|
| 61 |
+
->getId();
|
| 62 |
+
$isSubscribeOwnEmail = $customerSession->isLoggedIn() && $ownerId == $customerSession->getId();
|
| 63 |
+
|
| 64 |
+
if (!$this->getId() || $this->getStatus() == self::STATUS_UNSUBSCRIBED
|
| 65 |
+
|| $this->getStatus() == self::STATUS_NOT_ACTIVE
|
| 66 |
+
) {
|
| 67 |
+
if ($isConfirmNeed === true) {
|
| 68 |
+
// if user subscribes own login email - confirmation is not needed
|
| 69 |
+
$isOwnSubscribes = $isSubscribeOwnEmail;
|
| 70 |
+
if ($isOwnSubscribes == true){
|
| 71 |
+
$this->setStatus(self::STATUS_SUBSCRIBED);
|
| 72 |
+
} else {
|
| 73 |
+
$this->setStatus(self::STATUS_NOT_ACTIVE);
|
| 74 |
+
}
|
| 75 |
+
} else {
|
| 76 |
+
$this->setStatus(self::STATUS_SUBSCRIBED);
|
| 77 |
+
}
|
| 78 |
+
$this->setSubscriberEmail($email);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
if ($isSubscribeOwnEmail) {
|
| 82 |
+
$this->setStoreId($customerSession->getCustomer()->getStoreId());
|
| 83 |
+
$this->setCustomerId($customerSession->getCustomerId());
|
| 84 |
+
} else {
|
| 85 |
+
$this->setStoreId(Mage::app()->getStore()->getId());
|
| 86 |
+
$this->setCustomerId(0);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
$this->setIsStatusChanged(true);
|
| 90 |
+
|
| 91 |
+
try {
|
| 92 |
+
$this->mwOptinRecipient(false);
|
| 93 |
+
|
| 94 |
+
$this->save();
|
| 95 |
+
return $this->getStatus();
|
| 96 |
+
} catch (Exception $e) {
|
| 97 |
+
throw new Exception($e->getMessage());
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Unsubscribes loaded subscription
|
| 103 |
+
*
|
| 104 |
+
*/
|
| 105 |
+
public function unsubscribe()
|
| 106 |
+
{
|
| 107 |
+
//prüfen ob Magento Plugin aktiviert ist.
|
| 108 |
+
if (!$this->helper->isMailingworkEnabled()) {
|
| 109 |
+
return parent::unsubscribe($email);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
if ($this->hasCheckCode() && $this->getCode() != $this->getCheckCode()) {
|
| 113 |
+
Mage::throwException(Mage::helper('newsletter')->__('Invalid subscription confirmation code.'));
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
if ($this->getSubscriberStatus() != self::STATUS_UNSUBSCRIBED) {
|
| 117 |
+
$result = $this->mwOptoutRecipient(true);
|
| 118 |
+
if (!empty($result) && empty($result['error'])) {
|
| 119 |
+
$this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED)->save();
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
return $this;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* Saving customer subscription status
|
| 128 |
+
*
|
| 129 |
+
* @param Mage_Customer_Model_Customer $customer
|
| 130 |
+
* @return Mage_Newsletter_Model_Subscriber
|
| 131 |
+
*/
|
| 132 |
+
public function subscribeCustomer($customer)
|
| 133 |
+
{
|
| 134 |
+
//prüfen ob Magento Plugin aktiviert ist.
|
| 135 |
+
if (!$this->helper->isMailingworkEnabled()) {
|
| 136 |
+
return parent::subscribeCustomer($customer);
|
| 137 |
+
}
|
| 138 |
+
$this->loadByCustomer($customer);
|
| 139 |
+
|
| 140 |
+
if ($customer->getImportMode()) {
|
| 141 |
+
$this->setImportMode(true);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
if (!$customer->getIsSubscribed() && !$this->getId()) {
|
| 145 |
+
// If subscription flag not set or customer is not a subscriber
|
| 146 |
+
// and no subscribe below
|
| 147 |
+
return $this;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
if(!$this->getId()) {
|
| 151 |
+
$this->setSubscriberConfirmCode($this->randomSequence());
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/*
|
| 155 |
+
* Logical mismatch between customer registration confirmation code and customer password confirmation
|
| 156 |
+
*/
|
| 157 |
+
$confirmation = null;
|
| 158 |
+
if ($customer->isConfirmationRequired() && ($customer->getConfirmation() != $customer->getPassword())) {
|
| 159 |
+
$confirmation = $customer->getConfirmation();
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
$sendInformationEmail = false;
|
| 163 |
+
if ($customer->hasIsSubscribed()) {
|
| 164 |
+
$status = $customer->getIsSubscribed()
|
| 165 |
+
? (!is_null($confirmation) ? self::STATUS_UNCONFIRMED : self::STATUS_SUBSCRIBED)
|
| 166 |
+
: self::STATUS_UNSUBSCRIBED;
|
| 167 |
+
/**
|
| 168 |
+
* If subscription status has been changed then send email to the customer
|
| 169 |
+
*/
|
| 170 |
+
if ($status != self::STATUS_UNCONFIRMED && $status != $this->getStatus()) {
|
| 171 |
+
$sendInformationEmail = true;
|
| 172 |
+
}
|
| 173 |
+
} elseif (($this->getStatus() == self::STATUS_UNCONFIRMED) && (is_null($confirmation))) {
|
| 174 |
+
$status = self::STATUS_SUBSCRIBED;
|
| 175 |
+
$sendInformationEmail = true;
|
| 176 |
+
} else {
|
| 177 |
+
$status = ($this->getStatus() == self::STATUS_NOT_ACTIVE ? self::STATUS_UNSUBSCRIBED : $this->getStatus());
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
if($status != $this->getStatus()) {
|
| 181 |
+
$this->setIsStatusChanged(true);
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
$this->setStatus($status);
|
| 185 |
+
|
| 186 |
+
if(!$this->getId()) {
|
| 187 |
+
$storeId = $customer->getStoreId();
|
| 188 |
+
if ($customer->getStoreId() == 0) {
|
| 189 |
+
$storeId = Mage::app()->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId();
|
| 190 |
+
}
|
| 191 |
+
$this->setStoreId($storeId)
|
| 192 |
+
->setCustomerId($customer->getId())
|
| 193 |
+
->setEmail($customer->getEmail());
|
| 194 |
+
} else {
|
| 195 |
+
$this->setStoreId($customer->getStoreId())
|
| 196 |
+
->setEmail($customer->getEmail());
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
$sendSubscription = $customer->getData('sendSubscription') || $sendInformationEmail;
|
| 200 |
+
if (is_null($sendSubscription) xor $sendSubscription) {
|
| 201 |
+
if ($this->getIsStatusChanged() && $status == self::STATUS_UNSUBSCRIBED) {
|
| 202 |
+
$result = $this->mwOptoutRecipient(true);
|
| 203 |
+
} elseif ($this->getIsStatusChanged() && $status == self::STATUS_SUBSCRIBED) {
|
| 204 |
+
$result = $this->mwOptinRecipient(true);
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
$this->save();
|
| 209 |
+
return $this;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* @return $this
|
| 214 |
+
*/
|
| 215 |
+
public function unsubscribeMagentoOnly()
|
| 216 |
+
{
|
| 217 |
+
if ($this->getSubscriberStatus() != self::STATUS_UNSUBSCRIBED) {
|
| 218 |
+
$this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED)->save();
|
| 219 |
+
}
|
| 220 |
+
return $this;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
protected function mwOptinRecipient($hasCustomer = false) {
|
| 224 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 225 |
+
$result = $mwApi->optinRecipient($this, $hasCustomer);
|
| 226 |
+
return $result;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
protected function mwOptoutRecipient($hasCustomer = false) {
|
| 230 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 231 |
+
$result = $mwApi->optoutRecipient($this, $hasCustomer);
|
| 232 |
+
return $result;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
protected function mwUpdateSubscriber() {
|
| 236 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 237 |
+
$result = $mwApi->updateRecipient($this);
|
| 238 |
+
return $result;
|
| 239 |
+
}
|
| 240 |
+
}
|
app/code/community/Mailingwork/Sync/Model/System/Config/Source/Lists.php
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Used in creating options for Yes|No config value selection
|
| 23 |
+
*
|
| 24 |
+
*/
|
| 25 |
+
class Mailingwork_Sync_Model_System_Config_Source_Lists
|
| 26 |
+
{
|
| 27 |
+
protected $_message = array();
|
| 28 |
+
protected $mwLists = array();
|
| 29 |
+
|
| 30 |
+
public function __construct() {
|
| 31 |
+
$helper = new Mailingwork_Sync_Helper_Data();
|
| 32 |
+
|
| 33 |
+
if ($helper->isMailingworkEnabled()) {
|
| 34 |
+
if ($helper->getUser()) {
|
| 35 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 36 |
+
$result = $mwApi->getLists();
|
| 37 |
+
if (empty($result['error'])) {
|
| 38 |
+
$this->mwLists = $result['result'];
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Options getter
|
| 46 |
+
*
|
| 47 |
+
* @return array
|
| 48 |
+
*/
|
| 49 |
+
public function toOptionArray()
|
| 50 |
+
{
|
| 51 |
+
$options = array();
|
| 52 |
+
$options[] = array('value' => '', 'label' => '');
|
| 53 |
+
if (!empty($this->mwLists)) {
|
| 54 |
+
foreach ($this->mwLists as $mwList) {
|
| 55 |
+
$options[] = array('value' => $mwList['id'], 'label' => $mwList['name'].' ('.$mwList['id'].')');
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
return $options;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* Get options in "key-value" format
|
| 64 |
+
*
|
| 65 |
+
* @return array
|
| 66 |
+
*/
|
| 67 |
+
public function toArray()
|
| 68 |
+
{
|
| 69 |
+
$options = array();
|
| 70 |
+
$options[''] = '';
|
| 71 |
+
if (!empty($this->mwLists)) {
|
| 72 |
+
foreach ($this->mwLists as $mwList) {
|
| 73 |
+
$options[$mwList['id']] = $mwList['name'].' ('.$mwList['id'].')';
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
return $options;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
}
|
app/code/community/Mailingwork/Sync/Model/System/Config/Source/Optinsetups.php
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Used in creating options for Yes|No config value selection
|
| 23 |
+
*
|
| 24 |
+
*/
|
| 25 |
+
class Mailingwork_Sync_Model_System_Config_Source_Optinsetups
|
| 26 |
+
{
|
| 27 |
+
protected $_message = array();
|
| 28 |
+
protected $mwOptinsetups = array();
|
| 29 |
+
|
| 30 |
+
public function __construct() {
|
| 31 |
+
$helper = new Mailingwork_Sync_Helper_Data();
|
| 32 |
+
|
| 33 |
+
if ($helper->isMailingworkEnabled()) {
|
| 34 |
+
if ($helper->getUser()) {
|
| 35 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 36 |
+
$result = $mwApi->getOptinsetups();
|
| 37 |
+
if (empty($result['error'])) {
|
| 38 |
+
$this->mwOptinsetups = $result['result'];
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Options getter
|
| 46 |
+
*
|
| 47 |
+
* @return array
|
| 48 |
+
*/
|
| 49 |
+
public function toOptionArray()
|
| 50 |
+
{
|
| 51 |
+
$options = array();
|
| 52 |
+
$options[] = array('value' => '', 'label' => '');
|
| 53 |
+
if (!empty($this->mwOptinsetups)) {
|
| 54 |
+
foreach ($this->mwOptinsetups as $mwOptinsetup) {
|
| 55 |
+
$options[] = array('value' => $mwOptinsetup['id'], 'label' => $mwOptinsetup['name'].' ('.$mwOptinsetup['id'].')');
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
return $options;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* Get options in "key-value" format
|
| 64 |
+
*
|
| 65 |
+
* @return array
|
| 66 |
+
*/
|
| 67 |
+
public function toArray()
|
| 68 |
+
{
|
| 69 |
+
$options = array();
|
| 70 |
+
$options[''] = '';
|
| 71 |
+
if (!empty($this->mwOptinsetups)) {
|
| 72 |
+
foreach ($this->mwOptinsetups as $mwOptinsetup) {
|
| 73 |
+
$options[$mwOptinsetup['id']] = $mwOptinsetup['name'].' ('.$mwOptinsetup['id'].')';
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
return $options;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
}
|
app/code/community/Mailingwork/Sync/Model/System/Config/Source/Optoutsetups.php
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Used in creating options for Yes|No config value selection
|
| 23 |
+
*
|
| 24 |
+
*/
|
| 25 |
+
class Mailingwork_Sync_Model_System_Config_Source_Optoutsetups
|
| 26 |
+
{
|
| 27 |
+
protected $_message = array();
|
| 28 |
+
protected $mwOptoutsetups = array();
|
| 29 |
+
|
| 30 |
+
public function __construct() {
|
| 31 |
+
$helper = new Mailingwork_Sync_Helper_Data();
|
| 32 |
+
|
| 33 |
+
if ($helper->isMailingworkEnabled()) {
|
| 34 |
+
if ($helper->getUser()) {
|
| 35 |
+
$mwApi = new Mailingwork_Sync_Model_MwApi();
|
| 36 |
+
$result = $mwApi->getOptoutsetups();
|
| 37 |
+
if (empty($result['error'])) {
|
| 38 |
+
$this->mwOptoutsetups = $result['result'];
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Options getter
|
| 46 |
+
*
|
| 47 |
+
* @return array
|
| 48 |
+
*/
|
| 49 |
+
public function toOptionArray()
|
| 50 |
+
{
|
| 51 |
+
$options = array();
|
| 52 |
+
$options[] = array('value' => '', 'label' => '');
|
| 53 |
+
if (!empty($this->mwOptoutsetups)) {
|
| 54 |
+
foreach ($this->mwOptoutsetups as $mwOptoutsetup) {
|
| 55 |
+
$options[] = array('value' => $mwOptoutsetup['id'], 'label' => $mwOptoutsetup['name'].' ('.$mwOptoutsetup['id'].')');
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
return $options;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* Get options in "key-value" format
|
| 64 |
+
*
|
| 65 |
+
* @return array
|
| 66 |
+
*/
|
| 67 |
+
public function toArray()
|
| 68 |
+
{
|
| 69 |
+
$options = array();
|
| 70 |
+
$options[''] = '';
|
| 71 |
+
if (!empty($this->mwOptoutsetups)) {
|
| 72 |
+
foreach ($this->mwOptoutsetups as $mwOptoutsetup) {
|
| 73 |
+
$options[$mwOptoutsetup['id']] = $mwOptoutsetup['name'].' ('.$mwOptoutsetup['id'].')';
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
return $options;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
}
|
app/code/community/Mailingwork/Sync/controllers/Adminhtml/InitialimportController.php
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
class Mailingwork_Sync_Adminhtml_InitialimportController extends Mage_Adminhtml_Controller_Action
|
| 22 |
+
{
|
| 23 |
+
/**
|
| 24 |
+
* @var JsonFactory
|
| 25 |
+
*/
|
| 26 |
+
protected $resultJsonFactory;
|
| 27 |
+
|
| 28 |
+
protected function _construct()
|
| 29 |
+
{
|
| 30 |
+
$this->setUsedModuleName('Mailingwork_Sync');
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
public function indexAction()
|
| 34 |
+
{
|
| 35 |
+
$listId = $this->getRequest()->getParam('importlist');
|
| 36 |
+
|
| 37 |
+
if (!empty($listId)) {
|
| 38 |
+
$initialImportModel = new Mailingwork_Sync_Model_InitialImport();
|
| 39 |
+
$result = $initialImportModel->mwInitialImport($listId);
|
| 40 |
+
} else {
|
| 41 |
+
$result = array('error' => true,
|
| 42 |
+
'message' => 'Bitte Abonnentenliste für Import angeben!'
|
| 43 |
+
);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
$arrRes = array('valid' => (!empty($result['error']) ? 0 : 1),
|
| 47 |
+
'message' => $result['message']
|
| 48 |
+
);
|
| 49 |
+
|
| 50 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($arrRes));
|
| 51 |
+
}
|
| 52 |
+
}
|
app/code/community/Mailingwork/Sync/controllers/OnepageController.php
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
require_once Mage::getModuleDir('controllers', 'Mage_Checkout') . DS . 'OnepageController.php';
|
| 22 |
+
|
| 23 |
+
class Mailingwork_Sync_OnepageController extends Mage_Checkout_OnepageController
|
| 24 |
+
{
|
| 25 |
+
/**
|
| 26 |
+
* Checkout page
|
| 27 |
+
*/
|
| 28 |
+
public function indexAction()
|
| 29 |
+
{
|
| 30 |
+
if (!Mage::helper('checkout')->canOnepageCheckout()) {
|
| 31 |
+
Mage::getSingleton('checkout/session')->addError($this->__('The onepage checkout is disabled.'));
|
| 32 |
+
$this->_redirect('checkout/cart');
|
| 33 |
+
return;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
$quote = $this->getOnepage()->getQuote();
|
| 37 |
+
if (!$quote->hasItems() || $quote->getHasError()) {
|
| 38 |
+
$this->_redirect('checkout/cart');
|
| 39 |
+
return;
|
| 40 |
+
}
|
| 41 |
+
if (!$quote->validateMinimumAmount()) {
|
| 42 |
+
$error = Mage::getStoreConfig('sales/minimum_order/error_message') ?
|
| 43 |
+
Mage::getStoreConfig('sales/minimum_order/error_message') :
|
| 44 |
+
Mage::helper('checkout')->__('Subtotal must exceed minimum order amount');
|
| 45 |
+
|
| 46 |
+
Mage::getSingleton('checkout/session')->addError($error);
|
| 47 |
+
$this->_redirect('checkout/cart');
|
| 48 |
+
return;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
Mage::getModel('mailingwork_sync/abandonedcartcheckoutstatus')->updateStatus($quote->getId(), 'index');
|
| 52 |
+
|
| 53 |
+
parent::indexAction();
|
| 54 |
+
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Refreshes the previous step
|
| 59 |
+
* Loads the block corresponding to the current step and sets it
|
| 60 |
+
* in to the response body
|
| 61 |
+
*
|
| 62 |
+
* This function is called from the reloadProgessBlock
|
| 63 |
+
* function from the javascript
|
| 64 |
+
*
|
| 65 |
+
* @return string|null
|
| 66 |
+
*/
|
| 67 |
+
public function progressAction()
|
| 68 |
+
{
|
| 69 |
+
// prevStep available only from version 1.8.0.0
|
| 70 |
+
if (version_compare(Mage::getVersion(), '1.8', '>=')){
|
| 71 |
+
// previous step should never be null. We always start with billing and go forward
|
| 72 |
+
$prevStep = $this->getRequest()->getParam('prevStep', false);
|
| 73 |
+
|
| 74 |
+
if ($this->_expireAjax() || !$prevStep) {
|
| 75 |
+
return null;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
$quote = $this->getOnepage()->getQuote();
|
| 79 |
+
Mage::getModel('mailingwork_sync/abandonedcartcheckoutstatus')->updateStatus($quote->getId(), $prevStep);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
parent::progressAction();
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
}
|
app/code/community/Mailingwork/Sync/etc/api.xml
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* mailignwork GmbH
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category mailingwork
|
| 17 |
+
* @package Mailingwork_Sync
|
| 18 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
-->
|
| 22 |
+
<config>
|
| 23 |
+
<api>
|
| 24 |
+
<resources>
|
| 25 |
+
<mwsync translate="title" module="mailingwork_sync">
|
| 26 |
+
<title>Mailingwork Sync</title>
|
| 27 |
+
<model>mailingwork_sync/api</model>
|
| 28 |
+
<acl>mailingwork_sync/api</acl>
|
| 29 |
+
<methods>
|
| 30 |
+
<getAbandonedCarts translate="title" module="mailingwork_sync">
|
| 31 |
+
<title>getAbandonedCarts</title>
|
| 32 |
+
</getAbandonedCarts>
|
| 33 |
+
<unsubscribeSubscriber translate="title" module="mailingwork_sync">
|
| 34 |
+
<title>unsubscribeSubscriber</title>
|
| 35 |
+
</unsubscribeSubscriber>
|
| 36 |
+
<getMailingworkLog translate="title" module="mailingwork_sync">
|
| 37 |
+
<title>getMailingworkLog</title>
|
| 38 |
+
</getMailingworkLog>
|
| 39 |
+
</methods>
|
| 40 |
+
</mwsync>
|
| 41 |
+
</resources>
|
| 42 |
+
<resources_alias>
|
| 43 |
+
<mailingwork_api>mwsync</mailingwork_api>
|
| 44 |
+
</resources_alias>
|
| 45 |
+
<v2>
|
| 46 |
+
<resources_function_prefix>
|
| 47 |
+
<mailingwork_api>MailingworkSyncApi</mailingwork_api>
|
| 48 |
+
</resources_function_prefix>
|
| 49 |
+
</v2>
|
| 50 |
+
<acl>
|
| 51 |
+
<resources>
|
| 52 |
+
<mailingwork_sync translate="title" module="mailingwork_sync">
|
| 53 |
+
<title>Mailingwork Sync</title>
|
| 54 |
+
<sort_order>2000</sort_order>
|
| 55 |
+
<api translate="title" module="mailingwork_sync">
|
| 56 |
+
<title>Mailingwork Sync API</title>
|
| 57 |
+
</api>
|
| 58 |
+
</mailingwork_sync>
|
| 59 |
+
</resources>
|
| 60 |
+
</acl>
|
| 61 |
+
</api>
|
| 62 |
+
</config>
|
app/code/community/Mailingwork/Sync/etc/config.xml
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* mailignwork GmbH
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category mailingwork
|
| 17 |
+
* @package Mailingwork_Sync
|
| 18 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
-->
|
| 22 |
+
<config>
|
| 23 |
+
<modules>
|
| 24 |
+
<Mailingwork_Sync>
|
| 25 |
+
<version>1.0.1</version>
|
| 26 |
+
</Mailingwork_Sync>
|
| 27 |
+
</modules>
|
| 28 |
+
|
| 29 |
+
<global>
|
| 30 |
+
<!-- MODELS -->
|
| 31 |
+
<models>
|
| 32 |
+
<mailingwork_sync>
|
| 33 |
+
<class>Mailingwork_Sync_Model</class>
|
| 34 |
+
<resourceModel>mailingwork_sync_resource</resourceModel>
|
| 35 |
+
</mailingwork_sync>
|
| 36 |
+
<newsletter>
|
| 37 |
+
<rewrite>
|
| 38 |
+
<subscriber>Mailingwork_Sync_Model_Subscriber</subscriber>
|
| 39 |
+
</rewrite>
|
| 40 |
+
</newsletter>
|
| 41 |
+
<mailingwork_sync_resource>
|
| 42 |
+
<class>Mailingwork_Sync_Model_Resource</class>
|
| 43 |
+
<entities>
|
| 44 |
+
<abandonedcartcheckoutstatus>
|
| 45 |
+
<table>mailingwork_sync_abandonedcartcheckoutstatus</table>
|
| 46 |
+
</abandonedcartcheckoutstatus>
|
| 47 |
+
</entities>
|
| 48 |
+
</mailingwork_sync_resource>
|
| 49 |
+
</models>
|
| 50 |
+
<!-- BLOCKS -->
|
| 51 |
+
<blocks>
|
| 52 |
+
<mailingwork_sync>
|
| 53 |
+
<class>Mailingwork_Sync_Block</class>
|
| 54 |
+
</mailingwork_sync>
|
| 55 |
+
</blocks>
|
| 56 |
+
<!-- HELPERS -->
|
| 57 |
+
<helpers>
|
| 58 |
+
<mailingwork_sync>
|
| 59 |
+
<class>Mailingwork_Sync_Helper</class>
|
| 60 |
+
</mailingwork_sync>
|
| 61 |
+
</helpers>
|
| 62 |
+
<!-- EVENTS -->
|
| 63 |
+
<events>
|
| 64 |
+
<customer_address_save_after>
|
| 65 |
+
<observers>
|
| 66 |
+
<mailingwork_sync>
|
| 67 |
+
<type>singleton</type>
|
| 68 |
+
<class>Mailingwork_Sync_Model_Observer</class>
|
| 69 |
+
<method>customer_address_save_after</method>
|
| 70 |
+
</mailingwork_sync>
|
| 71 |
+
</observers>
|
| 72 |
+
</customer_address_save_after>
|
| 73 |
+
|
| 74 |
+
<customer_save_after>
|
| 75 |
+
<observers>
|
| 76 |
+
<mailingwork_sync>
|
| 77 |
+
<type>singleton</type>
|
| 78 |
+
<class>Mailingwork_Sync_Model_Observer</class>
|
| 79 |
+
<method>customer_save_after</method>
|
| 80 |
+
</mailingwork_sync>
|
| 81 |
+
</observers>
|
| 82 |
+
</customer_save_after>
|
| 83 |
+
|
| 84 |
+
<sales_order_save_after>
|
| 85 |
+
<observers>
|
| 86 |
+
<mailingwork_sync>
|
| 87 |
+
<type>singleton</type>
|
| 88 |
+
<class>Mailingwork_Sync_Model_Observer</class>
|
| 89 |
+
<method>sales_order_save_after</method>
|
| 90 |
+
</mailingwork_sync>
|
| 91 |
+
</observers>
|
| 92 |
+
</sales_order_save_after>
|
| 93 |
+
</events>
|
| 94 |
+
<!-- RESOURCES -->
|
| 95 |
+
<resources>
|
| 96 |
+
<mailingwork_sync_setup>
|
| 97 |
+
<setup>
|
| 98 |
+
<module>Mailingwork_Sync</module>
|
| 99 |
+
</setup>
|
| 100 |
+
</mailingwork_sync_setup>
|
| 101 |
+
</resources>
|
| 102 |
+
</global>
|
| 103 |
+
<admin>
|
| 104 |
+
<routers>
|
| 105 |
+
<adminhtml>
|
| 106 |
+
<args>
|
| 107 |
+
<modules>
|
| 108 |
+
<mailingwork_sync before="Mage_Adminhtml">Mailingwork_Sync_Adminhtml</mailingwork_sync>
|
| 109 |
+
</modules>
|
| 110 |
+
</args>
|
| 111 |
+
</adminhtml>
|
| 112 |
+
</routers>
|
| 113 |
+
</admin>
|
| 114 |
+
<adminhtml>
|
| 115 |
+
<translate>
|
| 116 |
+
<modules>
|
| 117 |
+
<mailingwork_sync>
|
| 118 |
+
<files>
|
| 119 |
+
<default>Mailingwork_Sync.csv</default>
|
| 120 |
+
</files>
|
| 121 |
+
</mailingwork_sync>
|
| 122 |
+
</modules>
|
| 123 |
+
</translate>
|
| 124 |
+
</adminhtml>
|
| 125 |
+
<frontend>
|
| 126 |
+
<routers>
|
| 127 |
+
<checkout>
|
| 128 |
+
<args>
|
| 129 |
+
<modules>
|
| 130 |
+
<Mailingwork_Sync before="Mage_Checkout">Mailingwork_Sync</Mailingwork_Sync>
|
| 131 |
+
</modules>
|
| 132 |
+
<frontName>checkout</frontName>
|
| 133 |
+
</args>
|
| 134 |
+
</checkout>
|
| 135 |
+
</routers>
|
| 136 |
+
</frontend>
|
| 137 |
+
<!-- KONFIGURATION -->
|
| 138 |
+
<default>
|
| 139 |
+
<mailingwork_sync>
|
| 140 |
+
<mailingwork_sync_configuration>
|
| 141 |
+
<wsdl_url>https://login.mailingwork.de/webservice/webservice/</wsdl_url>
|
| 142 |
+
<ws_type>soap3</ws_type>
|
| 143 |
+
<ws_param>wsdl</ws_param>
|
| 144 |
+
<ws_location></ws_location>
|
| 145 |
+
</mailingwork_sync_configuration>
|
| 146 |
+
</mailingwork_sync>
|
| 147 |
+
</default>
|
| 148 |
+
</config>
|
app/code/community/Mailingwork/Sync/etc/system.xml
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* mailignwork GmbH
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* @category mailingwork
|
| 17 |
+
* @package Mailingwork_Sync
|
| 18 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 20 |
+
*/
|
| 21 |
+
-->
|
| 22 |
+
<config>
|
| 23 |
+
<sections>
|
| 24 |
+
<newsletter>
|
| 25 |
+
<groups>
|
| 26 |
+
<mailingwork_sync translate="label">
|
| 27 |
+
<label>Mailingwork</label>
|
| 28 |
+
<comment><![CDATA[]]></comment>
|
| 29 |
+
<sort_order>0</sort_order>
|
| 30 |
+
<show_in_default>1</show_in_default>
|
| 31 |
+
<show_in_website>1</show_in_website>
|
| 32 |
+
<show_in_store>1</show_in_store>
|
| 33 |
+
<fields>
|
| 34 |
+
<hint>
|
| 35 |
+
<frontend_model>mailingwork_sync/adminhtml_system_config_fieldset_hint</frontend_model>
|
| 36 |
+
<sort_order>1</sort_order>
|
| 37 |
+
<show_in_default>1</show_in_default>
|
| 38 |
+
<show_in_website>1</show_in_website>
|
| 39 |
+
<show_in_store>1</show_in_store>
|
| 40 |
+
</hint>
|
| 41 |
+
<active translate="label">
|
| 42 |
+
<label>Enabled</label>
|
| 43 |
+
<frontend_type>select</frontend_type>
|
| 44 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 45 |
+
<sort_order>1</sort_order>
|
| 46 |
+
<show_in_default>1</show_in_default>
|
| 47 |
+
<show_in_website>1</show_in_website>
|
| 48 |
+
<show_in_store>1</show_in_store>
|
| 49 |
+
</active>
|
| 50 |
+
<username translate="label">
|
| 51 |
+
<label>username</label>
|
| 52 |
+
<frontend_type>text</frontend_type>
|
| 53 |
+
<sort_order>2</sort_order>
|
| 54 |
+
<show_in_default>1</show_in_default>
|
| 55 |
+
<show_in_website>1</show_in_website>
|
| 56 |
+
<show_in_store>1</show_in_store>
|
| 57 |
+
</username>
|
| 58 |
+
<password translate="label">
|
| 59 |
+
<label>password</label>
|
| 60 |
+
<frontend_type>password</frontend_type>
|
| 61 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 62 |
+
<sort_order>3</sort_order>
|
| 63 |
+
<show_in_default>1</show_in_default>
|
| 64 |
+
<show_in_website>1</show_in_website>
|
| 65 |
+
<show_in_store>1</show_in_store>
|
| 66 |
+
</password>
|
| 67 |
+
<list_id translate="label">
|
| 68 |
+
<label>list_id</label>
|
| 69 |
+
<frontend_type>select</frontend_type>
|
| 70 |
+
<source_model>Mailingwork_Sync_Model_System_Config_Source_Lists</source_model>
|
| 71 |
+
<sort_order>4</sort_order>
|
| 72 |
+
<show_in_default>1</show_in_default>
|
| 73 |
+
<show_in_website>1</show_in_website>
|
| 74 |
+
<show_in_store>1</show_in_store>
|
| 75 |
+
</list_id>
|
| 76 |
+
<optin_setup_new translate="label">
|
| 77 |
+
<label>optin_setup_id_new</label>
|
| 78 |
+
<frontend_type>select</frontend_type>
|
| 79 |
+
<source_model>Mailingwork_Sync_Model_System_Config_Source_Optinsetups</source_model>
|
| 80 |
+
<sort_order>5</sort_order>
|
| 81 |
+
<show_in_default>1</show_in_default>
|
| 82 |
+
<show_in_website>1</show_in_website>
|
| 83 |
+
<show_in_store>1</show_in_store>
|
| 84 |
+
</optin_setup_new>
|
| 85 |
+
<optin_setup translate="label">
|
| 86 |
+
<label>optin_setup_id_customer</label>
|
| 87 |
+
<frontend_type>select</frontend_type>
|
| 88 |
+
<source_model>Mailingwork_Sync_Model_System_Config_Source_Optinsetups</source_model>
|
| 89 |
+
<sort_order>6</sort_order>
|
| 90 |
+
<show_in_default>1</show_in_default>
|
| 91 |
+
<show_in_website>1</show_in_website>
|
| 92 |
+
<show_in_store>1</show_in_store>
|
| 93 |
+
</optin_setup>
|
| 94 |
+
<optout_setup translate="label">
|
| 95 |
+
<label>optout_setup_id</label>
|
| 96 |
+
<frontend_type>select</frontend_type>
|
| 97 |
+
<source_model>Mailingwork_Sync_Model_System_Config_Source_Optoutsetups</source_model>
|
| 98 |
+
<sort_order>7</sort_order>
|
| 99 |
+
<show_in_default>1</show_in_default>
|
| 100 |
+
<show_in_website>1</show_in_website>
|
| 101 |
+
<show_in_store>1</show_in_store>
|
| 102 |
+
</optout_setup>
|
| 103 |
+
<mapping translate="label">
|
| 104 |
+
<label>field_mapping</label>
|
| 105 |
+
<frontend_model>mailingwork_sync/adminhtml_system_config_form_field_customermap</frontend_model>
|
| 106 |
+
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
|
| 107 |
+
<sort_order>8</sort_order>
|
| 108 |
+
<show_in_default>1</show_in_default>
|
| 109 |
+
<show_in_website>1</show_in_website>
|
| 110 |
+
<show_in_store>1</show_in_store>
|
| 111 |
+
</mapping>
|
| 112 |
+
</fields>
|
| 113 |
+
</mailingwork_sync>
|
| 114 |
+
<mailingwork_syncimport translate="label">
|
| 115 |
+
<label>mailingwork_initial_import_headline</label>
|
| 116 |
+
<sort_order>1</sort_order>
|
| 117 |
+
<show_in_default>1</show_in_default>
|
| 118 |
+
<show_in_website>1</show_in_website>
|
| 119 |
+
<show_in_store>1</show_in_store>
|
| 120 |
+
<fields>
|
| 121 |
+
<initialimport_list translate="label">
|
| 122 |
+
<label>mailingwork_list_initial_import</label>
|
| 123 |
+
<frontend_type>select</frontend_type>
|
| 124 |
+
<source_model>Mailingwork_Sync_Model_System_Config_Source_Lists</source_model>
|
| 125 |
+
<sort_order>0</sort_order>
|
| 126 |
+
<show_in_default>1</show_in_default>
|
| 127 |
+
<show_in_website>1</show_in_website>
|
| 128 |
+
<show_in_store>1</show_in_store>
|
| 129 |
+
</initialimport_list>
|
| 130 |
+
<initialimport_button translate="label comment">
|
| 131 |
+
<frontend_type>button</frontend_type>
|
| 132 |
+
<frontend_model>mailingwork_sync/adminhtml_system_config_initialimport</frontend_model>
|
| 133 |
+
<comment>mailingwork_initial_import_descr</comment>
|
| 134 |
+
<sort_order>1</sort_order>
|
| 135 |
+
<show_in_default>1</show_in_default>
|
| 136 |
+
<show_in_website>1</show_in_website>
|
| 137 |
+
<show_in_store>1</show_in_store>
|
| 138 |
+
</initialimport_button>
|
| 139 |
+
</fields>
|
| 140 |
+
</mailingwork_syncimport>
|
| 141 |
+
</groups>
|
| 142 |
+
</newsletter>
|
| 143 |
+
</sections>
|
| 144 |
+
</config>
|
app/code/community/Mailingwork/Sync/etc/wsdl.xml
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
| 3 |
+
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
|
| 4 |
+
name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
|
| 5 |
+
<types>
|
| 6 |
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
|
| 7 |
+
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
|
| 8 |
+
<complexType name="customerAddressEntityCreate">
|
| 9 |
+
<all>
|
| 10 |
+
<element name="email" type="xsd:string" minOccurs="0"/>
|
| 11 |
+
<element name="quote_id" type="xsd:string" minOccurs="0"/>
|
| 12 |
+
<element name="updated_at" type="xsd:string" minOccurs="0"/>
|
| 13 |
+
<element name="store_id" type="xsd:string" minOccurs="0"/>
|
| 14 |
+
<element name="checkout_status" type="xsd:string" minOccurs="0"/>
|
| 15 |
+
</all>
|
| 16 |
+
</complexType>
|
| 17 |
+
<complexType name="abandonedCartsResponseEntityArray">
|
| 18 |
+
<complexContent>
|
| 19 |
+
<restriction base="soapenc:Array">
|
| 20 |
+
<attribute ref="soapenc:arrayType" wsdl:arrayType="typens:abandonedCartsResponseEntity[]"/>
|
| 21 |
+
</restriction>
|
| 22 |
+
</complexContent>
|
| 23 |
+
</complexType>
|
| 24 |
+
</schema>
|
| 25 |
+
</types>
|
| 26 |
+
<message name="MailingworkSyncApiGetAbandonedCartsRequest">
|
| 27 |
+
<part name="sessionId" type="xsd:string"/>
|
| 28 |
+
<part name="secondsUntilLastUpdate" type="xsd:int" />
|
| 29 |
+
</message>
|
| 30 |
+
<message name="MailingworkSyncApiGetAbandonedCartsResponse">
|
| 31 |
+
<part name="result" type="typens:abandonedCartsResponseEntityArray" />
|
| 32 |
+
</message>
|
| 33 |
+
<message name="MailingworkSyncApiUnsubscribeSubscriberRequest">
|
| 34 |
+
<part name="sessionId" type="xsd:string"/>
|
| 35 |
+
<part name="email" type="xsd:string" />
|
| 36 |
+
</message>
|
| 37 |
+
<message name="MailingworkSyncApiUnsubscribeSubscriberResponse">
|
| 38 |
+
<part name="result" type="xsd:int" />
|
| 39 |
+
</message>
|
| 40 |
+
<message name="MailingworkSyncApiGetMailingworkLogRequest">
|
| 41 |
+
<part name="sessionId" type="xsd:string"/>
|
| 42 |
+
</message>
|
| 43 |
+
<message name="MailingworkSyncApiGetMailingworkLogResponse">
|
| 44 |
+
<part name="result" type="xsd:string" />
|
| 45 |
+
</message>
|
| 46 |
+
<portType name="{{var wsdl.handler}}PortType">
|
| 47 |
+
<operation name="MailingworkSyncApiGetAbandonedCarts">
|
| 48 |
+
<documentation>get Abandoned Carts</documentation>
|
| 49 |
+
<input message="typens:MailingworkSyncApiGetAbandonedCartsRequest" />
|
| 50 |
+
<output message="typens:MailingworkSyncApiGetAbandonedCartsResponse" />
|
| 51 |
+
</operation>
|
| 52 |
+
<operation name="MailingworkSyncApiUnsubscribeSubscriber">
|
| 53 |
+
<documentation>unsubscribe Magento Newslettersubscriber</documentation>
|
| 54 |
+
<input message="typens:MailingworkSyncApiUnsubscribeSubscriberRequest" />
|
| 55 |
+
<output message="typens:MailingworkSyncApiUnsubscribeSubscriberResponse" />
|
| 56 |
+
</operation>
|
| 57 |
+
<operation name="MailingworkSyncApiGetMailingworkLog">
|
| 58 |
+
<documentation>gets Mailingwork Logfile for Support</documentation>
|
| 59 |
+
<input message="typens:MailingworkSyncApiGetMailingworkLogRequest" />
|
| 60 |
+
<output message="typens:MailingworkSyncApiGetMailingworkLogResponse" />
|
| 61 |
+
</operation>
|
| 62 |
+
</portType>
|
| 63 |
+
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
|
| 64 |
+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
|
| 65 |
+
<operation name="MailingworkSyncApiGetAbandonedCarts">
|
| 66 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
| 67 |
+
<input>
|
| 68 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
| 69 |
+
</input>
|
| 70 |
+
<output>
|
| 71 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
| 72 |
+
</output>
|
| 73 |
+
</operation>
|
| 74 |
+
<operation name="MailingworkSyncApiUnsubscribeSubscriber">
|
| 75 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
| 76 |
+
<input>
|
| 77 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
| 78 |
+
</input>
|
| 79 |
+
<output>
|
| 80 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
| 81 |
+
</output>
|
| 82 |
+
</operation>
|
| 83 |
+
<operation name="MailingworkSyncApiGetMailingworkLog">
|
| 84 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
| 85 |
+
<input>
|
| 86 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
| 87 |
+
</input>
|
| 88 |
+
<output>
|
| 89 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
| 90 |
+
</output>
|
| 91 |
+
</operation>
|
| 92 |
+
</binding>
|
| 93 |
+
<service name="{{var wsdl.name}}Service">
|
| 94 |
+
<port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
|
| 95 |
+
<soap:address location="{{var wsdl.url}}" />
|
| 96 |
+
</port>
|
| 97 |
+
</service>
|
| 98 |
+
</definitions>
|
app/code/community/Mailingwork/Sync/sql/mailingwork_sync_setup/install-1.0.1.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* mailignwork GmbH
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com and you will be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* @category mailingwork
|
| 16 |
+
* @package Mailingwork_Sync
|
| 17 |
+
* @copyright Copyright (c) 2016 mailingwork GmbH (http://mailingwork.de)
|
| 18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
$installer = $this;
|
| 22 |
+
|
| 23 |
+
$installer->startSetup();
|
| 24 |
+
|
| 25 |
+
$table = $installer->getConnection()
|
| 26 |
+
->newTable($installer->getTable('mailingwork_sync/abandonedcartcheckoutstatus'))
|
| 27 |
+
->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 28 |
+
'unsigned' => true,
|
| 29 |
+
'nullable' => false,
|
| 30 |
+
'primary' => true,
|
| 31 |
+
), 'Quote Id')
|
| 32 |
+
->addColumn('status', Varien_Db_Ddl_Table::TYPE_VARCHAR, 20, array(
|
| 33 |
+
'nullable' => false,
|
| 34 |
+
), 'Status');
|
| 35 |
+
$installer->getConnection()->createTable($table);
|
| 36 |
+
|
| 37 |
+
$installer->endSetup();
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mailingwork_Sync</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="https://opensource.org/licenses/OSL-3.0">OSL-3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -10,9 +10,9 @@
|
|
| 10 |
<description>Plugin to connect Magento with mailingwork to use mailingwork E-Mail marketing service</description>
|
| 11 |
<notes>First Stable Extension Release</notes>
|
| 12 |
<authors><author><name>mailingwork GmbH</name><user>mailingwork</user><email>magento@mailingwork.de</email></author></authors>
|
| 13 |
-
<date>2016-09-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="mailingwork"><file name="customermap.phtml" hash="68230b8942d497d2ec55f3b2a3c36f22"/><file name="hint.phtml" hash="45ef33edd0e5e5b8a458b4f213a50924"/><file name="initialimport.phtml" hash="f6790aa1da6d12d5c2dc0400541d2ba6"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mailingwork_Sync.xml" hash="d685fac8dd99b04f24a1b2ec52e83310"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Mailingwork_Sync.csv" hash="fb2ed931c1045784f313e8858a98f5e2"/></dir><dir name="en_US"><file name="Mailingwork_Sync.csv" hash="70a91df3fa881282c6b9da35802b3766"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.24</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mailingwork_Sync</name>
|
| 4 |
+
<version>1.0.2</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="https://opensource.org/licenses/OSL-3.0">OSL-3.0</license>
|
| 7 |
<channel>community</channel>
|
| 10 |
<description>Plugin to connect Magento with mailingwork to use mailingwork E-Mail marketing service</description>
|
| 11 |
<notes>First Stable Extension Release</notes>
|
| 12 |
<authors><author><name>mailingwork GmbH</name><user>mailingwork</user><email>magento@mailingwork.de</email></author></authors>
|
| 13 |
+
<date>2016-09-23</date>
|
| 14 |
+
<time>09:32:31</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Mailingwork"><dir name="Sync"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="c9e21fbfabd0d410b687c947b9b0b7b6"/></dir><dir name="Form"><dir name="Field"><file name="Customermap.php" hash="6b88e691c02a9a6d3a9ce467b15b54b5"/></dir></dir><file name="Initialimport.php" hash="b9dbe022c8ac22f2c288feccfec4410a"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="caf4b1cb30a23e230fae5d36daaf7734"/></dir><dir name="Model"><file name="Abandonedcartcheckoutstatus.php" hash="a4ca964649271c2ff21eb8d53221fa20"/><dir name="Api"><file name="V2.php" hash="40cf1c4ac2889a5c6ca7dd82d6703192"/></dir><file name="Api.php" hash="2da24216de562cf3b910c6fe8f80f263"/><file name="InitialImport.php" hash="fb4170844dfd91bed10ad2b06c1516aa"/><file name="Logger.php" hash="be6b060fcfba407429733ae7f8907c45"/><file name="MwApi.php" hash="b0d1638d2b9a57867e13055fa0b860fa"/><file name="Observer.php" hash="0a2b250d44128c29e30292bee1a9fd47"/><dir name="Resource"><file name="Abandonedcartcheckoutstatus.php" hash="16d6b411928febdd580608d206aa4473"/><file name="Subscriber.php" hash="09e5ca2ddf30034fa6d24187fd5c8312"/></dir><file name="Subscriber.php" hash="19106dcf681a7e79d9fd6e33184f8658"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Lists.php" hash="4618675443c71dcde70bf74a0b2029f5"/><file name="Optinsetups.php" hash="364dad4012d766ca8b234dfc8ea58939"/><file name="Optoutsetups.php" hash="b93d169c55e1a54dc3640a9d02c673e4"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="InitialimportController.php" hash="f0ff66bb2a1e92825cfd92562ce28ddf"/></dir><file name="OnepageController.php" hash="ebba362f746e72a0b05180ee9cd4e346"/></dir><dir name="etc"><file name="api.xml" hash="8597a97d6160a5048483fd34f63650b8"/><file name="config.xml" hash="96b47b18663c1687c802f6b6b0a94707"/><file name="system.xml" hash="9d153db32f902f513db80514389b27cc"/><file name="wsdl.xml" hash="2cd1ececb061ba25e5e5579aff46d323"/></dir><dir name="sql"><dir name="mailingwork_sync_setup"><file name="install-1.0.1.php" hash="733c5e7f68a15a00b049e93df4226c12"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="mailingwork"><file name="customermap.phtml" hash="68230b8942d497d2ec55f3b2a3c36f22"/><file name="hint.phtml" hash="45ef33edd0e5e5b8a458b4f213a50924"/><file name="initialimport.phtml" hash="f6790aa1da6d12d5c2dc0400541d2ba6"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mailingwork_Sync.xml" hash="d685fac8dd99b04f24a1b2ec52e83310"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Mailingwork_Sync.csv" hash="fb2ed931c1045784f313e8858a98f5e2"/></dir><dir name="en_US"><file name="Mailingwork_Sync.csv" hash="70a91df3fa881282c6b9da35802b3766"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.24</max></php></required></dependencies>
|
| 18 |
</package>
|
