Version Notes
Changelog:
- "Send all fields to MailUp" configuration was removed
- "Web Service Username" configuration was added
- MagentoMailUp fields mapping feature was added
- Users' data uploading (to MailUp) process was rewritten for better performance
- When a customer logs in Magento his subscription preference is automatically downloaded from MailUp
- When a customer saves his Magento profile his subscription preference is automatically uploaded to MailUp
- Italian translation was completed
Note: you'll have to review your configuration right after updating the extension.
Download this release
Release Info
Developer | Sevenlike |
Extension | MailUp |
Version | 1.5.2 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.5.2
- app/code/local/SevenLike/MailUp/Helper/Data.php +202 -195
- app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Cron/Frequency.php +40 -0
- app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Cron/Hours.php +19 -0
- app/code/local/SevenLike/MailUp/Model/Cron.php +24 -4
- app/code/local/SevenLike/MailUp/Model/Lists.php +55 -55
- app/code/local/SevenLike/MailUp/Model/Observer.php +162 -0
- app/code/local/SevenLike/MailUp/Model/System/Source/Cron/Frequency.php +61 -0
- app/code/local/SevenLike/MailUp/Model/System/Source/Cron/Hours.php +48 -0
- app/code/local/SevenLike/MailUp/Model/Ws.php +34 -9
- app/code/local/SevenLike/MailUp/Model/Wssend.php +2 -11
- app/code/local/SevenLike/MailUp/controllers/Adminhtml/FieldsmappingController.php +25 -0
- app/code/local/SevenLike/MailUp/controllers/Adminhtml/FilterController.php +268 -292
- app/code/local/SevenLike/MailUp/etc/config.xml +154 -144
- app/code/local/SevenLike/MailUp/etc/system.xml +61 -95
- app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-1.0.0-1.5.2.php +11 -0
- app/design/adminhtml/default/default/layout/mailup.xml +10 -0
- app/design/adminhtml/default/default/template/sevenlike/mailup/confirm.phtml +3 -4
- app/design/adminhtml/default/default/template/sevenlike/mailup/fieldsmapping.phtml +52 -0
- app/design/adminhtml/default/default/template/sevenlike/mailup/filter.phtml +14 -11
- app/locale/it_IT/SevenLike_MailUp.csv +86 -73
- package.xml +17 -5
app/code/local/SevenLike/MailUp/Helper/Data.php
CHANGED
@@ -1,196 +1,203 @@
|
|
1 |
-
<?php
|
2 |
-
class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract {
|
3 |
-
|
4 |
-
public static function getCustomersData() {
|
5 |
-
Mage::log('Getting customers data', 0);
|
6 |
-
$dateFormat = 'm/d/y h:i:s';
|
7 |
-
$lastDateTime = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-7*3600*24);
|
8 |
-
$thirtyDaysAgo = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-30*3600*24);
|
9 |
-
$twelveMonthsAgo = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-365*3600*24);
|
10 |
-
|
11 |
-
$toSend = array();
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
Mage::log('Customer with id '.$currentCustomerId, 0);
|
19 |
-
$customer = Mage::getModel('customer/customer')->load($currentCustomerId);
|
20 |
-
|
21 |
-
//recupero gli ordini del cliente corrente
|
22 |
-
$
|
23 |
-
$
|
24 |
-
$
|
25 |
-
$
|
26 |
-
$
|
27 |
-
$
|
28 |
-
$
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
$
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
$
|
50 |
-
|
51 |
-
$
|
52 |
-
$
|
53 |
-
|
54 |
-
$
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$
|
106 |
-
$
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$toSend[$i]['
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
$
|
128 |
-
$
|
129 |
-
$
|
130 |
-
$toSend[$i]['
|
131 |
-
$toSend[$i]['
|
132 |
-
$
|
133 |
-
$
|
134 |
-
$
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
$
|
145 |
-
|
146 |
-
$
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
$
|
178 |
-
$toSend[$i]['
|
179 |
-
|
180 |
-
$i
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
?>
|
1 |
+
<?php
|
2 |
+
class SevenLike_MailUp_Helper_Data extends Mage_Core_Helper_Abstract {
|
3 |
+
|
4 |
+
public static function getCustomersData() {
|
5 |
+
Mage::log('Getting customers data', 0);
|
6 |
+
$dateFormat = 'm/d/y h:i:s';
|
7 |
+
$lastDateTime = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-7*3600*24);
|
8 |
+
$thirtyDaysAgo = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-30*3600*24);
|
9 |
+
$twelveMonthsAgo = date($dateFormat, Mage::getModel('core/date')->timestamp(time())-365*3600*24);
|
10 |
+
|
11 |
+
$toSend = array();
|
12 |
+
|
13 |
+
//ottengo la collection con tutti i clienti
|
14 |
+
$customerCollection = Mage::getModel('customer/customer')->getCollection();
|
15 |
+
foreach ($customerCollection as $customer) {
|
16 |
+
$currentCustomerId = $customer->getId();
|
17 |
+
$i = $customer->getEmail();
|
18 |
+
Mage::log('Customer with id '.$currentCustomerId, 0);
|
19 |
+
$customer = Mage::getModel('customer/customer')->load($currentCustomerId);
|
20 |
+
|
21 |
+
//recupero gli ordini del cliente corrente
|
22 |
+
$allOrdersTotalAmount = 0;
|
23 |
+
$allOrdersDateTimes = array();
|
24 |
+
$allOrdersTotals = array();
|
25 |
+
$allOrdersIds = array();
|
26 |
+
$allProductsIds = array();
|
27 |
+
$last30daysOrdersAmount = 0;
|
28 |
+
$last12monthsOrdersAmount = 0;
|
29 |
+
$lastShipmentOrderId = null;
|
30 |
+
$lastShipmentOrderDate = null;
|
31 |
+
|
32 |
+
Mage::log('Parsing orders of customer with id '.$currentCustomerId, 0);
|
33 |
+
$orders = Mage::getModel('sales/order')
|
34 |
+
->getCollection()
|
35 |
+
->addAttributeToFilter('customer_id', $currentCustomerId);
|
36 |
+
foreach ($orders as $order) {
|
37 |
+
$currentOrderTotal = floatval($order->getGrandTotal());
|
38 |
+
$allOrdersTotalAmount += $currentOrderTotal;
|
39 |
+
|
40 |
+
$currentOrderCreationDate = $order->getCreatedAt();
|
41 |
+
if ($currentOrderCreationDate > $thirtyDaysAgo) {
|
42 |
+
$last30daysOrdersAmount += $currentOrderTotal;
|
43 |
+
|
44 |
+
}
|
45 |
+
if ($currentOrderCreationDate > $twelveMonthsAgo) {
|
46 |
+
$last12monthsOrdersAmount += $currentOrderTotal;
|
47 |
+
}
|
48 |
+
|
49 |
+
$currentOrderTotal = self::_formatPrice($currentOrderTotal);
|
50 |
+
|
51 |
+
$currentOrderId = $order->getIncrementId();
|
52 |
+
$allOrdersTotals[$currentOrderId] = $currentOrderTotal;
|
53 |
+
$allOrdersDateTimes[$currentOrderId] = $currentOrderCreationDate;
|
54 |
+
$allOrdersIds[$currentOrderId] = $currentOrderId;
|
55 |
+
|
56 |
+
if ($order->hasShipments() and ($order->getId()>$lastShipmentOrderId)) {
|
57 |
+
$lastShipmentOrderId = $order->getId();
|
58 |
+
$lastShipmentOrderDate = self::_retriveDateFromDatetime($order->getCreatedAt());
|
59 |
+
}
|
60 |
+
|
61 |
+
$items = $order->getAllItems();
|
62 |
+
foreach ($items as $item) {
|
63 |
+
$allProductsIds[] = $item->getProductId();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
$toSend[$i]['TotaleFatturatoUltimi30gg'] = self::_formatPrice($last30daysOrdersAmount);
|
68 |
+
$toSend[$i]['TotaleFatturatoUltimi12Mesi'] = self::_formatPrice($last12monthsOrdersAmount);
|
69 |
+
$toSend[$i]['IDTuttiProdottiAcquistati'] = implode(',', $allProductsIds);
|
70 |
+
|
71 |
+
ksort($allOrdersDateTimes);
|
72 |
+
ksort($allOrdersTotals);
|
73 |
+
ksort($allOrdersIds);
|
74 |
+
|
75 |
+
//recupero i carrelli abbandonati del cliente
|
76 |
+
Mage::log('Parsing abandoned carts of customer with id '.$currentCustomerId, 0);
|
77 |
+
$cartCollection = Mage::getResourceModel('reports/quote_collection');
|
78 |
+
$cartCollection->prepareForAbandonedReport(array(1));
|
79 |
+
$cartCollection->addFieldToFilter('customer_id', $currentCustomerId);
|
80 |
+
$cartCollection->load();
|
81 |
+
|
82 |
+
$datetimeCart = null;
|
83 |
+
if (! empty($cartCollection)) {
|
84 |
+
$lastCart = end($cartCollection);
|
85 |
+
|
86 |
+
$toSend[$i]['TotaleCarrelloAbbandonato'] = '';
|
87 |
+
$toSend[$i]['DataCarrelloAbbandonato'] = '';
|
88 |
+
$toSend[$i]['IDCarrelloAbbandonato'] = '';
|
89 |
+
|
90 |
+
if (! empty($lastCart)) {
|
91 |
+
Mage::log('Customer with id '.$currentCustomerId .' has abandoned cart', 0);
|
92 |
+
$datetimeCart = $lastCart->getUpdatedAt();
|
93 |
+
$toSend[$i]['TotaleCarrelloAbbandonato'] = self::_formatPrice($lastCart->getGrandTotal());
|
94 |
+
$toSend[$i]['DataCarrelloAbbandonato'] = self::_retriveDateFromDatetime($datetimeCart);
|
95 |
+
$toSend[$i]['IDCarrelloAbbandonato'] = $lastCart->getId();
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
$toSend[$i]['IDUltimoOrdineSpedito'] = $lastShipmentOrderId;
|
100 |
+
$toSend[$i]['DataUltimoOrdineSpedito'] = $lastShipmentOrderDate;
|
101 |
+
|
102 |
+
$lastOrderDateTime = end($allOrdersDateTimes);
|
103 |
+
|
104 |
+
if ($customer->getUpdatedAt() > $lastDateTime
|
105 |
+
|| $lastOrderDateTime > $lastDateTime
|
106 |
+
|| ($datetimeCart && $datetimeCart > $lastDateTime))
|
107 |
+
{
|
108 |
+
Mage::log('Adding customer with id '.$currentCustomerId, 0);
|
109 |
+
|
110 |
+
$toSend[$i]['nome'] = $customer->getFirstname();
|
111 |
+
$toSend[$i]['cognome'] = $customer->getLastname();
|
112 |
+
$toSend[$i]['email'] = $customer->getEmail();
|
113 |
+
$toSend[$i]['IDCliente'] = $currentCustomerId;
|
114 |
+
|
115 |
+
$toSend[$i]['registeredDate'] = self::_retriveDateFromDatetime($customer->getCreatedAt());
|
116 |
+
|
117 |
+
//controllo se iscritto o meno alla newsletter
|
118 |
+
if (Mage::getModel('newsletter/subscriber')->loadByCustomer($customer)->isSubscribed()) {
|
119 |
+
$toSend[$i]['subscribed'] = 'yes';
|
120 |
+
} else {
|
121 |
+
$toSend[$i]['subscribed'] = 'no';
|
122 |
+
}
|
123 |
+
|
124 |
+
//recupero i dati dal default billing address
|
125 |
+
$customerAddressId = $customer->getDefaultBilling();
|
126 |
+
if ($customerAddressId) {
|
127 |
+
$address = Mage::getModel('customer/address')->load($customerAddressId);
|
128 |
+
$toSend[$i]['azienda'] = $address->getData('company');
|
129 |
+
$toSend[$i]['paese'] = $address->getCountry();
|
130 |
+
$toSend[$i]['città '] = $address->getData('city');
|
131 |
+
$toSend[$i]['regione'] = $address->getData('region');
|
132 |
+
$regionId = $address->getData('region_id');
|
133 |
+
$regionModel = Mage::getModel('directory/region')->load($regionId);
|
134 |
+
$regionCode = $regionModel->getCode();
|
135 |
+
$toSend[$i]['provincia'] = $regionCode;
|
136 |
+
$toSend[$i]['cap'] = $address->getData('postcode');
|
137 |
+
$toSend[$i]['indirizzo'] = $address->getData('street');
|
138 |
+
$toSend[$i]['fax'] = $address->getData('fax');
|
139 |
+
$toSend[$i]['telefono'] = $address->getData('telephone');
|
140 |
+
}
|
141 |
+
|
142 |
+
$toSend[$i]['DataUltimoOrdine'] = self::_retriveDateFromDatetime($lastOrderDateTime);
|
143 |
+
$toSend[$i]['TotaleUltimoOrdine'] = end($allOrdersTotals);
|
144 |
+
$toSend[$i]['IDUltimoOrdine'] = end($allOrdersIds);
|
145 |
+
|
146 |
+
$toSend[$i]['TotaleFatturato'] = self::_formatPrice($allOrdersTotalAmount);
|
147 |
+
|
148 |
+
//ottengo gli id di prodotti e categorie (dell'ultimo ordine)
|
149 |
+
$lastOrder = Mage::getModel('sales/order')->loadByIncrementId(end($allOrdersIds));
|
150 |
+
$items = $lastOrder->getAllItems();
|
151 |
+
$productIds = array();
|
152 |
+
$categoryIds = array();
|
153 |
+
foreach ($items as $item) {
|
154 |
+
$productId = $item->getProductId();
|
155 |
+
$productIds[] = $productId;
|
156 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
157 |
+
if ($product->getCategoryIds()) {
|
158 |
+
$categoryIds[] = implode(',', $product->getCategoryIds());
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
$toSend[$i]['IDProdottiUltimoOrdine'] = implode(',', $productIds);
|
163 |
+
$toSend[$i]['IDCategorieUltimoOrdine'] = implode(',', $categoryIds);
|
164 |
+
}
|
165 |
+
|
166 |
+
//unsetto la variabile
|
167 |
+
unset($customer);
|
168 |
+
}
|
169 |
+
|
170 |
+
Mage::log('Parsing subscribers', 0);
|
171 |
+
$subscriberCollection = Mage::getModel('newsletter/subscriber')
|
172 |
+
->getCollection()
|
173 |
+
->useOnlySubscribed()
|
174 |
+
->addFieldToFilter('customer_id', 0);
|
175 |
+
|
176 |
+
foreach ($subscriberCollection as $subscriber) {
|
177 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->load($subscriber->getId());
|
178 |
+
$toSend[$i]['nome'] = '';
|
179 |
+
$toSend[$i]['cognome'] = '';
|
180 |
+
$toSend[$i]['email'] = $subscriber->getEmail();
|
181 |
+
$toSend[$i]['subscribed'] = 'yes';
|
182 |
+
|
183 |
+
$i++;
|
184 |
+
}
|
185 |
+
|
186 |
+
Mage::log('End getting customers data', 0);
|
187 |
+
|
188 |
+
return $toSend;
|
189 |
+
}
|
190 |
+
|
191 |
+
private static function _formatPrice($price) {
|
192 |
+
return number_format($price, 2, ',', '');
|
193 |
+
}
|
194 |
+
|
195 |
+
private static function _retriveDateFromDatetime($datetime) {
|
196 |
+
if ($datetime && !empty($datetime)) {
|
197 |
+
$exploded = explode(' ', $datetime);
|
198 |
+
return $exploded[0];
|
199 |
+
}
|
200 |
+
return '';
|
201 |
+
}
|
202 |
+
}
|
203 |
?>
|
app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Cron/Frequency.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency
|
4 |
+
{
|
5 |
+
const HOURLY = 0;
|
6 |
+
const DAILY = 1;
|
7 |
+
const WEEKLY = 2;
|
8 |
+
const MONTHLY = 3;
|
9 |
+
const EVERY_MINUTE = 4;
|
10 |
+
const EVERY_2_HOURS = 5;
|
11 |
+
const EVERY_6_HOURS = 6;
|
12 |
+
const EVERY_12_HOURS = 7;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Fetch options array
|
16 |
+
*
|
17 |
+
* @return array
|
18 |
+
*/
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
+
return array(
|
22 |
+
array(
|
23 |
+
'label' => 'Hourly',
|
24 |
+
'value' => self::HOURLY),
|
25 |
+
array(
|
26 |
+
'label' => 'Every 2 Hours',
|
27 |
+
'value' => self::EVERY_2_HOURS),
|
28 |
+
array(
|
29 |
+
'label' => 'Every 6 hours',
|
30 |
+
'value' => self::EVERY_6_HOURS),
|
31 |
+
array(
|
32 |
+
'label' => 'Every 12 hours',
|
33 |
+
'value' => self::EVERY_12_HOURS),
|
34 |
+
array(
|
35 |
+
'label' => 'Daily',
|
36 |
+
'value' => self::DAILY),
|
37 |
+
|
38 |
+
);
|
39 |
+
}
|
40 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Adminhtml/System/Source/Cron/Hours.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Hours
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Fetch options array
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function toOptionArray()
|
12 |
+
{
|
13 |
+
$hours = array();
|
14 |
+
for ($i = 1; $i <= 24; $i++) {
|
15 |
+
$hours[] = array('label' => $i, 'value' => $i);
|
16 |
+
}
|
17 |
+
return $hours;
|
18 |
+
}
|
19 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Cron.php
CHANGED
@@ -6,16 +6,36 @@ class SevenLike_MailUp_Model_Cron {
|
|
6 |
public function run() {
|
7 |
//echo 'lanciato';
|
8 |
Mage::log('Cron mailup', 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
if (Mage::getStoreConfig('newsletter/mailup/enable_cron_export') == 1) {
|
10 |
Mage::log('Cron export enabled', 0);
|
11 |
-
|
12 |
$MailUpWsImport = Mage::getModel('mailup/ws');
|
13 |
$wsImport = new MailUpWsImport();
|
14 |
-
|
15 |
require_once(dirname(__FILE__) . '/../Helper/Data.php');
|
16 |
self::saveToCsv(SevenLike_MailUp_Helper_Data::getCustomersData());
|
17 |
} else {
|
18 |
-
Mage::log('Cron export enabled', 0);
|
19 |
}
|
20 |
|
21 |
Mage::log('Cron mailup terminato', 0);
|
@@ -34,6 +54,6 @@ class SevenLike_MailUp_Model_Cron {
|
|
34 |
$csv = fopen(Mage::getBaseDir('media').'/slMailupSubscribers.csv', 'w');
|
35 |
fwrite($csv, $file);
|
36 |
fclose($csv);
|
37 |
-
}
|
38 |
|
39 |
}
|
6 |
public function run() {
|
7 |
//echo 'lanciato';
|
8 |
Mage::log('Cron mailup', 0);
|
9 |
+
|
10 |
+
if (Mage::getStoreConfig('newsletter/mailup/enable_cron_export') == 1) {
|
11 |
+
Mage::log('Cron export enabled', 0);
|
12 |
+
|
13 |
+
require_once(dirname(__FILE__) . '/../Helper/Data.php');
|
14 |
+
self::saveToCsv(SevenLike_MailUp_Helper_Data::getCustomersData());
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
} else {
|
19 |
+
Mage::log('Cron export not enabled', 0);
|
20 |
+
}
|
21 |
+
|
22 |
+
Mage::log('Cron mailup terminato', 0);
|
23 |
+
}
|
24 |
+
|
25 |
+
/*
|
26 |
+
public function oldRun() {
|
27 |
+
//echo 'lanciato';
|
28 |
+
Mage::log('Cron mailup', 0);
|
29 |
if (Mage::getStoreConfig('newsletter/mailup/enable_cron_export') == 1) {
|
30 |
Mage::log('Cron export enabled', 0);
|
31 |
+
|
32 |
$MailUpWsImport = Mage::getModel('mailup/ws');
|
33 |
$wsImport = new MailUpWsImport();
|
34 |
+
|
35 |
require_once(dirname(__FILE__) . '/../Helper/Data.php');
|
36 |
self::saveToCsv(SevenLike_MailUp_Helper_Data::getCustomersData());
|
37 |
} else {
|
38 |
+
Mage::log('Cron export not enabled', 0);
|
39 |
}
|
40 |
|
41 |
Mage::log('Cron mailup terminato', 0);
|
54 |
$csv = fopen(Mage::getBaseDir('media').'/slMailupSubscribers.csv', 'w');
|
55 |
fwrite($csv, $file);
|
56 |
fclose($csv);
|
57 |
+
} */
|
58 |
|
59 |
}
|
app/code/local/SevenLike/MailUp/Model/Lists.php
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class SevenLike_MailUp_Model_Lists {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Options getter
|
7 |
-
*
|
8 |
-
* @return array
|
9 |
-
*/
|
10 |
-
public function toOptionArray() {
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
$
|
16 |
-
$
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
$
|
21 |
-
|
22 |
-
|
23 |
-
$
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
return $selectLists;
|
53 |
-
}
|
54 |
-
|
55 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SevenLike_MailUp_Model_Lists {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Options getter
|
7 |
+
*
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function toOptionArray() {
|
11 |
+
//genero la select per Magento
|
12 |
+
$selectLists = array();
|
13 |
+
|
14 |
+
if (Mage::getStoreConfig('newsletter/mailup/url_console') && Mage::getStoreConfig('newsletter/mailup/username_ws') && Mage::getStoreConfig('newsletter/mailup/password_ws')) {
|
15 |
+
$MailUpWsSend = Mage::getModel('mailup/wssend');
|
16 |
+
$wsSend = new MailUpWsSend();
|
17 |
+
$accessKey = $wsSend->loginFromId();
|
18 |
+
|
19 |
+
if ($accessKey !== false) {
|
20 |
+
$MailUpWsImport = Mage::getModel('mailup/ws');
|
21 |
+
$wsImport = new MailUpWsImport();
|
22 |
+
|
23 |
+
$xmlString = $wsImport->GetNlList();
|
24 |
+
|
25 |
+
$selectLists[0] = array('value' => 0, 'label'=>'-- Select a list (if any) --');
|
26 |
+
|
27 |
+
if ($xmlString) {
|
28 |
+
$xmlString = html_entity_decode($xmlString);
|
29 |
+
|
30 |
+
$startLists = strpos($xmlString, '<Lists>');
|
31 |
+
$endPos = strpos($xmlString, '</Lists>');
|
32 |
+
$endLists = $endPos + strlen('</Lists>') - $startLists;
|
33 |
+
|
34 |
+
$xmlLists = substr($xmlString, $startLists, $endLists);
|
35 |
+
|
36 |
+
$xmlLists = str_replace("&", "&", $xmlLists);
|
37 |
+
|
38 |
+
$xml = simplexml_load_string($xmlLists);
|
39 |
+
|
40 |
+
$count = 1;
|
41 |
+
foreach ($xml->List as $list) {
|
42 |
+
$selectLists[$count] = array('value' => $list['idList'], 'label'=> $list['listName']);
|
43 |
+
$count++;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
} else {
|
47 |
+
Mage::log('LoginFromId failed', 0);
|
48 |
+
$selectLists[0] = array('value' => 0, 'label'=>'-- Error, please check your configuration --');
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
return $selectLists;
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Observer.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SevenLike_MailUp_Model_Observer
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Save system config event
|
7 |
+
*
|
8 |
+
* @param Varien_Object $observer
|
9 |
+
*/
|
10 |
+
public function saveSystemConfig($observer)
|
11 |
+
{
|
12 |
+
$store = $observer->getStore();
|
13 |
+
$website = $observer->getWebsite();
|
14 |
+
$groups['settings']['fields']['cron_schedule']['value'] = $this->_getSchedule();
|
15 |
+
|
16 |
+
Mage::getModel('adminhtml/config_data')
|
17 |
+
->setSection('feed')
|
18 |
+
->setWebsite($website)
|
19 |
+
->setStore($store)
|
20 |
+
->setGroups($groups)
|
21 |
+
->save();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Transform system settings option to cron schedule string
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
protected function _getSchedule()
|
30 |
+
{
|
31 |
+
$data = Mage::app()->getRequest()->getPost('groups');
|
32 |
+
|
33 |
+
$frequency = !empty($data['settings']['fields']['mailup_cron_frequency']['value'])?
|
34 |
+
$data['settings']['fields']['mailup_cron_frequency']['value']:
|
35 |
+
0;
|
36 |
+
|
37 |
+
$hours = !empty($data['settings']['fields']['mailup_cron_hours']['value'])?
|
38 |
+
$data['settings']['fields']['mailup_cron_hours']['value']:
|
39 |
+
0;
|
40 |
+
|
41 |
+
$schedule = "0 $hours ";
|
42 |
+
|
43 |
+
switch ($frequency) {
|
44 |
+
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::DAILY:
|
45 |
+
$schedule .= "* * *";
|
46 |
+
break;
|
47 |
+
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::WEEKLY:
|
48 |
+
$schedule .= "* * 1";
|
49 |
+
break;
|
50 |
+
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::MONTHLY:
|
51 |
+
$schedule .= "1 * *";
|
52 |
+
break;
|
53 |
+
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_MINUTE:
|
54 |
+
$schedule = "0-59 * * * *";
|
55 |
+
break;
|
56 |
+
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::HOURLY:
|
57 |
+
$schedule = "* 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * *";
|
58 |
+
break;
|
59 |
+
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_2_HOURS:
|
60 |
+
$schedule = "* 0,2,4,6,8,10,12,14,16,18,20,22 * * *";
|
61 |
+
break;
|
62 |
+
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_6_HOURS:
|
63 |
+
$schedule = "* 0,6,12,18 * * * *";
|
64 |
+
break;
|
65 |
+
case SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_12_HOURS:
|
66 |
+
$schedule = "* 0,12 * * *";
|
67 |
+
break;
|
68 |
+
default:
|
69 |
+
$schedule .= "* */1 *";
|
70 |
+
break;
|
71 |
+
}
|
72 |
+
|
73 |
+
return $schedule;
|
74 |
+
}
|
75 |
+
|
76 |
+
public function leggiUtente($observer)
|
77 |
+
{
|
78 |
+
$model = $observer->getEvent()->getModel();
|
79 |
+
|
80 |
+
$WSDLUrl = 'http://services.mailupnet.it/MailupReport.asmx?WSDL';
|
81 |
+
$user = Mage::getStoreConfig('newsletter/mailup/username_ws');
|
82 |
+
$password = Mage::getStoreConfig('newsletter/mailup/password_ws');
|
83 |
+
$headers = array('User' => $user, 'Password' => $password);
|
84 |
+
$header = new SOAPHeader($this->ns, 'Authentication', $headers);
|
85 |
+
$soapclient = new SoapClient($WSDLUrl, array('trace' => 1, 'exceptions' => 0));
|
86 |
+
$soapclient->__setSoapHeaders($this->header);
|
87 |
+
|
88 |
+
$loginData = array ('user' => Mage::getStoreConfig('newsletter/mailup/username_ws'),
|
89 |
+
'pwd' => Mage::getStoreConfig('newsletter/mailup/password_ws'),
|
90 |
+
'consoleId' => substr(Mage::getStoreConfig('newsletter/mailup/username_ws'), 1));
|
91 |
+
$result = get_object_vars($soapclient->LoginFromId($loginData));
|
92 |
+
$xml = simplexml_load_string($result['LoginFromIdResult']);
|
93 |
+
$errorCode = $xml->errorCode->__toString();
|
94 |
+
$errorDescription = $xml->errorDescription->__toString();
|
95 |
+
$accessKey = $xml->accessKey->__toString();
|
96 |
+
|
97 |
+
$result = $soapclient->ReportByUser(array(
|
98 |
+
"accessKey" => $accessKey,
|
99 |
+
"email" => $model->getEmail(),
|
100 |
+
"listID" => Mage::getStoreConfig('newsletter/mailup/list'),
|
101 |
+
"messageID" => 0
|
102 |
+
));
|
103 |
+
$result = get_object_vars($result);
|
104 |
+
$xml = simplexml_load_string($result['ReportByUserResult']);
|
105 |
+
|
106 |
+
$stato_registrazione = (string)$xml->Canali->Email;
|
107 |
+
if ($stato_registrazione) {
|
108 |
+
if ($stato_registrazione == "Iscritto") {
|
109 |
+
Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)->save();
|
110 |
+
} else {
|
111 |
+
Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)->save();
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
|
118 |
+
public function inviaUtente($observer)
|
119 |
+
{
|
120 |
+
$model = $observer->getEvent()->getDataObject();
|
121 |
+
$status = Mage::getModel('newsletter/subscriber')->loadByEmail($model->getEmail())->getStatus();
|
122 |
+
|
123 |
+
$console = Mage::getStoreConfig('newsletter/mailup/url_console');
|
124 |
+
$listId = Mage::getStoreConfig('newsletter/mailup/list');
|
125 |
+
|
126 |
+
if(!class_exists(MailUpWsImport)) $MailUpWsImport = Mage::getModel('mailup/ws');
|
127 |
+
$wsImport = new MailUpWsImport();
|
128 |
+
$xmlString = $wsImport->GetNlList();
|
129 |
+
if (!$xmlString) return $this;
|
130 |
+
|
131 |
+
$xmlString = html_entity_decode($xmlString);
|
132 |
+
$startLists = strpos($xmlString, '<Lists>');
|
133 |
+
$endPos = strpos($xmlString, '</Lists>');
|
134 |
+
$endLists = $endPos + strlen('</Lists>') - $startLists;
|
135 |
+
$xmlLists = substr($xmlString, $startLists, $endLists);
|
136 |
+
$xmlLists = str_replace("&", "&", $xmlLists);
|
137 |
+
$xml = simplexml_load_string($xmlLists);
|
138 |
+
|
139 |
+
foreach ($xml->List as $list) {
|
140 |
+
if ($list['idList'] == $listId) {
|
141 |
+
$listGUID = $list["listGUID"];
|
142 |
+
break;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
if ($status == 1) {
|
147 |
+
$ws = "http://{$console}/frontend/Xmlsubscribe.aspx";
|
148 |
+
} else {
|
149 |
+
$ws = "http://{$console}/frontend/Xmlunsubscribe.aspx";
|
150 |
+
}
|
151 |
+
|
152 |
+
$ws .= "?ListGuid=" . rawurlencode($listGUID);
|
153 |
+
$ws .= "&List=" . rawurlencode($listId);
|
154 |
+
$ws .= "&Email=" . rawurlencode($model->getEmail());
|
155 |
+
|
156 |
+
try {
|
157 |
+
$result = @file_get_contents($ws);
|
158 |
+
} catch (Exception $e) {}
|
159 |
+
|
160 |
+
return $this;
|
161 |
+
}
|
162 |
+
}
|
app/code/local/SevenLike/MailUp/Model/System/Source/Cron/Frequency.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Commercial Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Commercial Edition License
|
8 |
+
* that is available at: http://www.magentocommerce.com/license/commercial-edition
|
9 |
+
* If you did not receive a copy of the license and are unable to
|
10 |
+
* obtain it through the world-wide-web, please send an email
|
11 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
12 |
+
*
|
13 |
+
* DISCLAIMER
|
14 |
+
*
|
15 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
16 |
+
* versions in the future. If you wish to customize Magento for your
|
17 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
18 |
+
*
|
19 |
+
* @category
|
20 |
+
* @package _storage
|
21 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
22 |
+
* @license http://www.magentocommerce.com/license/commercial-edition
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Source for cron frequency
|
28 |
+
*
|
29 |
+
* @category Find
|
30 |
+
* @package Find_Feed
|
31 |
+
*/
|
32 |
+
class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Frequency
|
33 |
+
{
|
34 |
+
const DAILY = 1;
|
35 |
+
const WEEKLY = 2;
|
36 |
+
const MONTHLY = 3;
|
37 |
+
const EVERY_MINUTE = 4;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Fetch options array
|
41 |
+
*
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function toOptionArray()
|
45 |
+
{
|
46 |
+
return array(
|
47 |
+
array(
|
48 |
+
'label' => 'Daily',
|
49 |
+
'value' => self::DAILY),
|
50 |
+
array(
|
51 |
+
'label' => 'Weekly',
|
52 |
+
'value' => self::WEEKLY),
|
53 |
+
array(
|
54 |
+
'label' => 'Monthly',
|
55 |
+
'value' => self::MONTHLY),
|
56 |
+
array(
|
57 |
+
'label' => 'Every minute',
|
58 |
+
'value' => self::EVERY_MINUTE)
|
59 |
+
);
|
60 |
+
}
|
61 |
+
}
|
app/code/local/SevenLike/MailUp/Model/System/Source/Cron/Hours.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Commercial Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Commercial Edition License
|
8 |
+
* that is available at: http://www.magentocommerce.com/license/commercial-edition
|
9 |
+
* If you did not receive a copy of the license and are unable to
|
10 |
+
* obtain it through the world-wide-web, please send an email
|
11 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
12 |
+
*
|
13 |
+
* DISCLAIMER
|
14 |
+
*
|
15 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
16 |
+
* versions in the future. If you wish to customize Magento for your
|
17 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
18 |
+
*
|
19 |
+
* @category
|
20 |
+
* @package _storage
|
21 |
+
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
|
22 |
+
* @license http://www.magentocommerce.com/license/commercial-edition
|
23 |
+
*/
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Source for cron hours
|
28 |
+
*
|
29 |
+
* @category Find
|
30 |
+
* @package Find_Feed
|
31 |
+
*/
|
32 |
+
class SevenLike_MailUp_Model_Adminhtml_System_Source_Cron_Hours
|
33 |
+
{
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Fetch options array
|
37 |
+
*
|
38 |
+
* @return array
|
39 |
+
*/
|
40 |
+
public function toOptionArray()
|
41 |
+
{
|
42 |
+
$hours = array();
|
43 |
+
for ($i = 1; $i <= 24; $i++) {
|
44 |
+
$hours[] = array('label' => $i, 'value' => $i);
|
45 |
+
}
|
46 |
+
return $hours;
|
47 |
+
}
|
48 |
+
}
|
app/code/local/SevenLike/MailUp/Model/Ws.php
CHANGED
@@ -15,8 +15,8 @@ class MailUpWsImport {
|
|
15 |
function __construct() {
|
16 |
$urlConsole = Mage::getStoreConfig('newsletter/mailup/url_console');
|
17 |
$WSDLUrl = 'http://'. $urlConsole .'/services/WSMailUpImport.asmx?WSDL';
|
18 |
-
$user = Mage::getStoreConfig('newsletter/mailup/
|
19 |
-
$password = Mage::getStoreConfig('newsletter/mailup/
|
20 |
$headers = array('User' => $user, 'Password' => $password);
|
21 |
$this->header = new SOAPHeader($this->ns, 'Authentication', $headers);
|
22 |
$this->soapClient = new SoapClient($WSDLUrl, array('trace' => 1, 'exceptions' => 0));
|
@@ -36,7 +36,7 @@ class MailUpWsImport {
|
|
36 |
$this->soapClient->CreateGroup($newGroup);
|
37 |
$this-> printLastRequest();
|
38 |
$this->printLastResponse();
|
39 |
-
return $this->readReturnCode
|
40 |
} catch (SoapFault $soapFault) {
|
41 |
Mage::log('SOAP error', 0);
|
42 |
Mage::log($soapFault, 0);
|
@@ -557,7 +557,6 @@ class MailUpWsImport {
|
|
557 |
public function saveFilterHint($filter_name, $post) {
|
558 |
try {
|
559 |
$hints = '';
|
560 |
-
//TODO: concateno le coppie filtri-valori selezionati in post
|
561 |
foreach ($post as $k => $v) {
|
562 |
if ($v!='' && $k!='form_key') {
|
563 |
if ($hints!='') {
|
@@ -566,12 +565,10 @@ class MailUpWsImport {
|
|
566 |
$hints .= $k.'='.$v;
|
567 |
}
|
568 |
}
|
569 |
-
|
570 |
|
571 |
-
// fetch write database connection that is used in Mage_Core module
|
572 |
$connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
|
573 |
|
574 |
-
// now $write is an instance of Zend_Db_Adapter_Abstract
|
575 |
$connectionWrite->query("INSERT INTO mailup_filter_hints (filter_name, hints) VALUES ('".$filter_name."', '".$hints."')");
|
576 |
} catch (Exception $e) {
|
577 |
Mage::log('Exception: '.$e->getMessage(), 0);
|
@@ -581,14 +578,42 @@ class MailUpWsImport {
|
|
581 |
|
582 |
public function deleteFilterHint($filter_name) {
|
583 |
try {
|
584 |
-
// fetch write database connection that is used in Mage_Core module
|
585 |
$connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
|
586 |
|
587 |
-
// now $write is an instance of Zend_Db_Adapter_Abstract
|
588 |
$connectionWrite->query("DELETE FROM mailup_filter_hints WHERE filter_name LIKE '".$filter_name."'");
|
589 |
} catch (Exception $e) {
|
590 |
Mage::log('Exception: '.$e->getMessage(), 0);
|
591 |
die($e);
|
592 |
}
|
593 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
}
|
15 |
function __construct() {
|
16 |
$urlConsole = Mage::getStoreConfig('newsletter/mailup/url_console');
|
17 |
$WSDLUrl = 'http://'. $urlConsole .'/services/WSMailUpImport.asmx?WSDL';
|
18 |
+
$user = Mage::getStoreConfig('newsletter/mailup/username_ws');
|
19 |
+
$password = Mage::getStoreConfig('newsletter/mailup/password_ws');
|
20 |
$headers = array('User' => $user, 'Password' => $password);
|
21 |
$this->header = new SOAPHeader($this->ns, 'Authentication', $headers);
|
22 |
$this->soapClient = new SoapClient($WSDLUrl, array('trace' => 1, 'exceptions' => 0));
|
36 |
$this->soapClient->CreateGroup($newGroup);
|
37 |
$this-> printLastRequest();
|
38 |
$this->printLastResponse();
|
39 |
+
return $this->readReturnCode('CreateGroup', 'ReturnCode');
|
40 |
} catch (SoapFault $soapFault) {
|
41 |
Mage::log('SOAP error', 0);
|
42 |
Mage::log($soapFault, 0);
|
557 |
public function saveFilterHint($filter_name, $post) {
|
558 |
try {
|
559 |
$hints = '';
|
|
|
560 |
foreach ($post as $k => $v) {
|
561 |
if ($v!='' && $k!='form_key') {
|
562 |
if ($hints!='') {
|
565 |
$hints .= $k.'='.$v;
|
566 |
}
|
567 |
}
|
568 |
+
//(e.g. $hints = 'mailupCustomers=2|mailupSubscribed=1';)
|
569 |
|
|
|
570 |
$connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
|
571 |
|
|
|
572 |
$connectionWrite->query("INSERT INTO mailup_filter_hints (filter_name, hints) VALUES ('".$filter_name."', '".$hints."')");
|
573 |
} catch (Exception $e) {
|
574 |
Mage::log('Exception: '.$e->getMessage(), 0);
|
578 |
|
579 |
public function deleteFilterHint($filter_name) {
|
580 |
try {
|
|
|
581 |
$connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
|
582 |
|
|
|
583 |
$connectionWrite->query("DELETE FROM mailup_filter_hints WHERE filter_name LIKE '".$filter_name."'");
|
584 |
} catch (Exception $e) {
|
585 |
Mage::log('Exception: '.$e->getMessage(), 0);
|
586 |
die($e);
|
587 |
}
|
588 |
}
|
589 |
+
|
590 |
+
public function getFieldsMapping() {
|
591 |
+
$fieldsMappings = array();
|
592 |
+
try {
|
593 |
+
$connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
|
594 |
+
return $connectionRead->fetchPairs("select magento_field_name, mailup_field_id from mailup_fields_mapping");
|
595 |
+
} catch (Exception $e) {
|
596 |
+
Mage::log('Exception: '.$e->getMessage(), 0);
|
597 |
+
die($e);
|
598 |
+
}
|
599 |
+
|
600 |
+
return $fieldsMappings;
|
601 |
+
}
|
602 |
+
|
603 |
+
public function saveFieldMapping($post) {
|
604 |
+
try {
|
605 |
+
$connectionWrite = Mage::getSingleton('core/resource')->getConnection('core_write');
|
606 |
+
$connectionWrite->query("DELETE FROM mailup_fields_mapping");
|
607 |
+
foreach ($post as $k => $v) {
|
608 |
+
if (strlen($v) == 0) continue;
|
609 |
+
$connectionWrite->insert("mailup_fields_mapping", array(
|
610 |
+
"magento_field_name" => $k,
|
611 |
+
"mailup_field_id" => $v
|
612 |
+
));
|
613 |
+
}
|
614 |
+
} catch (Exception $e) {
|
615 |
+
Mage::log('Exception: '.$e->getMessage(), 0);
|
616 |
+
die($e);
|
617 |
+
}
|
618 |
+
}
|
619 |
}
|
app/code/local/SevenLike/MailUp/Model/Wssend.php
CHANGED
@@ -37,17 +37,10 @@ class MailUpWsSend {
|
|
37 |
*/
|
38 |
public function loginFromId() {
|
39 |
try {
|
40 |
-
//TODO: selezionare i dati di login opportuni
|
41 |
-
|
42 |
-
//login with web user
|
43 |
-
$loginData = array ('user' => Mage::getStoreConfig('newsletter/mailup/user'),
|
44 |
-
'pwd' => Mage::getStoreConfig('newsletter/mailup/password'),
|
45 |
-
'consoleId' => Mage::getStoreConfig('newsletter/mailup/id_console'));
|
46 |
-
|
47 |
//login with webservice user
|
48 |
-
$loginData = array ('user' =>
|
49 |
'pwd' => Mage::getStoreConfig('newsletter/mailup/password_ws'),
|
50 |
-
'consoleId' => Mage::getStoreConfig('newsletter/mailup/
|
51 |
|
52 |
$result = get_object_vars($this->soapClient->LoginFromId($loginData));
|
53 |
$xml = simplexml_load_string($result['LoginFromIdResult']);
|
@@ -70,7 +63,6 @@ class MailUpWsSend {
|
|
70 |
}
|
71 |
}
|
72 |
|
73 |
-
|
74 |
public function GetFields($accessKey) {
|
75 |
$fields = null;
|
76 |
|
@@ -101,7 +93,6 @@ class MailUpWsSend {
|
|
101 |
if ($xmlSimpleElement->Fields && sizeof($xmlSimpleElement->Fields->Field) > 0) {
|
102 |
Mage::log('Fields returned, overwriting default configuration', 0);
|
103 |
foreach ($xmlSimpleElement->Fields->Field as $fieldSimpleElement) {
|
104 |
-
//Mage::log($fieldSimpleElement['Name'] . ''. $fieldSimpleElement['Id'], 0);
|
105 |
$fields[$fieldSimpleElement['Name']->__toString()] = $fieldSimpleElement['Id']->__toString();
|
106 |
}
|
107 |
}
|
37 |
*/
|
38 |
public function loginFromId() {
|
39 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
//login with webservice user
|
41 |
+
$loginData = array ('user' => Mage::getStoreConfig('newsletter/mailup/username_ws'),
|
42 |
'pwd' => Mage::getStoreConfig('newsletter/mailup/password_ws'),
|
43 |
+
'consoleId' => substr(Mage::getStoreConfig('newsletter/mailup/username_ws'), 1));
|
44 |
|
45 |
$result = get_object_vars($this->soapClient->LoginFromId($loginData));
|
46 |
$xml = simplexml_load_string($result['LoginFromIdResult']);
|
63 |
}
|
64 |
}
|
65 |
|
|
|
66 |
public function GetFields($accessKey) {
|
67 |
$fields = null;
|
68 |
|
93 |
if ($xmlSimpleElement->Fields && sizeof($xmlSimpleElement->Fields->Field) > 0) {
|
94 |
Mage::log('Fields returned, overwriting default configuration', 0);
|
95 |
foreach ($xmlSimpleElement->Fields->Field as $fieldSimpleElement) {
|
|
|
96 |
$fields[$fieldSimpleElement['Name']->__toString()] = $fieldSimpleElement['Id']->__toString();
|
97 |
}
|
98 |
}
|
app/code/local/SevenLike/MailUp/controllers/Adminhtml/FieldsmappingController.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SevenLike_MailUp_Adminhtml_FieldsMappingController extends Mage_Adminhtml_Controller_Action {
|
4 |
+
|
5 |
+
public function indexAction() {
|
6 |
+
$this->loadLayout()->renderLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function saveAction() {
|
10 |
+
try {
|
11 |
+
$post = $this->getRequest()->getPost();
|
12 |
+
unset($post["form_key"]);
|
13 |
+
$MailUpWsImport = Mage::getModel('mailup/ws');
|
14 |
+
$wsImport = new MailUpWsImport();
|
15 |
+
$wsImport->saveFieldMapping($post);
|
16 |
+
} catch (Exception $e) {
|
17 |
+
$errorMessage = $this->__('Error: unable to save current filter');
|
18 |
+
Mage::getSingleton('adminhtml/session')->addError($errorMessage);
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->_redirect('*/*');
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
?>
|
app/code/local/SevenLike/MailUp/controllers/Adminhtml/FilterController.php
CHANGED
@@ -1,292 +1,268 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Controller_Action {
|
4 |
-
|
5 |
-
public function indexAction() {
|
6 |
-
$this->loadLayout()->renderLayout();
|
7 |
-
}
|
8 |
-
|
9 |
-
public function confirmAction() {
|
10 |
-
$this->loadLayout()->renderLayout();
|
11 |
-
}
|
12 |
-
|
13 |
-
public function csvAction() {
|
14 |
-
$post = $this->getRequest()->getPost();
|
15 |
-
$file = '';
|
16 |
-
|
17 |
-
if ($post['countPost'] > 0) {
|
18 |
-
//preparo l'elenco degli iscritti da salvare nel csv
|
19 |
-
$mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
|
20 |
-
|
21 |
-
//require_once(dirname(__FILE__) . '/../Helper/Data.php');
|
22 |
-
$customersData = SevenLike_MailUp_Helper_Data::getCustomersData();
|
23 |
-
|
24 |
-
//CSV Column names
|
25 |
-
$file = '"Email","First Name","Last Name"';
|
26 |
-
if (Mage::getStoreConfig('newsletter/mailup/enable_mailup_synchro') == 1) {
|
27 |
-
$file .= ',"Company","City","Province","Zip code","Region","Country code","Address","Fax","Phone","Customer id"';
|
28 |
-
$file .= ',"Last Order id","Last Order date","Last Order total","Last order product ids","Last order category ids"';
|
29 |
-
$file .= ',"Last sent order date","Last sent order id"';
|
30 |
-
$file .= ',"Last abandoned cart date","Last abandoned cart total","Last abandoned cart id"';
|
31 |
-
$file .= ',"Total orders amount","Last 12 months amount","Last 30 days amount","All products ids"';
|
32 |
-
}
|
33 |
-
$file .= ';';
|
34 |
-
|
35 |
-
|
36 |
-
foreach ($mailupCustomerIds as $customerId) {
|
37 |
-
foreach ($customersData as $subscriber) {
|
38 |
-
if ($subscriber['email'] == $customerId['email']) {
|
39 |
-
$file .= "\n";
|
40 |
-
$file .= '"'.$subscriber['email'].'"';
|
41 |
-
$file .= ',"'.((!empty($subscriber['nome'])) ? $subscriber['nome'] : '') .'"';
|
42 |
-
$file .= ',"'.((!empty($subscriber['cognome'])) ? $subscriber['cognome'] : '') .'"';
|
43 |
-
|
44 |
-
$synchroConfig = Mage::getStoreConfig('newsletter/mailup/enable_mailup_synchro') == 1;
|
45 |
-
|
46 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['azienda'])) ? $subscriber['azienda'] : '') .'"';
|
47 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['città '])) ? $subscriber['città '] : '') .'"';
|
48 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['provincia'])) ? $subscriber['provincia'] : '') .'"';
|
49 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['cap'])) ? $subscriber['cap'] : '') .'"';
|
50 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['regione'])) ? $subscriber['regione'] : '') .'"';
|
51 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['paese'])) ? $subscriber['paese'] : '') .'"';
|
52 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['indirizzo'])) ? $subscriber['indirizzo'] : '') .'"';
|
53 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['fax'])) ? $subscriber['fax'] : '') .'"';
|
54 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['telefono'])) ? $subscriber['telefono'] : '') .'"';
|
55 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCliente'])) ? $subscriber['IDCliente'] : '') .'"';
|
56 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDUltimoOrdine'])) ? $subscriber['IDUltimoOrdine'] : '') .'"';
|
57 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['DataUltimoOrdine'])) ? $subscriber['DataUltimoOrdine'] : '') .'"';
|
58 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleUltimoOrdine'])) ? $subscriber['TotaleUltimoOrdine'] : '') .'"';
|
59 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDProdottiUltimoOrdine'])) ? $subscriber['IDProdottiUltimoOrdine'] : '') .'"';
|
60 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCategorieUltimoOrdine'])) ? $subscriber['IDCategorieUltimoOrdine'] : '') .'"';
|
61 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['DataUltimoOrdineSpedito'])) ? $subscriber['DataUltimoOrdineSpedito'] : '') .'"';
|
62 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDUltimoOrdineSpedito'])) ? $subscriber['IDUltimoOrdineSpedito'] : '') .'"';
|
63 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['DataCarrelloAbbandonato'])) ? $subscriber['DataCarrelloAbbandonato'] : '') .'"';
|
64 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleCarrelloAbbandonato'])) ? $subscriber['TotaleCarrelloAbbandonato'] : '') .'"';
|
65 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCarrelloAbbandonato'])) ? $subscriber['IDCarrelloAbbandonato'] : '') .'"';
|
66 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturato'])) ? $subscriber['TotaleFatturato'] : '') .'"';
|
67 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturatoUltimi12Mesi'])) ? $subscriber['TotaleFatturatoUltimi12Mesi'] : '') .'"';
|
68 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturatoUltimi30gg'])) ? $subscriber['TotaleFatturatoUltimi30gg'] : '') .'"';
|
69 |
-
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDTuttiProdottiAcquistati'])) ? $subscriber['IDTuttiProdottiAcquistati'] : '') .'"';
|
70 |
-
$file .= ';';
|
71 |
-
|
72 |
-
continue 2;
|
73 |
-
}
|
74 |
-
}
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
//lancio il download del file
|
79 |
-
header("Content-type: application/csv");
|
80 |
-
header("Content-Disposition: attachment;Filename=clienti_filtrati.csv");
|
81 |
-
echo $file;
|
82 |
-
}
|
83 |
-
|
84 |
-
public function postAction() {
|
85 |
-
$post = $this->getRequest()->getPost();
|
86 |
-
|
87 |
-
try {
|
88 |
-
if (empty($post)) {
|
89 |
-
Mage::throwException($this->__('Invalid form data.'));
|
90 |
-
}
|
91 |
-
|
92 |
-
$mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
|
93 |
-
|
94 |
-
//require_once(dirname(__FILE__) . '/../Helper/Data.php');
|
95 |
-
$customersData = SevenLike_MailUp_Helper_Data::getCustomersData();
|
96 |
-
|
97 |
-
$MailUpWsSend = Mage::getModel('mailup/wssend');
|
98 |
-
$wsSend = new MailUpWsSend();
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
"
|
178 |
-
"
|
179 |
-
"
|
180 |
-
"
|
181 |
-
"
|
182 |
-
"
|
183 |
-
"
|
184 |
-
"
|
185 |
-
"
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
$
|
218 |
-
$
|
219 |
-
|
220 |
-
|
221 |
-
$
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
$
|
235 |
-
|
236 |
-
$
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
$
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
$
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
}
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
CAMPO4 -> CITTÀ
|
270 |
-
CAMPO5 -> PROVINCIA
|
271 |
-
CAMPO6 -> CAP
|
272 |
-
CAMPO7 -> REGIONE
|
273 |
-
CAMPO8 -> PAESE
|
274 |
-
CAMPO9 -> INDIRIZZO
|
275 |
-
CAMPO10 -> FAX
|
276 |
-
CAMPO11 -> TELEFONO
|
277 |
-
CAMPO12 -> IDCLIENTE
|
278 |
-
CAMPO13 -> IDULTIMOORDINE
|
279 |
-
CAMPO14 -> DATAULTIMOORDINE
|
280 |
-
CAMPO15 -> TOTALEULTIMOORDINE
|
281 |
-
CAMPO16 -> IDPRODOTTIULTIMOORDINE
|
282 |
-
CAMPO17 -> IDCATEGORIEULTIMOORDINE
|
283 |
-
CAMPO18 -> DATAULTIMOORDINESPEDITO
|
284 |
-
CAMPO19 -> IDULTIMOORDINESPEDITO
|
285 |
-
CAMPO20 -> DATACARRELLOABBANDONATO
|
286 |
-
CAMPO21 -> TOTALECARRELLOABBANDONATO
|
287 |
-
CAMPO22 -> IDCARRELLOABBANDONATO
|
288 |
-
CAMPO23 -> TOTALEFATTURATO
|
289 |
-
CAMPO24 -> TOTALEFATTURATOULTIMI12MESI
|
290 |
-
CAMPO25 -> TOTALEFATTURATOULTIMI30GG
|
291 |
-
CAMPO26 -> IDTUTTIPRODOTTIACQUISTATI*/
|
292 |
-
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SevenLike_MailUp_Adminhtml_FilterController extends Mage_Adminhtml_Controller_Action {
|
4 |
+
|
5 |
+
public function indexAction() {
|
6 |
+
$this->loadLayout()->renderLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function confirmAction() {
|
10 |
+
$this->loadLayout()->renderLayout();
|
11 |
+
}
|
12 |
+
|
13 |
+
public function csvAction() {
|
14 |
+
$post = $this->getRequest()->getPost();
|
15 |
+
$file = '';
|
16 |
+
|
17 |
+
if ($post['countPost'] > 0) {
|
18 |
+
//preparo l'elenco degli iscritti da salvare nel csv
|
19 |
+
$mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
|
20 |
+
|
21 |
+
//require_once(dirname(__FILE__) . '/../Helper/Data.php');
|
22 |
+
$customersData = SevenLike_MailUp_Helper_Data::getCustomersData();
|
23 |
+
|
24 |
+
//CSV Column names
|
25 |
+
$file = '"Email","First Name","Last Name"';
|
26 |
+
if (Mage::getStoreConfig('newsletter/mailup/enable_mailup_synchro') == 1) {
|
27 |
+
$file .= ',"Company","City","Province","Zip code","Region","Country code","Address","Fax","Phone","Customer id"';
|
28 |
+
$file .= ',"Last Order id","Last Order date","Last Order total","Last order product ids","Last order category ids"';
|
29 |
+
$file .= ',"Last sent order date","Last sent order id"';
|
30 |
+
$file .= ',"Last abandoned cart date","Last abandoned cart total","Last abandoned cart id"';
|
31 |
+
$file .= ',"Total orders amount","Last 12 months amount","Last 30 days amount","All products ids"';
|
32 |
+
}
|
33 |
+
$file .= ';';
|
34 |
+
|
35 |
+
|
36 |
+
foreach ($mailupCustomerIds as $customerId) {
|
37 |
+
foreach ($customersData as $subscriber) {
|
38 |
+
if ($subscriber['email'] == $customerId['email']) {
|
39 |
+
$file .= "\n";
|
40 |
+
$file .= '"'.$subscriber['email'].'"';
|
41 |
+
$file .= ',"'.((!empty($subscriber['nome'])) ? $subscriber['nome'] : '') .'"';
|
42 |
+
$file .= ',"'.((!empty($subscriber['cognome'])) ? $subscriber['cognome'] : '') .'"';
|
43 |
+
|
44 |
+
$synchroConfig = Mage::getStoreConfig('newsletter/mailup/enable_mailup_synchro') == 1;
|
45 |
+
|
46 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['azienda'])) ? $subscriber['azienda'] : '') .'"';
|
47 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['città '])) ? $subscriber['città '] : '') .'"';
|
48 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['provincia'])) ? $subscriber['provincia'] : '') .'"';
|
49 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['cap'])) ? $subscriber['cap'] : '') .'"';
|
50 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['regione'])) ? $subscriber['regione'] : '') .'"';
|
51 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['paese'])) ? $subscriber['paese'] : '') .'"';
|
52 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['indirizzo'])) ? $subscriber['indirizzo'] : '') .'"';
|
53 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['fax'])) ? $subscriber['fax'] : '') .'"';
|
54 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['telefono'])) ? $subscriber['telefono'] : '') .'"';
|
55 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCliente'])) ? $subscriber['IDCliente'] : '') .'"';
|
56 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDUltimoOrdine'])) ? $subscriber['IDUltimoOrdine'] : '') .'"';
|
57 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['DataUltimoOrdine'])) ? $subscriber['DataUltimoOrdine'] : '') .'"';
|
58 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleUltimoOrdine'])) ? $subscriber['TotaleUltimoOrdine'] : '') .'"';
|
59 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDProdottiUltimoOrdine'])) ? $subscriber['IDProdottiUltimoOrdine'] : '') .'"';
|
60 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCategorieUltimoOrdine'])) ? $subscriber['IDCategorieUltimoOrdine'] : '') .'"';
|
61 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['DataUltimoOrdineSpedito'])) ? $subscriber['DataUltimoOrdineSpedito'] : '') .'"';
|
62 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDUltimoOrdineSpedito'])) ? $subscriber['IDUltimoOrdineSpedito'] : '') .'"';
|
63 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['DataCarrelloAbbandonato'])) ? $subscriber['DataCarrelloAbbandonato'] : '') .'"';
|
64 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleCarrelloAbbandonato'])) ? $subscriber['TotaleCarrelloAbbandonato'] : '') .'"';
|
65 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDCarrelloAbbandonato'])) ? $subscriber['IDCarrelloAbbandonato'] : '') .'"';
|
66 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturato'])) ? $subscriber['TotaleFatturato'] : '') .'"';
|
67 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturatoUltimi12Mesi'])) ? $subscriber['TotaleFatturatoUltimi12Mesi'] : '') .'"';
|
68 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['TotaleFatturatoUltimi30gg'])) ? $subscriber['TotaleFatturatoUltimi30gg'] : '') .'"';
|
69 |
+
$file .= ',"'. ($synchroConfig && (!empty($subscriber['IDTuttiProdottiAcquistati'])) ? $subscriber['IDTuttiProdottiAcquistati'] : '') .'"';
|
70 |
+
$file .= ';';
|
71 |
+
|
72 |
+
continue 2;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
//lancio il download del file
|
79 |
+
header("Content-type: application/csv");
|
80 |
+
header("Content-Disposition: attachment;Filename=clienti_filtrati.csv");
|
81 |
+
echo $file;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function postAction() {
|
85 |
+
$post = $this->getRequest()->getPost();
|
86 |
+
|
87 |
+
try {
|
88 |
+
if (empty($post)) {
|
89 |
+
Mage::throwException($this->__('Invalid form data.'));
|
90 |
+
}
|
91 |
+
|
92 |
+
$mailupCustomerIds = Mage::getSingleton('core/session')->getMailupCustomerIds();
|
93 |
+
|
94 |
+
//require_once(dirname(__FILE__) . '/../Helper/Data.php');
|
95 |
+
$customersData = SevenLike_MailUp_Helper_Data::getCustomersData();
|
96 |
+
|
97 |
+
$MailUpWsSend = Mage::getModel('mailup/wssend');
|
98 |
+
$wsSend = new MailUpWsSend();
|
99 |
+
$MailUpWsSend = Mage::getModel('mailup/ws');
|
100 |
+
$wsImport = new MailUpWsImport();
|
101 |
+
$accessKey = $wsSend->loginFromId();
|
102 |
+
|
103 |
+
if ($accessKey === false) {
|
104 |
+
Mage::throwException('no access key returned');
|
105 |
+
}
|
106 |
+
$fields = $wsSend->GetFields($accessKey);
|
107 |
+
$fields_mapping = $wsImport->getFieldsMapping();
|
108 |
+
|
109 |
+
//preparo l'xml degli iscritti da inviare a mailup (da gestire in base ai filtri)
|
110 |
+
$xmlData = '<subscribers>';
|
111 |
+
foreach ($mailupCustomerIds as $customerId) {
|
112 |
+
$tmp = array();
|
113 |
+
$subscriber = $customersData[$customerId['email']];
|
114 |
+
$xmlData .= '<subscriber email="'.$subscriber['email'].'" Number="" Name="">';
|
115 |
+
|
116 |
+
if (@$fields_mapping["Name"]) $tmp[$fields_mapping["Name"]] = '<campo'.$fields_mapping["Name"].'>'. ((!empty($subscriber['nome'])) ? $subscriber['nome'] : '') .'</campo'.$fields_mapping["Name"].'>';
|
117 |
+
if (@$fields_mapping["Last"]) $tmp[$fields_mapping["Last"]] = '<campo'.$fields_mapping["Last"].'>'. ((!empty($subscriber['cognome'])) ? $subscriber['cognome'] : '') .'</campo'.$fields_mapping["Last"].'>';
|
118 |
+
|
119 |
+
foreach ($subscriber as $k=>$v) {
|
120 |
+
if (!strlen($subscriber[$k])) $subscriber[$k] = "-";
|
121 |
+
}
|
122 |
+
|
123 |
+
if (@$fields_mapping["Company"]) $tmp[$fields_mapping["Company"]] = '<campo'.$fields_mapping["Company"].'>'. $subscriber['azienda'] .'</campo'.$fields_mapping["Company"].'>';
|
124 |
+
if (@$fields_mapping["City"]) $tmp[$fields_mapping["City"]] = '<campo'.$fields_mapping["City"].'>'. $subscriber['città '] .'</campo'.$fields_mapping["City"].'>';
|
125 |
+
if (@$fields_mapping["Province"]) $tmp[$fields_mapping["Province"]] = '<campo'.$fields_mapping["Province"].'>'. $subscriber['provincia'] .'</campo'.$fields_mapping["Province"].'>';
|
126 |
+
if (@$fields_mapping["ZIP"]) $tmp[$fields_mapping["ZIP"]] = '<campo'.$fields_mapping["ZIP"].'>'. $subscriber['cap'].'</campo'.$fields_mapping["ZIP"].'>';
|
127 |
+
if (@$fields_mapping["Region"]) $tmp[$fields_mapping["Region"]] = '<campo'.$fields_mapping["Region"].'>'. $subscriber['regione'] .'</campo'.$fields_mapping["Region"].'>';
|
128 |
+
if (@$fields_mapping["Country"]) $tmp[$fields_mapping["Country"]] = '<campo'.$fields_mapping["Country"].'>'. $subscriber['paese'] .'</campo'.$fields_mapping["Country"].'>';
|
129 |
+
if (@$fields_mapping["Address"]) $tmp[$fields_mapping["Address"]] = '<campo'.$fields_mapping["Address"].'>'. $subscriber['indirizzo'] .'</campo'.$fields_mapping["Address"].'>';
|
130 |
+
if (@$fields_mapping["Fax"]) $tmp[$fields_mapping["Fax"]] = '<campo'.$fields_mapping["Fax"].'>'. $subscriber['fax'] .'</campo'.$fields_mapping["Fax"].'>';
|
131 |
+
if (@$fields_mapping["Phone"]) $tmp[$fields_mapping["Phone"]] = '<campo'.$fields_mapping["Phone"].'>'. $subscriber['telefono'] .'</campo'.$fields_mapping["Phone"].'>';
|
132 |
+
if (@$fields_mapping["CustomerID"]) $tmp[$fields_mapping["CustomerID"]] = '<campo'.$fields_mapping["CustomerID"].'>'. $subscriber['IDCliente'] .'</campo'.$fields_mapping["CustomerID"].'>';
|
133 |
+
if (@$fields_mapping["LatestOrderID"]) $tmp[$fields_mapping["LatestOrderID"]] = '<campo'.$fields_mapping["LatestOrderID"].'>'. $subscriber['IDUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderID"].'>';
|
134 |
+
if (@$fields_mapping["LatestOrderDate"]) $tmp[$fields_mapping["LatestOrderDate"]] = '<campo'.$fields_mapping["LatestOrderDate"].'>'. $subscriber['DataUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderDate"].'>';
|
135 |
+
if (@$fields_mapping["LatestOrderAmount"]) $tmp[$fields_mapping["LatestOrderAmount"]] = '<campo'.$fields_mapping["LatestOrderAmount"].'>'. $subscriber['TotaleUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderAmount"].'>';
|
136 |
+
if (@$fields_mapping["LatestOrderProductIDs"]) $tmp[$fields_mapping["LatestOrderProductIDs"]] = '<campo'.$fields_mapping["LatestOrderProductIDs"].'>'. $subscriber['IDProdottiUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderProductIDs"].'>';
|
137 |
+
if (@$fields_mapping["LatestOrderCategoryIDs"]) $tmp[$fields_mapping["LatestOrderCategoryIDs"]] = '<campo'.$fields_mapping["LatestOrderCategoryIDs"].'>'. $subscriber['IDCategorieUltimoOrdine'] .'</campo'.$fields_mapping["LatestOrderCategoryIDs"].'>';
|
138 |
+
if (@$fields_mapping["LatestShippedOrderDate"]) $tmp[$fields_mapping["LatestShippedOrderDate"]] = '<campo'.$fields_mapping["LatestShippedOrderDate"].'>'. $subscriber['DataUltimoOrdineSpedito'] .'</campo'.$fields_mapping["LatestShippedOrderDate"].'>';
|
139 |
+
if (@$fields_mapping["LatestShippedOrderID"]) $tmp[$fields_mapping["LatestShippedOrderID"]] = '<campo'.$fields_mapping["LatestShippedOrderID"].'>'. $subscriber['IDUltimoOrdineSpedito'] .'</campo'.$fields_mapping["LatestShippedOrderID"].'>';
|
140 |
+
if (@$fields_mapping["LatestAbandonedCartDate"]) $tmp[$fields_mapping["LatestAbandonedCartDate"]] = '<campo'.$fields_mapping["LatestAbandonedCartDate"].'>'. $subscriber['DataCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartDate"].'>';
|
141 |
+
if (@$fields_mapping["LatestAbandonedCartTotal"]) $tmp[$fields_mapping["LatestAbandonedCartTotal"]] = '<campo'.$fields_mapping["LatestAbandonedCartTotal"].'>'. $subscriber['TotaleCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartTotal"].'>';
|
142 |
+
if (@$fields_mapping["LatestAbandonedCartID"]) $tmp[$fields_mapping["LatestAbandonedCartID"]] = '<campo'.$fields_mapping["LatestAbandonedCartID"].'>'. $subscriber['IDCarrelloAbbandonato'] .'</campo'.$fields_mapping["LatestAbandonedCartID"].'>';
|
143 |
+
if (@$fields_mapping["TotalOrdered"]) $tmp[$fields_mapping["TotalOrdered"]] = '<campo'.$fields_mapping["TotalOrdered"].'>'. $subscriber['TotaleFatturato'] .'</campo'.$fields_mapping["TotalOrdered"].'>';
|
144 |
+
if (@$fields_mapping["TotalOrderedLast12m"]) $tmp[$fields_mapping["TotalOrderedLast12m"]] = '<campo'.$fields_mapping["TotalOrderedLast12m"].'>'. $subscriber['TotaleFatturatoUltimi12Mesi'] .'</campo'.$fields_mapping["TotalOrderedLast12m"].'>';
|
145 |
+
if (@$fields_mapping["TotalOrderedLast30d"]) $tmp[$fields_mapping["TotalOrderedLast30d"]] = '<campo'.$fields_mapping["TotalOrderedLast30d"].'>'. $subscriber['TotaleFatturatoUltimi30gg'] .'</campo'.$fields_mapping["TotalOrderedLast30d"].'>';
|
146 |
+
if (@$fields_mapping["AllOrderedProductIDs"]) $tmp[$fields_mapping["AllOrderedProductIDs"]] = '<campo'.$fields_mapping["AllOrderedProductIDs"].'>'. $subscriber['IDTuttiProdottiAcquistati'] .'</campo'.$fields_mapping["AllOrderedProductIDs"].'>';
|
147 |
+
|
148 |
+
$last_field = max(array_keys($tmp));
|
149 |
+
for ($i=1; $i<$last_field; $i++) {
|
150 |
+
if (!isset($tmp[$i])) $tmp[$i] = "<campo{$i}>-</campo{$i}>";
|
151 |
+
}
|
152 |
+
ksort($tmp);
|
153 |
+
$tmp = implode("", $tmp);
|
154 |
+
$xmlData .= $tmp;
|
155 |
+
$xmlData .= "</subscriber>\n";
|
156 |
+
}
|
157 |
+
$xmlData .= '</subscribers>';
|
158 |
+
|
159 |
+
Mage::log($xmlData, 0);
|
160 |
+
|
161 |
+
//definisco il gruppo a cui aggiungere gli iscritti
|
162 |
+
$groupId = $post['mailupGroupId'];
|
163 |
+
$listGUID = $post['mailupListGUID'];
|
164 |
+
$idList = $post['mailupIdList'];
|
165 |
+
|
166 |
+
if ($post['mailupNewGroup'] == 1) {
|
167 |
+
$newGroup = array(
|
168 |
+
"idList" => $idList,
|
169 |
+
"listGUID" => $listGUID,
|
170 |
+
"newGroupName" => $post['mailupNewGroupName']
|
171 |
+
);
|
172 |
+
|
173 |
+
$groupId = $wsImport->CreaGruppo($newGroup);
|
174 |
+
}
|
175 |
+
|
176 |
+
$importProcessData = array(
|
177 |
+
"idList" => $idList,
|
178 |
+
"listGUID" => $listGUID,
|
179 |
+
"idGroup" => $groupId,
|
180 |
+
"xmlDoc" => $xmlData,
|
181 |
+
"idGroups" => $groupId,
|
182 |
+
"importType" => "3",
|
183 |
+
"mobileInputType" => "2",
|
184 |
+
"asPending" => "0",
|
185 |
+
"ConfirmEmail" => "0",
|
186 |
+
"asOptOut" => "0",
|
187 |
+
"forceOptIn" => "0",
|
188 |
+
"replaceGroups" => "0",
|
189 |
+
"idConfirmNL" => "0"
|
190 |
+
);
|
191 |
+
|
192 |
+
//avvio l'importazione su mailup
|
193 |
+
$processID = $wsImport->newImportProcess($importProcessData);
|
194 |
+
|
195 |
+
$process = array(
|
196 |
+
"idList" => $post['mailupIdList'],
|
197 |
+
"listGUID" => $post['mailupListGUID'],
|
198 |
+
"idProcess" => $processID
|
199 |
+
);
|
200 |
+
|
201 |
+
$wsImport->startProcess($process);
|
202 |
+
|
203 |
+
//echo $wsImport->getProcessDetail($process);
|
204 |
+
|
205 |
+
$message = $this->__('Members have been sent correctly');
|
206 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
207 |
+
} catch (Exception $e) {
|
208 |
+
$errorMessage = $this->__('Warning: no member has been selected');
|
209 |
+
Mage::getSingleton('adminhtml/session')->addError($errorMessage);
|
210 |
+
}
|
211 |
+
|
212 |
+
$this->_redirect('*/*');
|
213 |
+
}
|
214 |
+
|
215 |
+
public function saveFilterHintAction() {
|
216 |
+
try {
|
217 |
+
$post = $this->getRequest()->getPost();
|
218 |
+
$filter_name = $post['filter_name'];
|
219 |
+
unset($post['filter_name']);
|
220 |
+
|
221 |
+
$MailUpWsImport = Mage::getModel('mailup/ws');
|
222 |
+
$wsImport = new MailUpWsImport();
|
223 |
+
$wsImport->saveFilterHint($filter_name, $post);
|
224 |
+
} catch (Exception $e) {
|
225 |
+
$errorMessage = $this->__('Error: unable to save current filter');
|
226 |
+
Mage::getSingleton('adminhtml/session')->addError($errorMessage);
|
227 |
+
}
|
228 |
+
|
229 |
+
$this->_redirect('*/*');
|
230 |
+
}
|
231 |
+
|
232 |
+
public function deleteFilterHintAction() {
|
233 |
+
try {
|
234 |
+
$post = $this->getRequest()->getPost();
|
235 |
+
|
236 |
+
$MailUpWsImport = Mage::getModel('mailup/ws');
|
237 |
+
$wsImport = new MailUpWsImport();
|
238 |
+
$wsImport->deleteFilterHint($post['filter_name']);
|
239 |
+
} catch (Exception $e) {
|
240 |
+
$errorMessage = $this->__('Error: unable to delete the filter');
|
241 |
+
Mage::getSingleton('adminhtml/session')->addError($errorMessage);
|
242 |
+
}
|
243 |
+
|
244 |
+
$this->_redirect('*/*');
|
245 |
+
}
|
246 |
+
|
247 |
+
public function testCronAction() {
|
248 |
+
$cron = new SevenLike_MailUp_Model_Cron();
|
249 |
+
$cron->run();
|
250 |
+
}
|
251 |
+
|
252 |
+
public function testFieldsAction() {
|
253 |
+
$MailUpWsSend = Mage::getModel('mailup/wssend');
|
254 |
+
$wsSend = new MailUpWsSend();
|
255 |
+
$accessKey = $wsSend->loginFromId();
|
256 |
+
|
257 |
+
if ($accessKey !== false) {
|
258 |
+
$fields = $wsSend->GetFields($accessKey);
|
259 |
+
|
260 |
+
print_r($fields);
|
261 |
+
die('success');
|
262 |
+
} else {
|
263 |
+
die('no access key returned');
|
264 |
+
}
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/SevenLike/MailUp/etc/config.xml
CHANGED
@@ -1,145 +1,155 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
<
|
27 |
-
<
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
<
|
73 |
-
|
74 |
-
<
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
<
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
</
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<SevenLike_MailUp>
|
6 |
+
<version>1.5.2</version>
|
7 |
+
</SevenLike_MailUp>
|
8 |
+
</modules>
|
9 |
+
|
10 |
+
<global>
|
11 |
+
<models>
|
12 |
+
<mailup>
|
13 |
+
<class>SevenLike_MailUp_Model</class>
|
14 |
+
</mailup>
|
15 |
+
</models>
|
16 |
+
<blocks>
|
17 |
+
<mailup>
|
18 |
+
<class>SevenLike_MailUp_Block</class>
|
19 |
+
</mailup>
|
20 |
+
</blocks>
|
21 |
+
<helpers>
|
22 |
+
<sintax>
|
23 |
+
<class>SevenLike_MailUp_Helper</class>
|
24 |
+
</sintax>
|
25 |
+
</helpers>
|
26 |
+
<resources>
|
27 |
+
<mailup_setup>
|
28 |
+
<setup>
|
29 |
+
<module>SevenLike_MailUp</module>
|
30 |
+
</setup>
|
31 |
+
<connection>
|
32 |
+
<use>core_setup</use>
|
33 |
+
</connection>
|
34 |
+
</mailup_setup>
|
35 |
+
<mailup_write>
|
36 |
+
<connection>
|
37 |
+
<use>core_write</use>
|
38 |
+
</connection>
|
39 |
+
</mailup_write>
|
40 |
+
<mailup_read>
|
41 |
+
<connection>
|
42 |
+
<use>core_read</use>
|
43 |
+
</connection>
|
44 |
+
</mailup_read>
|
45 |
+
</resources>
|
46 |
+
<events>
|
47 |
+
<customer_save_after>
|
48 |
+
<observers>
|
49 |
+
<mailupinviautente_observer>
|
50 |
+
<type>singleton</type>
|
51 |
+
<class>SevenLike_MailUp_Model_Observer</class>
|
52 |
+
<method>inviaUtente</method>
|
53 |
+
</mailupinviautente_observer>
|
54 |
+
</observers>
|
55 |
+
</customer_save_after>
|
56 |
+
<customer_customer_authenticated>
|
57 |
+
<observers>
|
58 |
+
<mailupleggiutente_observer>
|
59 |
+
<type>singleton</type>
|
60 |
+
<class>SevenLike_MailUp_Model_Observer</class>
|
61 |
+
<method>leggiUtente</method>
|
62 |
+
</mailupleggiutente_observer>
|
63 |
+
</observers>
|
64 |
+
</customer_customer_authenticated>
|
65 |
+
</events>
|
66 |
+
</global>
|
67 |
+
|
68 |
+
<admin>
|
69 |
+
<routers>
|
70 |
+
<mailup>
|
71 |
+
<use>admin</use>
|
72 |
+
<args>
|
73 |
+
<module>SevenLike_MailUp</module>
|
74 |
+
<frontName>mailup</frontName>
|
75 |
+
</args>
|
76 |
+
</mailup>
|
77 |
+
</routers>
|
78 |
+
</admin>
|
79 |
+
|
80 |
+
<default>
|
81 |
+
<newsletter>
|
82 |
+
<mailup>
|
83 |
+
<model>mailup/ws</model>
|
84 |
+
</mailup>
|
85 |
+
</newsletter>
|
86 |
+
</default>
|
87 |
+
|
88 |
+
<adminhtml>
|
89 |
+
<menu>
|
90 |
+
<newsletter>
|
91 |
+
<children>
|
92 |
+
<extensions translate="title">
|
93 |
+
<title>MailUp</title>
|
94 |
+
<children>
|
95 |
+
<local translate="title">
|
96 |
+
<title>Filters</title>
|
97 |
+
<action>mailup/adminhtml_filter</action>
|
98 |
+
<sort_order>0</sort_order>
|
99 |
+
</local>
|
100 |
+
<custom translate="title">
|
101 |
+
<title>Fields mapping</title>
|
102 |
+
<action>mailup/adminhtml_fieldsmapping</action>
|
103 |
+
<sort_order>5</sort_order>
|
104 |
+
</custom>
|
105 |
+
</children>
|
106 |
+
</extensions>
|
107 |
+
</children>
|
108 |
+
</newsletter>
|
109 |
+
</menu>
|
110 |
+
<acl>
|
111 |
+
<resources>
|
112 |
+
<admin>
|
113 |
+
<children>
|
114 |
+
<catalog>
|
115 |
+
<children>
|
116 |
+
<mailup_groups>
|
117 |
+
<title>Mailup</title>
|
118 |
+
</mailup_groups>
|
119 |
+
</children>
|
120 |
+
</catalog>
|
121 |
+
</children>
|
122 |
+
</admin>
|
123 |
+
</resources>
|
124 |
+
</acl>
|
125 |
+
<layout>
|
126 |
+
<updates>
|
127 |
+
<mailup>
|
128 |
+
<file>mailup.xml</file>
|
129 |
+
</mailup>
|
130 |
+
</updates>
|
131 |
+
</layout>
|
132 |
+
<translate>
|
133 |
+
<modules>
|
134 |
+
<mailup>
|
135 |
+
<files>
|
136 |
+
<default>SevenLike_MailUp.csv</default>
|
137 |
+
</files>
|
138 |
+
</mailup>
|
139 |
+
</modules>
|
140 |
+
</translate>
|
141 |
+
</adminhtml>
|
142 |
+
|
143 |
+
<crontab>
|
144 |
+
<jobs>
|
145 |
+
<sevenlike_mailup>
|
146 |
+
<schedule>
|
147 |
+
<cron_expr>0 * * * *</cron_expr>
|
148 |
+
</schedule>
|
149 |
+
<run>
|
150 |
+
<model>mailup/Cron::run</model>
|
151 |
+
</run>
|
152 |
+
</sevenlike_mailup>
|
153 |
+
</jobs>
|
154 |
+
</crontab>
|
155 |
</config>
|
app/code/local/SevenLike/MailUp/etc/system.xml
CHANGED
@@ -1,96 +1,62 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
<
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
<
|
36 |
-
<
|
37 |
-
<sort_order>
|
38 |
-
<show_in_default>1</show_in_default>
|
39 |
-
|
40 |
-
</
|
41 |
-
<
|
42 |
-
<label>
|
43 |
-
<frontend_type>
|
44 |
-
<
|
45 |
-
<
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
<
|
50 |
-
<
|
51 |
-
<
|
52 |
-
|
53 |
-
|
54 |
-
<
|
55 |
-
<
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
<frontend_type>password</frontend_type>
|
63 |
-
<sort_order>60</sort_order>
|
64 |
-
<show_in_default>1</show_in_default>
|
65 |
-
<comment>You can set it in your console (Manage->Web Services), then type it here</comment>
|
66 |
-
</password_ws>
|
67 |
-
<list translate="comment">
|
68 |
-
<label>List</label>
|
69 |
-
<frontend_type>select</frontend_type>
|
70 |
-
<source_model>mailup/lists</source_model>
|
71 |
-
<sort_order>60</sort_order>
|
72 |
-
<show_in_default>1</show_in_default>
|
73 |
-
<!--comment>If you haven't yet, we suggest you to create a DEM list directly from your mailup console</comment-->
|
74 |
-
</list>
|
75 |
-
<enable_cron_export tranlate="label">
|
76 |
-
<label>Enable Automatic Data Export</label>
|
77 |
-
<frontend_type>select</frontend_type>
|
78 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
79 |
-
<sort_order>70</sort_order>
|
80 |
-
<show_in_default>1</show_in_default>
|
81 |
-
<comment>Contact your account MailUp account representative for more information about this feature.</comment>
|
82 |
-
</enable_cron_export>
|
83 |
-
<enable_mailup_synchro tranlate="label">
|
84 |
-
<label>Enable Automatic Synchronization with your Mailup account</label>
|
85 |
-
<frontend_type>select</frontend_type>
|
86 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
87 |
-
<sort_order>80</sort_order>
|
88 |
-
<show_in_default>1</show_in_default>
|
89 |
-
<comment>Contact your account MailUp account representative for more information about this feature.</comment>
|
90 |
-
</enable_mailup_synchro>
|
91 |
-
</fields>
|
92 |
-
</mailup>
|
93 |
-
</groups>
|
94 |
-
</newsletter>
|
95 |
-
</sections>
|
96 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<sections>
|
5 |
+
<newsletter>
|
6 |
+
<groups>
|
7 |
+
<mailup translate="label">
|
8 |
+
<label>MailUp Extension Settings</label>
|
9 |
+
<frontend_type>text</frontend_type>
|
10 |
+
<sort_order>0</sort_order>
|
11 |
+
<show_in_default>1</show_in_default>
|
12 |
+
<fields>
|
13 |
+
<url_console translate="comment">
|
14 |
+
<label>Admin Console URL</label>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>10</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<comment>It's the domain portion of the browser address field when you using the MailUp Admin console (e.g. g4a0.s03.it)</comment>
|
19 |
+
</url_console>
|
20 |
+
<username_ws translate="comment">
|
21 |
+
<label>Web Service Username</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>20</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
</username_ws>
|
26 |
+
<password_ws translate="comment">
|
27 |
+
<label>Web Service Password</label>
|
28 |
+
<frontend_type>password</frontend_type>
|
29 |
+
<sort_order>40</sort_order>
|
30 |
+
<show_in_default>1</show_in_default>
|
31 |
+
<comment>You can set it in your console (Manage->Web Services), then type it here</comment>
|
32 |
+
</password_ws>
|
33 |
+
<list translate="label comment">
|
34 |
+
<label>List</label>
|
35 |
+
<frontend_type>select</frontend_type>
|
36 |
+
<source_model>mailup/lists</source_model>
|
37 |
+
<sort_order>60</sort_order>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
<!--comment>If you haven't yet, we suggest you to create a DEM list directly from your mailup console</comment-->
|
40 |
+
</list>
|
41 |
+
<enable_cron_export tranlate="label comment">
|
42 |
+
<label>Enable Automatic Data Export to MailUp</label>
|
43 |
+
<frontend_type>select</frontend_type>
|
44 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
45 |
+
<sort_order>70</sort_order>
|
46 |
+
<show_in_default>1</show_in_default>
|
47 |
+
</enable_cron_export>
|
48 |
+
<mailup_cron_frequency translate="label comment">
|
49 |
+
<label>Export Frequency</label>
|
50 |
+
<frontend_type>select</frontend_type>
|
51 |
+
<source_model>mailup/adminhtml_system_source_cron_frequency</source_model>
|
52 |
+
<sort_order>80</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
</mailup_cron_frequency>
|
57 |
+
</fields>
|
58 |
+
</mailup>
|
59 |
+
</groups>
|
60 |
+
</newsletter>
|
61 |
+
</sections>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
</config>
|
app/code/local/SevenLike/MailUp/sql/mailup_setup/mysql4-upgrade-1.0.0-1.5.2.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$this->startSetup();
|
3 |
+
|
4 |
+
$this->run("CREATE TABLE IF NOT EXISTS `mailup_fields_mapping` (
|
5 |
+
`magento_field_name` varchar(255) collate utf8_unicode_ci NOT NULL,
|
6 |
+
`mailup_field_id` int(11) NOT NULL,
|
7 |
+
PRIMARY KEY (`magento_field_name`, `mailup_field_id`)
|
8 |
+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
|
9 |
+
|
10 |
+
$this->endSetup();
|
11 |
+
?>
|
app/design/adminhtml/default/default/layout/mailup.xml
CHANGED
@@ -18,4 +18,14 @@
|
|
18 |
<action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
|
19 |
</reference>
|
20 |
</mailup_adminhtml_filter_confirm>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
</layout>
|
18 |
<action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
|
19 |
</reference>
|
20 |
</mailup_adminhtml_filter_confirm>
|
21 |
+
|
22 |
+
<mailup_adminhtml_fieldsmapping_index>
|
23 |
+
<update handle="mailup_adminhtml_index" />
|
24 |
+
<reference name="content">
|
25 |
+
<block type="adminhtml/template" name="fieldsmapping" template="sevenlike/mailup/fieldsmapping.phtml" />
|
26 |
+
</reference>
|
27 |
+
<reference name="head">
|
28 |
+
<action method="addCss"><stylesheet>sevenlike/mailup/mailup.css</stylesheet></action>
|
29 |
+
</reference>
|
30 |
+
</mailup_adminhtml_fieldsmapping_index>
|
31 |
</layout>
|
app/design/adminhtml/default/default/template/sevenlike/mailup/confirm.phtml
CHANGED
@@ -71,7 +71,6 @@ $xml = simplexml_load_string($xmlLists);
|
|
71 |
<td><h3><?=$this->__('MailUp')?></h3></td>
|
72 |
<td class="a-right">
|
73 |
<button onclick="back_form.submit()" class="scalable back" type="button"><span><?=$this->__('Reset filters')?></span></button>
|
74 |
-
<button onclick="csv_form.submit()" class="scalable save" type="button"><span><?=$this->__('Export to CSV')?></span></button>
|
75 |
<button onclick="editForm.submit()" class="scalable save" type="button"><span><?=$this->__('Send to MailUp')?></span></button>
|
76 |
</td>
|
77 |
</tr>
|
@@ -81,7 +80,7 @@ $xml = simplexml_load_string($xmlLists);
|
|
81 |
<?php
|
82 |
//gestisco la lista selezionata in configurazione
|
83 |
foreach($xml->List as $list) {
|
84 |
-
if ($list['
|
85 |
$listName = $list['listName'];
|
86 |
$idList = $list['idList'];
|
87 |
$listGUID = $list['listGUID'];
|
@@ -137,7 +136,7 @@ $xml = simplexml_load_string($xmlLists);
|
|
137 |
<select class="required-entry slctpg1" name="mailupGroupId">
|
138 |
<?php
|
139 |
foreach($xml->List as $list) {
|
140 |
-
if ($list['
|
141 |
foreach($list->Groups->Group as $group) {
|
142 |
echo '<option value="'.$group['idGroup'].'">'.$group['groupName'].'</option>';
|
143 |
}
|
@@ -198,4 +197,4 @@ $xml = simplexml_load_string($xmlLists);
|
|
198 |
</div>
|
199 |
<script type="text/javascript">
|
200 |
var editForm = new varienForm('edit_form');
|
201 |
-
</script>
|
71 |
<td><h3><?=$this->__('MailUp')?></h3></td>
|
72 |
<td class="a-right">
|
73 |
<button onclick="back_form.submit()" class="scalable back" type="button"><span><?=$this->__('Reset filters')?></span></button>
|
|
|
74 |
<button onclick="editForm.submit()" class="scalable save" type="button"><span><?=$this->__('Send to MailUp')?></span></button>
|
75 |
</td>
|
76 |
</tr>
|
80 |
<?php
|
81 |
//gestisco la lista selezionata in configurazione
|
82 |
foreach($xml->List as $list) {
|
83 |
+
if ($list['idList'] == Mage::getStoreConfig('newsletter/mailup/list')) {
|
84 |
$listName = $list['listName'];
|
85 |
$idList = $list['idList'];
|
86 |
$listGUID = $list['listGUID'];
|
136 |
<select class="required-entry slctpg1" name="mailupGroupId">
|
137 |
<?php
|
138 |
foreach($xml->List as $list) {
|
139 |
+
if ($list['idList'] == Mage::getStoreConfig('newsletter/mailup/list')){
|
140 |
foreach($list->Groups->Group as $group) {
|
141 |
echo '<option value="'.$group['idGroup'].'">'.$group['groupName'].'</option>';
|
142 |
}
|
197 |
</div>
|
198 |
<script type="text/javascript">
|
199 |
var editForm = new varienForm('edit_form');
|
200 |
+
</script>
|
app/design/adminhtml/default/default/template/sevenlike/mailup/fieldsmapping.phtml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$allmagentofields = array("Name", "Last", "Email", "Company", "Address", "City", "ZIP", "Province", "Region", "Country", "Gender", "DateOfBirth", "CustomerID", "Phone", "Fax", "LatestOrderID", "LatestOrderDate", "LatestOrderAmount", "LatestOrderProductIDs", "LatestOrderCategoryIDs", "LatestShippedOrderDate", "LatestShippedOrderID", "LatestAbandonedCartDate", "LatestAbandonedCartTotal", "LatestAbandonedCartID", "TotalOrdered", "TotalOrderedLast12m", "TotalOrderedLast30d", "AllOrderedProductIDs");
|
4 |
+
$MailUpWsSend = Mage::getModel('mailup/wssend');
|
5 |
+
$wsSend = new MailUpWsSend();
|
6 |
+
$accessKey = $wsSend->loginFromId();
|
7 |
+
|
8 |
+
if ($accessKey === false) {
|
9 |
+
echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
|
10 |
+
} else {
|
11 |
+
$MailUpWsImport = Mage::getModel('mailup/ws');
|
12 |
+
$wsImport = new MailUpWsImport();
|
13 |
+
|
14 |
+
$wsSend = new MailUpWsSend();
|
15 |
+
// campi che arrivano da mailup
|
16 |
+
$wsFields = $wsSend->getFields($accessKey);
|
17 |
+
|
18 |
+
//carico i mapping salvati
|
19 |
+
$fields = $wsImport->getFieldsMapping();
|
20 |
+
?>
|
21 |
+
<div class="content-header">
|
22 |
+
<table cellspacing="0" class="grid-header">
|
23 |
+
<tr>
|
24 |
+
<td>
|
25 |
+
<h3><?=$this->__('Fields mapping')?></h3>
|
26 |
+
</td>
|
27 |
+
<td class="a-right">
|
28 |
+
<button onclick="document.forms.saveFieldsMappingForm.submit()" class="scalable save" type="button"><span><?=$this->__('Save configuration')?></span></button>
|
29 |
+
</td>
|
30 |
+
</tr>
|
31 |
+
</table>
|
32 |
+
</div>
|
33 |
+
<p><?php echo $this->__('Associate all Magento fields with MailUp ones') ?></p>
|
34 |
+
<form name="saveFieldsMappingForm" method="post" action="<?php echo $this->getUrl('*/*/save')?>">
|
35 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
36 |
+
<?php foreach ($allmagentofields as $magentofield): ?>
|
37 |
+
<div>
|
38 |
+
<label for="sl_<?php echo $magentofield ?>" style="display:block;float:left;width:180px;"><?php echo $magentofield ?></label>
|
39 |
+
<select name="<?php echo $magentofield ?>" id="sl_<?php echo $magentofield ?>">
|
40 |
+
<option value=""></option>
|
41 |
+
<?php
|
42 |
+
foreach ($wsFields as $nome=>$id) {
|
43 |
+
$selected = ($id == $fields[$magentofield]) ? "selected='selected'" : "";
|
44 |
+
$nome = htmlspecialchars($nome);
|
45 |
+
echo "<option value='$id' $selected>$nome</option>";
|
46 |
+
}
|
47 |
+
echo '</select>';
|
48 |
+
?>
|
49 |
+
</div>
|
50 |
+
<?php endforeach; ?>
|
51 |
+
</form>
|
52 |
+
<?php } ?>
|
app/design/adminhtml/default/default/template/sevenlike/mailup/filter.phtml
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
|
6 |
$MailUpWsSend = Mage::getModel('mailup/wssend');
|
7 |
$wsSend = new MailUpWsSend();
|
8 |
-
$
|
9 |
|
10 |
/* TEST SOAP AL MOMENTO DISABILITATO
|
11 |
|
@@ -22,18 +22,21 @@ if ($loginTest > 0){
|
|
22 |
|
23 |
*/
|
24 |
|
25 |
-
if ($
|
26 |
echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
|
27 |
} else {
|
28 |
//controllo se la lista e' stata selezionata correttamente
|
29 |
$MailUpWsImport = Mage::getModel('mailup/ws');
|
30 |
$wsImport = new MailUpWsImport();
|
31 |
$mailupLists = $wsImport->GetNlList();
|
|
|
|
|
32 |
$filterHints = $wsImport->getFilterHints();
|
33 |
|
|
|
34 |
//chiamata attivazione web services su MailUp
|
35 |
-
|
36 |
-
fopen($urlWSActivation, 'r');
|
37 |
|
38 |
//salvo i parametri in variabili
|
39 |
$mailupCustomers = $this->getRequest()->getParam('mailupCustomers');
|
@@ -322,7 +325,7 @@ if ($login > 0 || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 2) {
|
|
322 |
<tr>
|
323 |
<td>
|
324 |
<input name="filter_name_text" id="filter_name_text" type="text" value="" maxlength="100" size="50" />
|
325 |
-
<input type="submit" onclick="saveFilterHint();return false;" value="<?=$this->__('Save hint')?>" />
|
326 |
</td>
|
327 |
</tr>
|
328 |
</table>
|
@@ -341,7 +344,7 @@ if ($login > 0 || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 2) {
|
|
341 |
<input name="mailupCustomers" type="hidden" value="2" />
|
342 |
<input name="mailupCustomerGroupId" type="hidden" value="2" />
|
343 |
<p class="parscefil"><?=$this->__("All wholesale customers who haven't purchased yet")?> »</p>
|
344 |
-
<input type="submit" value="<?=$this->__('Set hint')?>" />
|
345 |
</form>
|
346 |
</td>
|
347 |
</tr>
|
@@ -353,7 +356,7 @@ if ($login > 0 || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 2) {
|
|
353 |
<input name="mailupTotalAmountCond" type="hidden" value="gt" />
|
354 |
<input name="mailupTotalAmountValue" type="hidden" value="50" />
|
355 |
<p class="parscefil"><?=$this->__('More than 50 Euros orders')?> »</p>
|
356 |
-
<input type="submit" value="<?=$this->__('Set hint')?>" />
|
357 |
</form>
|
358 |
</td>
|
359 |
</tr>
|
@@ -365,7 +368,7 @@ if ($login > 0 || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 2) {
|
|
365 |
<input name="mailupOrderYesNo" type="hidden" value="no" />
|
366 |
<input name="mailupOrderStartDate" type="hidden" value="01/01/<?php echo date('Y'); ?>" />
|
367 |
<p class="parscefil"><?=$this->__('Members with no purchase in')?> <?php echo date('Y'); ?> »</p>
|
368 |
-
<input type="submit" value="<?=$this->__('Set hint')?>" />
|
369 |
</form>
|
370 |
|
371 |
</td>
|
@@ -406,8 +409,8 @@ if ($login > 0 || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 2) {
|
|
406 |
</table>
|
407 |
</fieldset>
|
408 |
|
409 |
-
|
410 |
-
<a href="<?=$this->getUrl('*/*/testFields')?>">TEST GETFIELDS</a
|
411 |
</div>
|
412 |
<script type="text/javascript">
|
413 |
var editForm = new varienForm('edit_form');
|
@@ -454,4 +457,4 @@ if ($login > 0 || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 2) {
|
|
454 |
customerDependentFilters(isDisabled);
|
455 |
}
|
456 |
</script>
|
457 |
-
<?php } ?>
|
5 |
|
6 |
$MailUpWsSend = Mage::getModel('mailup/wssend');
|
7 |
$wsSend = new MailUpWsSend();
|
8 |
+
$accessKey = $wsSend->loginFromId();
|
9 |
|
10 |
/* TEST SOAP AL MOMENTO DISABILITATO
|
11 |
|
22 |
|
23 |
*/
|
24 |
|
25 |
+
if ($accessKey === false || strlen(Mage::getStoreConfig('newsletter/mailup/list')) < 1) {
|
26 |
echo $this->__('WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp');
|
27 |
} else {
|
28 |
//controllo se la lista e' stata selezionata correttamente
|
29 |
$MailUpWsImport = Mage::getModel('mailup/ws');
|
30 |
$wsImport = new MailUpWsImport();
|
31 |
$mailupLists = $wsImport->GetNlList();
|
32 |
+
|
33 |
+
//carico i filtri salvati
|
34 |
$filterHints = $wsImport->getFilterHints();
|
35 |
|
36 |
+
//TODO: sembra inutilizzata
|
37 |
//chiamata attivazione web services su MailUp
|
38 |
+
//$urlWSActivation = 'http://'.Mage::getStoreConfig('newsletter/mailup/url_console').'/frontend/WSActivation.aspx?usr='.Mage::getStoreConfig('newsletter/mailup/user').'&pwd='.Mage::getStoreConfig('newsletter/mailup/password').'&nl_url='.Mage::getStoreConfig('newsletter/mailup/url_console').'&ws_name=WSMailUpImport';
|
39 |
+
//fopen($urlWSActivation, 'r');
|
40 |
|
41 |
//salvo i parametri in variabili
|
42 |
$mailupCustomers = $this->getRequest()->getParam('mailupCustomers');
|
325 |
<tr>
|
326 |
<td>
|
327 |
<input name="filter_name_text" id="filter_name_text" type="text" value="" maxlength="100" size="50" />
|
328 |
+
<input class="form-button" type="submit" onclick="saveFilterHint();return false;" value="<?=$this->__('Save hint')?>" />
|
329 |
</td>
|
330 |
</tr>
|
331 |
</table>
|
344 |
<input name="mailupCustomers" type="hidden" value="2" />
|
345 |
<input name="mailupCustomerGroupId" type="hidden" value="2" />
|
346 |
<p class="parscefil"><?=$this->__("All wholesale customers who haven't purchased yet")?> »</p>
|
347 |
+
<input class="form-button" type="submit" value="<?=$this->__('Set hint')?>" />
|
348 |
</form>
|
349 |
</td>
|
350 |
</tr>
|
356 |
<input name="mailupTotalAmountCond" type="hidden" value="gt" />
|
357 |
<input name="mailupTotalAmountValue" type="hidden" value="50" />
|
358 |
<p class="parscefil"><?=$this->__('More than 50 Euros orders')?> »</p>
|
359 |
+
<input class="form-button" type="submit" value="<?=$this->__('Set hint')?>" />
|
360 |
</form>
|
361 |
</td>
|
362 |
</tr>
|
368 |
<input name="mailupOrderYesNo" type="hidden" value="no" />
|
369 |
<input name="mailupOrderStartDate" type="hidden" value="01/01/<?php echo date('Y'); ?>" />
|
370 |
<p class="parscefil"><?=$this->__('Members with no purchase in')?> <?php echo date('Y'); ?> »</p>
|
371 |
+
<input class="form-button" type="submit" value="<?=$this->__('Set hint')?>" />
|
372 |
</form>
|
373 |
|
374 |
</td>
|
409 |
</table>
|
410 |
</fieldset>
|
411 |
|
412 |
+
<a href="<?=$this->getUrl('*/*/testCron')?>">TEST CRON</a>
|
413 |
+
<a href="<?=$this->getUrl('*/*/testFields')?>">TEST GETFIELDS</a>
|
414 |
</div>
|
415 |
<script type="text/javascript">
|
416 |
var editForm = new varienForm('edit_form');
|
457 |
customerDependentFilters(isDisabled);
|
458 |
}
|
459 |
</script>
|
460 |
+
<?php } ?>
|
app/locale/it_IT/SevenLike_MailUp.csv
CHANGED
@@ -1,73 +1,86 @@
|
|
1 |
-
"Members have been sent correctly","Gli iscritti sono stati inviati correttamente"
|
2 |
-
"Warning: no member has been selected","Attenzione: non hai inviato nessun iscritto"
|
3 |
-
"WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp","ATTENZIONE: prima di procedere devi configurare correttamente i parametri per accedere a MailUp in Sistema->Configurazione->Newsletter->MailUp"
|
4 |
-
"Apply filter","Applica filtro"
|
5 |
-
"Get hints","Ottieni suggerimenti"
|
6 |
-
"Sold products","Prodotti venduti"
|
7 |
-
"All customers","Tutti i clienti"
|
8 |
-
"Customers who have purchased","I clienti che hanno acquistato"
|
9 |
-
"Customers who have not purchased","I clienti che non hanno mai acquistato"
|
10 |
-
"Select product","Seleziona un prodotto"
|
11 |
-
"Any","Qualsiasi"
|
12 |
-
"Select category","Seleziona una categoria"
|
13 |
-
"Groups","Tipo di cliente"
|
14 |
-
"Select customer group","Seleziona gruppo di clienti"
|
15 |
-
"Location","Provenienza cliente"
|
16 |
-
"Select country","Seleziona paese"
|
17 |
-
"Zip code","CAP"
|
18 |
-
"From","Data inizio"
|
19 |
-
"To","Data fine"
|
20 |
-
"Total purchased amount","Somma totale ordinata"
|
21 |
-
"Order total","Totale ordinato"
|
22 |
-
"less than","minore di"
|
23 |
-
"same as","uguale a"
|
24 |
-
"more than","maggiore di"
|
25 |
-
"Specify amount","Inserisci il valore"
|
26 |
-
"Date of purchase","Data ordini"
|
27 |
-
"Show customers who","Seleziona utenti che"
|
28 |
-
"Haven't purchased","Non hanno effettuato un ordine"
|
29 |
-
"Have purchased","Hanno effettuato un ordine"
|
30 |
-
"In this period","Nel periodo"
|
31 |
-
"Filter hints","Filtri suggeriti"
|
32 |
-
"All wholesale customers who haven't purchased yet","Tutti i clienti all'ingrosso che non hanno mai acquistato"
|
33 |
-
"Set filter","imposta filtro"
|
34 |
-
"More than 50 Euros orders","Tutti i clienti che hanno acquistato per oltre 50 Euro"
|
35 |
-
"Members with no purchase in","Tutti i clienti che non hanno acquistato nel"
|
36 |
-
"Reset filters","Reimposta i filtri"
|
37 |
-
"Export to CSV","Esporta in CSV"
|
38 |
-
"Send to MailUp","Invia a MailUp"
|
39 |
-
"Confirm filtered customers and select MailUp group","Conferma i clienti filtrati e scegli gruppo di MailUp"
|
40 |
-
"Were found","Sono stati trovati"
|
41 |
-
"records","clienti corrispondenti ai criteri di ricerca"
|
42 |
-
"Filtered customers","Clienti filtrati"
|
43 |
-
"Selected list","Lista selezionata"
|
44 |
-
"Next step","Prossimo Step"
|
45 |
-
"Select group","Seleziona gruppo"
|
46 |
-
"Select an existing group","Scegli tra i gruppi già presenti su MailUp"
|
47 |
-
"or","oppure"
|
48 |
-
"Create new customer group","Crea nuovo gruppo"
|
49 |
-
"Group name","Inserisci il nome del nuovo gruppo"
|
50 |
-
"Add a new e-mail address or select adresses to be removed from list","Aggiungi o rimuovi manualmente gli indirizzi email dalla lista"
|
51 |
-
"Change members list: please add one email adress per row","Modifica manualmente l'elenco degli iscritti, scrivere un solo indirizzo email per ogni riga"
|
52 |
-
"Save changes","Applica modifiche"
|
53 |
-
"By this plugin you can import contacts registered in your eCommerce in the MailUp platform.","Tramite questo plugin potete importare nella piattaforma MailUp i nominativi registrati nel vostro eCommerce."
|
54 |
-
"Set and customize one of the following filters:","Imposta e personalizza uno dei seguenti filtri:"
|
55 |
-
"Filter customers","Filtra i clienti"
|
56 |
-
"You can find it on your browser url bar (e.g. g4a0.s03.it)","Si trova nella barra degli indirizzi del tuo browser (es. g4a0.s03.it)"
|
57 |
-
"If you haven't yet, we suggest you to create a DEM list directly from your mailup console","Se non è stato ancora fatto è consigliabile creare una lista dedicata alle DEM direttamente dalla console di MailUp"
|
58 |
-
"Insert product SKU","Inserisci lo SKU del prodotto"
|
59 |
-
"Enable Cron Export","Abilita Export Automatico"
|
60 |
-
"Subscription date","Data di iscrizione"
|
61 |
-
"Save hint","Salva il suggerimento"
|
62 |
-
"Delete hint","Cancella il suggerimento"
|
63 |
-
"Set hint","Applica il suggerimento"
|
64 |
-
"Or choose one of those you saved:","O scegline uno tra quelli che hai salvato:"
|
65 |
-
"Do you really want to delete this hint?","Vuoi davvero cancellare questo suggerimento?"
|
66 |
-
"Please, give your new hint a name.","Per favore, dai un nome al tuo nuovo suggerimento."
|
67 |
-
"Save current filters as hint","Salva i filtri correnti come suggerimento"
|
68 |
-
"Opted-in Only","Clienti iscritti alla newsletter"
|
69 |
-
"All customers","Tutti i clienti"
|
70 |
-
"Products and categories","Prodotti e categorie"
|
71 |
-
"dd/mm/yyyy","gg/mm/aaaa"
|
72 |
-
"e.g.","es."
|
73 |
-
"Opt-in Status","Iscrizione alla newsletter"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Members have been sent correctly","Gli iscritti sono stati inviati correttamente"
|
2 |
+
"Warning: no member has been selected","Attenzione: non hai inviato nessun iscritto"
|
3 |
+
"WARNING: before proceeding you must correctly configure the settings of MailUp access in System->Configuration->Newsletter->MailUp","ATTENZIONE: prima di procedere devi configurare correttamente i parametri per accedere a MailUp in Sistema->Configurazione->Newsletter->MailUp"
|
4 |
+
"Apply filter","Applica filtro"
|
5 |
+
"Get hints","Ottieni suggerimenti"
|
6 |
+
"Sold products","Prodotti venduti"
|
7 |
+
"All customers","Tutti i clienti"
|
8 |
+
"Customers who have purchased","I clienti che hanno acquistato"
|
9 |
+
"Customers who have not purchased","I clienti che non hanno mai acquistato"
|
10 |
+
"Select product","Seleziona un prodotto"
|
11 |
+
"Any","Qualsiasi"
|
12 |
+
"Select category","Seleziona una categoria"
|
13 |
+
"Groups","Tipo di cliente"
|
14 |
+
"Select customer group","Seleziona gruppo di clienti"
|
15 |
+
"Location","Provenienza cliente"
|
16 |
+
"Select country","Seleziona paese"
|
17 |
+
"Zip code","CAP"
|
18 |
+
"From","Data inizio"
|
19 |
+
"To","Data fine"
|
20 |
+
"Total purchased amount","Somma totale ordinata"
|
21 |
+
"Order total","Totale ordinato"
|
22 |
+
"less than","minore di"
|
23 |
+
"same as","uguale a"
|
24 |
+
"more than","maggiore di"
|
25 |
+
"Specify amount","Inserisci il valore"
|
26 |
+
"Date of purchase","Data ordini"
|
27 |
+
"Show customers who","Seleziona utenti che"
|
28 |
+
"Haven't purchased","Non hanno effettuato un ordine"
|
29 |
+
"Have purchased","Hanno effettuato un ordine"
|
30 |
+
"In this period","Nel periodo"
|
31 |
+
"Filter hints","Filtri suggeriti"
|
32 |
+
"All wholesale customers who haven't purchased yet","Tutti i clienti all'ingrosso che non hanno mai acquistato"
|
33 |
+
"Set filter","imposta filtro"
|
34 |
+ |