コード例 #1
0
ファイル: Plugin.php プロジェクト: sendpulse/mageia
 public function beforeSubscribeCustomerById($subscriber, $customerId)
 {
     $subscriber->loadByCustomerId($customerId);
     $storeId = $subscriber->getStoreId();
     if ($this->_helper->isMageiaEnabled($storeId)) {
         $customer = $this->_customer->load($customerId);
         $mergeVars = $this->_helper->getMergeVars($customer);
         $api = $this->_api;
         /*
         $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn()
             && $this->_customerSession->getCustomerDataObject()->getEmail()
             == $subscriber->getSubscriberEmail();
         
         if ($this->_helper->isDoubleOptInEnabled($storeId)
             && !$isSubscribeOwnEmail
         ) {
             $status = 'pending';
         } else {
             $status = 'subscribed';
         }
         */
         $email = ['email' => $customer->getEmail()];
         if ($mergeVars) {
             $email['variables'] = $mergeVars;
         }
         $data = ['emails' => json_encode([$email])];
         $listId = $this->_helper->getDefaultList();
         $return = $api->listCreateMember($listId, $data);
         if (isset($return->result) && $return->result) {
             $subscriber->setMageiaId($customer->getEmail());
             $subscriber->save();
         }
     }
     return [$customerId];
 }
コード例 #2
0
ファイル: Subscriber.php プロジェクト: Doability/magento2dev
 public function beforeSubscribeCustomerById($subscriber, $customerId)
 {
     $subscriber->loadByCustomerId($customerId);
     $storeId = $subscriber->getStoreId();
     if ($this->_helper->isMonkeyEnabled($storeId)) {
         $customer = $this->_customer->load($customerId);
         $mergeVars = $this->_helper->getMergeVars($customer);
         $api = $this->_api;
         $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
         if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
             $status = 'pending';
         } else {
             $status = 'subscribed';
         }
         if ($mergeVars) {
             $data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => $mergeVars);
         } else {
             $data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status);
         }
         $return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
         if (isset($return->id)) {
             $subscriber->setMagemonkeyId($return->id);
         }
     }
     return [$customerId];
 }
コード例 #3
0
ファイル: AddressTest.php プロジェクト: aiesh/magento2
 /**
  * Initialize quote and customer fixtures
  */
 public function setUp()
 {
     $this->_quote = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Quote');
     $this->_quote->load('test01', 'reserved_order_id');
     $this->_quote->setIsMultiShipping('0');
     /** @var \Magento\Customer\Model\Customer $customer */
     $this->_customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Customer');
     $this->_customer->load(1);
     /** @var \Magento\Sales\Model\Order\Address $address */
     $this->_address = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Quote\\Address');
     $this->_address->load(1);
     $this->_address->setQuote($this->_quote);
 }
コード例 #4
0
 public function afterSubscribeCustomerById($subscriber)
 {
     $storeId = $subscriber->getStoreId();
     if ($this->_helper->isMonkeyEnabled($storeId)) {
         $customer = $this->_customer->load($subscriber->getCustomerId());
         $mergeVars = $this->_helper->getMergeVars($customer);
         $api = new \Ebizmarts\MageMonkey\Model\Api(array(), $this->_helper);
         $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
         if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
             $status = 'pending';
         } else {
             $status = 'subscribed';
         }
         $data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $subscriber->getEmail(), 'email_type' => 'html', 'status' => $status);
         $return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
         if (isset($return->id)) {
             $subscriber->setMagemonkeyId($return->id)->save();
         }
     }
 }
コード例 #5
0
 public function beforeSubscribeCustomerById($subscriber, $customerId)
 {
     $subscriber->loadByCustomerId($customerId);
     $subscriber->setImportMode(true);
     $storeId = $subscriber->getStoreId();
     if ($this->_helper->isMonkeyEnabled($storeId)) {
         $customer = $this->_customer->load($customerId);
         $mergeVars = $this->_helper->getMergeVars($customer);
         $api = $this->_api;
         $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $this->_customerSession->getCustomerDataObject()->getEmail() == $subscriber->getSubscriberEmail();
         if ($this->_helper->isDoubleOptInEnabled($storeId) && !$isSubscribeOwnEmail) {
             $status = 'pending';
         } else {
             $status = 'subscribed';
         }
         if ($mergeVars) {
             $data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => $mergeVars];
         } else {
             $data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => ['EMAIL' => $customer->getEmail()]];
         }
         try {
             $emailHash = md5(strtolower($customer->getEmail()));
             $return = $api->getMember($this->_helper->getDefaultList(), $emailHash);
             if (!isset($return->id)) {
                 $return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
                 if (isset($return->id)) {
                     $subscriber->setMagemonkeyId($return->id)->save();
                 }
             }
             $subscriber->setMagemonkeyId($emailHash)->save();
         } catch (\Exception $e) {
             $this->_helper->log($e->getMessage());
         }
     }
     return [$customerId];
 }
コード例 #6
0
ファイル: Quote.php プロジェクト: Atlis/docker-magento2
 /**
  * Retrieve customer model object
  *
  * @return \Magento\Customer\Model\Customer
  */
 public function getCustomer()
 {
     /**
      * @TODO: Remove the method after all external usages are refactored in MAGETWO-19930
      * _customer and _customerFactory variables should be eliminated as well
      */
     if (null === $this->_customer) {
         $this->_customer = $this->_customerFactory->create();
         $customerId = $this->getCustomerId();
         if ($customerId) {
             $this->_customer->load($customerId);
             if (!$this->_customer->getId()) {
                 $this->_customer->setCustomerId(null);
             }
         }
     }
     return $this->_customer;
 }