My observer :
<?php
namespace Gta\EnablePaymentMethod\Observer;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
class PaymentMethodEnable implements ObserverInterface {
protected $_customerSession;
public function __construct(
\Magento\Customer\Model\Session $customerSession
) {
$this->_customerSession = $customerSession;
}
protected $_storeManager;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->_storeManager = $storeManager;
}
public function execute(Observer $observer) {
$website_id = $this->_storeManager->getStore()->getWebsiteId();
if($website_id == '1')
{
$payment_method_code = $observer->getEvent()->getMethodInstance()->getCode();
if ($payment_method_code == 'paypal_express') {
$result = $observer->getEvent()->getResult();
$result->setData('is_available', false);
if ($this->_customerSession->isLoggedIn()) {
$customerGroupId = $this->_customerSession->getCustomer()->getGroupId();
if ($customerGroupId == 9) {
$result->setData('is_available', true);
}
}
}
}
}
}
Getting Fatal error:
Fatal error: Cannot redeclare Gta\EnablePaymentMethod\Observer\PaymentMethodEnable::__construct() in /var/www/html/test/app/code/Gta/EnablePaymentMethod/Observer/PaymentMethodEnable.php on line 15
How to solve the error?
Note : Without website id condition observer working, i want to add website Id.