Magento 2 create a custom attribute and save data
Create a custom module and follow the below step
Create InstallData.php file in Vender\Modulename\Setup
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<?php namespace Vender\Modulename\Setup; use Magento\Framework\Module\Setup\Migration; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { private $customerSetupFactory; public function __construct(\Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory) { $this->customerSetupFactory = $customerSetupFactory; } public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup; $installer->startSetup(); $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); $entityTypeId = $customerSetup->getEntityTypeId(\Magento\Customer\Model\Customer::ENTITY); $customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, "custom_attribute", array( "type" => "int", "backend" => "", "label" => "Custom Attribute", "input" => "select", "visible" => true, 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Table', "required" => false, "default" => "", "frontend" => "", "unique" => true, "note" => "", )); $employee = $customerSetup->getAttribute(\Magento\Customer\Model\Customer::ENTITY, "custom_attribute"); $employee = $customerSetup->getEavConfig()->getAttribute(\Magento\Customer\Model\Customer::ENTITY, 'custom_attribute'); $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"; $employee->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("is_used_in_grid", 1) ->setData("is_visible_in_grid", 1) ->setData("is_filterable_in_grid", 1) ->setData("is_searchable_in_grid", 1) ->setData("sort_order", 100); $employee->save(); $installer->endSetup(); } } |
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-628372086e8b2575876877/] Create...
You can try below code to change local date to...
Step 1: First you need to add registration.php file in...
Step1 : Override message.js in current theme file on the...