custom customer attribute value not storing in database magento 2Multiselect attribute not saving in Magento 2.3.0Customer Attribute Value not Option_IDMagento2: How to add pre defined data (installData.php) for Custom Modulemain.CRITICAL: Plugin class doesn't existcustom Customer attribute value not save while customer registerMagento2: get custom customer attribute valueI have created an extension to show Customer Company Name in Order grid. But when creating new order, order is not showing in order gridMagento offline custom Payment method with drop down listmagento 2.2.5: Adding Custom Attribute to Customer Edit Form in AdminMagento Custom Customer Attribute IssueMagento 2 How to upgrade existing custom customer address attribute?

Term for the "extreme-extension" version of a straw man fallacy?

What Brexit proposals are on the table in the indicative votes on the 27th of March 2019?

Lay out the Carpet

System.debug(JSON.Serialize(o)) Not longer shows full string

Integer addition + constant, is it a group?

Is the destination of a commercial flight important for the pilot?

Anatomically Correct Strange Women In Ponds Distributing Swords

CREATE opcode: what does it really do?

Go Pregnant or Go Home

Is HostGator storing my password in plaintext?

Opposite of a diet

Sequence of Tenses: Translating the subjunctive

How does the UK government determine the size of a mandate?

Are student evaluations of teaching assistants read by others in the faculty?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Purchasing a ticket for someone else in another country?

Failed to fetch jessie backports repository

Is there a good way to store credentials outside of a password manager?

Why are there no referendums in the US?

Type int? vs type int

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

How easy is it to start Magic from scratch?

Increase performance creating Mandelbrot set in python

Fastening aluminum fascia to wooden subfascia



custom customer attribute value not storing in database magento 2


Multiselect attribute not saving in Magento 2.3.0Customer Attribute Value not Option_IDMagento2: How to add pre defined data (installData.php) for Custom Modulemain.CRITICAL: Plugin class doesn't existcustom Customer attribute value not save while customer registerMagento2: get custom customer attribute valueI have created an extension to show Customer Company Name in Order grid. But when creating new order, order is not showing in order gridMagento offline custom Payment method with drop down listmagento 2.2.5: Adding Custom Attribute to Customer Edit Form in AdminMagento Custom Customer Attribute IssueMagento 2 How to upgrade existing custom customer address attribute?













1















<?php

namespace VendorModuleSetup;

use MagentoFrameworkDBDdlTable;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetup;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetup;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

private $attributeSetFactory;

public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];


private $eavSetupFactory;

public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @inheritdoc
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
]);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
]);


$attribute->save();










Here pincode attribute not storing in db,can you please guide me.after editing from individual customer its not loading the data.











share|improve this question






















  • hi guys please update the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday















1















<?php

namespace VendorModuleSetup;

use MagentoFrameworkDBDdlTable;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetup;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetup;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

private $attributeSetFactory;

public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];


private $eavSetupFactory;

public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @inheritdoc
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
]);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
]);


$attribute->save();










Here pincode attribute not storing in db,can you please guide me.after editing from individual customer its not loading the data.











share|improve this question






















  • hi guys please update the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday













1












1








1








<?php

namespace VendorModuleSetup;

use MagentoFrameworkDBDdlTable;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetup;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetup;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

private $attributeSetFactory;

public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];


private $eavSetupFactory;

public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @inheritdoc
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
]);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
]);


$attribute->save();










Here pincode attribute not storing in db,can you please guide me.after editing from individual customer its not loading the data.











share|improve this question














<?php

namespace VendorModuleSetup;

use MagentoFrameworkDBDdlTable;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetup;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetup;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

private $attributeSetFactory;

public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];


private $eavSetupFactory;

public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @inheritdoc
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
]);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$attribute = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
]);


$attribute->save();










Here pincode attribute not storing in db,can you please guide me.after editing from individual customer its not loading the data.








magento2 database customer-attribute






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









hitesh balpandehitesh balpande

3819




3819












  • hi guys please update the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday

















  • hi guys please update the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday
















hi guys please update the same version for module.xml with UpgradeData.php then its fine

– hitesh balpande
yesterday





hi guys please update the same version for module.xml with UpgradeData.php then its fine

– hitesh balpande
yesterday










1 Answer
1






active

oldest

votes


















0














I am not really sure about how your code works but I have modified it the way you want it to work.

Please try below code:



<?php

namespace VendorModuleSetup;

use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;

/**
* @var array
*/
public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];

/**
* @var MagentoEavSetupEavSetupFactory
*/
private $eavSetupFactory;


/**
* UpgradeData constructor.
* @param CustomerSetupFactory $customerSetupFactory
* @param SalesSetupFactory $salesSetupFactory
* @param QuoteSetupFactory $quoteSetupFactory
* @param MagentoEavSetupEavSetupFactory $eavSetupFactory
* @param MagentoEavModelConfig $eavConfig
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
$installer->startSetup();

/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();;

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();



$installer->endSetup();




And let me know if ever you'll get an error.






share|improve this answer


















  • 1





    my code is working fine and updated the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267386%2fcustom-customer-attribute-value-not-storing-in-database-magento-2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I am not really sure about how your code works but I have modified it the way you want it to work.

Please try below code:



<?php

namespace VendorModuleSetup;

use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;

/**
* @var array
*/
public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];

