Sometimes, it is easy if we can add an attribute to a customer as we can do with products. This is possible, but there is no interface for adding attributes in the backend. We have to create it using a module that adds the attributes to the customer
object. In this recipe, we will add a loyaltynumber
field to the customer.
For adding a customer
attribute, the only task is to create an upgrade script which adds the attribute. Then, we have to link the attribute in the form
table.
Perform the following steps to add the loyaltynumber
attribute to your customer objects:
The first step is to create the upgrade script. In the previous chapters, we have created an
install
andupgrade
script in theapp/code/local/Packt/Helloworld/sql/helloworld_setup
folder. Create an extra install script with the nameupgrade-002-003.php
.To install the
customer
attribute, add the following code in thatinstall
script:<?php $installer = $this; $installer-...