-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Description
Preconditions
- Magento Enterprise 2.1.4
Steps to reproduce
-
Added Custom customer attribute in UpgradeData
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); $attribute_values = array( ['code' => 'custom_attr_1', 'label' => 'XXXXX', 'input' => 'text'], ['code' => 'custom_attr_2', 'label' => 'XXXX', 'input' => 'text'] ); foreach ($attribute_values as $value) { if (!$customerSetup->getAttributeId(Customer::ENTITY, $value['code'])) { $customerSetup->addAttribute(Customer::ENTITY, $value['code'], [ 'type' => 'text', 'label' => $value['label'], 'input' => $value['input'], 'required' => false, 'visible' => false, 'position' => 120, 'system' => false ]); $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, $value['code']) ->addData([ 'used_in_forms' => ['adminhtml_customer'], 'is_user_defined' => 1 ]); $attribute->save(); } }
These custom attribute has been saved in Database upon customer login.
-
And on saving the data for these attributes used the below code.
$data = array( 'custom_attr_1' => 'XXXX', 'custom_attr_2' => 'XXXXX' ); $customer_info = $this->_customerFactory->create()->load(10); if ($customer_info->getId()) { try { $customer_info->addData($data); $customer_info->save(); } catch (Exception $e) { return false; } }
-
These customer custom attribute are saved in customer_entity_text table. On running magento setup:upgrade command(during code deployment on other environment), and customer login, the above code is called and the data from the customer_entity_text table is deleted.
-
It doesn't happen when setup:upgrade is not run.
Expected result
- Data is updated in customer_entity_text table
Actual result
- Data (custom customer attribute) gets removed from customer_entity_text table on saving customer object.
Any suggestions please??
Metadata
Metadata
Assignees
Labels
No labels