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;
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
add a comment |
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
did you try likeselected => '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 usingdefault
?
– magefms
May 29 at 11:13
yes i also tried with default but not working
– sumeet bajaj
May 29 at 11:20
add a comment |
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
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
adminhtml magento2.3 customer-attribute
asked May 29 at 11:01
sumeet bajajsumeet bajaj
1839
1839
did you try likeselected => '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 usingdefault
?
– magefms
May 29 at 11:13
yes i also tried with default but not working
– sumeet bajaj
May 29 at 11:20
add a comment |
did you try likeselected => '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 usingdefault
?
– 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
add a comment |
1 Answer
1
active
oldest
votes
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.
ok checking and let you know
– sumeet bajaj
May 29 at 14:27
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
ok checking and let you know
– sumeet bajaj
May 29 at 14:27
add a comment |
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.
ok checking and let you know
– sumeet bajaj
May 29 at 14:27
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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