Version Notes
update code when get contacts from magento database quey. Foreach every 1000 contacts
Download this release
Release Info
Developer | Toni |
Extension | Livedata_Solutions |
Version | 1.0.4 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.4
app/code/community/Livedata/Trans/Model/Observer.php
CHANGED
@@ -34,43 +34,7 @@ class Livedata_Trans_Model_Observer
|
|
34 |
// validate that the contact attributes are created
|
35 |
if($customExist) {
|
36 |
// get the magento contacts
|
37 |
-
$
|
38 |
-
$updated = true;
|
39 |
-
foreach ($contacts as $user) {
|
40 |
-
$contactdb = $user->getData();
|
41 |
-
// get only the active contacts
|
42 |
-
if($contactdb['is_active'] == '1') {
|
43 |
-
// get customer postcode
|
44 |
-
$contactdb['postcode'] = $this->getCustomerAddress($contactdb['email']);
|
45 |
-
// get cutomer grand total
|
46 |
-
$customerAmount = $this->getCustomerGrandTotal($contactdb['email']);
|
47 |
-
$contactdb['totalAmount'] = $customerAmount['total'];
|
48 |
-
$contactdb['lastAmount'] = $customerAmount['last'];
|
49 |
-
// sync contact: add/update contact with standard attr in database
|
50 |
-
$contact = $this->addOrUpdateContact($contactdb);
|
51 |
-
if($contact['code'] == 200 || $contact['code'] == 201) {
|
52 |
-
// if the contact has been inserted or updated, and there is a contact list selected and allowed, insert it in the list
|
53 |
-
$listId = Mage::getStoreConfig('trans/selectlist/from_list');
|
54 |
-
if($listId != 0)
|
55 |
-
Mage::helper('livedata_trans/contact')->insertContactToList($contactdb['email'], $listId);
|
56 |
-
} else
|
57 |
-
$updated = false;
|
58 |
-
// if it is a new contact, unsubscribe it if it is not subscribed in the newsletter
|
59 |
-
if($contact['code'] == 201) {
|
60 |
-
//unsubscribe contact
|
61 |
-
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($contactdb['email']);
|
62 |
-
if (array_key_exists('subscriber_status', $subscriber) && $subscriber['subscriber_status'] == 3) {
|
63 |
-
$unsubscribeContact = Mage::helper('livedata_trans/contact')->unsubscribeContact($contactdb['email']);
|
64 |
-
if($unsubscribeContact['statusCode'] != 200)
|
65 |
-
$updated = false;
|
66 |
-
} elseif (!array_key_exists('subscriber_status', $subscriber)) {
|
67 |
-
$unsubscribeContact = Mage::helper('livedata_trans/contact')->unsubscribeContact($contactdb['email']);
|
68 |
-
if($unsubscribeContact['statusCode'] != 200)
|
69 |
-
$updated = false;
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
73 |
-
}
|
74 |
// if some contact has not been inserted or included in the list or unsubscribe it show a notice
|
75 |
if(!$updated)
|
76 |
Mage::getSingleton('core/session')->addNotice('Some contact has not been inserted correctly in the synchronization process');
|
@@ -229,10 +193,53 @@ class Livedata_Trans_Model_Observer
|
|
229 |
*/
|
230 |
private function getCustomerContacts()
|
231 |
{
|
232 |
-
$
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
}
|
235 |
|
|
|
236 |
/**
|
237 |
* function to get the customer addresses by email
|
238 |
*
|
34 |
// validate that the contact attributes are created
|
35 |
if($customExist) {
|
36 |
// get the magento contacts
|
37 |
+
$updated = $this->getCustomerContacts();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
// if some contact has not been inserted or included in the list or unsubscribe it show a notice
|
39 |
if(!$updated)
|
40 |
Mage::getSingleton('core/session')->addNotice('Some contact has not been inserted correctly in the synchronization process');
|
193 |
*/
|
194 |
private function getCustomerContacts()
|
195 |
{
|
196 |
+
$total = mage::getModel('customer/customer')->getCollection()->getSize();
|
197 |
+
$pages = ceil($total / 1000);
|
198 |
+
$contact = array();
|
199 |
+
$updated = true;
|
200 |
+
for($i = 1; $i <= $pages; $i++) {
|
201 |
+
$contacts = mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('email')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname')->addAttributeToSelect('prefix')->addAttributeToSelect('dob')->setPageSize(1000)->setCurPage($i);
|
202 |
+
foreach ($contacts as $contactdbfilter) {
|
203 |
+
$contactdb = $contactdbfilter->getData();
|
204 |
+
// get only the active contacts
|
205 |
+
if($contactdb['is_active'] == '1') {
|
206 |
+
// get customer postcode
|
207 |
+
$contactdb['postcode'] = $this->getCustomerAddress($contactdb['email']);
|
208 |
+
// get cutomer grand total
|
209 |
+
$customerAmount = $this->getCustomerGrandTotal($contactdb['email']);
|
210 |
+
$contactdb['totalAmount'] = $customerAmount['total'];
|
211 |
+
$contactdb['lastAmount'] = $customerAmount['last'];
|
212 |
+
// sync contact: add/update contact with standard attr in database
|
213 |
+
$contact = $this->addOrUpdateContact($contactdb);
|
214 |
+
if($contact['code'] == 200 || $contact['code'] == 201) {
|
215 |
+
// if the contact has been inserted or updated, and there is a contact list selected and allowed, insert it in the list
|
216 |
+
$listId = Mage::getStoreConfig('trans/selectlist/from_list');
|
217 |
+
if($listId != 0)
|
218 |
+
Mage::helper('livedata_trans/contact')->insertContactToList($contactdb['email'], $listId);
|
219 |
+
} else
|
220 |
+
$updated = false;
|
221 |
+
// if it is a new contact, unsubscribe it if it is not subscribed in the newsletter
|
222 |
+
if($contact['code'] == 201) {
|
223 |
+
//unsubscribe contact
|
224 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($contactdb['email']);
|
225 |
+
if (array_key_exists('subscriber_status', $subscriber) && $subscriber['subscriber_status'] == 3) {
|
226 |
+
$unsubscribeContact = Mage::helper('livedata_trans/contact')->unsubscribeContact($contactdb['email']);
|
227 |
+
if($unsubscribeContact['statusCode'] != 200)
|
228 |
+
$updated = false;
|
229 |
+
} elseif (!array_key_exists('subscriber_status', $subscriber)) {
|
230 |
+
$unsubscribeContact = Mage::helper('livedata_trans/contact')->unsubscribeContact($contactdb['email']);
|
231 |
+
if($unsubscribeContact['statusCode'] != 200)
|
232 |
+
$updated = false;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
return $updated;
|
240 |
}
|
241 |
|
242 |
+
|
243 |
/**
|
244 |
* function to get the customer addresses by email
|
245 |
*
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Livedata_Solutions</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Allow you to synchronize your magento contacts with our database and send transactional messages.</summary>
|
10 |
<description>Live Data is a cloud based emailing platform that enables client engagement by one to one campaigns, scenario automation and customer retention. Intuitive and easy to employ, Live Data Emailing is the perfect tool for email marketers who don’t want to spend their time reading user manuals. Whether you’re a content editor, online store or a traditional retailer, Live Data Platform has been created to satisfy your needs.Live Data Emailing enables you to build and manage customer lifecycles and deliver context driven messages. It takes into account your clients’ behavior and device preferences, for a targeted and personalized dialogue.Access your campaign manager directly on our online interface our plug our API to your system. A specialized consultant will help you set up your account and accompany you on a daily basis to get the best out of your email marketing experience.</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>Toni</name><user>Toni</user><email>tcarreno@livedata-solutions.com</email></author></authors>
|
13 |
-
<date>2016-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Livedata"><file name="README.txt" hash="ceb13527ad00b32bd4e76ba057421ba9"/><dir name="Trans"><dir name="Helper"><file name="Contact.php" hash="f7eddee0fa61fb197d4a90d813a4b579"/><file name="Contactlist.php" hash="e288ff740871f4d21c9781f730959417"/><file name="Scenario.php" hash="5ddd91cfbb70afbcb57f2084bb1e80e3"/></dir><dir name="Model"><file name="Observer.php" hash="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php><package><name>Aschroder_ SMTPPro</name><channel>local</channel><min>1.6</min><max>1.9.2</max><files><file target="." path="app/etc/modules/Aschroder_SMTPPro.xml
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Livedata_Solutions</name>
|
4 |
+
<version>1.0.4</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Allow you to synchronize your magento contacts with our database and send transactional messages.</summary>
|
10 |
<description>Live Data is a cloud based emailing platform that enables client engagement by one to one campaigns, scenario automation and customer retention. Intuitive and easy to employ, Live Data Emailing is the perfect tool for email marketers who don’t want to spend their time reading user manuals. Whether you’re a content editor, online store or a traditional retailer, Live Data Platform has been created to satisfy your needs.Live Data Emailing enables you to build and manage customer lifecycles and deliver context driven messages. It takes into account your clients’ behavior and device preferences, for a targeted and personalized dialogue.Access your campaign manager directly on our online interface our plug our API to your system. A specialized consultant will help you set up your account and accompany you on a daily basis to get the best out of your email marketing experience.</description>
|
11 |
+
<notes>update code when get contacts from magento database quey. Foreach every 1000 contacts</notes>
|
12 |
<authors><author><name>Toni</name><user>Toni</user><email>tcarreno@livedata-solutions.com</email></author></authors>
|
13 |
+
<date>2016-09-20</date>
|
14 |
+
<time>14:20:55</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Livedata"><file name="README.txt" hash="ceb13527ad00b32bd4e76ba057421ba9"/><dir name="Trans"><dir name="Helper"><file name="Contact.php" hash="f7eddee0fa61fb197d4a90d813a4b579"/><file name="Contactlist.php" hash="e288ff740871f4d21c9781f730959417"/><file name="Scenario.php" hash="5ddd91cfbb70afbcb57f2084bb1e80e3"/></dir><dir name="Model"><file name="Observer.php" hash="70cede658f89324972e6d3cb9b0ff367"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Contactlists.php" hash="246ecc00a9381e3468062ec4b10c6584"/><file name="Scenariolist.php" hash="e0c99ca7ac545b18fc5b5540867ea6b8"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="86910cfba6392ca627a6cf23938a87b7"/><file name="config.xml" hash="449970d062bd6d57be6edad8f8f22b8a"/><file name="system.xml" hash="fa1976f9423e26e29a42bf155876703f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Livedata_Trans.xml" hash="513a947383ede06a9fa880a3bcacebf7"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php><package><name>Aschroder_ SMTPPro</name><channel>local</channel><min>1.6</min><max>1.9.2</max><files><file target="." path="app/etc/modules/Aschroder_SMTPPro.xml "/></files></package></required></dependencies>
|
18 |
</package>
|