last day (15 days later) » 

2:24 PM
0
Q: Add customer programmatically magento 2

Developper Magento I have added 3 new custom attributes(code client, Social status, web site) and i want to add a customer prgrammatically and also set the id group when registrating. how to do so and how to recuperate the input name of first name, last name and tel and how to set the new attributes because when i ...

 
Where you call your custom code? Either Event Observer or Plugin or What? Share the code which you try for this.
 
in new module : i created 3 attributes via upgradedata then i created another register form and now i want to save the customer one with specific group and specific attributs that are differents to the second form
 
But your requirement is to set custom attribute value, right?
 
i want t set the new attributes and other attributs (email, lastname, first name , group_id..)
 
Look, the default fields like email, lastname, firstname must be set when you create customer, after creating you can set custom attribute value.
 
2:24 PM
so the is no way to set all the attributs from controller ???
 
You need to do same things into that controller
 
hi
i want to explain to you what i need
fisrt of all
i have created 2 form for customer registration
 
into controller,

First create customer with basic fields which required to create customer.

Now after that, set it custom attribute value.
 
in the first i added two attributs with other attributs
then i aded one attributs (code_client) in the second form
 
What is your real name?
 
2:26 PM
kaled
I have to hide the first name and second name in the second form
 
Look you need to do like this.

1. When First form submit, create customer

2. When Second form submit, set custom attribute.
 
but they are required so i have to set all the attributs
manually
by code
 
Look,

In step one, the field which are required, you need to currenly set demo value there and create customer
 
did you understand me
 
yes, I understand
 
2:28 PM
??? you need to currenly set demo value there and create customer??
$customer->setFirstname($_POST['name']);
and name is the name of input in form
is it possible
??
 
Step 1 :
Create Customer : Pass the real value if availble otherwise pass demo value like
$customer->setFirstname('Test');

Step 2 :
Set the custom attribute value and default value which you want to set.
$customer->setFirstname($_POST['name']);
$customer->setCustomCode('Custom Value');
Are able to understand what I write above?
 
not very well
becuase i can't find the setter of the new attributes
and for name
the is no input name for this
so i can't do like that: $_POST['name']
 
Your problem is that, you do not know how to get posted value from user fill by frontend.
 
yes exactlly
 
That you need to search first
then you understand, what I says above
and it working into that way.
 
2:34 PM
so what to search exactly
because i am a beginner
 
You need to first search, how to access post value to controller
 
can i add some attributs to customer entity
 
because i have to create later in BO two grid
one to customer belong to group1
and a grid for customer that belong to group 2
but i really added the attributs to customer_entity but i just see them in eav_attributs
and not in custsomer_entity
so any advice please
and thanks for your time brother
 

last day (15 days later) »