Skip to content

Commit

Permalink
closes #1805 for magento 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Sep 5, 2023
1 parent aa6d2ff commit d257dee
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Block/Newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

namespace Ebizmarts\MailChimp\Block;

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

class Newsletter extends \Magento\Framework\View\Element\Template
{
Expand All @@ -37,17 +36,17 @@ class Newsletter extends \Magento\Framework\View\Element\Template
*/
private $customerRepository;
/**
* @var Registry
* @var Session
*/
private $registry;
private $session;

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

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

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 +90,6 @@ private function getCurrentCustomer()
}
private function getCurrentCustomerId(): int
{
return (int)$this->registry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
return $this->session->getCustomerId();
}

}

0 comments on commit d257dee

Please sign in to comment.