2016-12-09 48 views
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(); 

任何人都可以指导我什么可能的问题,它打破了现场执行,但一切都在开发服务器上正常工作。 我们也尝试过在本地系统上开发数据库的副本,它也工作正常。问题是代码是一样的,数据库没有任何问题,更改保存过程后,执行开始完美没有任何错误。什么可能的问题?

回答

0

我会检查服务器的Apache规格。正如你所说,它在你的本地数据库中正常工作是一样的,除了服务器之外,所有东西都是一样的。然后检查apache php.ini并比较Local和Live。你可能有一些配置不让代码正常运行。

相关问题