Manage Customer Attributes
12 Oct 2010, by Jeremy Champion
0 Comments · Posted in Magento

    From the start Magento has included the ability to modify product attributes through an interface in the administration panel. With Enterprise Edition 1.9, you can now manage customer attributes through a similar interface. This article will show you how to use this interface, as well as show you what this interface can and can't do.

    The most useful feature that this interface provides is the ability to create brand new customer attributes and then define where in the site these attributes should be shown. To create a new attribute, go to Customers → Attributes → Manage Customer Attributes. The Customers → Attributes → Manage Customer Address Attributes screen works in the same way, but on customer addresses rather than customers. From this screen you can either select one of the existing attributes to edit or you can click on the Add New Attribute button to create a new attribute. You will see the following screen:

    Screenshot of the customer attribute edit interface

    At this point, we come to the first restriction of this interface: you cannot modify all of the options for the built-in attributes. Most of the unchangeable options make sense to lock, however there are some options, for example the sort order, that I feel should be editable. Furthermore, not all of the built-in attributes are in this list. One attribute you cannot change is the region_id attribute. This is the attribute that has a list of the available states. Magento doesn't come with Australian states by default and even with this feature you cannot add them. We recommend using our Australia extension to add this functionality as well as a number of other Australia-related improvements.

    The Input/Output Filter

    Screenshot of the input and output filter control

    If you have used the manage product attribute interface at all, these manage customer attribute screens should be completely familiar. However, there are a few new options on an attribute that are new and need explanation. The Input/Output Filter is a useful option. This allows you to set a filter on the text that the customer enters. Given that anybody who signs up to your site can enter text into this field, I recommend setting this to something other than None. If set to none the text the customer enters will be output verbatim; if a customer was to enter HTML code it would be output on the frontend and rendered by the browser, possibly hijacking the user's browser - either by redirecting to a new page or by putting harmful, invisible code into the page.

    Setting the option to one of the other two options is by far safer; setting it to Strip HTML Tags will remove any HTML code from the input, whereas setting the option to Escape HTML Entities will display the HTML code as text rather than rendering it.

    Use in Customer Segment

    Screenshot of the customer segment control

    Customer segments are another Magento Enterprise-only feature and while they are beyond the scope of this article, they add the ability to sort your customers based on various attributes for use in things like reporting and marketing. Setting the Use in Customer Segment option to Yes, allows you to also use this attribute in automatically filtering customers into segments.

    Forms to Use In

    Screenshot of the forms to use in control

    This option is used to set where in the site the attribute will be used. The first three options - Customer Checkout Register, Customer Registration and Customer Account Edit - are quite self-explanatory. The fourth and final option is the Admin Checkout option which will allow you to show or hide the option in the create new customer form when you are creating a new order in the admin panel. Unfortunately there is no option for Admin Customer Creation so this attribute will always show up in the create new customer form in the admin panel.

    Attribute Visibility

    Here we run into a possible drawback - there is no way to set an attribute to be invisible. While this is not necessarily a show-stopping problem it could be frustrating if you need this functionality. In previous versions of Magento there was a flag you could set to make an attribute invisible but this flag is not present in Enterprise Edition 1.9 so there is no way to hide an attribute from the customer create and edit screens.

    While Magento's flexible attribute system has always allowed for the inclusion of additional customer attributes, this interface for the administration panel makes this achievable without needing to extend the core system through code. The system is still new but overall it is easy to use and shows off the power of Magento's attribute system.