In magento 2 I am trying to update session_cutoff
column in table customer_entity
during login
Below is my code which I add in observer using event customer_login
public function execute(\Magento\Framework\Event\Observer $observer)
{
$this->_customerSession->setGTMSuccessfulLogin($this->helper->successfulLoginPushData());
$customer_data = $observer->getEvent()->getCustomer();
$gtrustCustNo = $customer_data->getData('gtrust_custno');
$param = array('custNo' => $gtrustCustNo);
$result = $this->_gtrustApiHelper->getUserBenefit(($param));
$customer = $this->customerFactory->create();
$customer = $customer->setWebsiteId(1);
// set sessionCutOff to null
$customer = $customer->setSessionCutOff(NULL);
$customer = $customer->loadByEmail($customer_data->getEmail());
$customerData = $customer->getDataModel();
if (isset($result['resultData']['result']['usableSaveamt'])){
$saveamt = $result['resultData']['result']['usableSaveamt'];
$this->_customerSession->setCustomerPoint($saveamt);
$customerData->setCustomAttribute('customer_point', $saveamt);
}
if (isset($result['resultData']['result']['usePbDeposit'])){
$deposit = $result['resultData']['result']['usePbDeposit'];
$customerData->setCustomAttribute('customer_deposit', $deposit);
}
if (isset($result['resultData']['result']['usableCouponCnt'])){
$coupon = $result['resultData']['result']['usableCouponCnt'];
$this->_customerSession->setCouponDownloaded($coupon);
$customerData->setCustomAttribute('coupon_downloaded', $coupon);
}
$customer->updateData($customerData);
$customer->save();
}
As you can see I already added the $customer->setSessionCutOff(NULL);
to set the customer session_cutoff
to null but apparently when I try login the value doesnt change
I already var_dump
to confirm whether the observer is being read or not, and able to see clearly that the soure code is being read and passed through during login
$customer->setWebsiteId(1)
also didn't work I check, I already dicompile, upgrade and cache clean but nothing works
Please help check and advice on what is causing this issue