Adding Company Field to Customer Registration Field? Magento 2.1
I want to add a company field to the customer registration form, but i can not find the backend option for it. Is there a way i can do it programmatically?
magento2 customer customer-account
add a comment |
I want to add a company field to the customer registration form, but i can not find the backend option for it. Is there a way i can do it programmatically?
magento2 customer customer-account
add a comment |
I want to add a company field to the customer registration form, but i can not find the backend option for it. Is there a way i can do it programmatically?
magento2 customer customer-account
I want to add a company field to the customer registration form, but i can not find the backend option for it. Is there a way i can do it programmatically?
magento2 customer customer-account
magento2 customer customer-account
asked Aug 31 '16 at 9:32
RadosavRadosav
326113
326113
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Try this script.
<?php
namespace MynamespaceModulenameSetup;
use MagentoFrameworkModuleSetupMigration;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
/**
* Customer setup factory
*
* @var MagentoCustomerSetupCustomerSetupFactory
*/
private $customerSetupFactory;
/**
* Init
*
* @param MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory
*/
public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory)
{
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* Installs DB schema for a module
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$entityTypeId = $customerSetup->getEntityTypeId(MagentoCustomerModelCustomer::ENTITY);
$customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, "company", array(
"type" => "varchar",
"backend" => "",
"label" => "company",
"input" => "text",
"source" => "",
"visible" => true,
"required" => true,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$company = $customerSetup->getAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$company = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'company');
$used_in_forms="adminhtml_customer";
$used_in_forms="checkout_register";
$used_in_forms="customer_account_create";
$used_in_forms="customer_account_edit";
$used_in_forms="adminhtml_checkout";
$company->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100);
$company->save();
$installer->endSetup();
}
}
Not working. And you're creating a new attribute, but i need to use the existing one...
– Radosav
Aug 31 '16 at 10:44
Is there a working solution now?
– Kevin Krieger
Dec 9 '16 at 8:08
add a comment |
This should be an easy and taken as a serious inquiry. Additional customer registration data is key for sorting and marketing to different customer groups.
This does not provide an answer to the question. I would request to please explain a bit more so that the answer can benefit someone.
– Mohit Kumar Arora
55 mins ago
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%2f133997%2fadding-company-field-to-customer-registration-field-magento-2-1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this script.
<?php
namespace MynamespaceModulenameSetup;
use MagentoFrameworkModuleSetupMigration;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
/**
* Customer setup factory
*
* @var MagentoCustomerSetupCustomerSetupFactory
*/
private $customerSetupFactory;
/**
* Init
*
* @param MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory
*/
public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory)
{
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* Installs DB schema for a module
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$entityTypeId = $customerSetup->getEntityTypeId(MagentoCustomerModelCustomer::ENTITY);
$customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, "company", array(
"type" => "varchar",
"backend" => "",
"label" => "company",
"input" => "text",
"source" => "",
"visible" => true,
"required" => true,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$company = $customerSetup->getAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$company = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'company');
$used_in_forms="adminhtml_customer";
$used_in_forms="checkout_register";
$used_in_forms="customer_account_create";
$used_in_forms="customer_account_edit";
$used_in_forms="adminhtml_checkout";
$company->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100);
$company->save();
$installer->endSetup();
}
}
Not working. And you're creating a new attribute, but i need to use the existing one...
– Radosav
Aug 31 '16 at 10:44
Is there a working solution now?
– Kevin Krieger
Dec 9 '16 at 8:08
add a comment |
Try this script.
<?php
namespace MynamespaceModulenameSetup;
use MagentoFrameworkModuleSetupMigration;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
/**
* Customer setup factory
*
* @var MagentoCustomerSetupCustomerSetupFactory
*/
private $customerSetupFactory;
/**
* Init
*
* @param MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory
*/
public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory)
{
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* Installs DB schema for a module
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$entityTypeId = $customerSetup->getEntityTypeId(MagentoCustomerModelCustomer::ENTITY);
$customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, "company", array(
"type" => "varchar",
"backend" => "",
"label" => "company",
"input" => "text",
"source" => "",
"visible" => true,
"required" => true,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$company = $customerSetup->getAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$company = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'company');
$used_in_forms="adminhtml_customer";
$used_in_forms="checkout_register";
$used_in_forms="customer_account_create";
$used_in_forms="customer_account_edit";
$used_in_forms="adminhtml_checkout";
$company->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100);
$company->save();
$installer->endSetup();
}
}
Not working. And you're creating a new attribute, but i need to use the existing one...
– Radosav
Aug 31 '16 at 10:44
Is there a working solution now?
– Kevin Krieger
Dec 9 '16 at 8:08
add a comment |
Try this script.
<?php
namespace MynamespaceModulenameSetup;
use MagentoFrameworkModuleSetupMigration;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
/**
* Customer setup factory
*
* @var MagentoCustomerSetupCustomerSetupFactory
*/
private $customerSetupFactory;
/**
* Init
*
* @param MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory
*/
public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory)
{
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* Installs DB schema for a module
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$entityTypeId = $customerSetup->getEntityTypeId(MagentoCustomerModelCustomer::ENTITY);
$customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, "company", array(
"type" => "varchar",
"backend" => "",
"label" => "company",
"input" => "text",
"source" => "",
"visible" => true,
"required" => true,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$company = $customerSetup->getAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$company = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'company');
$used_in_forms="adminhtml_customer";
$used_in_forms="checkout_register";
$used_in_forms="customer_account_create";
$used_in_forms="customer_account_edit";
$used_in_forms="adminhtml_checkout";
$company->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100);
$company->save();
$installer->endSetup();
}
}
Try this script.
<?php
namespace MynamespaceModulenameSetup;
use MagentoFrameworkModuleSetupMigration;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
/**
* Customer setup factory
*
* @var MagentoCustomerSetupCustomerSetupFactory
*/
private $customerSetupFactory;
/**
* Init
*
* @param MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory
*/
public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory)
{
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* Installs DB schema for a module
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$entityTypeId = $customerSetup->getEntityTypeId(MagentoCustomerModelCustomer::ENTITY);
$customerSetup->removeAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, "company", array(
"type" => "varchar",
"backend" => "",
"label" => "company",
"input" => "text",
"source" => "",
"visible" => true,
"required" => true,
"default" => "",
"frontend" => "",
"unique" => false,
"note" => ""
));
$company = $customerSetup->getAttribute(MagentoCustomerModelCustomer::ENTITY, "company");
$company = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'company');
$used_in_forms="adminhtml_customer";
$used_in_forms="checkout_register";
$used_in_forms="customer_account_create";
$used_in_forms="customer_account_edit";
$used_in_forms="adminhtml_checkout";
$company->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100);
$company->save();
$installer->endSetup();
}
}
answered Aug 31 '16 at 9:43
Jignesh KhuntJignesh Khunt
1,0651517
1,0651517
Not working. And you're creating a new attribute, but i need to use the existing one...
– Radosav
Aug 31 '16 at 10:44
Is there a working solution now?
– Kevin Krieger
Dec 9 '16 at 8:08
add a comment |
Not working. And you're creating a new attribute, but i need to use the existing one...
– Radosav
Aug 31 '16 at 10:44
Is there a working solution now?
– Kevin Krieger
Dec 9 '16 at 8:08
Not working. And you're creating a new attribute, but i need to use the existing one...
– Radosav
Aug 31 '16 at 10:44
Not working. And you're creating a new attribute, but i need to use the existing one...
– Radosav
Aug 31 '16 at 10:44
Is there a working solution now?
– Kevin Krieger
Dec 9 '16 at 8:08
Is there a working solution now?
– Kevin Krieger
Dec 9 '16 at 8:08
add a comment |
This should be an easy and taken as a serious inquiry. Additional customer registration data is key for sorting and marketing to different customer groups.
This does not provide an answer to the question. I would request to please explain a bit more so that the answer can benefit someone.
– Mohit Kumar Arora
55 mins ago
add a comment |
This should be an easy and taken as a serious inquiry. Additional customer registration data is key for sorting and marketing to different customer groups.
This does not provide an answer to the question. I would request to please explain a bit more so that the answer can benefit someone.
– Mohit Kumar Arora
55 mins ago
add a comment |
This should be an easy and taken as a serious inquiry. Additional customer registration data is key for sorting and marketing to different customer groups.
This should be an easy and taken as a serious inquiry. Additional customer registration data is key for sorting and marketing to different customer groups.
edited 43 mins ago
Teja Bhagavan Kollepara
2,95841847
2,95841847
answered Apr 13 '17 at 1:24
DavidDavid
1
1
This does not provide an answer to the question. I would request to please explain a bit more so that the answer can benefit someone.
– Mohit Kumar Arora
55 mins ago
add a comment |
This does not provide an answer to the question. I would request to please explain a bit more so that the answer can benefit someone.
– Mohit Kumar Arora
55 mins ago
This does not provide an answer to the question. I would request to please explain a bit more so that the answer can benefit someone.
– Mohit Kumar Arora
55 mins ago
This does not provide an answer to the question. I would request to please explain a bit more so that the answer can benefit someone.
– Mohit Kumar Arora
55 mins ago
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%2f133997%2fadding-company-field-to-customer-registration-field-magento-2-1%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