0
我们使用自定义扩展在magento中创建了自定义客户属性。在此扩展中,我们还创建了customer_save_after的观察者并以编程方式更新客户属性。自定义字段不保存在magento 2中
$customerId = $this->_customersession->getCustomerId();
$customer = $this->customerFactory->create();
$websiteId = $this->storeManager->getWebsite()->getWebsiteId();
$customer->setWebsiteId($websiteId);
$customer->load($customerId);
$customer->setCustomAttribute('Test');
$customer->save();
以上代码在本地和开发服务器上正常工作,但网站已移至生产服务器,上述代码停止工作。为了使它再次工作,我们需要按照以下方式更新保存过程。
$customerData = $customer->getDataModel();
$customerData->setCustomAttribute('my_attr_code', $val);
$customer->updateData($customerData);
$customer->save();
任何人都可以指导我什么可能的问题,它打破了现场执行,但一切都在开发服务器上正常工作。 我们也尝试过在本地系统上开发数据库的副本,它也工作正常。问题是代码是一样的,数据库没有任何问题,更改保存过程后,执行开始完美没有任何错误。什么可能的问题?