Add Filter Criteria To Drupal Commerce Product Administration Page
The Drupal Commerce product administration page is a View which created using Views module. It means, we can customize that page with no code by using the Views administration page. Now we will see how to add a form with some filter criteria such as product Title and Price to that page so we can search the product list based on the product Title/Name and Price.
Please, follow the steps below to make that happen.
- First, we have to open the Views administration page (admin/structure/views). Then, edit the View with the name Products.
- Find the Filter Criteria section then click Add button.
- Choose the Commerce Product: Title as the filter criteria then click Add and configure filter criteria button.
- Now, this is the key. Check the Expose this filter to visitors, to allow them to change it option so the user can use it to filter the product list by product name. Then click the Apply (all displays) button.
- To add the price filter criteria, click the Add button once again. Choose the Commerce Product: Price (commerce_price:amount) option. Then click the Add and configure filter criteria button.
- Check the Expose this filter to visitors, to allow them to change it option.
- Choose is between as the operator, then click the Apply (all displays) button.
- Save your View.
- Now open the commerce product administration page (admin/commerce/products). You will see the filter form above the list.