ProductSearch

Extends Search. ProductSearch replaces the default Search algorithm with a more specific Product search.

Methods
exclude(Mixed:products)

Excludes one or more products from the ProductSearch.results. The excluded products may be supplied as an Array, ProductCollection of Product objects, or an individual Product object.

Returns the original Search object allowing for method chaining.

featured()

Find products that have been marked as featured.

Returns the original Search object allowing for method chaining.

inCategories(Array:categories [, Boolean:recursive])

Find products within one or more Category objects either recursively within the categories or directly within the category. The default is False - non-recursive search.

Returns the original Search object allowing for method chaining.

orderBy(String:order)

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

  • created:asc
  • created:desc
  • modified:asc
  • modified:desc
  • price:asc
  • price:desc
  • title:asc
  • title:desc

Returns the original Search object allowing for method chaining.

withManufacturer(String:name)

Find products with a manufacturer name.

Returns the original Search object allowing for method chaining.

withManufacturerRange(String:name, String:range)

Find products with a matching manufacturer and range.

Returns the original Search object allowing for method chaining.



How to use

ProductSearch is not instantiated automatically. You can create a new instance of ProductSearch anywhere within a layout, page or included partial. 


<?ev
    var productSearch = new ProductSearch;
    productSearch.withManufacturer('Sony').limit(10).orderBy('price:asc');
    for(var result of productSearch.results){
        // do something
    }
?>