Question

Version : Magento cloud commerce 2.3.2

In magento_customerbalance I've added new column date and I'm trying to save it in following way

/*Obj for testing purpose only */
$balance = $obj->get('\Magento\CustomerBalance\Model\BalanceFactory')->create();
$balance = $balance
        ->setCustomer($customer)
        ->setWebsiteId($customer->getWebsiteId())
        ->setAmountDelta('5293')
        ->setNotifyByEmail(false)
        ->setData('mydate','1388951999');
$balance->save();

It is saving the above details but it is not updating mydate column value.

It is saving mydate only 1st time, After that I'm not able to update it.

I want to update that date multiple times. So how do I do that?

Was it helpful?

Solution

Resolved it by following

$balance = $obj->get('\Magento\CustomerBalance\Model\BalanceFactory')->create();
$balance = $balance
        ->setCustomer($customer)
        ->setWebsiteId($customer->getWebsiteId())
        ->setAmountDelta('5293')
        ->setNotifyByEmail(false);
$balance = $balance->loadbyCustomer();
$balance->setData('mydate','1388951999');
$balance->save();
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top