Skip to content

Commit

Permalink
Merge pull request #1806 from mailchimp/Issue1805-2.4
Browse files Browse the repository at this point in the history
closes #1805 for magento 2.4
  • Loading branch information
gonzaloebiz authored Sep 5, 2023
2 parents aa6d2ff + f16642d commit 9fbc163
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions Block/Newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

namespace Ebizmarts\MailChimp\Block;

use Magento\Customer\Controller\RegistryConstants;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Registry;

class Newsletter extends \Magento\Framework\View\Element\Template
{
Expand All @@ -36,18 +34,13 @@ class Newsletter extends \Magento\Framework\View\Element\Template
* @var CustomerRepositoryInterface
*/
private $customerRepository;
/**
* @var Registry
*/
private $registry;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param CustomerRepositoryInterface $customerRepository
* @param Registry $registry
* @param array $data
*/
public function __construct(
Expand All @@ -56,24 +49,20 @@ public function __construct(
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Ebizmarts\MailChimp\Helper\Data $helper,
CustomerRepositoryInterface $customerRepository,
Registry $registry,
array $data
) {

parent::__construct($context, $data);
$this->_helper = $helper;
$this->subscriberFactory = $subscriberFactory;
$this->customerSession = $customerSession;
$this->customerRepository = $customerRepository;
$this->registry = $registry;
}

public function getInterest()
{
$customer = $this->getCurrentCustomer();
$subscriber = $this->subscriberFactory->create();
$subscriber->loadByCustomer($customer->getId(),$customer->getStoreId());
// $subscriber = $this->getSubscriptionObject();
return $this->_helper->getSubscriberInterest($subscriber->getSubscriberId(), $subscriber->getStoreId());
}
public function getFormUrl()
Expand All @@ -93,7 +82,6 @@ private function getCurrentCustomer()
}
private function getCurrentCustomerId(): int
{
return (int)$this->registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
return $this->customerSession->getCustomerId();
}

}

0 comments on commit 9fbc163

Please sign in to comment.