Add Custom Data to Existing Models in Commerce Cloud Endless Aisle

You can add data to existing models. For example, you might want to add the store employee’s department to the associate model. The goal of this example is to show the store associate’s department in the app header. You modify the data that ‘feeds’ the model, including the custom object and the server code that gets the custom object data. You then modify the app code so that it shows the new data.

Modify the Custom Object

There is a custom object defined for store associates. To add a department, you modify the custom object.

  1. In Business Manager, select Administration > Site Development > Custom Object Types.
  2. Select associates and click the Attribute Definitions tab.
  3. Click New and enter:
    • ID - department
    • Display Name - Department
    • Help Text - The department the associate works in
    • Value Type - String
  4. Click Apply, then click Back to return to the list of attributes.
  5. Click the Attribute Grouping tab, click Edit next to the associate's attribute group.
  6. Click the ellipsis (…), click the checkbox next to department, and click Select.
  7. Go to site > Merchant Tools >Custom Objects->Custom Objects Editor.
  8. Find the object type associates.
  9. Select an associate.
  10. Enter Men as the Department. (You can do this for any and every associate.)

Modify the Server Code

You modify the server code so that it can get the department information from the server.

To determine what code to modify:

  1. Look in the model: app/models/associate.js.
  2. Determine what urlRoot is called: EAAccount-AgentLogin.
  3. Follow the logic through the pipeline or controller to determine what other pipelines and scripts are called for an associate login:
    • AgentLogin calls the AssociateLogin node.
    • The AssociateLogin node calls the actions/checkUser.ds script.
    • The actions/checkUser.ds script calls api/Authorize.ds.

To modify the script:

  1. Open the file api/Authorize.ds
  2. Search for firstName and then add this line: this.associateInfo.department = storeAssociates.employee.custom.department

Modify the Client Code

On the client side, in the renderStandard function, modify this bit of code.

var associateInfo = currentAssociate.getAssociateInfo();
   if (associateInfo) {
      var firstName = associateInfo.firstName;
      var lastName = associateInfo.lastName;
      var dept = associateInfo.department;

      var associateText = firstName ? firstName + ' ' : '';
      associateText += lastName ? lastName[0] + '.' : '';
      if (dept) {
         associateText += ' (' + dept + ')';
      }

   if (!firstName && !lastName) {
      associateText = _L('Associate');
   }
$.associate_label.setText(associateText);
}

Test the Modifications

When you run the updated code and log in as the store associate for whom you added the department, the app header should show the department after the associate's name.

Related Links

Customize the Endless Aisle App

Change the Look of the Endless Aisle App

Setting Category Images for the Endless Aisle Home Page

Enable Address Verification in Endless Aisle

Customize Emails Sent by Endless Aisle

Debug the Endless Aisle App

Endless Aisle Loggable Categories

Running Endless Aisle in the Simulator