Ecommerce stores always strive to provide customers with a great shopping experience adding a touch of personalization could mean satisfied customers. Happy customers are definitely loyal!
Magento offers a very simple account signup page with minimal fields. This is good from a customer point of view. But some store owners require a little extra information to provide their customers with a personalized shopping experience. Targeted and personalized interactions with customers definitely will help boost sales.
Here’s how you can add extra customer attributes:
To do this, we need to create a separate customer attribute module and we will use the Brainvire namespace for it.
create NAMESPACE folder under app/code/local/Brainvire
1. Create module folder “Customerattr” as we will use this one as the name of our module
-
app/code/local/Brainvire/ Customerattr
2. Create Folders
-
app/code/local/Brainvire/ Customerattr/etc
-
app/code/local/Brainvire/ Customerattr/sql/bvcustomerattr_setup
3. Create the config.xml file
-
app/code/local/Brainvire/ Customerattr/etc/config.xml
4. rewrite customer and forms in our module
Inside the config.xml file copy and paste the code below:
2.4.2
Brainvire_Customerattr
Create the file for the attributes insertion
app/code/local/Brainvire/Customerattr/sql/bvcustomerattr_setup/mysql4-install-1.0.1.php
1. Now comes the fun part, inside the app/code/local/Brainvire/Customerattr/sql/bvcustomerattr_setup/mysql4-install-1.0.1.php file copy and paste the code below:
startSetup();
$installer->run("
ALTER TABLE `{$this->getTable('customer/eav_attribute')}` ADD `is_filterable_in_search` TINYINT( 1 ) UNSIGNED NOT NULL ,
ADD `used_in_product_listing` TINYINT( 1 ) UNSIGNED NOT NULL ;
");
startSetup();
$installer->run("
ALTER TABLE `{$this->getTable('customer/eav_attribute')}` ADD `is_filterable_in_search` TINYINT( 1 ) UNSIGNED NOT NULL ,
ADD `used_in_product_listing` TINYINT( 1 ) UNSIGNED NOT NULL ;
ALTER TABLE `{$this->getTable('customer/eav_attribute')}` ADD `store_ids` VARCHAR( 255 ) NOT NULL ;
ALTER TABLE `{$this->getTable('customer/eav_attribute')}` ADD `sorting_order` SMALLINT UNSIGNED NOT NULL ;
ALTER TABLE `{$this->getTable('customer/eav_attribute')}` ADD `is_visible_on_front` TINYINT( 1 ) UNSIGNED NOT NULL ;
ALTER TABLE `{$this->getTable('customer/eav_attribute')}` ADD `type_internal` VARCHAR( 255 ) NOT NULL ;
ALTER TABLE `{$this->getTable('customer/eav_attribute')}` ADD `on_order_view` TINYINT( 1 ) UNSIGNED NOT NULL ;
ALTER TABLE `{$this->getTable('customer/eav_attribute')}` ADD `on_registration` TINYINT( 1 ) UNSIGNED NOT NULL ;
");
$installer->endSetup();
$installer->endSetup();
In order to activate the Customerattr module create the module file:
1. app/etc/modules/Brainvire_Customerattr.xml
2. Copy and paste the code below
true
local
Ensure that all the files are saved and at the Magento Admin, CLEARALLCACHE.
With these steps, you can easily get customer profile extended with new attributes as per your specifications in the installation file.