/**
* @var MagentoEavSetupEavSetupFactory
*/
private $eavSetupFactory;


/**
* UpgradeData constructor.
* @param CustomerSetupFactory $customerSetupFactory
* @param SalesSetupFactory $salesSetupFactory
* @param QuoteSetupFactory $quoteSetupFactory
* @param MagentoEavSetupEavSetupFactory $eavSetupFactory
* @param MagentoEavModelConfig $eavConfig
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
$installer->startSetup();

/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();;

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();



$installer->endSetup();




And let me know if ever you'll get an error.






share|improve this answer


















  • 1





    my code is working fine and updated the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday
















0














I am not really sure about how your code works but I have modified it the way you want it to work.

Please try below code:



<?php

namespace VendorModuleSetup;

use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;

/**
* @var array
*/
public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];

/**
* @var MagentoEavSetupEavSetupFactory
*/
private $eavSetupFactory;


/**
* UpgradeData constructor.
* @param CustomerSetupFactory $customerSetupFactory
* @param SalesSetupFactory $salesSetupFactory
* @param QuoteSetupFactory $quoteSetupFactory
* @param MagentoEavSetupEavSetupFactory $eavSetupFactory
* @param MagentoEavModelConfig $eavConfig
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
$installer->startSetup();

/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();;

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();



$installer->endSetup();




And let me know if ever you'll get an error.






share|improve this answer


















  • 1





    my code is working fine and updated the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday














0












0








0







I am not really sure about how your code works but I have modified it the way you want it to work.

Please try below code:



<?php

namespace VendorModuleSetup;

use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;

/**
* @var array
*/
public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];

/**
* @var MagentoEavSetupEavSetupFactory
*/
private $eavSetupFactory;


/**
* UpgradeData constructor.
* @param CustomerSetupFactory $customerSetupFactory
* @param SalesSetupFactory $salesSetupFactory
* @param QuoteSetupFactory $quoteSetupFactory
* @param MagentoEavSetupEavSetupFactory $eavSetupFactory
* @param MagentoEavModelConfig $eavConfig
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
$installer->startSetup();

/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();;

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();



$installer->endSetup();




And let me know if ever you'll get an error.






share|improve this answer













I am not really sure about how your code works but I have modified it the way you want it to work.

Please try below code:



<?php

namespace VendorModuleSetup;

use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoQuoteSetupQuoteSetupFactory;
use MagentoSalesSetupSalesSetupFactory;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoCustomerApiCustomerMetadataInterface;

/**
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface

/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;

/**
* @var SalesSetupFactory
*/
private $salesSetupFactory;

/**
* @var QuoteSetupFactory
*/
private $quoteSetupFactory;

/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;

/**
* @var array
*/
public $customer_attribute_used_in_forms = ['adminhtml_checkout','adminhtml_customer','adminhtml_customer_address','customer_account_edit','customer_address_edit','customer_register_address','customer_account_create','customer_address_edit','customer_register_address'];

/**
* @var MagentoEavSetupEavSetupFactory
*/
private $eavSetupFactory;


/**
* UpgradeData constructor.
* @param CustomerSetupFactory $customerSetupFactory
* @param SalesSetupFactory $salesSetupFactory
* @param QuoteSetupFactory $quoteSetupFactory
* @param MagentoEavSetupEavSetupFactory $eavSetupFactory
* @param MagentoEavModelConfig $eavConfig
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
SalesSetupFactory $salesSetupFactory,
QuoteSetupFactory $quoteSetupFactory,
MagentoEavSetupEavSetupFactory $eavSetupFactory,
MagentoEavModelConfig $eavConfig,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->eavSetupFactory = $eavSetupFactory;
$this->eavConfig = $eavConfig;
$this->attributeSetFactory = $attributeSetFactory;


/**
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)


$installer = $setup;
$installer->startSetup();

/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);


if (version_compare($context->getVersion(), '1.3.6') < 0)

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();


$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode', [
'type' => 'varchar',
'label' => 'PINCODE',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'pincode');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'pincode')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();;

$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile', [
'type' => 'varchar',
'label' => 'Mobile',
'input' => 'text',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
]);

$eavSetup->addAttributeToSet(
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
null,
'mobile');

$customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'mobile')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_address_edit','adminhtml_customer_address', 'customer_register_address','customer_account_edit', 'customer_account_create']
])->save();



$installer->endSetup();




And let me know if ever you'll get an error.







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









magefmsmagefms

2,0722426




2,0722426







  • 1





    my code is working fine and updated the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday













  • 1





    my code is working fine and updated the same version for module.xml with UpgradeData.php then its fine

    – hitesh balpande
    yesterday








1




1





my code is working fine and updated the same version for module.xml with UpgradeData.php then its fine

– hitesh balpande
yesterday






my code is working fine and updated the same version for module.xml with UpgradeData.php then its fine

– hitesh balpande
yesterday


















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f267386%2fcustom-customer-attribute-value-not-storing-in-database-magento-2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

БиармияSxpst500bh2ntaf! 3h2r