CategorySearch

Extends Search. CategorySearch replaces the default Search algorithm with a more specific product category search. Currently the CategorySearch object has limited functionality.

CategorySearch is not instantiated automatically. You can create a new instance anywhere within a layout, template or included partial.


<?ev
    var categorySearch = new CategorySearch();
    categorySearch.featured().limit(10);
    for (var category of categorySearch) {
        // do something
    }
?>

Methods
featured([isFeatured]) CategorySearch

Filter search results to include/exclude featured categories.
Returns the original Category Search object.

Parameters

isFeatured Boolean
Optional. Supply true to limit results to featured Categories only, or falseto exclude featured Categories. Defaults to true.

Example


<?ev
    var categorySearch = new CategorySearch();
    categorySearch.featured(false); // exclude featured products
?>
orderBy(sortString) CategorySearch

Sets the order and direction of the search.
The available sortString for this algorithm are:

  • created:asc
  • created:desc
  • featured:asc
  • featured:desc
  • modified:asc
  • modified:desc
  • sequence:asc
  • sequence:desc
  • title:asc
  • title:desc

Returns the original Search object allowing for method chaining.

withIds(idArray) CategorySearch

Limit search results to Categories with an ID matching any within the supplied array.

Parameters

idArray Array
An array containing Category ID integers.

Example


<?ev
    var categorySearch = new CategorySearch();
    categorySearch.withIds([423, 542]);
?>