Magento 2 how to set custom customer attribute select valuesCustom renderer for custom customer address attributeset custom dropdown attribute for customerMagento 2 Load/Set Custom Customer AttributeForm is not displayed on panel admin Magento 2M2 registration form custom customer select attribute in select boxmagento 2.2.5: Adding Custom Attribute to Customer Edit Form in AdminHow to set customer custom attribute in magento 2?Magento 2.3 Can't view module's front end page output?Magento 2 : Create file type customer attributeMagento 2 - Add Customer Attribute with Select Field

At what point in time did Dumbledore ask Snape for this favor?

Are there downsides to using std::string as a buffer?

Why only the fundamental frequency component is said to give useful power?

My coworkers think I had a long honeymoon. Actually I was diagnosed with cancer. How do I talk about it?

Is this a mistake? (regarding maximum likelihood estimator)

Winning Strategy for the Magician and his Apprentice

What language is the software written in on the ISS?

Should I compare a std::string to "string" or "string"s?

Why doesn’t a normal window produce an apparent rainbow?

Passing multiple files through stdin (over ssh)

Movie about a boy who was born old and grew young

How to tell your grandparent to not come to fetch you with their car?

Preventing Employees from either switching to Competitors or Opening Their Own Business

Using a found spellbook as a Sorcerer-Wizard multiclass

PhD - Well known professor or well known school?

Last survivors from different time periods living together

Inconsistent behavior of compiler optimization of unused string

Scrum Master role: Reporting?

Can the poison from Kingsmen be concocted?

Watts vs. Volt Amps

What does the "c." listed under weapon length mean?

How to create a dictionary within a dictionary

Find duplicated column value in CSV

Genetic limitations to learn certain instruments



Magento 2 how to set custom customer attribute select values


Custom renderer for custom customer address attributeset custom dropdown attribute for customerMagento 2 Load/Set Custom Customer AttributeForm is not displayed on panel admin Magento 2M2 registration form custom customer select attribute in select boxmagento 2.2.5: Adding Custom Attribute to Customer Edit Form in AdminHow to set customer custom attribute in magento 2?Magento 2.3 Can't view module's front end page output?Magento 2 : Create file type customer attributeMagento 2 - Add Customer Attribute with Select Field






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am successfully able to create custom customer dropdown attribute but how to set select default values ?



I am using that code -



<?php
namespace XXXCustomerstatusSetup;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoCustomerModelCustomer;
use MagentoEavModelEntityAttributeSet as AttributeSet;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements InstallDataInterface


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

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

