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. If the administrator dashboard isn’t displayed, click Manage to display it.
  3. Click Structure > Content types > Product > Manage fields.
  4. Click + Add field.
  5. In Add a new field, select Number (Integer). Enter Weighting as the label title.

    A screen shot of the add field page

  6. Click Save and continue.
  7. Leave the Allowed number of values set to 1 and click Save field settings.
  8. Enter 0 as the default value, click Save settings.
  9. Click Save.

The Weighting field now shows in the Manage fields list.

Modify the Products view to change the sort order

  1. If the administrator dashboard isn’t displayed, click Manage to display it.
  2. Navigate to Structure > Views, scroll down to the Products view and click Edit.
  3. In the SORT CRITERIA section click Add.
  4. Enter weight in the search box. Then, select Weighting (field_weighting), and click Apply (all displays).
  5. Leave the Order as Sort ascending, click Apply (all displays).
  6. In the SORTCRITERIA section, select Rearrange from the drop-down menu next to the Add.

    A screenshot of the Rearrange sort criteria page

  7. For all rows except Weighting (field_weighting), 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. If the administrator dashboard isn’t displayed, click Manage to display it.
  2. Click Content, and select Product from the Content type, click Filter. A list of available Products on your site is displayed.

    A screenshot of the contents page showing a list of products

  3. For Product1 click edit, in the Weighting field, select 2 as the value, click Save.
  4. For Product2 click edit, in the Weighting field, select 3 as the value, click Save.
  5. For Product3 click edit, in the Weighting field, select 1 as the value, 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