-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b537c3
commit c5ff022
Showing
18 changed files
with
339 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Ebizmarts\MailChimp\Controller\Subscriber; | ||
|
||
use Magento\Customer\Api\AccountManagementInterface as CustomerAccountManagement; | ||
use Magento\Customer\Model\Session; | ||
use Magento\Customer\Model\Url as CustomerUrl; | ||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\App\Action\HttpPostActionInterface; | ||
use Magento\Framework\Validator\EmailAddress as EmailValidator; | ||
use Magento\Newsletter\Controller\Subscriber\NewAction as SubscriberController; | ||
use Magento\Newsletter\Model\SubscriberFactory; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
class Subscribe extends SubscriberController implements HttpPostActionInterface | ||
{ | ||
private $session; | ||
public function __construct( | ||
Context $context, | ||
SubscriberFactory $subscriberFactory, | ||
Session $customerSession, | ||
StoreManagerInterface $storeManager, | ||
CustomerUrl $customerUrl, | ||
CustomerAccountManagement $customerAccountManagement, | ||
EmailValidator $emailValidator = null | ||
) | ||
{ | ||
$this->session = $customerSession; | ||
parent::__construct($context, $subscriberFactory, $customerSession, $storeManager, $customerUrl, $customerAccountManagement, $emailValidator); | ||
} | ||
|
||
public function execute() | ||
{ | ||
if($this->getRequest()->isPost() && $this->getRequest()->getPost('phone')) { | ||
$phone = (string)$this->getRequest()->getPost('phone'); | ||
$this->session->setPhone($phone); | ||
} | ||
return parent::execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Ebizmarts\MailChimp\Model\Config\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Ebizmarts\MailChimp\Helper\Data as MailchimpHelper; | ||
use Magento\Framework\App\RequestInterface; | ||
class Maps implements OptionSourceInterface | ||
{ | ||
private $options = null; | ||
public function __construct( | ||
RequestInterface $request, | ||
MailchimpHelper $helper | ||
) | ||
{ | ||
$storeId = (int) $request->getParam("store", 0); | ||
if ($request->getParam('website', 0)) { | ||
$scope = 'website'; | ||
$storeId = $request->getParam('website', 0); | ||
} elseif ($request->getParam('store', 0)) { | ||
$scope = 'stores'; | ||
$storeId = $request->getParam('store', 0); | ||
} else { | ||
$scope = 'default'; | ||
} | ||
|
||
if ($helper->getApiKey($storeId, $scope)) { | ||
try { | ||
$this->options = $helper->getApi($storeId, $scope)->lists->mergeFields->getAll( | ||
$helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_LIST, $storeId, $scope), | ||
null, | ||
null, | ||
MailchimpHelper::MAX_MERGEFIELDS | ||
); | ||
} catch (\Mailchimp_Error $e) { | ||
$helper->log($e->getFriendlyMessage()); | ||
} | ||
} | ||
|
||
} | ||
public function toOptionArray() | ||
{ | ||
if (is_array($this->options)&&key_exists('merge_fields', $this->options)) { | ||
$rc = []; | ||
foreach ($this->options['merge_fields'] as $item) { | ||
$rc[$item['tag']] = $item['tag'] . ' (' . $item['name'] . ' : ' . $item['type'] . ')'; | ||
} | ||
} else { | ||
$rc[] = ['value' => 0, 'label' => __('---No Data---')]; | ||
} | ||
return $rc; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Ebizmarts\MailChimp\Model\ResourceModel\Newsletter; | ||
|
||
class Collection extends \Magento\Newsletter\Model\ResourceModel\Subscriber\Collection | ||
{ | ||
protected function _initSelect() | ||
{ | ||
parent::_initSelect(); | ||
$this->showCustomerInfo(true)->addSubscriberTypeField()->showStoreInfo(); | ||
$this->_map['fields']['phone'] = 'main_table.phone'; | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Ebizmarts\MailChimp\Observer\Subscriber; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\Customer\Model\Session; | ||
|
||
class SaveBefore implements \Magento\Framework\Event\ObserverInterface | ||
{ | ||
/** | ||
* @var Session | ||
*/ | ||
private $customerSession; | ||
|
||
/** | ||
* @param Session $customerSession | ||
*/ | ||
public function __construct( | ||
Session $customerSession | ||
) | ||
{ | ||
$this->customerSession = $customerSession; | ||
} | ||
public function execute(Observer $observer) | ||
{ | ||
// TODO: Implement execute() method. | ||
$subscriber = $observer->getSubscriber(); | ||
if ($this->customerSession->getPhone()) { | ||
$subscriber->setPhone($this->customerSession->getPhone()); | ||
$this->customerSession->unsPhone(); | ||
} | ||
return $subscriber; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Ebizmarts_MailChimp Magento JS component | ||
* | ||
* @category Ebizmarts | ||
* @package Ebizmarts_MailChimp | ||
* @author Ebizmarts Team <[email protected]> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<preference for="Magento\Newsletter\Model\ResourceModel\Subscriber\Grid\Collection" type="Ebizmarts\MailChimp\Model\ResourceModel\Newsletter\Collection" /> | ||
</config> |
Oops, something went wrong.