/**
* @param CustomerSetupFactory $customerSetupFactory
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;


public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)

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

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

/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
'type' => 'int',
'label' => 'Custom Customer Status',
'input' => 'select',
'source' => 'MagentoEavModelEntityAttributeSourceTable',
'required' => false,
'user_defined' => true,
'sort_order' => 11,
'position' => 11,
'system' => false,
'option' => ['values' => ['Awaiting Reply', 'Yes', 'No']],
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
]);

$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_customer_status_custom')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer'],
]);

$attribute->save();




I want "Awaiting Reply" by default it will be selected.










share|improve this question






















  • did you try like selected => 'Awaiting Reply',

    – magefms
    May 29 at 11:06












  • ok trying this also

    – sumeet bajaj
    May 29 at 11:07











  • @magefms tried not working

    – sumeet bajaj
    May 29 at 11:13











  • how about using default ?

    – magefms
    May 29 at 11:13











  • yes i also tried with default but not working

    – sumeet bajaj
    May 29 at 11:20

















1















I am successfully able to create custom customer dropdown attribute but how to set select default values ?



I am using that code -



<?php
namespace XXXCustomerstatusSetup;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoCustomerModelCustomer;
use MagentoEavModelEntityAttributeSet as AttributeSet;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements InstallDataInterface


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

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

/**
* @param CustomerSetupFactory $customerSetupFactory
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;


public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)

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

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

/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
'type' => 'int',
'label' => 'Custom Customer Status',
'input' => 'select',
'source' => 'MagentoEavModelEntityAttributeSourceTable',
'required' => false,
'user_defined' => true,
'sort_order' => 11,
'position' => 11,
'system' => false,
'option' => ['values' => ['Awaiting Reply', 'Yes', 'No']],
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
]);

$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_customer_status_custom')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer'],
]);

$attribute->save();




I want "Awaiting Reply" by default it will be selected.










share|improve this question






















  • did you try like selected => 'Awaiting Reply',

    – magefms
    May 29 at 11:06












  • ok trying this also

    – sumeet bajaj
    May 29 at 11:07











  • @magefms tried not working

    – sumeet bajaj
    May 29 at 11:13











  • how about using default ?

    – magefms
    May 29 at 11:13











  • yes i also tried with default but not working

    – sumeet bajaj
    May 29 at 11:20













1












1








1








I am successfully able to create custom customer dropdown attribute but how to set select default values ?



I am using that code -



<?php
namespace XXXCustomerstatusSetup;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoCustomerModelCustomer;
use MagentoEavModelEntityAttributeSet as AttributeSet;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements InstallDataInterface


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

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

/**
* @param CustomerSetupFactory $customerSetupFactory
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;


public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)

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

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

/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
'type' => 'int',
'label' => 'Custom Customer Status',
'input' => 'select',
'source' => 'MagentoEavModelEntityAttributeSourceTable',
'required' => false,
'user_defined' => true,
'sort_order' => 11,
'position' => 11,
'system' => false,
'option' => ['values' => ['Awaiting Reply', 'Yes', 'No']],
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
]);

$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_customer_status_custom')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer'],
]);

$attribute->save();




I want "Awaiting Reply" by default it will be selected.










share|improve this question














I am successfully able to create custom customer dropdown attribute but how to set select default values ?



I am using that code -



<?php
namespace XXXCustomerstatusSetup;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoCustomerModelCustomer;
use MagentoEavModelEntityAttributeSet as AttributeSet;
use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements InstallDataInterface


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

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

/**
* @param CustomerSetupFactory $customerSetupFactory
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
AttributeSetFactory $attributeSetFactory
)
$this->customerSetupFactory = $customerSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;


public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)

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

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

/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
'type' => 'int',
'label' => 'Custom Customer Status',
'input' => 'select',
'source' => 'MagentoEavModelEntityAttributeSourceTable',
'required' => false,
'user_defined' => true,
'sort_order' => 11,
'position' => 11,
'system' => false,
'option' => ['values' => ['Awaiting Reply', 'Yes', 'No']],
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
]);

$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_customer_status_custom')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer'],
]);

$attribute->save();




I want "Awaiting Reply" by default it will be selected.







adminhtml magento2.3 customer-attribute






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 29 at 11:01









sumeet bajajsumeet bajaj

1839




1839












  • did you try like selected => 'Awaiting Reply',

    – magefms
    May 29 at 11:06












  • ok trying this also

    – sumeet bajaj
    May 29 at 11:07











  • @magefms tried not working

    – sumeet bajaj
    May 29 at 11:13











  • how about using default ?

    – magefms
    May 29 at 11:13











  • yes i also tried with default but not working

    – sumeet bajaj
    May 29 at 11:20

















  • did you try like selected => 'Awaiting Reply',

    – magefms
    May 29 at 11:06












  • ok trying this also

    – sumeet bajaj
    May 29 at 11:07











  • @magefms tried not working

    – sumeet bajaj
    May 29 at 11:13











  • how about using default ?

    – magefms
    May 29 at 11:13











  • yes i also tried with default but not working

    – sumeet bajaj
    May 29 at 11:20
















did you try like selected => 'Awaiting Reply',

– magefms
May 29 at 11:06






did you try like selected => 'Awaiting Reply',

– magefms
May 29 at 11:06














ok trying this also

– sumeet bajaj
May 29 at 11:07





ok trying this also

– sumeet bajaj
May 29 at 11:07













@magefms tried not working

– sumeet bajaj
May 29 at 11:13





@magefms tried not working

– sumeet bajaj
May 29 at 11:13













how about using default ?

– magefms
May 29 at 11:13





how about using default ?

– magefms
May 29 at 11:13













yes i also tried with default but not working

– sumeet bajaj
May 29 at 11:20





yes i also tried with default but not working

– sumeet bajaj
May 29 at 11:20










1 Answer
1






active

oldest

votes


















0














In your setup script, I think all you need to do is set a default value, for example:



$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
[...]
'default' => 'Awaiting Reply',
[...]
]);


You will need to delete and recreate attribute.



If that still doesn't work I'm wondering whether you need this



'option' => ['values' => [['Awaiting Reply' => 'Awaiting Reply'], ['Yes' => 'Yes'], ['No' => 'No']],


Not 100% that will work though. Default should work.






share|improve this answer

























  • ok checking and let you know

    – sumeet bajaj
    May 29 at 14:27











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%2f276568%2fmagento-2-how-to-set-custom-customer-attribute-select-values%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














In your setup script, I think all you need to do is set a default value, for example:



$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
[...]
'default' => 'Awaiting Reply',
[...]
]);


You will need to delete and recreate attribute.



If that still doesn't work I'm wondering whether you need this



'option' => ['values' => [['Awaiting Reply' => 'Awaiting Reply'], ['Yes' => 'Yes'], ['No' => 'No']],


Not 100% that will work though. Default should work.






share|improve this answer

























  • ok checking and let you know

    – sumeet bajaj
    May 29 at 14:27















0














In your setup script, I think all you need to do is set a default value, for example:



$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
[...]
'default' => 'Awaiting Reply',
[...]
]);


You will need to delete and recreate attribute.



If that still doesn't work I'm wondering whether you need this



'option' => ['values' => [['Awaiting Reply' => 'Awaiting Reply'], ['Yes' => 'Yes'], ['No' => 'No']],


Not 100% that will work though. Default should work.






share|improve this answer

























  • ok checking and let you know

    – sumeet bajaj
    May 29 at 14:27













0












0








0







In your setup script, I think all you need to do is set a default value, for example:



$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
[...]
'default' => 'Awaiting Reply',
[...]
]);


You will need to delete and recreate attribute.



If that still doesn't work I'm wondering whether you need this



'option' => ['values' => [['Awaiting Reply' => 'Awaiting Reply'], ['Yes' => 'Yes'], ['No' => 'No']],


Not 100% that will work though. Default should work.






share|improve this answer















In your setup script, I think all you need to do is set a default value, for example:



$customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
[...]
'default' => 'Awaiting Reply',
[...]
]);


You will need to delete and recreate attribute.



If that still doesn't work I'm wondering whether you need this



'option' => ['values' => [['Awaiting Reply' => 'Awaiting Reply'], ['Yes' => 'Yes'], ['No' => 'No']],


Not 100% that will work though. Default should work.







share|improve this answer














share|improve this answer



share|improve this answer








edited May 29 at 12:59

























answered May 29 at 12:53









Dominic XigenDominic Xigen

97511




97511












  • ok checking and let you know

    – sumeet bajaj
    May 29 at 14:27

















  • ok checking and let you know

    – sumeet bajaj
    May 29 at 14:27
















ok checking and let you know

– sumeet bajaj
May 29 at 14:27





ok checking and let you know

– sumeet bajaj
May 29 at 14:27

















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%2f276568%2fmagento-2-how-to-set-custom-customer-attribute-select-values%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

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?