Tutorial: Using a custom weighting sort order on the product list page

You can use a custom weighting to sort your products on the API products list page of your Developer Portal.

Before you begin

You must have a Developer Portal enabled, and you must have administrator access to complete this tutorial. The tutorial Creating the Portal explains how to enable the portal if you have not already done so.

About this tutorial

In this task, you set up a weighting sort criteria and use it to list your products, on the API Products page, in a particular order. You set up the weightings so the order reads, Product3, Product1, and Product2.

Note: To complete this tutorial, you will need to have API products.

For example, the API Products page below displays Product1, Product2, and Product3 in this order before the weightings are added.

 A screen shot showing three products

Add a custom integer field to the API content type

  1. Log in to your Developer Portal as an administrator.
  2. Navigate to Structure > Content types.
  3. Find Product and click Manage fields.
  4. On the Manage fields page, click + Create a new field.
  5. From the Choose a type of field list, select Number, and click Continue.
  6. In the Label field, enter Weighting and select Number (integer).

    Add field page

  7. Click Continue.
  8. Leave the Allowed number of values as 1.
  9. Select the Set default value checkbox and enter 0 as the default value.
  10. Click Save settings.

The Weighting field now shows in the Manage fields list.

Modify the Products view to change the sort order

  1. Navigate to Structure > Views.
  2. Find Products view and click Edit.
  3. In the Sort criteria section, click Add.
  4. In the Search field, enter Weight. Then, select Weighting (field_weighting), and click Apply (all displays).
  5. Leave the Order as Sort ascending, click Apply (all displays).
  6. In the Sort Criteria section, click the arrow icon next to Add and click Rearrange.

    A screen shot of rearrange sort criteria page

  7. For all rows except Weighting (field_weighting) asc, click Remove.
  8. Click Apply (all displays).

You modified the Products view to sort based on Weighting (field_weighting).

Add a weighting to each Product

  1. Click Content, and from the Content type list, select Product.
  2. Click Filter. A list of available Products on your site is displayed.
  3. For Product1, click Edit, in the Weighting field, select 2 as the value, and click Save.
  4. For Product2 click Edit, in the Weighting field, select 3 as the value, and click Save.
  5. For Product3 click Edit, in the Weighting field, select 1 as the value, and click Save.

The API Products page displays Product3, Product1, and Product2 in this order after the weightings are added.

What you did in this tutorial

You changed the order that the API Products appear on the products page.

Screen shot showing the rearranged products