32
votes
Accepted
What's the difference between an user defined attribute and non user defined attribute?
Actually Magento user_defined = false attributes are known as system attributes.
So Magento has some of their system attribute, which we can not delete from admin panel. So magento won't allow system ...
29
votes
Accepted
Magento 2: How to create a customer custom attribute?
In the article Magento 2: How to make customer attribute? describe it step by step.
The main part is DataInstall::install method below:
public function install(ModuleDataSetupInterface $setup, ...
29
votes
Magento 2 custom customer attribute's values not getting saved in database?
You have probably solved your issue but for people who come here from google as me, there is a solution:
When creating the customer attribute, please take care of the following things:
Attribute is ...
24
votes
Accepted
Get attribute value in product view page
If you are in the product view page, in the catalog/product/view.phtml there is an instance of the product model usually called $_product.
From this variable you have access to all the attribute ...
22
votes
Accepted
Magento2 : user define customer attribute not save value while create / save from admin
looks like the issue was due to the fact your attributes are not assigned to the customer attribute set.
the following code is needed in your install: I added full code for you at https://bitbucket....
17
votes
Accepted
How to save customer attribute value in custom script in Magento 2
This is how it can be done with customer save method:
/** @var \Magento\Customer\Model\CustomerFactory $customerFactory */
/** @var \Magento\Customer\Model\Customer $customer */
/** @var \Magento\...
17
votes
Accepted
How to prevent "Call to a member function getValue() on null" when using getCustomAttribute()->getValue()?
Try following way:
if($myCustomAttribute = $customer->getCustomAttribute('my_custom_attribute')) {
echo $myCustomAttribute->getValue();
}
16
votes
How can we remove/delete the custom attribute(created for customer) in Magento 2
You should use UpgradeData now.
Create this file app/code/Bibhu/Customattribute/Setup/UpgradeData.php :
namespace Bibhu\Customattribute\Setup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\...
16
votes
Accepted
Customer custom attribute not showing in admin form
In contrast to Magento 1, in Magento 2 you now need to add some XML to make custom attributes appear in the edit customer section of the admin.
Create YourNamespace/YourModule/view/base/ui_component/...
16
votes
Accepted
Add a custom attribute in grid customer magento 2
You don't need customer_listing.xml or indexer.xml to show customer attribute in gird. these line will do it for you
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
...
16
votes
Accepted
Magento 2.3 - How to add custom column to customer_entity table
You can try using following code.
app/code/Anshu/CustomerEdit/registration.php
<?php
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::...
15
votes
Accepted
Magento 2: Save custom customer attribute value programmatically
I have got the solution
protected $customer;
protected $customerFactory;
public function __construct(
\Magento\Customer\Model\Customer $customer,
\Magento\Customer\Model\ResourceModel\...
12
votes
Accepted
Get Customer information from order Magento 2
Inside observer,
$order = $observer->getEvent()->getOrder();
$orderFromFront = $order->getRemoteIp();
$guestCustomer = $order->getCustomerIsGuest();
$groupId = $order->...
12
votes
Accepted
Magento 2 : How to know "used_in_forms" param of eav attribute for a form?
You can get all used_in_forms in magento by typing below query,
Used in form customer attribute:
SELECT DISTINCT form_code FROM customer_form_attribute WHERE 1
adminhtml_checkout
...
11
votes
Accepted
How to add cutom customer attribute field to call rest api via create new customer
The custom attribute mobile_number should be inside custom customer attribute data:
{
"customer": {
"email": "[email protected]",
"firstname": "First",
"lastname": "Last",
"storeId": ...
11
votes
Accepted
Magento2: get custom customer attribute value
Your code is working perfectly fine for me. The issue must be with no value for that attribute with the particular customer_is.
Have you tried and saved is_vendor value for customer_id 5 once. I mean ...
9
votes
Magento 2 Fail to save the value of a newly added Yes/No customer attribute
I found the answer finally.
adding:
$attributeMyhkt->addData([
'attribute_set_id' => 1,
'attribute_group_id' => 1
]);
below:
$attribute->...
9
votes
Accepted
Update customer password directly in database
Try this:
Replace testtest with your new password and $customer_entity_id with the customers entity_id in the customer_entity table.
update customer_entity_varchar set value = md5('testtest') where ...
8
votes
Accepted
How to add dropdown attribute to custom module in magento 2.0
Add bellow installation script in your module at path app/code/{Namespace} /{Module-Name}/Setup/InstallData.php
<?php
/**
* @author AR
* @category AR
* @package AR_CustomerAttribute
...
8
votes
Accepted
Magento 2 Save customer attribute value while customer register
You can do this by observer.
SR/StackExchange/etc/frontend/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:...
8
votes
Magento 2: How to get first and last name of customer?
The Best idea to use repository interface for getting customer data Magento 2.2..
Magento\Customer\Api\CustomerRepositoryInterface
Use function getById($customerId)
Inject that class on ...
8
votes
“Type Error occurred when creating object: Magento\\Eav\\Model\\Entity\\Attribute\\Source\\Config”
Try to look at the customer eav attribute with select value for frontend_input column in eav_attribute table, make sure the source_model column value is not null or empty or it fills with correct ...
7
votes
Accepted
Adding custom customer attribute to admin panel?
Try this
<?php
$installer = $this;
$attribute = array(
'type' => 'int',
'input' => 'text',
'label' => 'Is Active',
'global' => 1,
'visible' => 1,
'default'...
7
votes
Accepted
magento2 create customer attribute
Please make below change in module.xml,
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../...
7
votes
How to add a unique custom attribute for a customer?
You need to InstallData.php like below code :
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$this->logger->info("Username data installed.");
...
7
votes
Magento 2: Save custom customer attribute value programmatically
You need to do it the strange Magento 2 way:-
public function __construct(
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
) {
$this->_customerRepository = $...
6
votes
Source Model not found for Attribute
For those who might have this issue, I solved it by another way.
It happened when I disabled a module and some attributes were still trying to be launched in db, even if they were useless.
what i did ...
6
votes
Magento 2: Add custom attributes to customer grid
Leaving out view_id seems to work:
<indexer id="customer_grid">
This way, the XML will be merged into the existing indexer instead of defining a new indexer.
6
votes
Accepted
Magento 2 - how to update customer Info?
The email_backup is the custom customer attribute. We can use Magento\Customer\Api\CustomerRepositoryInterface to save the customer info.
/**
* @var CustomerRepositoryInterface
*/
protected $...
6
votes
What's the difference between an user defined attribute and non user defined attribute?
Magento system attributes are set to false for user_defined so our custom attributes should be set to true. System attributes can not be deleted so if you set false to user_defined, your attribute ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
customer-attribute × 450magento2 × 218
customer × 94
magento-1.9 × 60
attributes × 44
custom-attributes × 40
magento2.3 × 22
customer-account × 22
magento-2.1 × 21
magento2.2 × 20
customer-address × 18
checkout × 17
magento-1 × 17
eav-attributes × 17
eav × 16
database × 14
custom × 14
module × 12
adminhtml × 12
php × 11
customer-grid × 11
product-attribute × 10
frontend × 9
uicomponent × 9
multiselect-attribute × 9