Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Change Permissions

Fix merge_vars
Fix get url
  • Loading branch information...
gonzaloebiz committed Mar 2, 2016
1 parent ce16975 commit f0054b882ea21d2528c2965eab7f20ed7406c925
No changes.
No changes.
No changes.
No changes.
33 Helper/Data.php 100755 → 100644
@@ -81,13 +81,14 @@ public function getMergeVars($customer,$store = null)
$mergeVars = unserialize($this->scopeConfig->getValue(self::XML_PATH_MAPPING, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store));
foreach($mergeVars as $map)
{
$this->_getMergeVarsValue($map, $customer);
array_merge($merge_vars,$this->_getMergeVarsValue($map, $customer));
}
return $merge_vars;
}
protected function _getMergeVarsValue($map, $customer)
{
$merge_vars = array();
$customAtt = $map['magento'];
$chimpTag = $map['mailchimp'];
if($chimpTag && $customAtt) {
@@ -120,27 +121,18 @@ protected function _getMergeVarsValue($map, $customer)
case 'billing_address':
case 'shipping_address':
$addr = explode('_', $customAtt);
if ($address = $customer->{'getPrimary' . ucfirst($addr[0]) . 'Address'}()) {
$merge_vars[$key] = array(
'addr1' => $address->getStreet(1),
'addr2' => $address->getStreet(2),
'city' => $address->getCity(),
'state' => (!$address->getRegion() ? $address->getCity() : $address->getRegion()),
'zip' => $address->getPostcode(),
'country' => $address->getCountryId()
);
}
array_merge($merge_vars,$this->_updateMergeVars($key,ucfirst($addr[0]),$customer));
break;
case 'telephone':
if ($address = $customer->{'getPrimaryBillingAddress'}()) {
if ($address = $customer->{'getDefaultBillingAddress'}()) {
$telephone = $address->getTelephone();
if ($telephone) {
$merge_vars['TELEPHONE'] = $telephone;
}
}
break;
case 'company':
if ($address = $customer->{'getPrimaryBillingAddress'}()) {
if ($address = $customer->{'getDefaultBillingAddress'}()) {
$company = $address->getCompany();
if ($company) {
$merge_vars['COMPANY'] = $company;
@@ -168,4 +160,19 @@ protected function _getMergeVarsValue($map, $customer)
return $merge_vars;
}
}
protected function _updateMergeVars($key,$type,$customer)
{
$merge_vars = array();
if ($address = $customer->{'getDefault' . $type . 'Address'}()) {
$merge_vars[$key] = array(
'addr1' => $address->getStreetLine(1),
'addr2' => $address->getStreetLine(2),
'city' => $address->getCity(),
'state' => (!$address->getRegion() ? $address->getCity() : $address->getRegion()),
'zip' => $address->getPostcode(),
'country' => $address->getCountryId()
);
}
return $merge_vars;
}
}
0 Model/Api.php 100755 → 100644
No changes.
@@ -0,0 +1,19 @@
<?php
/**
* magento2magemonkey Magento Component
*
* @category Ebizmarts
* @package magento2magemonkey
* @author Ebizmarts Team <info@ebizmarts.com>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @date: 3/2/16 2:44 PM
* @file: ModelConfig.php
*/
namespace Ebizmarts\MageMonkey\Model;
class Config
{
CONST ENDPOINT = 'api.mailchimp.com';
CONST SCHEME = 'https';
}
0 Model/Config/Source/Details.php 100755 → 100644
No changes.
No changes.
0 Model/Logger/Handler/System.php 100755 → 100644
No changes.
0 Model/Logger/Magemonkey.php 100755 → 100644
No changes.
10 Model/MCAPI.php 100755 → 100644
@@ -14,7 +14,7 @@
class MCAPI
{
protected $_version = "3.0";
protected $_apiUrl = null;
// protected $_apiUrl = null;
protected $_timeout = 300;
protected $_chunkSize = 8192;
protected $_apiKey = null;
@@ -31,7 +31,7 @@ public function __construct(
)
{
$this->_helper = $helper;
$this->_apiUrl = parse_url("http://api.mailchimp.com/" . $this->_version);
// $this->_apiUrl = parse_url(\Ebizmarts\MageMonkey\Model\Config::MAILCHIMP_ENDPOINT);
}
public function load($apiKey, $secure = false){
@@ -72,7 +72,7 @@ public function callServer($use = 'GET',$method = null, $params = null,$fields =
$dc = 'us1';
}
}
$host = $dc.'.'.$this->_apiUrl['host'].'/'.$this->_version;
$host = $dc.'.'.\Ebizmarts\MageMonkey\Model\Config::ENDPOINT.'/'.$this->_version;
if($method)
{
$host .= "/$method";
@@ -120,7 +120,7 @@ public function callServer($use = 'GET',$method = null, $params = null,$fields =
}
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_URL, \Ebizmarts\MageMonkey\Model\Config::SCHEME.'://'.$host);
curl_setopt($ch, CURLOPT_USERAGENT, 'MageMonkey/'); // @todo put the version of MageMonkey
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: apikey '.$key,'Cache-Control: no-cache'));
@@ -136,7 +136,7 @@ public function callServer($use = 'GET',$method = null, $params = null,$fields =
$responseCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
$data = json_decode($body);
$this->_helper->log(print_r(json_encode($data),1));
$this->_helper->log(var_export(json_encode($data),1));
switch($use)
{
case 'DELETE':
2 Model/Plugin/Subscriber.php 100755 → 100644
@@ -87,7 +87,7 @@ public function beforeSubscribeCustomerById(
}else {
$data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status);
}
$this->_helper->log(print_r(json_encode($data), 1));
$this->_helper->log(var_export(json_encode($data), 1));
$return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
if (isset($return->id)) {
$subscriber->setMagemonkeyId($return->id);
0 Model/Resource/Setup.php 100755 → 100644
No changes.
0 Setup/InstallSchema.php 100755 → 100644
No changes.
0 Setup/UpgradeSchema.php 100755 → 100644
No changes.
No changes.
No changes.
No changes.
0 composer.json 100755 → 100644
No changes.
0 etc/adminhtml/system.xml 100755 → 100644
No changes.
0 etc/config.xml 100755 → 100644
No changes.
0 etc/di.xml 100755 → 100644
No changes.
0 etc/module.xml 100755 → 100644
No changes.
0 i18n/en_US.csv 100755 → 100644
No changes.
0 registration.php 100755 → 100644
No changes.
No changes.
No changes.

0 comments on commit f0054b8

Please sign in to comment.
You can’t perform that action at this time.