Version Notes
Stability Improvements
Download this release
Release Info
Developer | Conlabz GmbH |
Extension | Conlabz_CrConnect |
Version | 3.1.4 |
Comparing to | |
See all releases |
Code changes from version 3.0.5 to 3.1.4
- app/code/community/Conlabz/CrConnect/Block/Adminhtml/Customer/Edit/Tab/Newsletter.php +17 -14
- app/code/community/Conlabz/CrConnect/Block/Adminhtml/Newsletter/Subscriber.php +36 -37
- app/code/community/Conlabz/CrConnect/Block/Config/GroupsApis.php +8 -12
- app/code/community/Conlabz/CrConnect/Block/Config/Key.php +1 -2
- app/code/community/Conlabz/CrConnect/Block/Config/Url.php +1 -2
- app/code/community/Conlabz/CrConnect/Block/Customer/Newsletter.php +12 -10
- app/code/community/Conlabz/CrConnect/Block/Groupsapis.php +6 -11
- app/code/community/Conlabz/CrConnect/Helper/Data.php +90 -78
- app/code/community/Conlabz/CrConnect/Model/Api.php +87 -92
- app/code/community/Conlabz/CrConnect/Model/Checkout/Observer.php +127 -130
- app/code/community/Conlabz/CrConnect/Model/Customer/Observer.php +116 -129
- app/code/community/Conlabz/CrConnect/Model/Newsletter/Subscriber.php +7 -5
- app/code/community/Conlabz/CrConnect/Model/Observer.php +85 -109
- app/code/community/Conlabz/CrConnect/Model/Search.php +8 -6
- app/code/community/Conlabz/CrConnect/Model/Subscriber.php +10 -6
- app/code/community/Conlabz/CrConnect/Model/System/Config/Source/EmptyForms.php +0 -1
- app/code/community/Conlabz/CrConnect/Model/System/Config/Source/EmptyList.php +0 -1
- app/code/community/Conlabz/CrConnect/Model/Website/Observer.php +8 -7
- app/code/community/Conlabz/CrConnect/controllers/AccountController.php +12 -17
- app/code/community/Conlabz/CrConnect/controllers/Adminhtml/ConfigController.php +21 -17
- app/code/community/Conlabz/CrConnect/controllers/Adminhtml/CrconnectController.php +12 -10
- app/code/community/Conlabz/CrConnect/controllers/HookController.php +92 -93
- app/code/community/Conlabz/CrConnect/controllers/ManageController.php +5 -8
- app/code/community/Conlabz/CrConnect/controllers/SearchController.php +4 -3
- app/code/community/Conlabz/CrConnect/controllers/SubscriberController.php +5 -6
- app/code/community/Conlabz/CrConnect/controllers/UnsubscribeController.php +24 -32
- app/code/community/Conlabz/CrConnect/etc/adminhtml.xml +1 -1
- app/code/community/Conlabz/CrConnect/etc/config.xml +8 -8
- package.xml +5 -6
app/code/community/Conlabz/CrConnect/Block/Adminhtml/Customer/Edit/Tab/Newsletter.php
CHANGED
@@ -28,10 +28,11 @@ class Conlabz_CrConnect_Block_Adminhtml_Customer_Edit_Tab_Newsletter extends Mag
|
|
28 |
$fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('customer')->__('Newsletter Information')));
|
29 |
|
30 |
$isMultiply = Mage::helper("crconnect")->getGroupsIds($customer->getGroupId());
|
31 |
-
if (!Mage::helper('crconnect')->isShowDefaultGroup() || !$isMultiply){
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
'label' => Mage::helper('customer')->__('Subscribed to Newsletter?'),
|
36 |
'name' => 'subscription'
|
37 |
)
|
@@ -45,10 +46,11 @@ class Conlabz_CrConnect_Block_Adminhtml_Customer_Edit_Tab_Newsletter extends Mag
|
|
45 |
|
46 |
}
|
47 |
|
48 |
-
if (Mage::helper("crconnect")->isDefaultGroupUser($customer->getGroupId())){
|
49 |
-
|
50 |
$groupName = Mage::getModel('customer/group')->load($customer->getGroupId())->getCode();
|
51 |
-
$fieldset->addField(
|
|
|
|
|
52 |
array(
|
53 |
'label' => Mage::helper('customer')->__('Subscribed to %s Newsletter?', $groupName),
|
54 |
'name' => 'gsubscription'
|
@@ -56,26 +58,27 @@ class Conlabz_CrConnect_Block_Adminhtml_Customer_Edit_Tab_Newsletter extends Mag
|
|
56 |
);
|
57 |
|
58 |
$ifCustomSubscribed = Mage::getModel('crconnect/api')->isSubscribed(
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
$form->getElement('gsubscription')->setIsChecked($ifCustomSubscribed);
|
64 |
|
65 |
}
|
66 |
|
67 |
-
if($changedDate = $this->getStatusChangedDate()) {
|
68 |
-
$fieldset->addField(
|
|
|
|
|
69 |
array(
|
70 |
'label' => $subscriber->isSubscribed() ? Mage::helper('customer')->__('Last Date Subscribed') : Mage::helper('customer')->__('Last Date Unsubscribed'),
|
71 |
'value' => $changedDate,
|
72 |
'bold' => true
|
73 |
)
|
74 |
-
|
75 |
}
|
76 |
|
77 |
$this->setForm($form);
|
78 |
return $this;
|
79 |
}
|
80 |
-
|
81 |
}
|
28 |
$fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('customer')->__('Newsletter Information')));
|
29 |
|
30 |
$isMultiply = Mage::helper("crconnect")->getGroupsIds($customer->getGroupId());
|
31 |
+
if (!Mage::helper('crconnect')->isShowDefaultGroup() || !$isMultiply) {
|
32 |
+
$fieldset->addField(
|
33 |
+
'subscription',
|
34 |
+
'checkbox',
|
35 |
+
array(
|
36 |
'label' => Mage::helper('customer')->__('Subscribed to Newsletter?'),
|
37 |
'name' => 'subscription'
|
38 |
)
|
46 |
|
47 |
}
|
48 |
|
49 |
+
if (Mage::helper("crconnect")->isDefaultGroupUser($customer->getGroupId())) {
|
|
|
50 |
$groupName = Mage::getModel('customer/group')->load($customer->getGroupId())->getCode();
|
51 |
+
$fieldset->addField(
|
52 |
+
'gsubscription',
|
53 |
+
'checkbox',
|
54 |
array(
|
55 |
'label' => Mage::helper('customer')->__('Subscribed to %s Newsletter?', $groupName),
|
56 |
'name' => 'gsubscription'
|
58 |
);
|
59 |
|
60 |
$ifCustomSubscribed = Mage::getModel('crconnect/api')->isSubscribed(
|
61 |
+
$customer->getEmail(),
|
62 |
+
$customer->getGroupId()
|
63 |
+
);
|
64 |
|
65 |
$form->getElement('gsubscription')->setIsChecked($ifCustomSubscribed);
|
66 |
|
67 |
}
|
68 |
|
69 |
+
if ($changedDate = $this->getStatusChangedDate()) {
|
70 |
+
$fieldset->addField(
|
71 |
+
'change_status_date',
|
72 |
+
'label',
|
73 |
array(
|
74 |
'label' => $subscriber->isSubscribed() ? Mage::helper('customer')->__('Last Date Subscribed') : Mage::helper('customer')->__('Last Date Unsubscribed'),
|
75 |
'value' => $changedDate,
|
76 |
'bold' => true
|
77 |
)
|
78 |
+
);
|
79 |
}
|
80 |
|
81 |
$this->setForm($form);
|
82 |
return $this;
|
83 |
}
|
|
|
84 |
}
|
app/code/community/Conlabz/CrConnect/Block/Adminhtml/Newsletter/Subscriber.php
CHANGED
@@ -4,84 +4,83 @@ class Conlabz_CrConnect_Block_Adminhtml_Newsletter_Subscriber extends Mage_Admin
|
|
4 |
{
|
5 |
|
6 |
protected $_successStatus = "SUCCESS";
|
7 |
-
|
8 |
-
public function __construct()
|
|
|
9 |
|
10 |
$this->setTemplate('crconnect/newsletter/subscriber/list.phtml');
|
11 |
|
12 |
}
|
13 |
-
|
14 |
-
public function getSubscribersListData()
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
|
19 |
$api = Mage::getModel("crconnect/api");
|
20 |
|
21 |
-
if ($api->isConnected()){
|
22 |
-
$clientDetails = $api->clientGetDetails();
|
23 |
-
if ($clientDetails['error']){
|
24 |
$errorList[] = $clientDetails['error'];
|
25 |
-
}else{
|
26 |
$listInformation['client'] = $clientDetails['data'];
|
27 |
-
}
|
28 |
|
29 |
-
$groupStats = $api->groupGetStats();
|
30 |
-
if ($groupStats['error']){
|
31 |
$errorList[] = $groupStats['error'];
|
32 |
-
}else{
|
33 |
$listInformation['list'] = $groupStats['data'];
|
34 |
-
}
|
35 |
|
36 |
-
$groupDetails = $api->groupGetDetails();
|
37 |
-
if ($groupDetails['error']){
|
38 |
$errorList[] = $groupDetails['error'];
|
39 |
-
}else{
|
40 |
$listInformation['list']->name = $groupDetails['data']->name;
|
41 |
$listInformation['list']->last_mailing = $groupDetails['data']->last_mailing;
|
42 |
-
}
|
43 |
|
44 |
$listInformation['groups'] = array();
|
45 |
|
46 |
// If groups isset, get information for all groups in system
|
47 |
-
if ($api->isMultyGroups()){
|
48 |
-
|
49 |
$groups = Mage::helper("crconnect")->getGroupsIds();
|
50 |
-
$counter = 0;
|
51 |
-
foreach ($groups as $group){
|
52 |
-
|
53 |
-
|
54 |
-
if ($groupStats['error']){
|
55 |
$errorList[] = $groupStats['error'];
|
56 |
-
}else{
|
57 |
$listInformation['groups'][$counter] = $groupStats['data'];
|
58 |
}
|
59 |
|
60 |
-
$groupDetails = $api->groupGetDetails($group);
|
61 |
-
if ($groupDetails['error']){
|
62 |
$errorList[] = $groupDetails['error'];
|
63 |
-
}else{
|
64 |
$listInformation['groups'][$counter]->name = $groupDetails['data']->name;
|
65 |
-
}
|
66 |
|
67 |
-
$counter++;
|
68 |
}
|
69 |
|
70 |
}
|
71 |
|
72 |
|
73 |
-
}else{
|
74 |
-
|
75 |
$errorList[] = Mage::helper("crconnect")->__("Can not connect to CleverReach account. Please check your Cleverreach settings.");
|
76 |
-
|
77 |
}
|
78 |
|
79 |
//Get amount of active and not active subscribers in system
|
80 |
$activeSubscribers = count(Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter("subscriber_status", '1'));
|
81 |
$inactiveSubscribers = count(Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter("subscriber_status", '0'));
|
82 |
|
83 |
-
$listInformation['actvie_subscribers'] = $activeSubscribers;
|
84 |
-
|
85 |
|
86 |
return array('error'=>$errorList, 'info'=>$listInformation);
|
87 |
|
4 |
{
|
5 |
|
6 |
protected $_successStatus = "SUCCESS";
|
7 |
+
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
|
11 |
$this->setTemplate('crconnect/newsletter/subscriber/list.phtml');
|
12 |
|
13 |
}
|
14 |
+
|
15 |
+
public function getSubscribersListData()
|
16 |
+
{
|
17 |
|
18 |
+
$errorList = array();
|
19 |
+
$listInformation = array();
|
20 |
|
21 |
$api = Mage::getModel("crconnect/api");
|
22 |
|
23 |
+
if ($api->isConnected()) {
|
24 |
+
$clientDetails = $api->clientGetDetails();
|
25 |
+
if ($clientDetails['error']) {
|
26 |
$errorList[] = $clientDetails['error'];
|
27 |
+
} else {
|
28 |
$listInformation['client'] = $clientDetails['data'];
|
29 |
+
}
|
30 |
|
31 |
+
$groupStats = $api->groupGetStats();
|
32 |
+
if ($groupStats['error']) {
|
33 |
$errorList[] = $groupStats['error'];
|
34 |
+
} else {
|
35 |
$listInformation['list'] = $groupStats['data'];
|
36 |
+
}
|
37 |
|
38 |
+
$groupDetails = $api->groupGetDetails();
|
39 |
+
if ($groupDetails['error']) {
|
40 |
$errorList[] = $groupDetails['error'];
|
41 |
+
} else {
|
42 |
$listInformation['list']->name = $groupDetails['data']->name;
|
43 |
$listInformation['list']->last_mailing = $groupDetails['data']->last_mailing;
|
44 |
+
}
|
45 |
|
46 |
$listInformation['groups'] = array();
|
47 |
|
48 |
// If groups isset, get information for all groups in system
|
49 |
+
if ($api->isMultyGroups()) {
|
|
|
50 |
$groups = Mage::helper("crconnect")->getGroupsIds();
|
51 |
+
$counter = 0;
|
52 |
+
foreach ($groups as $group) {
|
53 |
+
$groupStats = $api->groupGetStats($group);
|
54 |
+
if ($groupStats['error']) {
|
|
|
55 |
$errorList[] = $groupStats['error'];
|
56 |
+
} else {
|
57 |
$listInformation['groups'][$counter] = $groupStats['data'];
|
58 |
}
|
59 |
|
60 |
+
$groupDetails = $api->groupGetDetails($group);
|
61 |
+
if ($groupDetails['error']) {
|
62 |
$errorList[] = $groupDetails['error'];
|
63 |
+
} else {
|
64 |
$listInformation['groups'][$counter]->name = $groupDetails['data']->name;
|
65 |
+
}
|
66 |
|
67 |
+
$counter++;
|
68 |
}
|
69 |
|
70 |
}
|
71 |
|
72 |
|
73 |
+
} else {
|
|
|
74 |
$errorList[] = Mage::helper("crconnect")->__("Can not connect to CleverReach account. Please check your Cleverreach settings.");
|
75 |
+
|
76 |
}
|
77 |
|
78 |
//Get amount of active and not active subscribers in system
|
79 |
$activeSubscribers = count(Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter("subscriber_status", '1'));
|
80 |
$inactiveSubscribers = count(Mage::getResourceModel('newsletter/subscriber_collection')->addFieldToFilter("subscriber_status", '0'));
|
81 |
|
82 |
+
$listInformation['actvie_subscribers'] = $activeSubscribers;
|
83 |
+
$listInformation['inactive_subscribers'] = $inactiveSubscribers;
|
84 |
|
85 |
return array('error'=>$errorList, 'info'=>$listInformation);
|
86 |
|
app/code/community/Conlabz/CrConnect/Block/Config/GroupsApis.php
CHANGED
@@ -32,10 +32,10 @@ class Conlabz_CrConnect_Block_Config_GroupsApis extends Mage_Adminhtml_Block_Sys
|
|
32 |
// Get Magento Groups List
|
33 |
$this->magentoOptions = array();
|
34 |
$allGroups = Mage::getModel('customer/group')->getCollection()->toOptionHash();
|
35 |
-
foreach($allGroups as $key
|
36 |
$this->magentoOptions[$key] = $allGroup;
|
37 |
}
|
38 |
-
|
39 |
}
|
40 |
/*
|
41 |
* Render Template
|
@@ -53,27 +53,24 @@ class Conlabz_CrConnect_Block_Config_GroupsApis extends Mage_Adminhtml_Block_Sys
|
|
53 |
|
54 |
$api = Mage::getModel("crconnect/api");
|
55 |
$groups = array();
|
56 |
-
if ($api->isConnected()){
|
57 |
$groups = $api->getGroupsForKey(Mage::helper('crconnect')->getApiKey());
|
58 |
-
if (!$groups){
|
59 |
$groups = array();
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
switch($columnName){
|
64 |
-
|
65 |
case 'magento':
|
66 |
$rendered = '<select style="width: 200px" name="'.$inputName.'" id="'.$inputId.'">';
|
67 |
-
foreach($this->magentoOptions as $att => $name)
|
68 |
-
{
|
69 |
$rendered .= '<option value="'.$att.'">'.$name.'</option>';
|
70 |
}
|
71 |
$rendered .= '</select>';
|
72 |
break;
|
73 |
case 'crconnect':
|
74 |
$rendered = '<select style="width: 200px" class="crconnect-groups-select" onchange="Crconnect.changeSubGroup(this)" id="'.$inputId.'" name="'.$inputName.'"><option value="">'.Mage::helper('crconnect')->__('Please select subscribers group').'</option>';
|
75 |
-
foreach($groups as $group)
|
76 |
-
{
|
77 |
$rendered .= '<option value="'.$group->id.'">'.$group->name.'</option>';
|
78 |
}
|
79 |
$rendered .= '</select>';
|
@@ -81,8 +78,7 @@ class Conlabz_CrConnect_Block_Config_GroupsApis extends Mage_Adminhtml_Block_Sys
|
|
81 |
case 'formid':
|
82 |
$emptyForms = Mage::getModel("crconnect/system_config_source_emptyForms")->toOptionArray();
|
83 |
$rendered = '<select style="width: 200px" name="'.$inputName.'" id="'.$inputId.'" class="crconnect-forms-select">';
|
84 |
-
foreach($emptyForms as $emptyForm)
|
85 |
-
{
|
86 |
$rendered .= '<option value="'.$emptyForm['value'].'">'.$emptyForm['label'].'</option>';
|
87 |
}
|
88 |
$rendered .= '</select>';
|
32 |
// Get Magento Groups List
|
33 |
$this->magentoOptions = array();
|
34 |
$allGroups = Mage::getModel('customer/group')->getCollection()->toOptionHash();
|
35 |
+
foreach ($allGroups as $key => $allGroup) {
|
36 |
$this->magentoOptions[$key] = $allGroup;
|
37 |
}
|
38 |
+
|
39 |
}
|
40 |
/*
|
41 |
* Render Template
|
53 |
|
54 |
$api = Mage::getModel("crconnect/api");
|
55 |
$groups = array();
|
56 |
+
if ($api->isConnected()) {
|
57 |
$groups = $api->getGroupsForKey(Mage::helper('crconnect')->getApiKey());
|
58 |
+
if (!$groups) {
|
59 |
$groups = array();
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
switch ($columnName) {
|
|
|
64 |
case 'magento':
|
65 |
$rendered = '<select style="width: 200px" name="'.$inputName.'" id="'.$inputId.'">';
|
66 |
+
foreach ($this->magentoOptions as $att => $name) {
|
|
|
67 |
$rendered .= '<option value="'.$att.'">'.$name.'</option>';
|
68 |
}
|
69 |
$rendered .= '</select>';
|
70 |
break;
|
71 |
case 'crconnect':
|
72 |
$rendered = '<select style="width: 200px" class="crconnect-groups-select" onchange="Crconnect.changeSubGroup(this)" id="'.$inputId.'" name="'.$inputName.'"><option value="">'.Mage::helper('crconnect')->__('Please select subscribers group').'</option>';
|
73 |
+
foreach ($groups as $group) {
|
|
|
74 |
$rendered .= '<option value="'.$group->id.'">'.$group->name.'</option>';
|
75 |
}
|
76 |
$rendered .= '</select>';
|
78 |
case 'formid':
|
79 |
$emptyForms = Mage::getModel("crconnect/system_config_source_emptyForms")->toOptionArray();
|
80 |
$rendered = '<select style="width: 200px" name="'.$inputName.'" id="'.$inputId.'" class="crconnect-forms-select">';
|
81 |
+
foreach ($emptyForms as $emptyForm) {
|
|
|
82 |
$rendered .= '<option value="'.$emptyForm['value'].'">'.$emptyForm['label'].'</option>';
|
83 |
}
|
84 |
$rendered .= '</select>';
|
app/code/community/Conlabz/CrConnect/Block/Config/Key.php
CHANGED
@@ -21,5 +21,4 @@ class Conlabz_CrConnect_Block_Config_Key extends Mage_Adminhtml_Block_System_Con
|
|
21 |
return '<div style="width:430px">'.$element."</div>";
|
22 |
|
23 |
}
|
24 |
-
|
25 |
-
}
|
21 |
return '<div style="width:430px">'.$element."</div>";
|
22 |
|
23 |
}
|
24 |
+
}
|
|
app/code/community/Conlabz/CrConnect/Block/Config/Url.php
CHANGED
@@ -10,5 +10,4 @@ class Conlabz_CrConnect_Block_Config_Url extends Mage_Adminhtml_Block_System_Con
|
|
10 |
$url .= "<font color='red'>store/1/</font>";
|
11 |
return "<b>".$url."</b>";
|
12 |
}
|
13 |
-
|
14 |
-
}
|
10 |
$url .= "<font color='red'>store/1/</font>";
|
11 |
return "<b>".$url."</b>";
|
12 |
}
|
13 |
+
}
|
|
app/code/community/Conlabz/CrConnect/Block/Customer/Newsletter.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
class Conlabz_CrConnect_Block_Customer_Newsletter extends Mage_Customer_Block_Newsletter
|
3 |
{
|
4 |
|
5 |
private $_api;
|
@@ -12,7 +12,8 @@ class Conlabz_CrConnect_Block_Customer_Newsletter extends Mage_Customer_Block_Ne
|
|
12 |
parent::__construct();
|
13 |
}
|
14 |
|
15 |
-
public function getCustomerGroupName()
|
|
|
16 |
|
17 |
$groupName = Mage::getModel('customer/group')->load($this->getCustomerGroupId())->getCode();
|
18 |
|
@@ -22,26 +23,27 @@ class Conlabz_CrConnect_Block_Customer_Newsletter extends Mage_Customer_Block_Ne
|
|
22 |
*
|
23 |
* @return bool
|
24 |
*/
|
25 |
-
public function isDefaultGroupUser()
|
|
|
26 |
|
27 |
return Mage::helper("crconnect")->isDefaultGroupUser($this->getCustomerGroupId());
|
28 |
|
29 |
}
|
30 |
|
31 |
-
public function isDefaultSubscribed()
|
|
|
32 |
|
33 |
return $this->_api->isSubscribed(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
|
34 |
|
35 |
}
|
36 |
|
37 |
-
public function isCustomSubscribed()
|
|
|
38 |
|
39 |
return $this->_api->isSubscribed(
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
}
|
45 |
-
|
46 |
-
|
47 |
}
|
1 |
<?php
|
2 |
+
class Conlabz_CrConnect_Block_Customer_Newsletter extends Mage_Customer_Block_Newsletter
|
3 |
{
|
4 |
|
5 |
private $_api;
|
12 |
parent::__construct();
|
13 |
}
|
14 |
|
15 |
+
public function getCustomerGroupName()
|
16 |
+
{
|
17 |
|
18 |
$groupName = Mage::getModel('customer/group')->load($this->getCustomerGroupId())->getCode();
|
19 |
|
23 |
*
|
24 |
* @return bool
|
25 |
*/
|
26 |
+
public function isDefaultGroupUser()
|
27 |
+
{
|
28 |
|
29 |
return Mage::helper("crconnect")->isDefaultGroupUser($this->getCustomerGroupId());
|
30 |
|
31 |
}
|
32 |
|
33 |
+
public function isDefaultSubscribed()
|
34 |
+
{
|
35 |
|
36 |
return $this->_api->isSubscribed(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
|
37 |
|
38 |
}
|
39 |
|
40 |
+
public function isCustomSubscribed()
|
41 |
+
{
|
42 |
|
43 |
return $this->_api->isSubscribed(
|
44 |
+
Mage::getSingleton('customer/session')->getCustomer()->getEmail(),
|
45 |
+
Mage::getSingleton('customer/session')->getCustomerGroupId()
|
46 |
+
);
|
47 |
|
48 |
}
|
|
|
|
|
49 |
}
|
app/code/community/Conlabz/CrConnect/Block/Groupsapis.php
CHANGED
@@ -21,11 +21,10 @@ class Conlabz_CrConnect_Block_GroupsApis extends Mage_Adminhtml_Block_System_Con
|
|
21 |
|
22 |
// customer options
|
23 |
$this->magentoOptions = array();
|
24 |
-
|
25 |
-
foreach($allGroups as $key
|
26 |
-
|
27 |
}
|
28 |
-
|
29 |
}
|
30 |
|
31 |
protected function _renderCellTemplate($columnName)
|
@@ -36,17 +35,13 @@ class Conlabz_CrConnect_Block_GroupsApis extends Mage_Adminhtml_Block_System_Con
|
|
36 |
$column = $this->_columns[$columnName];
|
37 |
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
38 |
|
39 |
-
if($columnName == 'magento')
|
40 |
-
{
|
41 |
$rendered = '<select name="'.$inputName.'">';
|
42 |
-
foreach($this->magentoOptions as $att => $name)
|
43 |
-
{
|
44 |
$rendered .= '<option value="'.$att.'">'.$name.'</option>';
|
45 |
}
|
46 |
$rendered .= '</select>';
|
47 |
-
}
|
48 |
-
else
|
49 |
-
{
|
50 |
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' . ($column['size'] ? 'size="' . $column['size'] . '"' : '') . '/>';
|
51 |
}
|
52 |
|
21 |
|
22 |
// customer options
|
23 |
$this->magentoOptions = array();
|
24 |
+
$allGroups = Mage::getModel('customer/group')->getCollection()->toOptionHash();
|
25 |
+
foreach ($allGroups as $key => $allGroup) {
|
26 |
+
$this->magentoOptions[$key] = $allGroup;
|
27 |
}
|
|
|
28 |
}
|
29 |
|
30 |
protected function _renderCellTemplate($columnName)
|
35 |
$column = $this->_columns[$columnName];
|
36 |
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
37 |
|
38 |
+
if ($columnName == 'magento') {
|
|
|
39 |
$rendered = '<select name="'.$inputName.'">';
|
40 |
+
foreach ($this->magentoOptions as $att => $name) {
|
|
|
41 |
$rendered .= '<option value="'.$att.'">'.$name.'</option>';
|
42 |
}
|
43 |
$rendered .= '</select>';
|
44 |
+
} else {
|
|
|
|
|
45 |
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' . ($column['size'] ? 'size="' . $column['size'] . '"' : '') . '/>';
|
46 |
}
|
47 |
|
app/code/community/Conlabz/CrConnect/Helper/Data.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract
|
|
|
4 |
|
5 |
const XML_WSDL_PATH = "http://api.cleverreach.com/soap/interface_v5.1.php?wsdl";
|
6 |
const XML_API_KEY_CONFIG_PATH = "crroot/crconnect/api_key";
|
@@ -22,147 +23,156 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
22 |
private $_currentStoreId = false;
|
23 |
private $_currentWebsiteId = false;
|
24 |
|
25 |
-
public function setCurrentStoreId($storeId = false)
|
|
|
26 |
$this->_currentStoreId = $storeId;
|
27 |
}
|
28 |
-
|
|
|
|
|
29 |
$this->_currentWebsiteId = $storeId;
|
30 |
}
|
31 |
|
32 |
-
|
33 |
* Get Wsdl path
|
34 |
*
|
35 |
* @return string - path
|
36 |
*/
|
37 |
-
|
38 |
-
|
39 |
return self::XML_WSDL_PATH;
|
40 |
}
|
41 |
|
42 |
-
|
43 |
* Get Feed password (same should be inserted on CleverReach account)
|
44 |
*/
|
45 |
-
|
46 |
-
|
47 |
return $this->getConfigForStore(self::XML_FEED_PASSWORD);
|
48 |
}
|
49 |
|
50 |
-
|
51 |
* Is exclude M2E orders from sync
|
52 |
*/
|
53 |
-
public function isM2eExclude()
|
|
|
54 |
return $this->getConfigForStore(self::XML_SYNC_ORDERS_M2E_PATH);
|
55 |
}
|
56 |
-
|
|
|
57 |
* Check if Douple Opt In enabled
|
58 |
*/
|
59 |
-
|
60 |
-
|
61 |
return $this->getConfigForStore(self::XML_PATH_LOGGED_CONFIRM_EMAIL_TEMPLATE);
|
62 |
}
|
63 |
|
64 |
-
|
65 |
* Get Api Key
|
66 |
*
|
67 |
* @return string - api key
|
68 |
*/
|
69 |
-
|
70 |
-
|
71 |
return $this->getConfigForStore(self::XML_API_KEY_CONFIG_PATH);
|
72 |
}
|
73 |
|
74 |
-
|
75 |
* Set Api Key
|
76 |
*
|
77 |
* @return string - api key
|
78 |
*/
|
79 |
-
public function setApiKey($key)
|
|
|
80 |
return Mage::getConfig()->saveConfig(self::XML_API_KEY_CONFIG_PATH, $key);
|
81 |
}
|
82 |
|
83 |
-
|
84 |
* Get Default List Id
|
85 |
*
|
86 |
* @return string - list Id
|
87 |
*/
|
88 |
-
|
89 |
-
|
90 |
|
91 |
return $this->getConfigForStore(self::XML_LIST_ID_CONFIG_PATH);
|
92 |
|
93 |
}
|
94 |
|
95 |
-
|
96 |
* Get Default Form Id
|
97 |
*
|
98 |
* @return string - list Id
|
99 |
*/
|
100 |
-
|
101 |
-
|
102 |
|
103 |
return $this->getConfigForStore(self::XML_FORM_ID_CONFIG_PATH);
|
104 |
|
105 |
}
|
106 |
|
107 |
-
|
108 |
* Check if orders tracking enabled
|
109 |
*
|
110 |
* @return bool - 0 or 1
|
111 |
*/
|
112 |
-
|
113 |
-
|
114 |
return $this->getConfigForStore(self::XML_SYNC_ORDERS_CONFIG_PATH);
|
115 |
}
|
116 |
|
117 |
-
|
118 |
* Check if automated separation enabled
|
119 |
*
|
120 |
* @return bool - 0 or 1
|
121 |
*/
|
122 |
-
|
123 |
-
|
124 |
return $this->getConfigForStore(self::XML_GROUP_SEPARATION_CONFIG_PATH);
|
125 |
}
|
126 |
|
127 |
-
|
128 |
* Log Clever Reach Connect activity
|
129 |
*
|
130 |
* @param - string message
|
131 |
*/
|
132 |
-
|
133 |
-
|
134 |
|
135 |
Mage::log($message, null, "crconnect.log", true);
|
136 |
}
|
137 |
|
138 |
-
|
139 |
* Get if sync order emails enabled
|
140 |
*/
|
141 |
-
public function isForceSyncEnabled()
|
|
|
142 |
return Mage::getStoreConfig(self::XML_SYNC_ORDERS_EMAILS_CONFIG_PATH);
|
143 |
}
|
144 |
|
145 |
-
|
146 |
* Get groups keys json value from system settings
|
147 |
*
|
148 |
* @return json
|
149 |
*/
|
150 |
-
public function getGroupsSystemValue()
|
|
|
151 |
|
152 |
return $this->getConfigForStore(self::XML_GROUP_KEYS);
|
153 |
|
154 |
}
|
155 |
|
156 |
-
public function getConfigForStore($path)
|
|
|
157 |
|
158 |
$newsletterConfig = Mage::getStoreConfig($path);
|
159 |
|
160 |
-
if ($store = $this->_currentStoreId){
|
161 |
return Mage::getStoreConfig($path, $store);
|
162 |
}
|
163 |
-
if ($website = $this->_currentWebsiteId){
|
164 |
$newsletterConfig = (array)Mage::getConfig()->getNode('websites/'.$website.'/'.$path);
|
165 |
-
if (isset($newsletterConfig[0])){
|
166 |
return $newsletterConfig[0];
|
167 |
}
|
168 |
}
|
@@ -173,12 +183,12 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
173 |
// }
|
174 |
// }
|
175 |
|
176 |
-
if ($store = Mage::app()->getRequest()->getParam('store')){
|
177 |
$newsletterConfig = Mage::getStoreConfig($path, $store);
|
178 |
-
}else{
|
179 |
-
if ($website = Mage::app()->getRequest()->getParam('website')){
|
180 |
$newsletterConfig = (array)Mage::getConfig()->getNode('websites/'.$website.'/'.$path);
|
181 |
-
if (isset($newsletterConfig[0])){
|
182 |
$newsletterConfig = $newsletterConfig[0];
|
183 |
}
|
184 |
}
|
@@ -186,7 +196,8 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
186 |
return $newsletterConfig;
|
187 |
|
188 |
}
|
189 |
-
|
|
|
190 |
* get non default groups ids
|
191 |
*
|
192 |
* @param int group ID - if isset get key for special group
|
@@ -194,8 +205,8 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
194 |
*
|
195 |
* @return array | int = array of keys, OR groups ID
|
196 |
*/
|
197 |
-
|
198 |
-
|
199 |
|
200 |
$newsletterConfig = unserialize($this->getConfigForStore(self::XML_GROUP_KEYS));
|
201 |
$keysArray = array();
|
@@ -220,7 +231,7 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
220 |
return $keysArray;
|
221 |
}
|
222 |
|
223 |
-
|
224 |
* get non default forms ids
|
225 |
*
|
226 |
* @param int group ID - if isset get key for special group
|
@@ -228,8 +239,8 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
228 |
*
|
229 |
* @return array | int = array of keys, OR groups ID
|
230 |
*/
|
231 |
-
|
232 |
-
|
233 |
|
234 |
$newsletterConfig = unserialize($this->getConfigForStore(self::XML_GROUP_KEYS));
|
235 |
$keysArray = array();
|
@@ -255,13 +266,13 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
255 |
return $keysArray;
|
256 |
}
|
257 |
|
258 |
-
|
259 |
* get non default forms ids
|
260 |
*
|
261 |
* @return array | int = array of keys, OR groups ID
|
262 |
*/
|
263 |
-
|
264 |
-
|
265 |
|
266 |
$newsletterConfig = unserialize($this->getConfigForStore(self::XML_GROUP_KEYS));
|
267 |
|
@@ -269,8 +280,8 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
269 |
|
270 |
// Generate array of groupId=>key
|
271 |
if (is_array($newsletterConfig)) {
|
272 |
-
foreach ($newsletterConfig as $key
|
273 |
-
if (isset($config['formid'])){
|
274 |
$keysArray[$key] = $config['formid'];
|
275 |
}
|
276 |
}
|
@@ -279,11 +290,11 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
279 |
return $keysArray;
|
280 |
}
|
281 |
|
282 |
-
|
283 |
* get active subscribers
|
284 |
*/
|
285 |
-
|
286 |
-
|
287 |
|
288 |
return Mage::getResourceModel('newsletter/subscriber_collection')
|
289 |
->showStoreInfo()
|
@@ -292,13 +303,14 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
292 |
->getData();
|
293 |
}
|
294 |
|
295 |
-
public function prepareUserdata($customer, $custom_fields = false, $deactivate = false)
|
|
|
296 |
|
297 |
$name = $customer->getFirstname() . " " . $customer->getLastname();
|
298 |
$newEmail = $customer->getEmail();
|
299 |
$subscribed = $customer->getIsSubscribed();
|
300 |
$shippingAddress = false;
|
301 |
-
if ($shippingAddress = $customer->getDefaultBillingAddress()){
|
302 |
$shippingAddress = $shippingAddress->getData();
|
303 |
}
|
304 |
|
@@ -332,7 +344,7 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
332 |
3 => array("key" => 'title', "value" => @$customer->getSuffix()));
|
333 |
}
|
334 |
|
335 |
-
if($deactivate){
|
336 |
$crReceiver['deactivated'] = 1;
|
337 |
}
|
338 |
|
@@ -350,38 +362,38 @@ class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
350 |
return $crReceiver;
|
351 |
}
|
352 |
|
353 |
-
|
354 |
* Show or not customer group as separate group
|
355 |
*/
|
356 |
-
public function isShowDefaultGroup()
|
|
|
357 |
|
358 |
return $this->getConfigForStore(self::XML_IS_SHOW_CUSTOMER_GROUP);
|
359 |
|
360 |
}
|
361 |
|
362 |
-
|
363 |
* If more then 1 user group key added, return true
|
364 |
*/
|
365 |
-
public function isMultiGroupsSettings()
|
366 |
-
|
367 |
$groupIds = $this->getGroupsIds();
|
368 |
-
if (is_array($groupIds) && sizeof($groupIds) > 1){
|
369 |
return true;
|
370 |
}
|
371 |
-
return false;
|
372 |
-
|
373 |
}
|
374 |
-
|
375 |
-
|
376 |
-
|
|
|
377 |
return true;
|
378 |
}
|
379 |
return false;
|
380 |
-
|
381 |
}
|
382 |
-
|
383 |
-
|
|
|
384 |
return array("m2eproshipping_m2eproshipping");
|
385 |
-
|
386 |
}
|
387 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Conlabz_CrConnect_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
|
6 |
const XML_WSDL_PATH = "http://api.cleverreach.com/soap/interface_v5.1.php?wsdl";
|
7 |
const XML_API_KEY_CONFIG_PATH = "crroot/crconnect/api_key";
|
23 |
private $_currentStoreId = false;
|
24 |
private $_currentWebsiteId = false;
|
25 |
|
26 |
+
public function setCurrentStoreId($storeId = false)
|
27 |
+
{
|
28 |
$this->_currentStoreId = $storeId;
|
29 |
}
|
30 |
+
|
31 |
+
public function setCurrentWebsiteId($storeId = false)
|
32 |
+
{
|
33 |
$this->_currentWebsiteId = $storeId;
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
* Get Wsdl path
|
38 |
*
|
39 |
* @return string - path
|
40 |
*/
|
41 |
+
public function getWsdl()
|
42 |
+
{
|
43 |
return self::XML_WSDL_PATH;
|
44 |
}
|
45 |
|
46 |
+
/**
|
47 |
* Get Feed password (same should be inserted on CleverReach account)
|
48 |
*/
|
49 |
+
public function getCleverReachFeedPassword()
|
50 |
+
{
|
51 |
return $this->getConfigForStore(self::XML_FEED_PASSWORD);
|
52 |
}
|
53 |
|
54 |
+
/**
|
55 |
* Is exclude M2E orders from sync
|
56 |
*/
|
57 |
+
public function isM2eExclude()
|
58 |
+
{
|
59 |
return $this->getConfigForStore(self::XML_SYNC_ORDERS_M2E_PATH);
|
60 |
}
|
61 |
+
|
62 |
+
/**
|
63 |
* Check if Douple Opt In enabled
|
64 |
*/
|
65 |
+
public function isDoubleOptInEnabled()
|
66 |
+
{
|
67 |
return $this->getConfigForStore(self::XML_PATH_LOGGED_CONFIRM_EMAIL_TEMPLATE);
|
68 |
}
|
69 |
|
70 |
+
/**
|
71 |
* Get Api Key
|
72 |
*
|
73 |
* @return string - api key
|
74 |
*/
|
75 |
+
public function getApiKey()
|
76 |
+
{
|
77 |
return $this->getConfigForStore(self::XML_API_KEY_CONFIG_PATH);
|
78 |
}
|
79 |
|
80 |
+
/**
|
81 |
* Set Api Key
|
82 |
*
|
83 |
* @return string - api key
|
84 |
*/
|
85 |
+
public function setApiKey($key)
|
86 |
+
{
|
87 |
return Mage::getConfig()->saveConfig(self::XML_API_KEY_CONFIG_PATH, $key);
|
88 |
}
|
89 |
|
90 |
+
/**
|
91 |
* Get Default List Id
|
92 |
*
|
93 |
* @return string - list Id
|
94 |
*/
|
95 |
+
public function getDefaultListId()
|
96 |
+
{
|
97 |
|
98 |
return $this->getConfigForStore(self::XML_LIST_ID_CONFIG_PATH);
|
99 |
|
100 |
}
|
101 |
|
102 |
+
/**
|
103 |
* Get Default Form Id
|
104 |
*
|
105 |
* @return string - list Id
|
106 |
*/
|
107 |
+
public function getDefaultFormId()
|
108 |
+
{
|
109 |
|
110 |
return $this->getConfigForStore(self::XML_FORM_ID_CONFIG_PATH);
|
111 |
|
112 |
}
|
113 |
|
114 |
+
/**
|
115 |
* Check if orders tracking enabled
|
116 |
*
|
117 |
* @return bool - 0 or 1
|
118 |
*/
|
119 |
+
public function isTrackingEnabled()
|
120 |
+
{
|
121 |
return $this->getConfigForStore(self::XML_SYNC_ORDERS_CONFIG_PATH);
|
122 |
}
|
123 |
|
124 |
+
/**
|
125 |
* Check if automated separation enabled
|
126 |
*
|
127 |
* @return bool - 0 or 1
|
128 |
*/
|
129 |
+
public function isSeparationEnabled()
|
130 |
+
{
|
131 |
return $this->getConfigForStore(self::XML_GROUP_SEPARATION_CONFIG_PATH);
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
* Log Clever Reach Connect activity
|
136 |
*
|
137 |
* @param - string message
|
138 |
*/
|
139 |
+
public function log($message)
|
140 |
+
{
|
141 |
|
142 |
Mage::log($message, null, "crconnect.log", true);
|
143 |
}
|
144 |
|
145 |
+
/**
|
146 |
* Get if sync order emails enabled
|
147 |
*/
|
148 |
+
public function isForceSyncEnabled()
|
149 |
+
{
|
150 |
return Mage::getStoreConfig(self::XML_SYNC_ORDERS_EMAILS_CONFIG_PATH);
|
151 |
}
|
152 |
|
153 |
+
/**
|
154 |
* Get groups keys json value from system settings
|
155 |
*
|
156 |
* @return json
|
157 |
*/
|
158 |
+
public function getGroupsSystemValue()
|
159 |
+
{
|
160 |
|
161 |
return $this->getConfigForStore(self::XML_GROUP_KEYS);
|
162 |
|
163 |
}
|
164 |
|
165 |
+
public function getConfigForStore($path)
|
166 |
+
{
|
167 |
|
168 |
$newsletterConfig = Mage::getStoreConfig($path);
|
169 |
|
170 |
+
if ($store = $this->_currentStoreId) {
|
171 |
return Mage::getStoreConfig($path, $store);
|
172 |
}
|
173 |
+
if ($website = $this->_currentWebsiteId) {
|
174 |
$newsletterConfig = (array)Mage::getConfig()->getNode('websites/'.$website.'/'.$path);
|
175 |
+
if (isset($newsletterConfig[0])) {
|
176 |
return $newsletterConfig[0];
|
177 |
}
|
178 |
}
|
183 |
// }
|
184 |
// }
|
185 |
|
186 |
+
if ($store = Mage::app()->getRequest()->getParam('store')) {
|
187 |
$newsletterConfig = Mage::getStoreConfig($path, $store);
|
188 |
+
} else {
|
189 |
+
if ($website = Mage::app()->getRequest()->getParam('website')) {
|
190 |
$newsletterConfig = (array)Mage::getConfig()->getNode('websites/'.$website.'/'.$path);
|
191 |
+
if (isset($newsletterConfig[0])) {
|
192 |
$newsletterConfig = $newsletterConfig[0];
|
193 |
}
|
194 |
}
|
196 |
return $newsletterConfig;
|
197 |
|
198 |
}
|
199 |
+
|
200 |
+
/**
|
201 |
* get non default groups ids
|
202 |
*
|
203 |
* @param int group ID - if isset get key for special group
|
205 |
*
|
206 |
* @return array | int = array of keys, OR groups ID
|
207 |
*/
|
208 |
+
public function getGroupsIds($groupId = false, $defaultOnFail = false)
|
209 |
+
{
|
210 |
|
211 |
$newsletterConfig = unserialize($this->getConfigForStore(self::XML_GROUP_KEYS));
|
212 |
$keysArray = array();
|
231 |
return $keysArray;
|
232 |
}
|
233 |
|
234 |
+
/**
|
235 |
* get non default forms ids
|
236 |
*
|
237 |
* @param int group ID - if isset get key for special group
|
239 |
*
|
240 |
* @return array | int = array of keys, OR groups ID
|
241 |
*/
|
242 |
+
public function getFormsIds($groupId = false, $defaultOnFail = false)
|
243 |
+
{
|
244 |
|
245 |
$newsletterConfig = unserialize($this->getConfigForStore(self::XML_GROUP_KEYS));
|
246 |
$keysArray = array();
|
266 |
return $keysArray;
|
267 |
}
|
268 |
|
269 |
+
/**
|
270 |
* get non default forms ids
|
271 |
*
|
272 |
* @return array | int = array of keys, OR groups ID
|
273 |
*/
|
274 |
+
public function getFormsIdsByKeys()
|
275 |
+
{
|
276 |
|
277 |
$newsletterConfig = unserialize($this->getConfigForStore(self::XML_GROUP_KEYS));
|
278 |
|
280 |
|
281 |
// Generate array of groupId=>key
|
282 |
if (is_array($newsletterConfig)) {
|
283 |
+
foreach ($newsletterConfig as $key => $config) {
|
284 |
+
if (isset($config['formid'])) {
|
285 |
$keysArray[$key] = $config['formid'];
|
286 |
}
|
287 |
}
|
290 |
return $keysArray;
|
291 |
}
|
292 |
|
293 |
+
/**
|
294 |
* get active subscribers
|
295 |
*/
|
296 |
+
public function getActiveMageSubscribers()
|
297 |
+
{
|
298 |
|
299 |
return Mage::getResourceModel('newsletter/subscriber_collection')
|
300 |
->showStoreInfo()
|
303 |
->getData();
|
304 |
}
|
305 |
|
306 |
+
public function prepareUserdata($customer, $custom_fields = false, $deactivate = false)
|
307 |
+
{
|
308 |
|
309 |
$name = $customer->getFirstname() . " " . $customer->getLastname();
|
310 |
$newEmail = $customer->getEmail();
|
311 |
$subscribed = $customer->getIsSubscribed();
|
312 |
$shippingAddress = false;
|
313 |
+
if ($shippingAddress = $customer->getDefaultBillingAddress()) {
|
314 |
$shippingAddress = $shippingAddress->getData();
|
315 |
}
|
316 |
|
344 |
3 => array("key" => 'title', "value" => @$customer->getSuffix()));
|
345 |
}
|
346 |
|
347 |
+
if ($deactivate) {
|
348 |
$crReceiver['deactivated'] = 1;
|
349 |
}
|
350 |
|
362 |
return $crReceiver;
|
363 |
}
|
364 |
|
365 |
+
/**
|
366 |
* Show or not customer group as separate group
|
367 |
*/
|
368 |
+
public function isShowDefaultGroup()
|
369 |
+
{
|
370 |
|
371 |
return $this->getConfigForStore(self::XML_IS_SHOW_CUSTOMER_GROUP);
|
372 |
|
373 |
}
|
374 |
|
375 |
+
/**
|
376 |
* If more then 1 user group key added, return true
|
377 |
*/
|
378 |
+
public function isMultiGroupsSettings()
|
379 |
+
{
|
380 |
$groupIds = $this->getGroupsIds();
|
381 |
+
if (is_array($groupIds) && sizeof($groupIds) > 1) {
|
382 |
return true;
|
383 |
}
|
384 |
+
return false;
|
|
|
385 |
}
|
386 |
+
|
387 |
+
public function isDefaultGroupUser($groupId)
|
388 |
+
{
|
389 |
+
if ($groupId != self::DEFAULT_GROUP_ID) {
|
390 |
return true;
|
391 |
}
|
392 |
return false;
|
|
|
393 |
}
|
394 |
+
|
395 |
+
public function getM2eShippingMethods()
|
396 |
+
{
|
397 |
return array("m2eproshipping_m2eproshipping");
|
|
|
398 |
}
|
399 |
}
|
app/code/community/Conlabz/CrConnect/Model/Api.php
CHANGED
@@ -1,23 +1,26 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract
|
|
|
4 |
|
5 |
const SUCCESS_STATUS = "SUCCESS";
|
6 |
|
7 |
const ERROR_CODE_DUPLICATED = 50;
|
8 |
const ERROR_CODE_INVALID = 40;
|
9 |
|
10 |
-
public function __construct()
|
|
|
11 |
|
12 |
$this->init();
|
13 |
|
14 |
}
|
15 |
|
16 |
-
public function init($storeId = false)
|
|
|
17 |
|
18 |
$this->_helper = Mage::helper('crconnect');
|
19 |
|
20 |
-
if ($storeId){
|
21 |
$this->_helper->log($this->_helper->__("SET Helper Store: ". $storeId));
|
22 |
$this->_helper->setCurrentStoreId($storeId);
|
23 |
}
|
@@ -32,7 +35,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
32 |
* Get Connection to CrConnect
|
33 |
*/
|
34 |
|
35 |
-
public function getSoapClient()
|
|
|
36 |
|
37 |
try {
|
38 |
$client = new SoapClient($this->_helper->getWsdl(), array("trace" => true, "exception" => 0));
|
@@ -46,24 +50,22 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
46 |
}
|
47 |
|
48 |
|
49 |
-
public function subscribe($customer = false, $groupId = 0)
|
|
|
50 |
|
51 |
-
if ($this->isConnected()){
|
52 |
-
|
53 |
if (!$customer) {
|
54 |
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
55 |
}
|
56 |
$crReceiver = $this->_helper->prepareUserdata($customer, array('newsletter' => 1));
|
57 |
$addResult = $this->receiverAdd($crReceiver, $groupId);
|
58 |
if ($addResult->status == self::SUCCESS_STATUS) {
|
59 |
-
|
60 |
$this->_helper->log($this->_helper->__("CALL: receiverAdd - SUCCESS"));
|
61 |
$this->_helper->log($crReceiver);
|
62 |
$this->_helper->log("receiverAdd: GroupId: ".$groupId);
|
63 |
|
64 |
return true;
|
65 |
} else {
|
66 |
-
|
67 |
$this->_helper->log($this->_helper->__("CALL: receiverAdd - FAIL, then call receiverSetActive:".$customer->getEmail()));
|
68 |
$this->_helper->log("receiverSetActive: GroupId: ".$groupId);
|
69 |
|
@@ -75,24 +77,22 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
75 |
return false;
|
76 |
}
|
77 |
|
78 |
-
public function update($customer = false, $groupId = 0)
|
|
|
79 |
|
80 |
-
if ($this->isConnected()){
|
81 |
-
|
82 |
if (!$customer) {
|
83 |
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
84 |
}
|
85 |
$crReceiver = $this->_helper->prepareUserdata($customer);
|
86 |
$updateResult = $this->receiverUpdate($crReceiver, $customer->getGroupId());
|
87 |
if ($updateResult->status == self::SUCCESS_STATUS) {
|
88 |
-
|
89 |
$this->_helper->log($this->_helper->__("CALL: receiverUpdate - SUCCESS"));
|
90 |
$this->_helper->log($crReceiver);
|
91 |
$this->_helper->log("receiverUpdate: GroupId: ".$customer->getGroupId());
|
92 |
|
93 |
return true;
|
94 |
} else {
|
95 |
-
|
96 |
$this->_helper->log($this->_helper->__("CALL: receiverUpdate - FAIL"));
|
97 |
|
98 |
}
|
@@ -103,10 +103,10 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
103 |
|
104 |
}
|
105 |
|
106 |
-
public function unsubscribe($email = false, $groupId = 0)
|
|
|
107 |
|
108 |
-
if ($this->isConnected() && $email){
|
109 |
-
|
110 |
$result = $this->receiverSetInactive($email, $groupId);
|
111 |
if ($result->status == self::SUCCESS_STATUS) {
|
112 |
$this->_helper->log($this->_helper->__("CALL: receiverSetInactive - SUCCESS, Email:".$email." | GroupId:".$groupId));
|
@@ -121,9 +121,10 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
121 |
* Check if connection was successfull
|
122 |
*/
|
123 |
|
124 |
-
public function isConnected()
|
|
|
125 |
|
126 |
-
if ($this->_client !== false && $this->_client !==
|
127 |
return true;
|
128 |
}
|
129 |
return false;
|
@@ -133,7 +134,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
133 |
* If Account have more then 1 group
|
134 |
*/
|
135 |
|
136 |
-
public function isMultyGroups()
|
|
|
137 |
|
138 |
if (is_array($this->_groupsListIds) && sizeof($this->_groupsListIds) > 0) {
|
139 |
return true;
|
@@ -141,7 +143,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
141 |
return false;
|
142 |
}
|
143 |
|
144 |
-
public function getGroupKey($groupId)
|
|
|
145 |
|
146 |
if ($groupId == 0) {
|
147 |
$listId = $this->_helper->getDefaultListId();
|
@@ -154,7 +157,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
154 |
/*
|
155 |
* Subscriber simple user to special group
|
156 |
*/
|
157 |
-
public function receiverAdd($customerData, $groupId = 0)
|
|
|
158 |
|
159 |
$listId = $this->getGroupKey($groupId);
|
160 |
|
@@ -168,7 +172,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
168 |
/*
|
169 |
* Update simple user
|
170 |
*/
|
171 |
-
public function receiverUpdate($customerData, $groupId = 0)
|
|
|
172 |
|
173 |
$listId = $this->getGroupKey($groupId);
|
174 |
|
@@ -182,7 +187,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
182 |
/*
|
183 |
* Deactivates a given receiver/email
|
184 |
*/
|
185 |
-
public function receiverSetInactive($email, $groupId = 0)
|
|
|
186 |
|
187 |
$listId = $this->getGroupKey($groupId);
|
188 |
$this->_helper->log("CALL: receiverSetInactive - Email".$email." | GroupId:". $groupId);
|
@@ -190,7 +196,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
190 |
|
191 |
}
|
192 |
|
193 |
-
public function receiverSetActive($email, $groupId = 0)
|
|
|
194 |
|
195 |
$listId = $this->getGroupKey($groupId);
|
196 |
$this->_helper->log("CALL: receiverSetActive - Email".$email." | GroupId:". $groupId);
|
@@ -208,7 +215,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
208 |
* @return array - result
|
209 |
*/
|
210 |
|
211 |
-
private function returnResult($result, $fail = false)
|
|
|
212 |
|
213 |
$return = array();
|
214 |
$return['error'] = $fail;
|
@@ -220,13 +228,13 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
220 |
* Get user account details
|
221 |
*/
|
222 |
|
223 |
-
public function clientGetDetails()
|
|
|
224 |
|
225 |
$result = $this->_client->clientGetDetails($this->_apiKey);
|
226 |
if ($result->status == self::SUCCESS_STATUS) {
|
227 |
return $this->returnResult($result->data);
|
228 |
} else {
|
229 |
-
|
230 |
$this->_helper->log($this->_helper->__("CALL: clientGetDetails - failed"));
|
231 |
$this->_helper->log($result->message);
|
232 |
|
@@ -238,7 +246,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
238 |
* Get Group Information
|
239 |
*/
|
240 |
|
241 |
-
public function groupGetStats($groupId = false)
|
|
|
242 |
|
243 |
if (!$groupId) {
|
244 |
$groupId = $this->_helper->getDefaultListId();
|
@@ -248,11 +257,10 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
248 |
if ($result->status == self::SUCCESS_STATUS) {
|
249 |
return $this->returnResult($result->data);
|
250 |
} else {
|
251 |
-
|
252 |
$this->_helper->log($this->_helper->__("CALL: groupGetStats - failed. List ID: ".$groupId));
|
253 |
$this->_helper->log($this->_helper->__($result->message));
|
254 |
|
255 |
-
if ($groupId){
|
256 |
return $this->returnResult($result->data, $this->_helper->__("Your list ID (%s) seem to be wrong. Please select other group!", $groupId));
|
257 |
}
|
258 |
return $this->returnResult($result->data, $this->_helper->__("Please set your CleverReach user group in Extension settings section."));
|
@@ -263,7 +271,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
263 |
* Get Group Information
|
264 |
*/
|
265 |
|
266 |
-
public function groupGetDetails($listId = false)
|
|
|
267 |
|
268 |
if (!$listId) {
|
269 |
$listId = $this->_helper->getDefaultListId();
|
@@ -271,14 +280,12 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
271 |
|
272 |
$result = $this->_client->groupGetDetails($this->_apiKey, $listId);
|
273 |
if ($result->status == self::SUCCESS_STATUS) {
|
274 |
-
|
275 |
return $this->returnResult($result->data);
|
276 |
} else {
|
277 |
-
|
278 |
$this->_helper->log($this->_helper->__("CALL: groupGetDetails - failed. List ID: ".$listId));
|
279 |
$this->_helper->log($this->_helper->__($result->message));
|
280 |
|
281 |
-
if ($listId){
|
282 |
return $this->returnResult($result->data, $this->_helper->__("Your list ID (%s) seem to be wrong. Please select other group!", $listId));
|
283 |
}
|
284 |
return $this->returnResult($result->data, $this->_helper->__("Please set your CleverReach user group in Extension settings section."));
|
@@ -295,7 +302,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
295 |
* @return int amount of synced users
|
296 |
*/
|
297 |
|
298 |
-
public function receiverAddBatch($batch, $groupId = 0)
|
|
|
299 |
|
300 |
if ($groupId == 0) {
|
301 |
$listId = $this->_helper->getDefaultListId();
|
@@ -308,13 +316,11 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
308 |
|
309 |
$result = $this->_client->receiverAddBatch($this->_apiKey, $listId, $batch);
|
310 |
if ($result->status == self::SUCCESS_STATUS) {
|
311 |
-
|
312 |
$this->_helper->log("CrConnect: receiverAddBatch - SUCCESS.");
|
313 |
$this->_helper->log("CrConnect: receiverAddBatch - key:".$this->_apiKey." | listId:".$listId);
|
314 |
|
315 |
return count($batch);
|
316 |
} else {
|
317 |
-
|
318 |
$this->_helper->log("CrConnect: receiverAddBatch - FAIL.");
|
319 |
$this->_helper->log("CrConnect: receiverAddBatch - key:".$this->_apiKey." | listId:".$listId);
|
320 |
$this->_helper->log("CrConnect: receiverAddBatch - message:".$result->message);
|
@@ -323,13 +329,14 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
323 |
}
|
324 |
}
|
325 |
|
326 |
-
public function receiverAddOrder($email, $orderInfo)
|
|
|
327 |
|
328 |
$listId = $this->_helper->getDefaultListId();
|
329 |
$result = $this->_client->receiverAddOrder($this->_apiKey, $listId, $email, $orderInfo);
|
330 |
-
Mage::helper("crconnect")->log("CALL receiverAddOrder: ".$email);
|
331 |
-
Mage::helper("crconnect")->log($orderInfo);
|
332 |
-
Mage::helper("crconnect")->log($result);
|
333 |
if ($result->status == self::SUCCESS_STATUS) {
|
334 |
return true;
|
335 |
} else {
|
@@ -346,7 +353,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
346 |
* @return bool true|false
|
347 |
*/
|
348 |
|
349 |
-
public function isSubscribed($email, $groupId = 0)
|
|
|
350 |
|
351 |
if ($groupId == 0) {
|
352 |
$listId = $this->_helper->getDefaultListId();
|
@@ -356,7 +364,6 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
356 |
|
357 |
$result = $this->_client->groupGetDetails($this->_apiKey, $listId);
|
358 |
if ($result->status == self::SUCCESS_STATUS) {
|
359 |
-
|
360 |
$result = $this->_client->receiverGetByEmail($this->_apiKey, $listId, $email);
|
361 |
if ($result->status == self::SUCCESS_STATUS && $result->data->active) {
|
362 |
return true;
|
@@ -368,12 +375,13 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
368 |
/*
|
369 |
* get groups for API key
|
370 |
*/
|
371 |
-
public function getGroupsForKey($apiKey)
|
|
|
372 |
|
373 |
$result = $this->_client->groupGetList($apiKey);
|
374 |
if ($result->status == self::SUCCESS_STATUS) {
|
375 |
-
return $result->data;
|
376 |
-
}else{
|
377 |
return false;
|
378 |
}
|
379 |
|
@@ -382,21 +390,22 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
382 |
/*
|
383 |
* get groups for API key
|
384 |
*/
|
385 |
-
public function getFormsForGroup($apiKey, $groupId)
|
|
|
386 |
|
387 |
$result = $this->_client->formsGetList($apiKey, $groupId);
|
388 |
if ($result->status == self::SUCCESS_STATUS) {
|
389 |
-
return $result->data;
|
390 |
-
}else{
|
391 |
return false;
|
392 |
}
|
393 |
|
394 |
}
|
395 |
|
396 |
-
public function formsSendActivationMail($customer, $groupId = 0)
|
|
|
397 |
|
398 |
-
if ($this->isConnected()){
|
399 |
-
|
400 |
// if not customer transfered, get current one from session
|
401 |
if (!$customer) {
|
402 |
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
@@ -415,7 +424,6 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
415 |
);
|
416 |
|
417 |
if ($addResult->status == self::SUCCESS_STATUS) {
|
418 |
-
|
419 |
// Send activation email for customer
|
420 |
$formId = $this->_helper->getFormsIds($groupId, true);
|
421 |
$result = $this->_client->formsSendActivationMail($this->_apiKey, $formId, $customer->getEmail(), $doidata);
|
@@ -424,33 +432,27 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
424 |
return true;
|
425 |
}
|
426 |
|
427 |
-
}else{
|
428 |
-
|
429 |
$this->_helper->log("during formsSendActivationMail :: receiverAdd :: ERROR");
|
430 |
$this->_helper->log($addResult);
|
431 |
|
432 |
-
if ($addResult->statuscode == self::ERROR_CODE_DUPLICATED){
|
433 |
-
|
434 |
-
if ($addResult->data->deactivated == 1){
|
435 |
-
|
436 |
-
|
437 |
// Send activation email for customer
|
438 |
$formId = $this->_helper->getFormsIds($groupId, true);
|
439 |
$result = $this->_client->formsSendActivationMail($this->_apiKey, $formId, $customer->getEmail(), $doidata);
|
440 |
if ($result->status == self::SUCCESS_STATUS) {
|
441 |
return true;
|
442 |
-
}else{
|
443 |
-
|
444 |
$this->_helper->log("during formsSendActivationMail :: formsSendActivationMail :: ERROR");
|
445 |
$this->_helper->log($result->message);
|
446 |
|
447 |
-
if ($result->statuscode == self::ERROR_CODE_INVALID){
|
448 |
Mage::getSingleton("core/session")->addError($this->_helper->__("This Email blocked or wrong"));
|
449 |
}
|
450 |
-
}
|
451 |
-
|
452 |
-
}else{
|
453 |
|
|
|
454 |
Mage::getSingleton("core/session")->addError($this->_helper->__("This Email already in our database"));
|
455 |
|
456 |
}
|
@@ -469,7 +471,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
469 |
* Sync data between Magento and Cleverreach
|
470 |
*/
|
471 |
|
472 |
-
public function synchronize()
|
|
|
473 |
|
474 |
//Check if we connected to Cr account
|
475 |
if (!$this->isConnected()) {
|
@@ -486,7 +489,6 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
486 |
$i = 0;
|
487 |
|
488 |
foreach ($subscribers as $subscriber) {
|
489 |
-
|
490 |
$userGroup = 0;
|
491 |
|
492 |
// If we should separate customers to different groups, then get customer Groups iD if exists
|
@@ -501,10 +503,9 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
501 |
}
|
502 |
|
503 |
|
504 |
-
if (isset($subscriber['customer_id']) && $subscriber['customer_id']){
|
505 |
$tmp = $this->_helper->prepareUserdata(Mage::getModel("customer/customer")->load($subscriber['customer_id']));
|
506 |
-
}else{
|
507 |
-
|
508 |
$tmp["email"] = $subscriber["subscriber_email"];
|
509 |
$tmp["source"] = "MAGENTO";
|
510 |
|
@@ -515,7 +516,7 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
515 |
2 => array("key" => "newsletter", "value" => "1")
|
516 |
);
|
517 |
|
518 |
-
}
|
519 |
|
520 |
// Separate users by Batch, 25 users in one
|
521 |
if ($tmp["email"]) {
|
@@ -524,19 +525,14 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
524 |
}
|
525 |
|
526 |
try {
|
527 |
-
|
528 |
-
// send subscribers batch to CleverReach
|
529 |
if ($batch) {
|
530 |
-
|
531 |
foreach ($batch as $storeId => $groupBatch) {
|
532 |
-
|
533 |
$this->init($storeId);
|
534 |
|
535 |
-
// send for each group
|
536 |
foreach ($groupBatch as $groupId => $batchStore) {
|
537 |
-
|
538 |
foreach ($batchStore as $part) {
|
539 |
-
|
540 |
$this->_helper->log("SYNCHRONIZATION - receiverAddBatch");
|
541 |
|
542 |
$result = $this->receiverAddBatch($part, $groupId);
|
@@ -563,7 +559,8 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
563 |
return $synced_users;
|
564 |
}
|
565 |
|
566 |
-
public function setupDefaultClereReachList()
|
|
|
567 |
|
568 |
//Check if we connected to Cr account
|
569 |
if (!$this->isConnected()) {
|
@@ -573,22 +570,21 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
573 |
$return = false;
|
574 |
|
575 |
try {
|
576 |
-
|
577 |
$return = $this->setupGroupFields($this->_helper->getDefaultListId());
|
578 |
$groups = $this->_helper->getGroupsIds();
|
579 |
-
foreach ($groups as $groupId){
|
580 |
$return = $this->setupGroupFields($groupId);
|
581 |
}
|
582 |
|
583 |
|
584 |
-
} catch(Exception $e) {
|
585 |
-
|
586 |
return false;
|
587 |
|
588 |
}
|
589 |
return $return;
|
590 |
}
|
591 |
-
public function setupGroupFields($listId)
|
|
|
592 |
|
593 |
$return = false;
|
594 |
|
@@ -608,14 +604,13 @@ class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract {
|
|
608 |
"store" => "store");
|
609 |
|
610 |
$return = $this->_client->groupGetDetails($this->_apiKey, $listId);
|
611 |
-
if($return->status == "SUCCESS"){
|
612 |
-
|
613 |
-
|
614 |
-
if(in_array($a->key, $fields)){
|
615 |
unset($fields[$a->key]);
|
616 |
}
|
617 |
}
|
618 |
-
foreach($fields as $field){
|
619 |
$return = $this->_client->groupAttributeAdd($this->_apiKey, $listId, $field, "text", "");
|
620 |
}
|
621 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Conlabz_CrConnect_Model_Api extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
|
6 |
const SUCCESS_STATUS = "SUCCESS";
|
7 |
|
8 |
const ERROR_CODE_DUPLICATED = 50;
|
9 |
const ERROR_CODE_INVALID = 40;
|
10 |
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
|
14 |
$this->init();
|
15 |
|
16 |
}
|
17 |
|
18 |
+
public function init($storeId = false)
|
19 |
+
{
|
20 |
|
21 |
$this->_helper = Mage::helper('crconnect');
|
22 |
|
23 |
+
if ($storeId) {
|
24 |
$this->_helper->log($this->_helper->__("SET Helper Store: ". $storeId));
|
25 |
$this->_helper->setCurrentStoreId($storeId);
|
26 |
}
|
35 |
* Get Connection to CrConnect
|
36 |
*/
|
37 |
|
38 |
+
public function getSoapClient()
|
39 |
+
{
|
40 |
|
41 |
try {
|
42 |
$client = new SoapClient($this->_helper->getWsdl(), array("trace" => true, "exception" => 0));
|
50 |
}
|
51 |
|
52 |
|
53 |
+
public function subscribe($customer = false, $groupId = 0)
|
54 |
+
{
|
55 |
|
56 |
+
if ($this->isConnected()) {
|
|
|
57 |
if (!$customer) {
|
58 |
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
59 |
}
|
60 |
$crReceiver = $this->_helper->prepareUserdata($customer, array('newsletter' => 1));
|
61 |
$addResult = $this->receiverAdd($crReceiver, $groupId);
|
62 |
if ($addResult->status == self::SUCCESS_STATUS) {
|
|
|
63 |
$this->_helper->log($this->_helper->__("CALL: receiverAdd - SUCCESS"));
|
64 |
$this->_helper->log($crReceiver);
|
65 |
$this->_helper->log("receiverAdd: GroupId: ".$groupId);
|
66 |
|
67 |
return true;
|
68 |
} else {
|
|
|
69 |
$this->_helper->log($this->_helper->__("CALL: receiverAdd - FAIL, then call receiverSetActive:".$customer->getEmail()));
|
70 |
$this->_helper->log("receiverSetActive: GroupId: ".$groupId);
|
71 |
|
77 |
return false;
|
78 |
}
|
79 |
|
80 |
+
public function update($customer = false, $groupId = 0)
|
81 |
+
{
|
82 |
|
83 |
+
if ($this->isConnected()) {
|
|
|
84 |
if (!$customer) {
|
85 |
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
86 |
}
|
87 |
$crReceiver = $this->_helper->prepareUserdata($customer);
|
88 |
$updateResult = $this->receiverUpdate($crReceiver, $customer->getGroupId());
|
89 |
if ($updateResult->status == self::SUCCESS_STATUS) {
|
|
|
90 |
$this->_helper->log($this->_helper->__("CALL: receiverUpdate - SUCCESS"));
|
91 |
$this->_helper->log($crReceiver);
|
92 |
$this->_helper->log("receiverUpdate: GroupId: ".$customer->getGroupId());
|
93 |
|
94 |
return true;
|
95 |
} else {
|
|
|
96 |
$this->_helper->log($this->_helper->__("CALL: receiverUpdate - FAIL"));
|
97 |
|
98 |
}
|
103 |
|
104 |
}
|
105 |
|
106 |
+
public function unsubscribe($email = false, $groupId = 0)
|
107 |
+
{
|
108 |
|
109 |
+
if ($this->isConnected() && $email) {
|
|
|
110 |
$result = $this->receiverSetInactive($email, $groupId);
|
111 |
if ($result->status == self::SUCCESS_STATUS) {
|
112 |
$this->_helper->log($this->_helper->__("CALL: receiverSetInactive - SUCCESS, Email:".$email." | GroupId:".$groupId));
|
121 |
* Check if connection was successfull
|
122 |
*/
|
123 |
|
124 |
+
public function isConnected()
|
125 |
+
{
|
126 |
|
127 |
+
if ($this->_client !== false && $this->_client !== null) {
|
128 |
return true;
|
129 |
}
|
130 |
return false;
|
134 |
* If Account have more then 1 group
|
135 |
*/
|
136 |
|
137 |
+
public function isMultyGroups()
|
138 |
+
{
|
139 |
|
140 |
if (is_array($this->_groupsListIds) && sizeof($this->_groupsListIds) > 0) {
|
141 |
return true;
|
143 |
return false;
|
144 |
}
|
145 |
|
146 |
+
public function getGroupKey($groupId)
|
147 |
+
{
|
148 |
|
149 |
if ($groupId == 0) {
|
150 |
$listId = $this->_helper->getDefaultListId();
|
157 |
/*
|
158 |
* Subscriber simple user to special group
|
159 |
*/
|
160 |
+
public function receiverAdd($customerData, $groupId = 0)
|
161 |
+
{
|
162 |
|
163 |
$listId = $this->getGroupKey($groupId);
|
164 |
|
172 |
/*
|
173 |
* Update simple user
|
174 |
*/
|
175 |
+
public function receiverUpdate($customerData, $groupId = 0)
|
176 |
+
{
|
177 |
|
178 |
$listId = $this->getGroupKey($groupId);
|
179 |
|
187 |
/*
|
188 |
* Deactivates a given receiver/email
|
189 |
*/
|
190 |
+
public function receiverSetInactive($email, $groupId = 0)
|
191 |
+
{
|
192 |
|
193 |
$listId = $this->getGroupKey($groupId);
|
194 |
$this->_helper->log("CALL: receiverSetInactive - Email".$email." | GroupId:". $groupId);
|
196 |
|
197 |
}
|
198 |
|
199 |
+
public function receiverSetActive($email, $groupId = 0)
|
200 |
+
{
|
201 |
|
202 |
$listId = $this->getGroupKey($groupId);
|
203 |
$this->_helper->log("CALL: receiverSetActive - Email".$email." | GroupId:". $groupId);
|
215 |
* @return array - result
|
216 |
*/
|
217 |
|
218 |
+
private function returnResult($result, $fail = false)
|
219 |
+
{
|
220 |
|
221 |
$return = array();
|
222 |
$return['error'] = $fail;
|
228 |
* Get user account details
|
229 |
*/
|
230 |
|
231 |
+
public function clientGetDetails()
|
232 |
+
{
|
233 |
|
234 |
$result = $this->_client->clientGetDetails($this->_apiKey);
|
235 |
if ($result->status == self::SUCCESS_STATUS) {
|
236 |
return $this->returnResult($result->data);
|
237 |
} else {
|
|
|
238 |
$this->_helper->log($this->_helper->__("CALL: clientGetDetails - failed"));
|
239 |
$this->_helper->log($result->message);
|
240 |
|
246 |
* Get Group Information
|
247 |
*/
|
248 |
|
249 |
+
public function groupGetStats($groupId = false)
|
250 |
+
{
|
251 |
|
252 |
if (!$groupId) {
|
253 |
$groupId = $this->_helper->getDefaultListId();
|
257 |
if ($result->status == self::SUCCESS_STATUS) {
|
258 |
return $this->returnResult($result->data);
|
259 |
} else {
|
|
|
260 |
$this->_helper->log($this->_helper->__("CALL: groupGetStats - failed. List ID: ".$groupId));
|
261 |
$this->_helper->log($this->_helper->__($result->message));
|
262 |
|
263 |
+
if ($groupId) {
|
264 |
return $this->returnResult($result->data, $this->_helper->__("Your list ID (%s) seem to be wrong. Please select other group!", $groupId));
|
265 |
}
|
266 |
return $this->returnResult($result->data, $this->_helper->__("Please set your CleverReach user group in Extension settings section."));
|
271 |
* Get Group Information
|
272 |
*/
|
273 |
|
274 |
+
public function groupGetDetails($listId = false)
|
275 |
+
{
|
276 |
|
277 |
if (!$listId) {
|
278 |
$listId = $this->_helper->getDefaultListId();
|
280 |
|
281 |
$result = $this->_client->groupGetDetails($this->_apiKey, $listId);
|
282 |
if ($result->status == self::SUCCESS_STATUS) {
|
|
|
283 |
return $this->returnResult($result->data);
|
284 |
} else {
|
|
|
285 |
$this->_helper->log($this->_helper->__("CALL: groupGetDetails - failed. List ID: ".$listId));
|
286 |
$this->_helper->log($this->_helper->__($result->message));
|
287 |
|
288 |
+
if ($listId) {
|
289 |
return $this->returnResult($result->data, $this->_helper->__("Your list ID (%s) seem to be wrong. Please select other group!", $listId));
|
290 |
}
|
291 |
return $this->returnResult($result->data, $this->_helper->__("Please set your CleverReach user group in Extension settings section."));
|
302 |
* @return int amount of synced users
|
303 |
*/
|
304 |
|
305 |
+
public function receiverAddBatch($batch, $groupId = 0)
|
306 |
+
{
|
307 |
|
308 |
if ($groupId == 0) {
|
309 |
$listId = $this->_helper->getDefaultListId();
|
316 |
|
317 |
$result = $this->_client->receiverAddBatch($this->_apiKey, $listId, $batch);
|
318 |
if ($result->status == self::SUCCESS_STATUS) {
|
|
|
319 |
$this->_helper->log("CrConnect: receiverAddBatch - SUCCESS.");
|
320 |
$this->_helper->log("CrConnect: receiverAddBatch - key:".$this->_apiKey." | listId:".$listId);
|
321 |
|
322 |
return count($batch);
|
323 |
} else {
|
|
|
324 |
$this->_helper->log("CrConnect: receiverAddBatch - FAIL.");
|
325 |
$this->_helper->log("CrConnect: receiverAddBatch - key:".$this->_apiKey." | listId:".$listId);
|
326 |
$this->_helper->log("CrConnect: receiverAddBatch - message:".$result->message);
|
329 |
}
|
330 |
}
|
331 |
|
332 |
+
public function receiverAddOrder($email, $orderInfo)
|
333 |
+
{
|
334 |
|
335 |
$listId = $this->_helper->getDefaultListId();
|
336 |
$result = $this->_client->receiverAddOrder($this->_apiKey, $listId, $email, $orderInfo);
|
337 |
+
Mage::helper("crconnect")->log("CALL receiverAddOrder: ".$email);
|
338 |
+
Mage::helper("crconnect")->log($orderInfo);
|
339 |
+
Mage::helper("crconnect")->log($result);
|
340 |
if ($result->status == self::SUCCESS_STATUS) {
|
341 |
return true;
|
342 |
} else {
|
353 |
* @return bool true|false
|
354 |
*/
|
355 |
|
356 |
+
public function isSubscribed($email, $groupId = 0)
|
357 |
+
{
|
358 |
|
359 |
if ($groupId == 0) {
|
360 |
$listId = $this->_helper->getDefaultListId();
|
364 |
|
365 |
$result = $this->_client->groupGetDetails($this->_apiKey, $listId);
|
366 |
if ($result->status == self::SUCCESS_STATUS) {
|
|
|
367 |
$result = $this->_client->receiverGetByEmail($this->_apiKey, $listId, $email);
|
368 |
if ($result->status == self::SUCCESS_STATUS && $result->data->active) {
|
369 |
return true;
|
375 |
/*
|
376 |
* get groups for API key
|
377 |
*/
|
378 |
+
public function getGroupsForKey($apiKey)
|
379 |
+
{
|
380 |
|
381 |
$result = $this->_client->groupGetList($apiKey);
|
382 |
if ($result->status == self::SUCCESS_STATUS) {
|
383 |
+
return $result->data;
|
384 |
+
} else {
|
385 |
return false;
|
386 |
}
|
387 |
|
390 |
/*
|
391 |
* get groups for API key
|
392 |
*/
|
393 |
+
public function getFormsForGroup($apiKey, $groupId)
|
394 |
+
{
|
395 |
|
396 |
$result = $this->_client->formsGetList($apiKey, $groupId);
|
397 |
if ($result->status == self::SUCCESS_STATUS) {
|
398 |
+
return $result->data;
|
399 |
+
} else {
|
400 |
return false;
|
401 |
}
|
402 |
|
403 |
}
|
404 |
|
405 |
+
public function formsSendActivationMail($customer, $groupId = 0)
|
406 |
+
{
|
407 |
|
408 |
+
if ($this->isConnected()) {
|
|
|
409 |
// if not customer transfered, get current one from session
|
410 |
if (!$customer) {
|
411 |
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
424 |
);
|
425 |
|
426 |
if ($addResult->status == self::SUCCESS_STATUS) {
|
|
|
427 |
// Send activation email for customer
|
428 |
$formId = $this->_helper->getFormsIds($groupId, true);
|
429 |
$result = $this->_client->formsSendActivationMail($this->_apiKey, $formId, $customer->getEmail(), $doidata);
|
432 |
return true;
|
433 |
}
|
434 |
|
435 |
+
} else {
|
|
|
436 |
$this->_helper->log("during formsSendActivationMail :: receiverAdd :: ERROR");
|
437 |
$this->_helper->log($addResult);
|
438 |
|
439 |
+
if ($addResult->statuscode == self::ERROR_CODE_DUPLICATED) {
|
440 |
+
if ($addResult->data->deactivated == 1) {
|
|
|
|
|
|
|
441 |
// Send activation email for customer
|
442 |
$formId = $this->_helper->getFormsIds($groupId, true);
|
443 |
$result = $this->_client->formsSendActivationMail($this->_apiKey, $formId, $customer->getEmail(), $doidata);
|
444 |
if ($result->status == self::SUCCESS_STATUS) {
|
445 |
return true;
|
446 |
+
} else {
|
|
|
447 |
$this->_helper->log("during formsSendActivationMail :: formsSendActivationMail :: ERROR");
|
448 |
$this->_helper->log($result->message);
|
449 |
|
450 |
+
if ($result->statuscode == self::ERROR_CODE_INVALID) {
|
451 |
Mage::getSingleton("core/session")->addError($this->_helper->__("This Email blocked or wrong"));
|
452 |
}
|
453 |
+
}
|
|
|
|
|
454 |
|
455 |
+
} else {
|
456 |
Mage::getSingleton("core/session")->addError($this->_helper->__("This Email already in our database"));
|
457 |
|
458 |
}
|
471 |
* Sync data between Magento and Cleverreach
|
472 |
*/
|
473 |
|
474 |
+
public function synchronize()
|
475 |
+
{
|
476 |
|
477 |
//Check if we connected to Cr account
|
478 |
if (!$this->isConnected()) {
|
489 |
$i = 0;
|
490 |
|
491 |
foreach ($subscribers as $subscriber) {
|
|
|
492 |
$userGroup = 0;
|
493 |
|
494 |
// If we should separate customers to different groups, then get customer Groups iD if exists
|
503 |
}
|
504 |
|
505 |
|
506 |
+
if (isset($subscriber['customer_id']) && $subscriber['customer_id']) {
|
507 |
$tmp = $this->_helper->prepareUserdata(Mage::getModel("customer/customer")->load($subscriber['customer_id']));
|
508 |
+
} else {
|
|
|
509 |
$tmp["email"] = $subscriber["subscriber_email"];
|
510 |
$tmp["source"] = "MAGENTO";
|
511 |
|
516 |
2 => array("key" => "newsletter", "value" => "1")
|
517 |
);
|
518 |
|
519 |
+
}
|
520 |
|
521 |
// Separate users by Batch, 25 users in one
|
522 |
if ($tmp["email"]) {
|
525 |
}
|
526 |
|
527 |
try {
|
528 |
+
// send subscribers batch to CleverReach
|
|
|
529 |
if ($batch) {
|
|
|
530 |
foreach ($batch as $storeId => $groupBatch) {
|
|
|
531 |
$this->init($storeId);
|
532 |
|
533 |
+
// send for each group
|
534 |
foreach ($groupBatch as $groupId => $batchStore) {
|
|
|
535 |
foreach ($batchStore as $part) {
|
|
|
536 |
$this->_helper->log("SYNCHRONIZATION - receiverAddBatch");
|
537 |
|
538 |
$result = $this->receiverAddBatch($part, $groupId);
|
559 |
return $synced_users;
|
560 |
}
|
561 |
|
562 |
+
public function setupDefaultClereReachList()
|
563 |
+
{
|
564 |
|
565 |
//Check if we connected to Cr account
|
566 |
if (!$this->isConnected()) {
|
570 |
$return = false;
|
571 |
|
572 |
try {
|
|
|
573 |
$return = $this->setupGroupFields($this->_helper->getDefaultListId());
|
574 |
$groups = $this->_helper->getGroupsIds();
|
575 |
+
foreach ($groups as $groupId) {
|
576 |
$return = $this->setupGroupFields($groupId);
|
577 |
}
|
578 |
|
579 |
|
580 |
+
} catch (Exception $e) {
|
|
|
581 |
return false;
|
582 |
|
583 |
}
|
584 |
return $return;
|
585 |
}
|
586 |
+
public function setupGroupFields($listId)
|
587 |
+
{
|
588 |
|
589 |
$return = false;
|
590 |
|
604 |
"store" => "store");
|
605 |
|
606 |
$return = $this->_client->groupGetDetails($this->_apiKey, $listId);
|
607 |
+
if ($return->status == "SUCCESS") {
|
608 |
+
foreach ($return->data->attributes as $a) {
|
609 |
+
if (in_array($a->key, $fields)) {
|
|
|
610 |
unset($fields[$a->key]);
|
611 |
}
|
612 |
}
|
613 |
+
foreach ($fields as $field) {
|
614 |
$return = $this->_client->groupAttributeAdd($this->_apiKey, $listId, $field, "text", "");
|
615 |
}
|
616 |
}
|
app/code/community/Conlabz/CrConnect/Model/Checkout/Observer.php
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
class Conlabz_CrConnect_Model_Checkout_Observer
|
21 |
{
|
22 |
public function success_action($observer)
|
23 |
-
{
|
24 |
$event = $observer->getEvent();
|
25 |
|
26 |
$email = false;
|
@@ -30,146 +30,143 @@ class Conlabz_CrConnect_Model_Checkout_Observer
|
|
30 |
$syncOrders = trim(Mage::getStoreConfig('crroot/crconnect/sync_orders'));
|
31 |
$syncOrderStatus = trim(Mage::getStoreConfig('crroot/crconnect/sync_order_status'));
|
32 |
|
33 |
-
if($syncOrders)
|
34 |
-
|
35 |
-
else{
|
36 |
-
|
37 |
-
|
38 |
}
|
39 |
-
if ($lastOrderId){
|
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 |
-
if($apiKey && $listID && $email && $lastOrderId && $syncOrders)
|
95 |
-
{
|
96 |
-
|
97 |
try {
|
98 |
$client = new SoapClient(Mage::helper('crconnect')->getWsdl(), array("trace" => true));
|
99 |
-
} catch(Exception $e) {
|
100 |
Mage::log("CleverReach_CrConnect: Error connecting to CleverReach server: ".$e->getMessage());
|
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 |
}
|
20 |
class Conlabz_CrConnect_Model_Checkout_Observer
|
21 |
{
|
22 |
public function success_action($observer)
|
23 |
+
{
|
24 |
$event = $observer->getEvent();
|
25 |
|
26 |
$email = false;
|
30 |
$syncOrders = trim(Mage::getStoreConfig('crroot/crconnect/sync_orders'));
|
31 |
$syncOrderStatus = trim(Mage::getStoreConfig('crroot/crconnect/sync_order_status'));
|
32 |
|
33 |
+
if ($syncOrders) {
|
34 |
+
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
35 |
+
} else {
|
36 |
+
$lastOrderId = false;
|
37 |
+
Mage::log("CleverReach_CrConnect: order sycing deactivated");
|
38 |
}
|
39 |
+
if ($lastOrderId) {
|
40 |
+
$order = Mage::getModel('sales/order')->load($lastOrderId);
|
41 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
42 |
+
|
43 |
+
$subscribed = $customer->getIsSubscribed();
|
44 |
+
|
45 |
+
if ($subscribed === null) {
|
46 |
+
$subscribed = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer)->isSubscribed();
|
47 |
+
}
|
48 |
+
|
49 |
+
if ($subscribed) {
|
50 |
+
$add = array("newsletter" => "1");
|
51 |
+
} else {
|
52 |
+
$add = array("newsletter" => "0");
|
53 |
+
}
|
54 |
+
|
55 |
+
$email = $order->getCustomerEmail();
|
56 |
+
|
57 |
+
if ($email) {
|
58 |
+
if ($customer->getEmail()) {
|
59 |
+
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer, $add, false);
|
60 |
+
} else {
|
61 |
+
$shippingAddress = $order->getBillingAddress()->getData();
|
62 |
+
if ($shippingAddress) {
|
63 |
+
$crReceiver = array (
|
64 |
+
'email' => $email,
|
65 |
+
//'registered' => strtotime($shippingAddress["created_at"]),
|
66 |
+
//'activated' => strtotime($shippingAddress["updated_at"]),
|
67 |
+
'source' => 'MAGENTO',
|
68 |
+
'attributes' => array(0 => array("key" => "firstname", "value" => @$shippingAddress["firstname"]),
|
69 |
+
1 => array("key" => "lastname", "value" => @$shippingAddress["lastname"]),
|
70 |
+
2 => array("key" => "street", "value" => @$shippingAddress["street"]),
|
71 |
+
3 => array("key" => "zip", "value" => @$shippingAddress["postcode"]),
|
72 |
+
4 => array("key" => "city", "value" => @$shippingAddress["city"]),
|
73 |
+
5 => array("key" => "country", "value" => @$shippingAddress["country_id"]),
|
74 |
+
6 => array("key" => "salutation", "value" => @$shippingAddress["prefix"]),
|
75 |
+
7 => array("key" => "title", "value" => @$shippingAddress["suffix"]),
|
76 |
+
8 => array("key" => "company", "value" => @$shippingAddress["company"]))
|
77 |
+
);
|
78 |
+
|
79 |
+
$cookie = Mage::getSingleton('core/cookie');
|
80 |
+
if ($cookie->get('crmailing')) {
|
81 |
+
$crReceiver['orders'][0]['mailings_id'] = $cookie->get('crmailing');
|
82 |
+
}
|
83 |
+
|
84 |
+
if ($subscribed) {
|
85 |
+
$crReceiver["attributes"][] = array("key" => 'newsletter', "value" => "1");
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
|
|
91 |
}
|
92 |
|
93 |
+
if ($apiKey && $listID && $email && $lastOrderId && $syncOrders) {
|
|
|
|
|
94 |
try {
|
95 |
$client = new SoapClient(Mage::helper('crconnect')->getWsdl(), array("trace" => true));
|
96 |
+
} catch (Exception $e) {
|
97 |
Mage::log("CleverReach_CrConnect: Error connecting to CleverReach server: ".$e->getMessage());
|
98 |
}
|
99 |
|
100 |
/* ########################### */
|
101 |
+
if ($crReceiver) {
|
102 |
+
try {
|
103 |
+
$tmp = $crReceiver;
|
104 |
+
$addTxt="keeping status";
|
105 |
+
//if new users should be activated by default. do it
|
106 |
+
if ($syncOrderStatus) {
|
107 |
+
$tmp["deactivated"] = 0;
|
108 |
+
$addTxt = "forced active";
|
109 |
+
}
|
110 |
+
|
111 |
+
// Get keys for different user groups
|
112 |
+
if (Mage::getStoreConfig('crroot/crconnect/showgroup') == '1') {
|
113 |
+
$groupKeys = Mage::helper('crconnect')->getKeys();
|
114 |
+
if ($groupId = $customer->getGroupId()) {
|
115 |
+
if (isset($groupKeys[$groupId])) {
|
116 |
+
$return = $client->receiverAdd($apiKey, $groupKeys[$groupId], $tmp);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
} else {
|
120 |
+
$return = $client->receiverAdd($apiKey, $listID, $tmp);
|
121 |
+
}
|
122 |
+
|
123 |
+
if ($return->status=="SUCCESS") {
|
124 |
+
Mage::log("CleverReach_CrConnect: subscribed ($addTxt) - ".$crReceiver["email"]);
|
125 |
+
} else {
|
126 |
+
if ($return->statuscode=="50") { //seems to exists allready, try update
|
127 |
+
$return = $client->receiverUpdate($apiKey, $listID, $tmp);
|
128 |
+
if (!$return->status=="SUCCESS") {
|
129 |
+
Mage::log("CleverReach_CrConnect: order insert error - ".$return->message);
|
130 |
+
} else {
|
131 |
+
Mage::log("CleverReach_CrConnect: resubscribed ($addTxt) - ".$crReceiver["email"]);
|
132 |
+
}
|
133 |
+
} else {
|
134 |
+
Mage::log("CleverReach_CrConnect: error - ".$return->message);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
} catch (Exception $e) {
|
138 |
+
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
139 |
+
}
|
140 |
+
}
|
|
|
141 |
|
142 |
/* ########################### */
|
143 |
|
144 |
+
$items = $order->getAllItems();
|
145 |
+
if ($items) {
|
146 |
+
foreach ($items as $item) {
|
147 |
+
$tmpItem = array();
|
148 |
+
$tmpItem["order_id"] = $lastOrderId;
|
149 |
+
$tmpItem["product"] = $item->getName();
|
150 |
+
$tmpItem["product_id"] = $item->getProductId();
|
151 |
+
$tmpItem["price"] = round($item->getPrice(), 2);
|
152 |
+
$tmpItem["quantity"] = (integer)$item->getQtyOrdered();
|
153 |
+
$tmpItem["purchase_date"] = time();
|
154 |
+
$tmpItem["currency"] = $order->getData('order_currency_code');
|
155 |
+
$tmpItem["source"] = "MAGENTO Order";
|
156 |
+
|
157 |
+
$cookie = Mage::getSingleton('core/cookie');
|
158 |
+
if ($cookie->get('crmailing')) {
|
159 |
+
$tmpItem['mailings_id'] = $cookie->get('crmailing');
|
160 |
+
}
|
161 |
+
|
162 |
+
$tmp = $client->receiverAddOrder($apiKey, $listID, $email, $tmpItem);
|
163 |
+
if ($tmp->status!="SUCCESS") {
|
164 |
+
Mage::log("CleverReach_CrConnect: Error - ".$tmp->message);
|
165 |
+
} else {
|
166 |
+
Mage::log("CleverReach_CrConnect: submitted: ".$tmpItem["order_id"]." - ".$tmpItem["product"]);
|
167 |
+
}
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
171 |
}
|
172 |
}
|
app/code/community/Conlabz/CrConnect/Model/Customer/Observer.php
CHANGED
@@ -29,26 +29,26 @@ class SubscriberCustomField
|
|
29 |
|
30 |
class Conlabz_CrConnect_Model_Customer_Observer
|
31 |
{
|
32 |
-
|
33 |
-
{
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
}
|
47 |
-
|
48 |
-
|
49 |
{
|
50 |
|
51 |
-
|
52 |
$customer = $event->getCustomer();
|
53 |
|
54 |
$apiKey = trim(Mage::getStoreConfig('crroot/crconnect/api_key'));
|
@@ -59,123 +59,113 @@ class Conlabz_CrConnect_Model_Customer_Observer
|
|
59 |
$subscribed = $customer->getIsSubscribed();
|
60 |
|
61 |
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
62 |
-
|
63 |
$shippingAddress = false;
|
64 |
-
if($tmp = $customer->getDefaultBillingAddress())
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
68 |
try {
|
69 |
$client = new SoapClient(Mage::helper('crconnect')->getWsdl(), array("trace" => true));
|
70 |
-
} catch(Exception $e) {
|
71 |
-
|
72 |
}
|
73 |
|
74 |
-
|
75 |
|
76 |
$isCustomSubscribed = false;
|
77 |
-
|
78 |
-
|
79 |
}
|
80 |
|
81 |
-
if ($isCustomSubscribed){
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
$return = $client->receiverSetInactive($apiKey, $keys[$groupId], $newEmail);
|
88 |
|
89 |
-
|
90 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
91 |
return;
|
92 |
}
|
93 |
-
|
94 |
-
}else{
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer, array('newsletter'=>1), true);
|
99 |
$return = $client->receiverAdd($apiKey, $keys[$groupId], $crReceiver);
|
100 |
-
if ($return->status == "ERROR"){
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
}
|
110 |
|
111 |
-
|
112 |
}
|
113 |
|
114 |
-
|
115 |
|
116 |
// if subscribed is NULL (i.e. because the form didn't set it one way
|
117 |
// or the other), get the existing value from the database
|
118 |
|
119 |
-
if($subscribed ===
|
120 |
-
{
|
121 |
$subscribed = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer)->isSubscribed();
|
122 |
}
|
123 |
|
124 |
-
if($apiKey and $listID)
|
125 |
-
|
126 |
-
|
127 |
-
{
|
128 |
-
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer, array('newsletter'=>1), true);
|
129 |
Mage::log("CleverReach_CrConnect: Subscribing new email address (ob): $newEmail");
|
130 |
try {
|
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 |
-
} catch(Exception $e) {
|
158 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
159 |
}
|
160 |
-
}
|
161 |
-
elseif($oldEmail)
|
162 |
-
{
|
163 |
-
|
164 |
Mage::log("CleverReach_CrConnect: Unsubscribing: $oldEmail");
|
165 |
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer, array('newsletter'=>0), false);
|
166 |
try {
|
167 |
$return = $client->receiverSetInactive($apiKey, $listID, $crReceiver["email"]);
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
} catch(Exception $e) {
|
179 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
180 |
}
|
181 |
}
|
@@ -193,51 +183,48 @@ class Conlabz_CrConnect_Model_Customer_Observer
|
|
193 |
|
194 |
$email = $customer->getEmail();
|
195 |
|
196 |
-
|
197 |
|
198 |
$isCustomSubscribed = false;
|
199 |
-
|
200 |
-
|
201 |
}
|
202 |
|
203 |
-
if($apiKey and $listID)
|
204 |
-
{
|
205 |
try {
|
206 |
$client = new SoapClient(Mage::helper('crconnect')->getWsdl(), array("trace" => true));
|
207 |
-
} catch(Exception $e) {
|
208 |
Mage::log("CleverReach_CrConnect: Error connecting to server: ".$e->getMessage());
|
209 |
}
|
210 |
-
|
211 |
Mage::log("CleverReach_CrConnect: Customer deleted, unsubscribing: $email");
|
212 |
try {
|
213 |
$return = $client->receiverDelete($apiKey, $listID, $email);
|
214 |
-
if($return->status=="SUCCESS"){
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
} catch(Exception $e) {
|
230 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
231 |
}
|
232 |
}
|
233 |
}
|
234 |
|
235 |
|
236 |
-
public function getIsSubscribed($observer)
|
237 |
-
|
238 |
-
|
|
|
239 |
}
|
240 |
-
|
241 |
-
|
242 |
}
|
243 |
-
?>
|
29 |
|
30 |
class Conlabz_CrConnect_Model_Customer_Observer
|
31 |
{
|
32 |
+
public function session_init($observer)
|
33 |
+
{
|
34 |
+
|
35 |
+
$mailingId = Mage::getSingleton('core/app')->getRequest()->getParam('crmailing');
|
36 |
+
$cookie = Mage::getSingleton('core/cookie');
|
37 |
+
if ($mailingId) {
|
38 |
+
$cookie->set('crmailing', $mailingId, time()+3600*24*14, '/');
|
39 |
+
}
|
40 |
+
$customerId = Mage::getSingleton('core/app')->getRequest()->getParam('crcustomer');
|
41 |
+
$cookie = Mage::getSingleton('core/cookie');
|
42 |
+
if ($customerId) {
|
43 |
+
$cookie->set('crcustomer', $customerId, time()+3600*24*14, '/');
|
44 |
+
}
|
45 |
|
46 |
}
|
47 |
+
|
48 |
+
public function check_subscription_status($observer)
|
49 |
{
|
50 |
|
51 |
+
$event = $observer->getEvent();
|
52 |
$customer = $event->getCustomer();
|
53 |
|
54 |
$apiKey = trim(Mage::getStoreConfig('crroot/crconnect/api_key'));
|
59 |
$subscribed = $customer->getIsSubscribed();
|
60 |
|
61 |
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
62 |
+
|
63 |
$shippingAddress = false;
|
64 |
+
if ($tmp = $customer->getDefaultBillingAddress()) {
|
65 |
+
$shippingAddress = $tmp->getData();
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
try {
|
70 |
$client = new SoapClient(Mage::helper('crconnect')->getWsdl(), array("trace" => true));
|
71 |
+
} catch (Exception $e) {
|
72 |
+
Mage::log("CleverReach_CrConnect: Error connecting to CleverReach server: ".$e->getMessage());
|
73 |
}
|
74 |
|
75 |
+
$keys = Mage::helper('crconnect')->getKeys();
|
76 |
|
77 |
$isCustomSubscribed = false;
|
78 |
+
if (isset($keys[$groupId])) {
|
79 |
+
$isCustomSubscribed = Mage::helper('crconnect')->getSubscriber($newEmail, $groupId);
|
80 |
}
|
81 |
|
82 |
+
if ($isCustomSubscribed) {
|
83 |
+
if (isset($_POST['is_gsubscribed']) && $_POST['is_gsubscribed'] == 1) {
|
84 |
+
} else {
|
85 |
+
try {
|
86 |
+
$return = $client->receiverSetInactive($apiKey, $keys[$groupId], $newEmail);
|
|
|
|
|
87 |
|
88 |
+
} catch (Exception $e) {
|
89 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
90 |
return;
|
91 |
}
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
if (isset($_POST['is_gsubscribed']) && $_POST['is_gsubscribed'] == 1) {
|
95 |
+
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer, array('newsletter'=>1), true);
|
|
|
|
|
96 |
$return = $client->receiverAdd($apiKey, $keys[$groupId], $crReceiver);
|
97 |
+
if ($return->status == "ERROR") {
|
98 |
+
if ($return->statuscode=="50") { //try update
|
99 |
+
$crReceiver["deactivated"] = 0;
|
100 |
+
$return = $client->receiverUpdate($apiKey, $keys[$groupId], $crReceiver);
|
101 |
+
Mage::log("CleverReach_CrConnect:". $crReceiver["attributes"][1]["key"]);
|
102 |
+
if (!$return->status=="SUCCESS") {
|
103 |
+
Mage::log("CleverReach_CrConnect: resubscribe error - ".$return->message);
|
104 |
+
}
|
105 |
+
}
|
106 |
}
|
107 |
|
108 |
+
}
|
109 |
}
|
110 |
|
111 |
+
$oldEmail = Mage::getModel('customer/customer')->load($customer->getId())->getEmail();
|
112 |
|
113 |
// if subscribed is NULL (i.e. because the form didn't set it one way
|
114 |
// or the other), get the existing value from the database
|
115 |
|
116 |
+
if ($subscribed === null) {
|
|
|
117 |
$subscribed = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer)->isSubscribed();
|
118 |
}
|
119 |
|
120 |
+
if ($apiKey and $listID) {
|
121 |
+
if ($subscribed) {
|
122 |
+
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer, array('newsletter'=>1), true);
|
|
|
|
|
123 |
Mage::log("CleverReach_CrConnect: Subscribing new email address (ob): $newEmail");
|
124 |
try {
|
125 |
+
// Get keys for different user groups
|
126 |
+
if (Mage::getStoreConfig('crroot/crconnect/showgroup') == '1') {
|
127 |
+
$groupKeys = Mage::helper('crconnect')->getKeys();
|
128 |
+
if ($groupId = $customer->getGroupId()) {
|
129 |
+
if (isset($groupKeys[$groupId])) {
|
130 |
+
$return = $client->receiverSetInactive($apiKey, $listID, $crReceiver["email"]);
|
131 |
+
$listID = $groupKeys[$groupId];
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
$return = $client->receiverAdd($apiKey, $listID, $crReceiver);
|
136 |
+
if ($return->status=="SUCCESS") {
|
137 |
+
Mage::log("CleverReach_CrConnect: subscribed - ".$crReceiver["email"]);
|
138 |
+
} else {
|
139 |
+
if ($return->statuscode=="50") { //try update
|
140 |
+
$crReceiver["deactivated"] = 0;
|
141 |
+
$return = $client->receiverUpdate($apiKey, $listID, $crReceiver);
|
142 |
+
Mage::log("CleverReach_CrConnect:". $crReceiver["attributes"][1]["key"]);
|
143 |
+
if (!$return->status=="SUCCESS") {
|
144 |
+
Mage::log("CleverReach_CrConnect: resubscribe error - ".$return->message);
|
145 |
+
}
|
146 |
+
} else {
|
147 |
+
Mage::log("CleverReach_CrConnect: error - ".$return->message);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
} catch (Exception $e) {
|
|
|
151 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
152 |
}
|
153 |
+
} elseif ($oldEmail) {
|
|
|
|
|
|
|
154 |
Mage::log("CleverReach_CrConnect: Unsubscribing: $oldEmail");
|
155 |
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer, array('newsletter'=>0), false);
|
156 |
try {
|
157 |
$return = $client->receiverSetInactive($apiKey, $listID, $crReceiver["email"]);
|
158 |
+
if ($return->status=="SUCCESS") {
|
159 |
+
Mage::log("CleverReach_CrConnect: unsubscribed - ".$crReceiver["email"]);
|
160 |
+
|
161 |
+
if ($return->status == "SUCCESS") {
|
162 |
+
Mage::log("CleverReach_CrConnect: updating newsletterflag");
|
163 |
+
$client->receiverUpdate($apiKey, $listID, $crReceiver);
|
164 |
+
}
|
165 |
+
} else { //call failed
|
166 |
+
Mage::log("CleverReach_CrConnect: error - ".$return->message);
|
167 |
+
}
|
168 |
+
} catch (Exception $e) {
|
169 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
170 |
}
|
171 |
}
|
183 |
|
184 |
$email = $customer->getEmail();
|
185 |
|
186 |
+
$keys = Mage::helper('crconnect')->getKeys();
|
187 |
|
188 |
$isCustomSubscribed = false;
|
189 |
+
if (isset($keys[$customer->getGroupId()])) {
|
190 |
+
$isCustomSubscribed = Mage::helper('crconnect')->getSubscriber($email, $customer->getGroupId());
|
191 |
}
|
192 |
|
193 |
+
if ($apiKey and $listID) {
|
|
|
194 |
try {
|
195 |
$client = new SoapClient(Mage::helper('crconnect')->getWsdl(), array("trace" => true));
|
196 |
+
} catch (Exception $e) {
|
197 |
Mage::log("CleverReach_CrConnect: Error connecting to server: ".$e->getMessage());
|
198 |
}
|
199 |
+
|
200 |
Mage::log("CleverReach_CrConnect: Customer deleted, unsubscribing: $email");
|
201 |
try {
|
202 |
$return = $client->receiverDelete($apiKey, $listID, $email);
|
203 |
+
if ($return->status=="SUCCESS") {
|
204 |
+
Mage::log("CleverReach_CrConnect: deleted - ".$email);
|
205 |
+
} else { //call failed
|
206 |
+
Mage::log("CleverReach_CrConnect: error - ".$return["message"]);
|
207 |
+
}
|
208 |
+
|
209 |
+
if ($isCustomSubscribed) {
|
210 |
+
$return = $client->receiverDelete($apiKey, $keys[$groupId], $email);
|
211 |
+
if ($return->status=="SUCCESS") {
|
212 |
+
Mage::log("CleverReach_CrConnect: deleted - ".$email);
|
213 |
+
} else { //call failed
|
214 |
+
Mage::log("CleverReach_CrConnect: error - ".$return["message"]);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
} catch (Exception $e) {
|
219 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
220 |
}
|
221 |
}
|
222 |
}
|
223 |
|
224 |
|
225 |
+
public function getIsSubscribed($observer)
|
226 |
+
{
|
227 |
+
Mage::log("CleverReach_CrConnect: stat");
|
228 |
+
//Mage_Customer_Block_Newsletter
|
229 |
}
|
|
|
|
|
230 |
}
|
|
app/code/community/Conlabz/CrConnect/Model/Newsletter/Subscriber.php
CHANGED
@@ -1,13 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Conlabz_CrConnect_Model_Newsletter_Subscriber extends Mage_Newsletter_Model_Subscriber
|
|
|
4 |
|
5 |
/*
|
6 |
* Check If customer is subscribed
|
7 |
*/
|
8 |
-
public function isSubscribed($groupId = 0)
|
|
|
9 |
|
10 |
-
if (!$this->getEmail()){
|
11 |
$this->setEmail(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
|
12 |
}
|
13 |
return Mage::getModel("crconnect/api")->isSubscribed($this->getEmail(), $groupId);
|
@@ -20,7 +22,8 @@ class Conlabz_CrConnect_Model_Newsletter_Subscriber extends Mage_Newsletter_Mode
|
|
20 |
* @throws Exception
|
21 |
* @return int
|
22 |
*/
|
23 |
-
public function subscribe($email, $groupId = 0)
|
|
|
24 |
|
25 |
if (Mage::helper("customer")->isLoggedIn()) {
|
26 |
$customerSession = Mage::getSingleton('customer/session');
|
@@ -46,5 +49,4 @@ class Conlabz_CrConnect_Model_Newsletter_Subscriber extends Mage_Newsletter_Mode
|
|
46 |
parent::sendConfirmationSuccessEmail();
|
47 |
}
|
48 |
}
|
49 |
-
|
50 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Conlabz_CrConnect_Model_Newsletter_Subscriber extends Mage_Newsletter_Model_Subscriber
|
4 |
+
{
|
5 |
|
6 |
/*
|
7 |
* Check If customer is subscribed
|
8 |
*/
|
9 |
+
public function isSubscribed($groupId = 0)
|
10 |
+
{
|
11 |
|
12 |
+
if (!$this->getEmail()) {
|
13 |
$this->setEmail(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
|
14 |
}
|
15 |
return Mage::getModel("crconnect/api")->isSubscribed($this->getEmail(), $groupId);
|
22 |
* @throws Exception
|
23 |
* @return int
|
24 |
*/
|
25 |
+
public function subscribe($email, $groupId = 0)
|
26 |
+
{
|
27 |
|
28 |
if (Mage::helper("customer")->isLoggedIn()) {
|
29 |
$customerSession = Mage::getSingleton('customer/session');
|
49 |
parent::sendConfirmationSuccessEmail();
|
50 |
}
|
51 |
}
|
|
|
52 |
}
|
app/code/community/Conlabz/CrConnect/Model/Observer.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
class Conlabz_CrConnect_Model_Observer
|
|
|
3 |
|
4 |
// 14 days
|
5 |
const SESSION_LIFE = 1209600;
|
@@ -7,11 +8,12 @@ class Conlabz_CrConnect_Model_Observer{
|
|
7 |
private $_allowedControllers = array("account");
|
8 |
private $_allowedActions = array("createpost");
|
9 |
|
10 |
-
public function customerSaveAfter($observer)
|
|
|
11 |
|
12 |
-
if (!Mage::registry('cr_aftersave_called')){
|
13 |
Mage::register('cr_aftersave_called', true);
|
14 |
-
}else{
|
15 |
return true;
|
16 |
}
|
17 |
|
@@ -20,19 +22,18 @@ class Conlabz_CrConnect_Model_Observer{
|
|
20 |
|
21 |
$customer = $observer->getCustomer();
|
22 |
|
23 |
-
$email = $customer->getEmail();
|
24 |
|
25 |
$subscriber = Mage::getModel("newsletter/subscriber")->loadByEmail($email);
|
26 |
$subscriber->setEmail($email);
|
27 |
-
if (Mage::app()->getStore()->isAdmin()){
|
28 |
return true;
|
29 |
}
|
30 |
|
31 |
$subscriptionCheckbox1 = Mage::app()->getRequest()->getParam('subscription');
|
32 |
$subscriptionCheckbox2 = Mage::app()->getRequest()->getParam('is_subscribed');
|
33 |
|
34 |
-
if ($subscriptionCheckbox1 !== null || $subscriptionCheckbox2 !== null){
|
35 |
-
|
36 |
if (!$subscriber->isSubscribed()) {
|
37 |
$status = Mage::getModel("newsletter/subscriber")->subscribe($email);
|
38 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
@@ -42,21 +43,20 @@ class Conlabz_CrConnect_Model_Observer{
|
|
42 |
}
|
43 |
}
|
44 |
|
45 |
-
}else{
|
46 |
-
|
47 |
-
if (in_array($controller, $this->_allowedControllers) && in_array($action, $this->_allowedActions)){
|
48 |
if ($subscriber->isSubscribed()) {
|
49 |
$status = Mage::getModel("crconnect/subscriber")->unsubscribe($email);
|
50 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper("core")->__('The subscription has been removed.'));
|
51 |
}
|
52 |
-
|
53 |
|
54 |
}
|
55 |
|
56 |
$gsubscription = Mage::app()->getRequest()->getParam('gsubscription');
|
57 |
$groupId = $customer->getGroupId();
|
58 |
|
59 |
-
if ($gsubscription !== null){
|
60 |
if (!$subscriber->isSubscribed($groupId)) {
|
61 |
$status = Mage::getModel("newsletter/subscriber")->subscribe($email, $groupId);
|
62 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
@@ -64,119 +64,108 @@ class Conlabz_CrConnect_Model_Observer{
|
|
64 |
} else {
|
65 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper("core")->__('Thank you for your subscription.'));
|
66 |
}
|
67 |
-
}
|
68 |
-
}else{
|
69 |
-
|
70 |
-
if (in_array($controller, $this->_allowedControllers) && in_array($action, $this->_allowedActions)){
|
71 |
if ($subscriber->isSubscribed($groupId)) {
|
72 |
$status = Mage::getModel("crconnect/subscriber")->unsubscribe($email, $groupId);
|
73 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper("core")->__('The subscription has been removed.'));
|
74 |
}
|
75 |
-
}
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
return true;
|
80 |
-
|
81 |
}
|
82 |
|
83 |
-
public function trackingCodesSet($observer)
|
84 |
-
|
85 |
$mailingId = Mage::getSingleton('core/app')->getRequest()->getParam('crmailing');
|
86 |
|
87 |
$cookie = Mage::getSingleton('core/cookie');
|
88 |
-
if ($mailingId){
|
89 |
-
$cookie->set('crmailing', $mailingId
|
90 |
}
|
91 |
|
92 |
-
|
93 |
$cookie = Mage::getSingleton('core/cookie');
|
94 |
-
if ($customerId){
|
95 |
-
$cookie->set('crcustomer', $customerId
|
96 |
-
}
|
97 |
-
|
98 |
}
|
99 |
-
|
|
|
|
|
100 |
|
101 |
-
if (!Mage::registry('order_track_start')){
|
102 |
Mage::register('order_track_start', true);
|
103 |
-
}else{
|
104 |
return true;
|
105 |
}
|
106 |
|
107 |
-
if(Mage::helper("crconnect")->isTrackingEnabled())
|
108 |
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
109 |
-
else{
|
110 |
Mage::helper("crconnect")->log("CleverReach_CrConnect: order sycing deactivated");
|
111 |
return false;
|
112 |
}
|
113 |
|
114 |
$order = Mage::getModel('sales/order')->load($lastOrderId);
|
115 |
-
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
116 |
$email = $order->getCustomerEmail();
|
117 |
|
118 |
-
if(Mage::helper("crconnect")->isTrackingEnabled()){
|
119 |
-
|
120 |
$items = $order->getAllItems();
|
121 |
-
if ($items){
|
122 |
-
foreach ($items as $item){
|
123 |
-
|
124 |
$tmpItem = array();
|
125 |
$tmpItem["order_id"] = $lastOrderId;
|
126 |
$tmpItem["product"] = $item->getName();
|
127 |
$tmpItem["product_id"] = $item->getProductId();
|
128 |
-
$tmpItem["price"] = round($item->getPrice(),2);
|
129 |
$tmpItem["quantity"] = (integer)$item->getQtyOrdered();
|
130 |
$tmpItem["purchase_date"] = time();
|
131 |
$tmpItem["currency"] = $order->getData('order_currency_code');
|
132 |
$tmpItem["source"] = "MAGENTO Order";
|
133 |
|
134 |
$cookie = Mage::getSingleton('core/cookie');
|
135 |
-
if ($cookie->get('crmailing')){
|
136 |
$tmpItem['mailings_id'] = $cookie->get('crmailing');
|
137 |
}
|
138 |
|
139 |
Mage::getModel("crconnect/api")->receiverAddOrder($email, $tmpItem);
|
140 |
|
141 |
-
}
|
142 |
}
|
143 |
|
144 |
-
}
|
145 |
-
|
146 |
}
|
147 |
-
public function orderPlacedAfter($observer){
|
148 |
-
try{
|
149 |
-
|
150 |
-
$order = $observer->getOrder();
|
151 |
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
154 |
$shippingMethod = $order->getShippingMethod();
|
155 |
-
Mage::helper("crconnect")->log("M2E sync disabled -> shipping method: "
|
156 |
-
|
157 |
-
if (in_array($shippingMethod, Mage::helper("crconnect")->getM2eShippingMethods())){
|
158 |
Mage::helper("crconnect")->log("Its M2E order -> Skip");
|
159 |
return true;
|
160 |
-
}
|
161 |
-
|
162 |
}
|
163 |
|
164 |
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
165 |
$email = $order->getCustomerEmail();
|
166 |
|
167 |
-
if(Mage::helper("crconnect")->isForceSyncEnabled()){
|
168 |
-
|
169 |
Mage::helper("crconnect")->log("Force sync orders enabled");
|
170 |
|
171 |
-
if($customer->getEmail()){
|
172 |
Mage::helper("crconnect")->log("Force sync orders for logged in customer");
|
173 |
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer);
|
174 |
$result = Mage::getModel("crconnect/api")->receiverAdd($crReceiver, $customer->getGroupId());
|
175 |
Mage::helper("crconnect")->log($result);
|
176 |
-
}else{
|
177 |
Mage::helper("crconnect")->log("Force sync orders for guest customer");
|
178 |
$billingAddress = $order->getBillingAddress()->getData();
|
179 |
-
if($billingAddress){
|
180 |
Mage::helper("crconnect")->log("Prepare info based on billing address");
|
181 |
$crReceiver = array (
|
182 |
'email' => $email,
|
@@ -194,19 +183,16 @@ class Conlabz_CrConnect_Model_Observer{
|
|
194 |
);
|
195 |
|
196 |
$cookie = Mage::getSingleton('core/cookie');
|
197 |
-
if ($cookie->get('crmailing')){
|
198 |
$crReceiver['orders'][0]['mailings_id'] = $cookie->get('crmailing');
|
199 |
}
|
200 |
Mage::helper("crconnect")->log($crReceiver);
|
201 |
|
202 |
$result = Mage::getModel("crconnect/api")->receiverAdd($crReceiver);
|
203 |
Mage::helper("crconnect")->log($result);
|
204 |
-
|
205 |
}
|
206 |
-
}
|
207 |
-
|
208 |
-
}
|
209 |
-
|
210 |
} catch (Exception $ex) {
|
211 |
Mage::helper("crconnect")->log("order_save_after Exception");
|
212 |
Mage::helper("crconnect")->log($ex);
|
@@ -216,67 +202,57 @@ class Conlabz_CrConnect_Model_Observer{
|
|
216 |
|
217 |
}
|
218 |
|
219 |
-
public function customerDeleted($observer)
|
|
|
220 |
|
221 |
$event = $observer->getEvent();
|
222 |
$customer = $event->getCustomer();
|
223 |
$email = $customer->getEmail();
|
224 |
$groupId = $customer->getGroupId();
|
225 |
-
|
226 |
Mage::getModel("crconnect/subscriber")->unsubscribe($email);
|
227 |
Mage::getModel("crconnect/subscriber")->unsubscribe($email, $groupId);
|
228 |
|
229 |
}
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
$store = Mage::app()->getRequest()->getParam('store');
|
236 |
-
|
237 |
-
if (Mage::helper("crconnect")->isDoubleOptInEnabled()){
|
238 |
-
|
239 |
$groupsIds = Mage::helper("crconnect")->getGroupsIds();
|
240 |
-
$formsIds = Mage::helper("crconnect")->getFormsIds();
|
241 |
-
|
242 |
$allow = true;
|
243 |
-
foreach ($groupsIds as $groupsId){
|
244 |
-
if (!$groupsId){
|
245 |
$allow = false;
|
246 |
}
|
247 |
-
}
|
248 |
-
|
249 |
-
|
250 |
-
if (!$formsId){
|
251 |
$allow = false;
|
252 |
}
|
253 |
-
}
|
254 |
-
|
255 |
$formId = Mage::helper("crconnect")->getDefaultFormId();
|
256 |
-
if (!$formId){
|
257 |
$allow = false;
|
258 |
-
}
|
259 |
-
|
260 |
-
if (!$allow){
|
261 |
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('Double Opt-In enabled, please select Form(s) and Group(s) for your Customer Groups'));
|
262 |
}
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
}
|
267 |
-
|
268 |
}
|
269 |
-
|
270 |
-
|
|
|
271 |
$session = Mage::getSingleton('adminhtml/session');
|
272 |
-
|
273 |
$setupResult = Mage::getModel('crconnect/api')->setupDefaultClereReachList();
|
274 |
-
if(!$setupResult){
|
275 |
$session->addError("Could not connect to CleverReach. Please chech your API keys.");
|
276 |
-
}
|
277 |
-
$
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
}
|
282 |
-
}
|
1 |
<?php
|
2 |
+
class Conlabz_CrConnect_Model_Observer
|
3 |
+
{
|
4 |
|
5 |
// 14 days
|
6 |
const SESSION_LIFE = 1209600;
|
8 |
private $_allowedControllers = array("account");
|
9 |
private $_allowedActions = array("createpost");
|
10 |
|
11 |
+
public function customerSaveAfter($observer)
|
12 |
+
{
|
13 |
|
14 |
+
if (!Mage::registry('cr_aftersave_called')) {
|
15 |
Mage::register('cr_aftersave_called', true);
|
16 |
+
} else {
|
17 |
return true;
|
18 |
}
|
19 |
|
22 |
|
23 |
$customer = $observer->getCustomer();
|
24 |
|
25 |
+
$email = $customer->getEmail();
|
26 |
|
27 |
$subscriber = Mage::getModel("newsletter/subscriber")->loadByEmail($email);
|
28 |
$subscriber->setEmail($email);
|
29 |
+
if (Mage::app()->getStore()->isAdmin()) {
|
30 |
return true;
|
31 |
}
|
32 |
|
33 |
$subscriptionCheckbox1 = Mage::app()->getRequest()->getParam('subscription');
|
34 |
$subscriptionCheckbox2 = Mage::app()->getRequest()->getParam('is_subscribed');
|
35 |
|
36 |
+
if ($subscriptionCheckbox1 !== null || $subscriptionCheckbox2 !== null) {
|
|
|
37 |
if (!$subscriber->isSubscribed()) {
|
38 |
$status = Mage::getModel("newsletter/subscriber")->subscribe($email);
|
39 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
43 |
}
|
44 |
}
|
45 |
|
46 |
+
} else {
|
47 |
+
if (in_array($controller, $this->_allowedControllers) && in_array($action, $this->_allowedActions)) {
|
|
|
48 |
if ($subscriber->isSubscribed()) {
|
49 |
$status = Mage::getModel("crconnect/subscriber")->unsubscribe($email);
|
50 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper("core")->__('The subscription has been removed.'));
|
51 |
}
|
52 |
+
}
|
53 |
|
54 |
}
|
55 |
|
56 |
$gsubscription = Mage::app()->getRequest()->getParam('gsubscription');
|
57 |
$groupId = $customer->getGroupId();
|
58 |
|
59 |
+
if ($gsubscription !== null) {
|
60 |
if (!$subscriber->isSubscribed($groupId)) {
|
61 |
$status = Mage::getModel("newsletter/subscriber")->subscribe($email, $groupId);
|
62 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
64 |
} else {
|
65 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper("core")->__('Thank you for your subscription.'));
|
66 |
}
|
67 |
+
}
|
68 |
+
} else {
|
69 |
+
if (in_array($controller, $this->_allowedControllers) && in_array($action, $this->_allowedActions)) {
|
|
|
70 |
if ($subscriber->isSubscribed($groupId)) {
|
71 |
$status = Mage::getModel("crconnect/subscriber")->unsubscribe($email, $groupId);
|
72 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper("core")->__('The subscription has been removed.'));
|
73 |
}
|
74 |
+
}
|
75 |
+
}
|
|
|
|
|
76 |
return true;
|
|
|
77 |
}
|
78 |
|
79 |
+
public function trackingCodesSet($observer)
|
80 |
+
{
|
81 |
$mailingId = Mage::getSingleton('core/app')->getRequest()->getParam('crmailing');
|
82 |
|
83 |
$cookie = Mage::getSingleton('core/cookie');
|
84 |
+
if ($mailingId) {
|
85 |
+
$cookie->set('crmailing', $mailingId, time()+self::SESSION_LIFE, '/');
|
86 |
}
|
87 |
|
88 |
+
$customerId = Mage::getSingleton('core/app')->getRequest()->getParam('crcustomer');
|
89 |
$cookie = Mage::getSingleton('core/cookie');
|
90 |
+
if ($customerId) {
|
91 |
+
$cookie->set('crcustomer', $customerId, time()+self::SESSION_LIFE, '/');
|
92 |
+
}
|
|
|
93 |
}
|
94 |
+
|
95 |
+
public function checkoutSuccess($observer)
|
96 |
+
{
|
97 |
|
98 |
+
if (!Mage::registry('order_track_start')) {
|
99 |
Mage::register('order_track_start', true);
|
100 |
+
} else {
|
101 |
return true;
|
102 |
}
|
103 |
|
104 |
+
if (Mage::helper("crconnect")->isTrackingEnabled()) {
|
105 |
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
106 |
+
} else {
|
107 |
Mage::helper("crconnect")->log("CleverReach_CrConnect: order sycing deactivated");
|
108 |
return false;
|
109 |
}
|
110 |
|
111 |
$order = Mage::getModel('sales/order')->load($lastOrderId);
|
|
|
112 |
$email = $order->getCustomerEmail();
|
113 |
|
114 |
+
if (Mage::helper("crconnect")->isTrackingEnabled()) {
|
|
|
115 |
$items = $order->getAllItems();
|
116 |
+
if ($items) {
|
117 |
+
foreach ($items as $item) {
|
|
|
118 |
$tmpItem = array();
|
119 |
$tmpItem["order_id"] = $lastOrderId;
|
120 |
$tmpItem["product"] = $item->getName();
|
121 |
$tmpItem["product_id"] = $item->getProductId();
|
122 |
+
$tmpItem["price"] = round($item->getPrice(), 2);
|
123 |
$tmpItem["quantity"] = (integer)$item->getQtyOrdered();
|
124 |
$tmpItem["purchase_date"] = time();
|
125 |
$tmpItem["currency"] = $order->getData('order_currency_code');
|
126 |
$tmpItem["source"] = "MAGENTO Order";
|
127 |
|
128 |
$cookie = Mage::getSingleton('core/cookie');
|
129 |
+
if ($cookie->get('crmailing')) {
|
130 |
$tmpItem['mailings_id'] = $cookie->get('crmailing');
|
131 |
}
|
132 |
|
133 |
Mage::getModel("crconnect/api")->receiverAddOrder($email, $tmpItem);
|
134 |
|
135 |
+
}
|
136 |
}
|
137 |
|
138 |
+
}
|
|
|
139 |
}
|
|
|
|
|
|
|
|
|
140 |
|
141 |
+
public function orderPlacedAfter($observer)
|
142 |
+
{
|
143 |
+
try {
|
144 |
+
$order = $observer->getOrder();
|
145 |
+
if (Mage::helper("crconnect")->isM2eExclude()) {
|
146 |
$shippingMethod = $order->getShippingMethod();
|
147 |
+
Mage::helper("crconnect")->log("M2E sync disabled -> shipping method: " . $shippingMethod);
|
148 |
+
if (in_array($shippingMethod, Mage::helper("crconnect")->getM2eShippingMethods())) {
|
|
|
149 |
Mage::helper("crconnect")->log("Its M2E order -> Skip");
|
150 |
return true;
|
151 |
+
}
|
|
|
152 |
}
|
153 |
|
154 |
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
155 |
$email = $order->getCustomerEmail();
|
156 |
|
157 |
+
if (Mage::helper("crconnect")->isForceSyncEnabled()) {
|
|
|
158 |
Mage::helper("crconnect")->log("Force sync orders enabled");
|
159 |
|
160 |
+
if ($customer->getEmail()) {
|
161 |
Mage::helper("crconnect")->log("Force sync orders for logged in customer");
|
162 |
$crReceiver = Mage::helper('crconnect')->prepareUserdata($customer);
|
163 |
$result = Mage::getModel("crconnect/api")->receiverAdd($crReceiver, $customer->getGroupId());
|
164 |
Mage::helper("crconnect")->log($result);
|
165 |
+
} else {
|
166 |
Mage::helper("crconnect")->log("Force sync orders for guest customer");
|
167 |
$billingAddress = $order->getBillingAddress()->getData();
|
168 |
+
if ($billingAddress) {
|
169 |
Mage::helper("crconnect")->log("Prepare info based on billing address");
|
170 |
$crReceiver = array (
|
171 |
'email' => $email,
|
183 |
);
|
184 |
|
185 |
$cookie = Mage::getSingleton('core/cookie');
|
186 |
+
if ($cookie->get('crmailing')) {
|
187 |
$crReceiver['orders'][0]['mailings_id'] = $cookie->get('crmailing');
|
188 |
}
|
189 |
Mage::helper("crconnect")->log($crReceiver);
|
190 |
|
191 |
$result = Mage::getModel("crconnect/api")->receiverAdd($crReceiver);
|
192 |
Mage::helper("crconnect")->log($result);
|
|
|
193 |
}
|
194 |
+
}
|
195 |
+
}
|
|
|
|
|
196 |
} catch (Exception $ex) {
|
197 |
Mage::helper("crconnect")->log("order_save_after Exception");
|
198 |
Mage::helper("crconnect")->log($ex);
|
202 |
|
203 |
}
|
204 |
|
205 |
+
public function customerDeleted($observer)
|
206 |
+
{
|
207 |
|
208 |
$event = $observer->getEvent();
|
209 |
$customer = $event->getCustomer();
|
210 |
$email = $customer->getEmail();
|
211 |
$groupId = $customer->getGroupId();
|
212 |
+
|
213 |
Mage::getModel("crconnect/subscriber")->unsubscribe($email);
|
214 |
Mage::getModel("crconnect/subscriber")->unsubscribe($email, $groupId);
|
215 |
|
216 |
}
|
217 |
+
|
218 |
+
public function configSave()
|
219 |
+
{
|
220 |
+
if (Mage::app()->getRequest()->getParam('section') == "newsletter" || Mage::app()->getRequest()->getParam('section') == "crroot") {
|
221 |
+
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
|
|
|
|
|
|
|
|
222 |
$groupsIds = Mage::helper("crconnect")->getGroupsIds();
|
223 |
+
$formsIds = Mage::helper("crconnect")->getFormsIds();
|
|
|
224 |
$allow = true;
|
225 |
+
foreach ($groupsIds as $groupsId) {
|
226 |
+
if (!$groupsId) {
|
227 |
$allow = false;
|
228 |
}
|
229 |
+
}
|
230 |
+
foreach ($formsIds as $formsId) {
|
231 |
+
if (!$formsId) {
|
|
|
232 |
$allow = false;
|
233 |
}
|
234 |
+
}
|
|
|
235 |
$formId = Mage::helper("crconnect")->getDefaultFormId();
|
236 |
+
if (!$formId) {
|
237 |
$allow = false;
|
238 |
+
}
|
239 |
+
if (!$allow) {
|
|
|
240 |
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('Double Opt-In enabled, please select Form(s) and Group(s) for your Customer Groups'));
|
241 |
}
|
242 |
+
}
|
243 |
+
}
|
|
|
|
|
|
|
244 |
}
|
245 |
+
|
246 |
+
public function initCleverReach()
|
247 |
+
{
|
248 |
$session = Mage::getSingleton('adminhtml/session');
|
249 |
+
|
250 |
$setupResult = Mage::getModel('crconnect/api')->setupDefaultClereReachList();
|
251 |
+
if (!$setupResult) {
|
252 |
$session->addError("Could not connect to CleverReach. Please chech your API keys.");
|
253 |
+
} elseif ($setupResult->status == "ERROR" && $setupResult->statuscode != 50) {
|
254 |
+
var_dump($setupResult);
|
255 |
+
$session->addError("Cleverreach connection Error: " . $setupResult->message);
|
256 |
+
}
|
|
|
257 |
}
|
258 |
+
}
|
app/code/community/Conlabz/CrConnect/Model/Search.php
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Conlabz_CrConnect_Model_Search
|
|
|
4 |
/*
|
5 |
* Get Search Filters values
|
6 |
*/
|
7 |
|
8 |
-
public function getFilter()
|
|
|
9 |
|
10 |
$filter = array();
|
11 |
|
@@ -45,7 +47,8 @@ class Conlabz_CrConnect_Model_Search {
|
|
45 |
* @return array of categories of one level
|
46 |
*/
|
47 |
|
48 |
-
public function getCategories($categories)
|
|
|
49 |
|
50 |
foreach ($categories as $category) {
|
51 |
$cat = Mage::getModel('catalog/category')->load($category->getId());
|
@@ -70,7 +73,8 @@ class Conlabz_CrConnect_Model_Search {
|
|
70 |
*
|
71 |
*/
|
72 |
|
73 |
-
public function getSearch($category = false, $product = "", $store = false)
|
|
|
74 |
|
75 |
$products = Mage::getModel('catalog/product')->getCollection()
|
76 |
->addAttributeToSelect("name")
|
@@ -99,7 +103,6 @@ class Conlabz_CrConnect_Model_Search {
|
|
99 |
$items = array();
|
100 |
if ($category || $product) {
|
101 |
foreach ($products as $product) {
|
102 |
-
|
103 |
$item = array();
|
104 |
$item['title'] = $product->getName();
|
105 |
$item['description'] = $product->getDescription();
|
@@ -114,5 +117,4 @@ class Conlabz_CrConnect_Model_Search {
|
|
114 |
$search['items'] = $items;
|
115 |
return $search;
|
116 |
}
|
117 |
-
|
118 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Conlabz_CrConnect_Model_Search
|
4 |
+
{
|
5 |
/*
|
6 |
* Get Search Filters values
|
7 |
*/
|
8 |
|
9 |
+
public function getFilter()
|
10 |
+
{
|
11 |
|
12 |
$filter = array();
|
13 |
|
47 |
* @return array of categories of one level
|
48 |
*/
|
49 |
|
50 |
+
public function getCategories($categories)
|
51 |
+
{
|
52 |
|
53 |
foreach ($categories as $category) {
|
54 |
$cat = Mage::getModel('catalog/category')->load($category->getId());
|
73 |
*
|
74 |
*/
|
75 |
|
76 |
+
public function getSearch($category = false, $product = "", $store = false)
|
77 |
+
{
|
78 |
|
79 |
$products = Mage::getModel('catalog/product')->getCollection()
|
80 |
->addAttributeToSelect("name")
|
103 |
$items = array();
|
104 |
if ($category || $product) {
|
105 |
foreach ($products as $product) {
|
|
|
106 |
$item = array();
|
107 |
$item['title'] = $product->getName();
|
108 |
$item['description'] = $product->getDescription();
|
117 |
$search['items'] = $items;
|
118 |
return $search;
|
119 |
}
|
|
|
120 |
}
|
app/code/community/Conlabz/CrConnect/Model/Subscriber.php
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Conlabz_CrConnect_Model_Subscriber extends Mage_Core_Model_Abstract
|
|
|
4 |
|
5 |
/*
|
6 |
* Subscribe cusotmer
|
7 |
*/
|
8 |
-
public function subscribe($customer = false, $groupId = 0)
|
|
|
9 |
|
10 |
return Mage::getModel("crconnect/api")->subscribe($customer, $groupId);
|
11 |
|
@@ -14,7 +16,8 @@ class Conlabz_CrConnect_Model_Subscriber extends Mage_Core_Model_Abstract {
|
|
14 |
/*
|
15 |
* Send activation email for customer
|
16 |
*/
|
17 |
-
public function formsSendActivationMail($customer = false, $groupId = 0)
|
|
|
18 |
|
19 |
return Mage::getModel("crconnect/api")->formsSendActivationMail($customer, $groupId);
|
20 |
|
@@ -23,16 +26,17 @@ class Conlabz_CrConnect_Model_Subscriber extends Mage_Core_Model_Abstract {
|
|
23 |
/*
|
24 |
* Subscribe cusotmer
|
25 |
*/
|
26 |
-
public function unsubscribe($email = false, $groupId = 0)
|
|
|
27 |
|
28 |
return Mage::getModel("crconnect/api")->unsubscribe($email, $groupId);
|
29 |
|
30 |
}
|
31 |
|
32 |
-
public function updateCustomer($customer, $groupId = 0)
|
|
|
33 |
|
34 |
return Mage::getModel("crconnect/api")->update($customer, $groupId);
|
35 |
|
36 |
}
|
37 |
-
|
38 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Conlabz_CrConnect_Model_Subscriber extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
|
6 |
/*
|
7 |
* Subscribe cusotmer
|
8 |
*/
|
9 |
+
public function subscribe($customer = false, $groupId = 0)
|
10 |
+
{
|
11 |
|
12 |
return Mage::getModel("crconnect/api")->subscribe($customer, $groupId);
|
13 |
|
16 |
/*
|
17 |
* Send activation email for customer
|
18 |
*/
|
19 |
+
public function formsSendActivationMail($customer = false, $groupId = 0)
|
20 |
+
{
|
21 |
|
22 |
return Mage::getModel("crconnect/api")->formsSendActivationMail($customer, $groupId);
|
23 |
|
26 |
/*
|
27 |
* Subscribe cusotmer
|
28 |
*/
|
29 |
+
public function unsubscribe($email = false, $groupId = 0)
|
30 |
+
{
|
31 |
|
32 |
return Mage::getModel("crconnect/api")->unsubscribe($email, $groupId);
|
33 |
|
34 |
}
|
35 |
|
36 |
+
public function updateCustomer($customer, $groupId = 0)
|
37 |
+
{
|
38 |
|
39 |
return Mage::getModel("crconnect/api")->update($customer, $groupId);
|
40 |
|
41 |
}
|
|
|
42 |
}
|
app/code/community/Conlabz/CrConnect/Model/System/Config/Source/EmptyForms.php
CHANGED
@@ -26,5 +26,4 @@ class Conlabz_CrConnect_Model_System_Config_Source_EmptyForms
|
|
26 |
// 1 => Mage::helper('adminhtml')->__('Yes'),
|
27 |
// );
|
28 |
// }
|
29 |
-
|
30 |
}
|
26 |
// 1 => Mage::helper('adminhtml')->__('Yes'),
|
27 |
// );
|
28 |
// }
|
|
|
29 |
}
|
app/code/community/Conlabz/CrConnect/Model/System/Config/Source/EmptyList.php
CHANGED
@@ -26,5 +26,4 @@ class Conlabz_CrConnect_Model_System_Config_Source_EmptyList
|
|
26 |
// 1 => Mage::helper('adminhtml')->__('Yes'),
|
27 |
// );
|
28 |
// }
|
29 |
-
|
30 |
}
|
26 |
// 1 => Mage::helper('adminhtml')->__('Yes'),
|
27 |
// );
|
28 |
// }
|
|
|
29 |
}
|
app/code/community/Conlabz/CrConnect/Model/Website/Observer.php
CHANGED
@@ -21,11 +21,12 @@
|
|
21 |
|
22 |
class Conlabz_CrConnect_Model_Website_Observer
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
}
|
21 |
|
22 |
class Conlabz_CrConnect_Model_Website_Observer
|
23 |
{
|
24 |
+
public function trackingCodeCheck()
|
25 |
+
{
|
26 |
+
$mailingId = Mage::getSingleton('core/app')->getRequest()->getParam('crmailing');
|
27 |
+
$cookie = Mage::getSingleton('core/cookie');
|
28 |
+
if ($mailingId) {
|
29 |
+
$cookie->set('crmailing', $mailingId, time()+3600*24*14, '/');
|
30 |
+
}
|
31 |
+
}
|
32 |
}
|
app/code/community/Conlabz/CrConnect/controllers/AccountController.php
CHANGED
@@ -4,7 +4,7 @@ include "Mage/Customer/controllers/AccountController.php";
|
|
4 |
class Conlabz_CrConnect_AccountController extends Mage_Customer_AccountController
|
5 |
{
|
6 |
|
7 |
-
|
8 |
* Create customer account action
|
9 |
*/
|
10 |
public function createPostAction()
|
@@ -29,24 +29,20 @@ class Conlabz_CrConnect_AccountController extends Mage_Customer_AccountControlle
|
|
29 |
|
30 |
$customerData = $customerForm->extractData($this->getRequest());
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
$status = Mage::getModel("newsletter/subscriber")->subscribe($this->getRequest()->getPost('email'));
|
35 |
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
|
36 |
Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
|
37 |
-
}
|
38 |
-
else {
|
39 |
Mage::getSingleton('customer/session')->addSuccess($this->__('Thank you for your subscription.'));
|
40 |
}
|
41 |
-
|
42 |
-
}else{
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
$customer->setIsSubscribed(1);
|
47 |
-
}
|
48 |
|
49 |
-
|
50 |
/**
|
51 |
* Initialize customer group id
|
52 |
*/
|
@@ -97,7 +93,8 @@ class Conlabz_CrConnect_AccountController extends Mage_Customer_AccountControlle
|
|
97 |
if (true === $validationResult) {
|
98 |
$customer->save();
|
99 |
|
100 |
-
Mage::dispatchEvent(
|
|
|
101 |
array('account_controller' => $this, 'customer' => $customer)
|
102 |
);
|
103 |
|
@@ -144,6 +141,4 @@ class Conlabz_CrConnect_AccountController extends Mage_Customer_AccountControlle
|
|
144 |
|
145 |
$this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
|
146 |
}
|
147 |
-
|
148 |
-
|
149 |
}
|
4 |
class Conlabz_CrConnect_AccountController extends Mage_Customer_AccountController
|
5 |
{
|
6 |
|
7 |
+
/**
|
8 |
* Create customer account action
|
9 |
*/
|
10 |
public function createPostAction()
|
29 |
|
30 |
$customerData = $customerForm->extractData($this->getRequest());
|
31 |
|
32 |
+
if (Mage::getStoreConfig("newsletter/subscription/confirm_logged_email_template") == 1) {
|
33 |
+
$status = Mage::getModel("newsletter/subscriber")->subscribe($this->getRequest()->getPost('email'));
|
|
|
34 |
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
|
35 |
Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
|
36 |
+
} else {
|
|
|
37 |
Mage::getSingleton('customer/session')->addSuccess($this->__('Thank you for your subscription.'));
|
38 |
}
|
39 |
+
|
40 |
+
} else {
|
41 |
+
if ($this->getRequest()->getParam('is_subscribed', false)) {
|
42 |
+
$customer->setIsSubscribed(1);
|
43 |
+
}
|
|
|
|
|
44 |
|
45 |
+
}
|
46 |
/**
|
47 |
* Initialize customer group id
|
48 |
*/
|
93 |
if (true === $validationResult) {
|
94 |
$customer->save();
|
95 |
|
96 |
+
Mage::dispatchEvent(
|
97 |
+
'customer_register_success',
|
98 |
array('account_controller' => $this, 'customer' => $customer)
|
99 |
);
|
100 |
|
141 |
|
142 |
$this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
|
143 |
}
|
|
|
|
|
144 |
}
|
app/code/community/Conlabz/CrConnect/controllers/Adminhtml/ConfigController.php
CHANGED
@@ -1,52 +1,56 @@
|
|
1 |
<?php
|
2 |
-
class Conlabz_Crconnect_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Action
|
|
|
3 |
|
4 |
|
5 |
const EMPTY_CODE = "empty";
|
6 |
|
7 |
-
public function confirmKeyAction()
|
|
|
8 |
|
9 |
$apiKey = $this->getRequest()->getParam("key");
|
10 |
//Mage::helper("crconnect")->setApiKey($apiKey);
|
11 |
|
12 |
$api = Mage::getModel("crconnect/api");
|
13 |
-
if ($api->isConnected()){
|
14 |
$groups = $api->getGroupsForKey($apiKey);
|
15 |
-
if ($groups){
|
16 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($groups));
|
17 |
-
}else{
|
18 |
-
$this->getResponse()->setBody(self::EMPTY_CODE);
|
19 |
}
|
20 |
}
|
21 |
|
22 |
}
|
23 |
|
24 |
-
public function changeGroupAction()
|
|
|
25 |
|
26 |
$groupId = $this->getRequest()->getParam("group");
|
27 |
$apiKey = $this->getRequest()->getParam("key");
|
28 |
|
29 |
$api = Mage::getModel("crconnect/api");
|
30 |
-
if ($api->isConnected()){
|
31 |
$forms = $api->getFormsForGroup($apiKey, $groupId);
|
32 |
-
if ($forms){
|
33 |
-
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($forms));
|
34 |
-
}else{
|
35 |
-
$this->getResponse()->setBody(self::EMPTY_CODE);
|
36 |
}
|
37 |
}
|
38 |
|
39 |
}
|
40 |
|
41 |
-
public function getGroupsBlockAction()
|
|
|
42 |
|
43 |
echo Mage::app()->getLayout()->createBlock('crconnect/config_groupsapis')->toHtml();
|
44 |
|
45 |
}
|
46 |
-
protected function _isAllowed()
|
|
|
47 |
|
48 |
return true;
|
49 |
|
50 |
}
|
51 |
-
|
52 |
-
}
|
1 |
<?php
|
2 |
+
class Conlabz_Crconnect_Adminhtml_ConfigController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
|
5 |
|
6 |
const EMPTY_CODE = "empty";
|
7 |
|
8 |
+
public function confirmKeyAction()
|
9 |
+
{
|
10 |
|
11 |
$apiKey = $this->getRequest()->getParam("key");
|
12 |
//Mage::helper("crconnect")->setApiKey($apiKey);
|
13 |
|
14 |
$api = Mage::getModel("crconnect/api");
|
15 |
+
if ($api->isConnected()) {
|
16 |
$groups = $api->getGroupsForKey($apiKey);
|
17 |
+
if ($groups) {
|
18 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($groups));
|
19 |
+
} else {
|
20 |
+
$this->getResponse()->setBody(self::EMPTY_CODE);
|
21 |
}
|
22 |
}
|
23 |
|
24 |
}
|
25 |
|
26 |
+
public function changeGroupAction()
|
27 |
+
{
|
28 |
|
29 |
$groupId = $this->getRequest()->getParam("group");
|
30 |
$apiKey = $this->getRequest()->getParam("key");
|
31 |
|
32 |
$api = Mage::getModel("crconnect/api");
|
33 |
+
if ($api->isConnected()) {
|
34 |
$forms = $api->getFormsForGroup($apiKey, $groupId);
|
35 |
+
if ($forms) {
|
36 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($forms));
|
37 |
+
} else {
|
38 |
+
$this->getResponse()->setBody(self::EMPTY_CODE);
|
39 |
}
|
40 |
}
|
41 |
|
42 |
}
|
43 |
|
44 |
+
public function getGroupsBlockAction()
|
45 |
+
{
|
46 |
|
47 |
echo Mage::app()->getLayout()->createBlock('crconnect/config_groupsapis')->toHtml();
|
48 |
|
49 |
}
|
50 |
+
protected function _isAllowed()
|
51 |
+
{
|
52 |
|
53 |
return true;
|
54 |
|
55 |
}
|
56 |
+
}
|
|
app/code/community/Conlabz/CrConnect/controllers/Adminhtml/CrconnectController.php
CHANGED
@@ -1,33 +1,35 @@
|
|
1 |
<?php
|
2 |
-
class Conlabz_Crconnect_Adminhtml_CrconnectController extends Mage_Adminhtml_Controller_Action
|
|
|
3 |
|
4 |
/*
|
5 |
* Accounts list action
|
6 |
*/
|
7 |
-
public function synchronizeAction()
|
|
|
8 |
|
9 |
|
10 |
$syncedUsers = Mage::getModel("crconnect/api")->synchronize();
|
11 |
$result = array();
|
12 |
-
|
13 |
-
if ($syncedUsers !== false){
|
14 |
$result['error'] = false;
|
15 |
$result['message'] = Mage::helper('crconnect')->__("Synchronization successfull. %s users were transmitted.", $syncedUsers);
|
16 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__("Synchronization successfull. %s users were transmitted.", $syncedUsers));
|
17 |
-
}else{
|
18 |
$result['error'] = true;
|
19 |
$result['message'] = Mage::helper('crconnect')->__("Error occured while synchronization process. Please try again later.");
|
20 |
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__("Error occured while synchronization process. Please try again later."));
|
21 |
}
|
22 |
-
|
23 |
$this->getResponse()->setBody(json_encode($result));
|
24 |
-
|
25 |
}
|
26 |
|
27 |
-
protected function _isAllowed()
|
|
|
28 |
|
29 |
return true;
|
30 |
|
31 |
}
|
32 |
-
|
33 |
-
}
|
1 |
<?php
|
2 |
+
class Conlabz_Crconnect_Adminhtml_CrconnectController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
|
5 |
/*
|
6 |
* Accounts list action
|
7 |
*/
|
8 |
+
public function synchronizeAction()
|
9 |
+
{
|
10 |
|
11 |
|
12 |
$syncedUsers = Mage::getModel("crconnect/api")->synchronize();
|
13 |
$result = array();
|
14 |
+
|
15 |
+
if ($syncedUsers !== false) {
|
16 |
$result['error'] = false;
|
17 |
$result['message'] = Mage::helper('crconnect')->__("Synchronization successfull. %s users were transmitted.", $syncedUsers);
|
18 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__("Synchronization successfull. %s users were transmitted.", $syncedUsers));
|
19 |
+
} else {
|
20 |
$result['error'] = true;
|
21 |
$result['message'] = Mage::helper('crconnect')->__("Error occured while synchronization process. Please try again later.");
|
22 |
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__("Error occured while synchronization process. Please try again later."));
|
23 |
}
|
24 |
+
|
25 |
$this->getResponse()->setBody(json_encode($result));
|
26 |
+
|
27 |
}
|
28 |
|
29 |
+
protected function _isAllowed()
|
30 |
+
{
|
31 |
|
32 |
return true;
|
33 |
|
34 |
}
|
35 |
+
}
|
|
app/code/community/Conlabz/CrConnect/controllers/HookController.php
CHANGED
@@ -26,77 +26,76 @@ include "Mage/Newsletter/controllers/SubscriberController.php";
|
|
26 |
// Instead we redirect all requests for newsletter/subscriber to this
|
27 |
// controller, which extends Mage_Newsletter_SubscriberController and
|
28 |
// overrides the newAction method.
|
29 |
-
class Conlabz_CrConnect_HookController extends Mage_Newsletter_SubscriberController
|
|
|
30 |
|
31 |
public function confirmAction()
|
32 |
{
|
33 |
$id = (int) $this->getRequest()->getParam('id');
|
34 |
$code = (string) $this->getRequest()->getParam('code');
|
35 |
-
|
36 |
-
|
37 |
$subscriber = Mage::getModel('newsletter/subscriber')->load($id);
|
38 |
$session = Mage::getSingleton('core/session');
|
39 |
-
|
40 |
-
|
41 |
-
if($subscriber->confirm($code)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
$apiKey = trim(Mage::getStoreConfig('crroot/crconnect/api_key'));
|
46 |
-
$listID = trim(Mage::getStoreConfig('crroot/crconnect/list_id'));
|
47 |
-
$confirm = trim(Mage::getStoreConfig('newsletter/subscription/confirm'));
|
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 |
-
try {
|
76 |
$result = $client->receiverAdd($apiKey, $listID, array(
|
77 |
"email" => $subscriber->getEmail(),
|
78 |
"source" => "MAGENTO (frontend)",
|
79 |
-
|
80 |
-
)
|
81 |
-
);
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
$result = $client->receiverUpdate($apiKey, $listID, array(
|
86 |
"email" => $subscriber->getEmail(),
|
87 |
"source" => "MAGENTO (frontend)",
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
} catch (Exception $e) {
|
95 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
96 |
$session->addException($e, $this->__('Subscription was invalid'));
|
97 |
$this->_redirectReferer();
|
98 |
}
|
99 |
-
|
100 |
parent::confirmAction();
|
101 |
} else {
|
102 |
$session->addError($this->__('Invalid subscription confirmation code'));
|
@@ -108,69 +107,69 @@ class Conlabz_CrConnect_HookController extends Mage_Newsletter_SubscriberControl
|
|
108 |
|
109 |
$this->_redirectUrl(Mage::getBaseUrl());
|
110 |
}
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
116 |
$session = Mage::getSingleton('core/session');
|
117 |
$customerSession = Mage::getSingleton('customer/session');
|
118 |
$email = (string) $this->getRequest()->getPost('email');
|
119 |
-
|
120 |
$apiKey = trim(Mage::getStoreConfig('crroot/crconnect/api_key'));
|
121 |
$listID = trim(Mage::getStoreConfig('crroot/crconnect/list_id'));
|
122 |
-
|
123 |
|
124 |
-
if($apiKey && $listID && !$confirm) {
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
$session->addException($e, $this->__('There was a problem with the subscription'));
|
132 |
$this->_redirectReferer();
|
133 |
-
|
134 |
|
135 |
|
136 |
$customerHelper = Mage::helper('customer');
|
137 |
-
|
138 |
// otherwise if nobody's logged in, ignore the custom
|
139 |
// attributes and just set the name to '(Guest)'
|
140 |
-
|
141 |
/* echo "<pre>"; */
|
142 |
/* $result = $client->receiverGetByEmail($apiKey, $listID, 'alex.nuzil@conlabz.de', 1); */
|
143 |
/* var_dump($result); */
|
144 |
/* exit; */
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
}
|
154 |
-
|
155 |
-
$result = $client->receiverAdd($apiKey, $listID, array(
|
156 |
-
"email" => $email,
|
157 |
-
"source" => "MAGENTO (frontend)",
|
158 |
-
"attributes" => array('0'=>array('key'=>'store', 'value'=>Mage::app()->getStore()->getCode(), 'variable'=>'{STORE}'),"newsletter"=>"1"),
|
159 |
-
)
|
160 |
-
);
|
161 |
-
} catch (Exception $e) {
|
162 |
-
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
163 |
-
$session->addException($e, $this->__('There was a problem with the subscription'));
|
164 |
-
$this->_redirectReferer();
|
165 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
}
|
167 |
-
}
|
168 |
-
|
169 |
-
}else{
|
170 |
-
|
171 |
}
|
172 |
}
|
173 |
|
174 |
parent::newAction();
|
175 |
}
|
176 |
-
}
|
26 |
// Instead we redirect all requests for newsletter/subscriber to this
|
27 |
// controller, which extends Mage_Newsletter_SubscriberController and
|
28 |
// overrides the newAction method.
|
29 |
+
class Conlabz_CrConnect_HookController extends Mage_Newsletter_SubscriberController
|
30 |
+
{
|
31 |
|
32 |
public function confirmAction()
|
33 |
{
|
34 |
$id = (int) $this->getRequest()->getParam('id');
|
35 |
$code = (string) $this->getRequest()->getParam('code');
|
36 |
+
|
37 |
+
if ($id && $code) {
|
38 |
$subscriber = Mage::getModel('newsletter/subscriber')->load($id);
|
39 |
$session = Mage::getSingleton('core/session');
|
40 |
+
|
41 |
+
if ($subscriber->getId() && $subscriber->getCode()) {
|
42 |
+
if ($subscriber->confirm($code)) {
|
43 |
+
Mage::log("Cleverreach_CrConnect: newsletter signup for ".$subscriber->getEmail().", confirmation");
|
44 |
+
|
45 |
+
$apiKey = trim(Mage::getStoreConfig('crroot/crconnect/api_key'));
|
46 |
+
$listID = trim(Mage::getStoreConfig('crroot/crconnect/list_id'));
|
47 |
+
$confirm = trim(Mage::getStoreConfig('newsletter/subscription/confirm'));
|
48 |
+
|
49 |
|
50 |
+
|
51 |
+
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($subscriber->getEmail());
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
if ($customer->getId()) {
|
54 |
+
if (Mage::getStoreConfig('crroot/crconnect/showgroup') == '1') {
|
55 |
+
$groupKeys = Mage::helper('crconnect')->getKeys();
|
56 |
+
if ($groupId = $customer->getGroupId()) {
|
57 |
+
if (isset($groupKeys[$groupId])) {
|
58 |
+
$listID = $groupKeys[$groupId];
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
try {
|
66 |
+
$client = new SoapClient(
|
67 |
+
Mage::helper('crconnect')->getWsdl(),
|
68 |
+
array("trace" => true)
|
69 |
+
);
|
70 |
+
} catch (Exception $e) {
|
71 |
+
Mage::log("CleverReach_CrConnect: Error connecting to server: ".$e->getMessage());
|
72 |
+
$session->addException($e, $this->__('There was a problem with the subscription'));
|
73 |
+
$this->_redirectReferer();
|
74 |
+
}
|
75 |
+
|
76 |
+
try {
|
|
|
|
|
77 |
$result = $client->receiverAdd($apiKey, $listID, array(
|
78 |
"email" => $subscriber->getEmail(),
|
79 |
"source" => "MAGENTO (frontend)",
|
80 |
+
"attributes" => array("key" => "newsletter", "value" => "1"),
|
81 |
+
));
|
|
|
82 |
|
83 |
+
if ($result->status!="SUCCESS" && $result->statuscode == "50") {
|
84 |
+
$result = $client->receiverUpdate($apiKey, $listID, array(
|
|
|
85 |
"email" => $subscriber->getEmail(),
|
86 |
"source" => "MAGENTO (frontend)",
|
87 |
+
"attributes" => array("key" => "newsletter", "value" => "1"),
|
88 |
+
"deactivated"=>0
|
89 |
+
));
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
} catch (Exception $e) {
|
94 |
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
95 |
$session->addException($e, $this->__('Subscription was invalid'));
|
96 |
$this->_redirectReferer();
|
97 |
}
|
98 |
+
|
99 |
parent::confirmAction();
|
100 |
} else {
|
101 |
$session->addError($this->__('Invalid subscription confirmation code'));
|
107 |
|
108 |
$this->_redirectUrl(Mage::getBaseUrl());
|
109 |
}
|
110 |
+
|
111 |
+
|
112 |
+
public function newAction()
|
113 |
+
{
|
114 |
+
|
115 |
+
if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
|
116 |
$session = Mage::getSingleton('core/session');
|
117 |
$customerSession = Mage::getSingleton('customer/session');
|
118 |
$email = (string) $this->getRequest()->getPost('email');
|
119 |
+
|
120 |
$apiKey = trim(Mage::getStoreConfig('crroot/crconnect/api_key'));
|
121 |
$listID = trim(Mage::getStoreConfig('crroot/crconnect/list_id'));
|
122 |
+
$confirm = trim(Mage::getStoreConfig('newsletter/subscription/confirm'));
|
123 |
|
124 |
+
if ($apiKey && $listID && !$confirm) {
|
125 |
+
Mage::log("Cleverreach_CrConnect: newsletter signup for $email, no confirmation");
|
126 |
+
|
127 |
+
try {
|
128 |
+
$client = new SoapClient(Mage::helper('crconnect')->getWsdl(), array("trace" => true));
|
129 |
+
} catch (Exception $e) {
|
130 |
+
Mage::log("CleverReach_CrConnect: Error connecting to server: ".$e->getMessage());
|
131 |
$session->addException($e, $this->__('There was a problem with the subscription'));
|
132 |
$this->_redirectReferer();
|
133 |
+
}
|
134 |
|
135 |
|
136 |
$customerHelper = Mage::helper('customer');
|
137 |
+
{
|
138 |
// otherwise if nobody's logged in, ignore the custom
|
139 |
// attributes and just set the name to '(Guest)'
|
140 |
+
try {
|
141 |
/* echo "<pre>"; */
|
142 |
/* $result = $client->receiverGetByEmail($apiKey, $listID, 'alex.nuzil@conlabz.de', 1); */
|
143 |
/* var_dump($result); */
|
144 |
/* exit; */
|
145 |
+
|
146 |
+
if (Mage::getStoreConfig('crroot/crconnect/showgroup') == '1') {
|
147 |
+
$groupKeys = Mage::helper('crconnect')->getKeys();
|
148 |
+
if ($groupId = $customerSession->getCustomerGroupId()) {
|
149 |
+
if (isset($groupKeys[$groupId])) {
|
150 |
+
$return = $listID = $groupKeys[$groupId];
|
151 |
+
}
|
152 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
+
|
155 |
+
$result = $client->receiverAdd($apiKey, $listID, array(
|
156 |
+
"email" => $email,
|
157 |
+
"source" => "MAGENTO (frontend)",
|
158 |
+
"attributes" => array('0'=>array('key'=>'store', 'value'=>Mage::app()->getStore()->getCode(), 'variable'=>'{STORE}'),"newsletter"=>"1"),
|
159 |
+
));
|
160 |
+
} catch (Exception $e) {
|
161 |
+
Mage::log("CleverReach_CrConnect: Error in SOAP call: ".$e->getMessage());
|
162 |
+
$session->addException($e, $this->__('There was a problem with the subscription'));
|
163 |
+
$this->_redirectReferer();
|
164 |
+
}
|
165 |
}
|
166 |
+
} elseif ($apiKey && $listID && $confirm) {
|
167 |
+
Mage::log("Cleverreach_CrConnect: skiping $email, waiting for confirmation");
|
168 |
+
} else {
|
169 |
+
Mage::log("Cleverreach_CrConnect: error: API key and/or ListID missing");
|
170 |
}
|
171 |
}
|
172 |
|
173 |
parent::newAction();
|
174 |
}
|
175 |
+
}
|
app/code/community/Conlabz/CrConnect/controllers/ManageController.php
CHANGED
@@ -2,22 +2,22 @@
|
|
2 |
|
3 |
include "Mage/Newsletter/controllers/ManageController.php";
|
4 |
|
5 |
-
class Conlabz_CrConnect_ManageController extends Mage_Newsletter_ManageController
|
|
|
6 |
|
7 |
-
public function saveAction()
|
|
|
8 |
|
9 |
if (!$this->_validateFormKey()) {
|
10 |
return $this->_redirect('customer/account/');
|
11 |
}
|
12 |
try {
|
13 |
-
|
14 |
-
$email = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
|
15 |
$subscriber = Mage::getModel("newsletter/subscriber")->loadByEmail($email);
|
16 |
$subscriber->setEmail(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
|
17 |
|
18 |
if ((boolean) $this->getRequest()->getParam('is_subscribed', false)) {
|
19 |
if (!$subscriber->isSubscribed()) {
|
20 |
-
|
21 |
$status = Mage::getModel("newsletter/subscriber")->subscribe($email);
|
22 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
23 |
Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
|
@@ -36,9 +36,7 @@ class Conlabz_CrConnect_ManageController extends Mage_Newsletter_ManageControlle
|
|
36 |
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
37 |
if ($groupId > 1) {
|
38 |
if ((boolean) $this->getRequest()->getParam('is_gsubscribed', false)) {
|
39 |
-
|
40 |
if (!$subscriber->isSubscribed($groupId)) {
|
41 |
-
|
42 |
$status = Mage::getModel("newsletter/subscriber")->subscribe(Mage::getSingleton('customer/session')->getCustomer()->getEmail(), $groupId);
|
43 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
44 |
Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
|
@@ -59,5 +57,4 @@ class Conlabz_CrConnect_ManageController extends Mage_Newsletter_ManageControlle
|
|
59 |
}
|
60 |
$this->_redirect('customer/account/');
|
61 |
}
|
62 |
-
|
63 |
}
|
2 |
|
3 |
include "Mage/Newsletter/controllers/ManageController.php";
|
4 |
|
5 |
+
class Conlabz_CrConnect_ManageController extends Mage_Newsletter_ManageController
|
6 |
+
{
|
7 |
|
8 |
+
public function saveAction()
|
9 |
+
{
|
10 |
|
11 |
if (!$this->_validateFormKey()) {
|
12 |
return $this->_redirect('customer/account/');
|
13 |
}
|
14 |
try {
|
15 |
+
$email = Mage::getSingleton('customer/session')->getCustomer()->getEmail();
|
|
|
16 |
$subscriber = Mage::getModel("newsletter/subscriber")->loadByEmail($email);
|
17 |
$subscriber->setEmail(Mage::getSingleton('customer/session')->getCustomer()->getEmail());
|
18 |
|
19 |
if ((boolean) $this->getRequest()->getParam('is_subscribed', false)) {
|
20 |
if (!$subscriber->isSubscribed()) {
|
|
|
21 |
$status = Mage::getModel("newsletter/subscriber")->subscribe($email);
|
22 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
23 |
Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
|
36 |
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
|
37 |
if ($groupId > 1) {
|
38 |
if ((boolean) $this->getRequest()->getParam('is_gsubscribed', false)) {
|
|
|
39 |
if (!$subscriber->isSubscribed($groupId)) {
|
|
|
40 |
$status = Mage::getModel("newsletter/subscriber")->subscribe(Mage::getSingleton('customer/session')->getCustomer()->getEmail(), $groupId);
|
41 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
42 |
Mage::getSingleton('customer/session')->addSuccess($this->__('Confirmation request has been sent.'));
|
57 |
}
|
58 |
$this->_redirect('customer/account/');
|
59 |
}
|
|
|
60 |
}
|
app/code/community/Conlabz/CrConnect/controllers/SearchController.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
-
class Conlabz_CrConnect_SearchController extends Mage_Core_Controller_Front_Action
|
|
|
3 |
|
4 |
-
public function indexAction()
|
|
|
5 |
|
6 |
$systemPassword = Mage::helper("crconnect")->getCleverReachFeedPassword();
|
7 |
|
@@ -27,5 +29,4 @@ class Conlabz_CrConnect_SearchController extends Mage_Core_Controller_Front_Acti
|
|
27 |
|
28 |
$this->getResponse()->setBody(json_encode($returnData));
|
29 |
}
|
30 |
-
|
31 |
}
|
1 |
<?php
|
2 |
+
class Conlabz_CrConnect_SearchController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
|
8 |
$systemPassword = Mage::helper("crconnect")->getCleverReachFeedPassword();
|
9 |
|
29 |
|
30 |
$this->getResponse()->setBody(json_encode($returnData));
|
31 |
}
|
|
|
32 |
}
|
app/code/community/Conlabz/CrConnect/controllers/SubscriberController.php
CHANGED
@@ -20,23 +20,23 @@
|
|
20 |
*/
|
21 |
include "Mage/Newsletter/controllers/SubscriberController.php";
|
22 |
|
23 |
-
class Conlabz_CrConnect_SubscriberController extends Mage_Newsletter_SubscriberController
|
|
|
24 |
|
25 |
const XML_PATH_LOGGED_CONFIRM_EMAIL_TEMPLATE = 'newsletter/subscription/confirm_logged_email_template';
|
26 |
|
27 |
-
public function newAction()
|
|
|
28 |
|
29 |
if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
|
30 |
-
|
31 |
$session = Mage::getSingleton('core/session');
|
32 |
$customerSession = Mage::getSingleton('customer/session');
|
33 |
$email = (string) $this->getRequest()->getPost('email');
|
34 |
|
35 |
try {
|
36 |
-
|
37 |
$status = Mage::getModel("newsletter/subscriber")->subscribe($email);
|
38 |
|
39 |
-
if ($status){
|
40 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
41 |
Mage::getSingleton('core/session')->addSuccess($this->__('Confirmation request has been sent.'));
|
42 |
} else {
|
@@ -51,5 +51,4 @@ class Conlabz_CrConnect_SubscriberController extends Mage_Newsletter_SubscriberC
|
|
51 |
}
|
52 |
}
|
53 |
}
|
54 |
-
|
55 |
}
|
20 |
*/
|
21 |
include "Mage/Newsletter/controllers/SubscriberController.php";
|
22 |
|
23 |
+
class Conlabz_CrConnect_SubscriberController extends Mage_Newsletter_SubscriberController
|
24 |
+
{
|
25 |
|
26 |
const XML_PATH_LOGGED_CONFIRM_EMAIL_TEMPLATE = 'newsletter/subscription/confirm_logged_email_template';
|
27 |
|
28 |
+
public function newAction()
|
29 |
+
{
|
30 |
|
31 |
if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
|
|
|
32 |
$session = Mage::getSingleton('core/session');
|
33 |
$customerSession = Mage::getSingleton('customer/session');
|
34 |
$email = (string) $this->getRequest()->getPost('email');
|
35 |
|
36 |
try {
|
|
|
37 |
$status = Mage::getModel("newsletter/subscriber")->subscribe($email);
|
38 |
|
39 |
+
if ($status) {
|
40 |
if (Mage::helper("crconnect")->isDoubleOptInEnabled()) {
|
41 |
Mage::getSingleton('core/session')->addSuccess($this->__('Confirmation request has been sent.'));
|
42 |
} else {
|
51 |
}
|
52 |
}
|
53 |
}
|
|
|
54 |
}
|
app/code/community/Conlabz/CrConnect/controllers/UnsubscribeController.php
CHANGED
@@ -24,56 +24,48 @@ class Conlabz_CrConnect_UnsubscribeController extends Mage_Core_Controller_Front
|
|
24 |
public function indexAction()
|
25 |
{
|
26 |
// don't do anything if we didn't get the email parameter
|
27 |
-
if(isset($_GET['email']))
|
28 |
-
{
|
29 |
$email = $_GET['email'];
|
30 |
-
|
31 |
-
|
32 |
|
33 |
// Check that the email address actually is unsubscribed in
|
34 |
// CleverReach
|
35 |
-
if($apiKey && $listID)
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
Mage::log("CleverReach_CrConnect: Error connecting to CleverReach server: ".$e->getMessage());
|
41 |
$session->addException($e, $this->__('There was a problem with the subscription'));
|
42 |
$this->_redirectReferer();
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
$this->_redirectReferer();
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
// If we are unsubscribed in cleverreach, mark us as
|
57 |
// unsubscribed in Magento.
|
58 |
-
if($tmp->data->deactivated)
|
59 |
-
|
60 |
-
try
|
61 |
-
{
|
62 |
Mage::log("CleverReach_CrConnect: Unsubscribing $email");
|
63 |
$collection = Mage::getModel('newsletter/subscriber')
|
64 |
->loadByEmail($email)
|
65 |
->unsubscribe();
|
66 |
|
67 |
Mage::getSingleton('customer/session')->addSuccess($this->__('You were successfully unsubscribed'));
|
68 |
-
}
|
69 |
-
catch (Exception $e)
|
70 |
-
{
|
71 |
Mage::log("CleverReach_CrConnect: ".$e->getMessage());
|
72 |
Mage::getSingleton('customer/session')->addError($this->__('There was an error while saving your subscription details'));
|
73 |
}
|
74 |
-
}
|
75 |
-
else
|
76 |
-
{
|
77 |
Mage::log("CleverReach_CrConnect: Not unsubscribing $email, not unsubscribed in Campaign Monitor");
|
78 |
}
|
79 |
}
|
@@ -81,4 +73,4 @@ class Conlabz_CrConnect_UnsubscribeController extends Mage_Core_Controller_Front
|
|
81 |
|
82 |
$this->_redirect('customer/account/');
|
83 |
}
|
84 |
-
}
|
24 |
public function indexAction()
|
25 |
{
|
26 |
// don't do anything if we didn't get the email parameter
|
27 |
+
if (isset($_GET['email'])) {
|
|
|
28 |
$email = $_GET['email'];
|
29 |
+
$apiKey = trim(Mage::getStoreConfig('newsletter/crconnect/api_key'));
|
30 |
+
$listID = trim(Mage::getStoreConfig('newsletter/crconnect/list_id'));
|
31 |
|
32 |
// Check that the email address actually is unsubscribed in
|
33 |
// CleverReach
|
34 |
+
if ($apiKey && $listID) {
|
35 |
+
try {
|
36 |
+
$client = new SoapClient(Mage::helper('crconnect')->getWsdl(), array("trace" => true));
|
37 |
+
} catch (Exception $e) {
|
38 |
+
Mage::log("CleverReach_CrConnect: Error connecting to CleverReach server: ".$e->getMessage());
|
|
|
39 |
$session->addException($e, $this->__('There was a problem with the subscription'));
|
40 |
$this->_redirectReferer();
|
41 |
+
}
|
42 |
|
43 |
+
//get data from cleverreach
|
44 |
+
Mage::log("CleverReach_CrConnect: Error - ".$tmp->message);
|
45 |
+
$tmp = $client->receiverGetByEmail($apiKey, $email);
|
46 |
+
if ($tmp->status!="SUCCESS") {
|
47 |
+
Mage::log("CleverReach_CrConnect: Error - ".$tmp->message);
|
48 |
+
$session->addException($e, $this->__('There was a problem with the unsubscription'));
|
49 |
$this->_redirectReferer();
|
50 |
+
} else {
|
51 |
+
Mage::log("CleverReach_CrConnect: Error - ".$tmp->message);
|
52 |
+
}
|
53 |
+
|
54 |
// If we are unsubscribed in cleverreach, mark us as
|
55 |
// unsubscribed in Magento.
|
56 |
+
if ($tmp->data->deactivated) {
|
57 |
+
try {
|
|
|
|
|
58 |
Mage::log("CleverReach_CrConnect: Unsubscribing $email");
|
59 |
$collection = Mage::getModel('newsletter/subscriber')
|
60 |
->loadByEmail($email)
|
61 |
->unsubscribe();
|
62 |
|
63 |
Mage::getSingleton('customer/session')->addSuccess($this->__('You were successfully unsubscribed'));
|
64 |
+
} catch (Exception $e) {
|
|
|
|
|
65 |
Mage::log("CleverReach_CrConnect: ".$e->getMessage());
|
66 |
Mage::getSingleton('customer/session')->addError($this->__('There was an error while saving your subscription details'));
|
67 |
}
|
68 |
+
} else {
|
|
|
|
|
69 |
Mage::log("CleverReach_CrConnect: Not unsubscribing $email, not unsubscribed in Campaign Monitor");
|
70 |
}
|
71 |
}
|
73 |
|
74 |
$this->_redirect('customer/account/');
|
75 |
}
|
76 |
+
}
|
app/code/community/Conlabz/CrConnect/etc/adminhtml.xml
CHANGED
@@ -20,4 +20,4 @@
|
|
20 |
</admin>
|
21 |
</resources>
|
22 |
</acl>
|
23 |
-
</config>
|
20 |
</admin>
|
21 |
</resources>
|
22 |
</acl>
|
23 |
+
</config>
|
app/code/community/Conlabz/CrConnect/etc/config.xml
CHANGED
@@ -2,11 +2,11 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Conlabz_CrConnect>
|
5 |
-
<version>3.0.
|
6 |
</Conlabz_CrConnect>
|
7 |
</modules>
|
8 |
<global>
|
9 |
-
|
10 |
<crconnect>
|
11 |
<class>Conlabz_CrConnect_Helper</class>
|
12 |
</crconnect>
|
@@ -31,7 +31,7 @@
|
|
31 |
<subscriber>Conlabz_CrConnect_Model_Newsletter_Subscriber</subscriber>
|
32 |
</rewrite>
|
33 |
</newsletter>
|
34 |
-
|
35 |
<events>
|
36 |
<controller_front_init_before>
|
37 |
<observers>
|
@@ -80,11 +80,11 @@
|
|
80 |
</customer_delete_before>
|
81 |
<customer_save_after>
|
82 |
<observers>
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
</observers>
|
89 |
</customer_save_after>
|
90 |
</events>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Conlabz_CrConnect>
|
5 |
+
<version>3.0.6</version>
|
6 |
</Conlabz_CrConnect>
|
7 |
</modules>
|
8 |
<global>
|
9 |
+
<helpers>
|
10 |
<crconnect>
|
11 |
<class>Conlabz_CrConnect_Helper</class>
|
12 |
</crconnect>
|
31 |
<subscriber>Conlabz_CrConnect_Model_Newsletter_Subscriber</subscriber>
|
32 |
</rewrite>
|
33 |
</newsletter>
|
34 |
+
</models>
|
35 |
<events>
|
36 |
<controller_front_init_before>
|
37 |
<observers>
|
80 |
</customer_delete_before>
|
81 |
<customer_save_after>
|
82 |
<observers>
|
83 |
+
<crconnect_adminhtml_customer_save_after>
|
84 |
+
<type>singleton</type>
|
85 |
+
<class>crconnect/observer</class>
|
86 |
+
<method>customerSaveAfter</method>
|
87 |
+
</crconnect_adminhtml_customer_save_after>
|
88 |
</observers>
|
89 |
</customer_save_after>
|
90 |
</events>
|
package.xml
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Conlabz_CrConnect</name>
|
4 |
-
<version>3.
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Synchronizes your Magento subscribers, customers and sales with CleverReach Email Marketing Software.</summary>
|
10 |
<description>With CleverReach (http://www.cleverreach.de) you can create professional emails online, dispatch them reliably, track their success and manage receivers. CleverReach is equipped with a particularly user-friendly interface, which you can use intuitively and without special knowledge.</description>
|
11 |
-
<notes>Stability Improvements
|
12 |
-
PHP requirements changed</notes>
|
13 |
<authors><author><name>conlabz GmbH</name><user>conlabz</user><email>info@conlabz.de</email></author></authors>
|
14 |
-
<date>
|
15 |
-
<time>
|
16 |
-
<contents><target name="magecommunity"><dir name="Conlabz"><dir name="CrConnect"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Tab"><file name="Newsletter.php" hash="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Conlabz_CrConnect</name>
|
4 |
+
<version>3.1.4</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Synchronizes your Magento subscribers, customers and sales with CleverReach Email Marketing Software.</summary>
|
10 |
<description>With CleverReach (http://www.cleverreach.de) you can create professional emails online, dispatch them reliably, track their success and manage receivers. CleverReach is equipped with a particularly user-friendly interface, which you can use intuitively and without special knowledge.</description>
|
11 |
+
<notes>Stability Improvements</notes>
|
|
|
12 |
<authors><author><name>conlabz GmbH</name><user>conlabz</user><email>info@conlabz.de</email></author></authors>
|
13 |
+
<date>2016-01-25</date>
|
14 |
+
<time>08:45:32</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Conlabz"><dir name="CrConnect"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Tab"><file name="Newsletter.php" hash="ff47d3028a8e766077ee78affd52eea6"/></dir></dir></dir><dir name="Newsletter"><file name="Subscriber.php" hash="e1b516bc593a41bcc6d00b259776c8b8"/></dir></dir><dir name="Config"><file name="GroupsApis.php" hash="da3907dba74081f724f23b7a6b6df255"/><file name="Key.php" hash="44c2fc49a5b97cdacec1cada7a256a88"/><file name="Url.php" hash="becf4140ce0997e95548b758d8b7ed68"/></dir><dir name="Customer"><file name="Newsletter.php" hash="b24e73f404a338e079854ca565a1f042"/></dir><file name="Groupsapis.php" hash="f20a158b439469cdd498b16cc459ab4a"/></dir><dir name="Helper"><file name="Data.php" hash="9f44473c621458480a723c1efa929105"/></dir><dir name="Model"><file name="Api.php" hash="040c50b65ddc04540ea994ff1bacd678"/><dir name="Checkout"><file name="Observer.php" hash="0daf2d1dba169f72bbea827556cf0a76"/></dir><dir name="Customer"><file name="Observer.php" hash="878370bd5958b3813f0b90f395b27ecf"/></dir><dir name="Newsletter"><file name="Subscriber.php" hash="96e4b452bf916d5afa209cb80192eba0"/></dir><file name="Observer.php" hash="b6dfa6eacb7da5b073dc68d0f5d953ca"/><file name="Search.php" hash="26cd428e4b7ae5222a1de5186ad1ab54"/><file name="Subscriber.php" hash="4c916fa47576f0b02f68846a98e38f80"/><dir name="System"><dir name="Config"><dir name="Source"><file name="EmptyForms.php" hash="910b9588b11edf73be1fc0103e49b997"/><file name="EmptyList.php" hash="6fe676d12ff5fa9231c3b0869b1ec750"/></dir></dir></dir><dir name="Website"><file name="Observer.php" hash="6c068fc61ae6ed512cbdce2a28f48cb7"/></dir></dir><dir name="controllers"><file name="AccountController.php" hash="86f79b2accced4b5dff847f855b46de9"/><dir name="Adminhtml"><file name="ConfigController.php" hash="1ceec04c5eda41140a00eee2de2971a4"/><file name="CrconnectController.php" hash="1136640545274b3bb6caa1451c625ee8"/></dir><file name="HookController.php" hash="2267000f03000c5696693b822a7054a0"/><file name="ManageController.php" hash="169191283031e6d0bc671e7bb88c6e30"/><file name="SearchController.php" hash="5ea211a82fd7239aaf8e3e7b78968d94"/><file name="SubscriberController.php" hash="2d1786f171f3fdf92ec839ba7bbc82b4"/><file name="UnsubscribeController.php" hash="06179908a7834597d6410f47f5868a98"/></dir><dir name="etc"><file name="adminhtml.xml" hash="05f8a5b43c8abe877f05e09eec5d8c65"/><file name="config.xml" hash="f9bc53c474b849311de20f30a39a2022"/><file name="system.xml" hash="634952e319523e7640152ddaeedeaef9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Conlabz_CrConnect.xml" hash="282358cc102bf617b7d5afcaa47ec489"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="crconnect.xml" hash="956fea6e3eb0e98fc6bbcc7241f9123e"/></dir><dir name="template"><dir name="crconnect"><dir name="customer"><dir name="account"><dir name="dashboard"><file name="info.phtml" hash="a533451e27b90284d3414e391b460231"/></dir></dir><dir name="form"><file name="newsletter.phtml" hash="4a1309d0d6d2587c8534dd4a1ccdf235"/></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="crconnect.xml" hash="1185a92ac6c2117d5e440f709d0eca24"/></dir><dir name="template"><dir name="crconnect"><dir name="config"><file name="header.phtml" hash="727bc6a2a9b67c1e5819faa91c06ffd3"/></dir><dir name="newsletter"><dir name="subscriber"><file name="list.phtml" hash="94952fb1921397c4ad33387d8387c463"/></dir></dir><dir name="system"><dir name="config"><dir name="form"><dir name="field"><file name="array_groups.phtml" hash="ac84db9b1e8b342337a478ecba62e0b1"/><file name="cr_array_groups.phtml" hash="d2f70aa406d8b15f819481acbf0ccbee"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Conlabz_CleverReach.csv" hash="4cb844c7288d9995d21d39eb4015fa44"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="cleverreach"><file name="cleverreach-logo.png" hash="bff60f831ca9e1dc9bcbdb2e3f5a5805"/></dir></dir><dir name="js"><file name="crconnect.js" hash="72c951b0b46862253c7159255d82b2e0"/></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|