ProductSearch

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

Methods
exclude(Mixed:products) ProductSearch

Excludes one or more products from the ProductSearch.results. 

The excluded products may be supplied as: 

  • an Array of Product objects, 
  • a ProductCollection 
  • a single Product object
  • an Array of Product IDs - each supplied as a Number or a String (see also excludeIds())
  • a single Product ID supplied as a Number or as a String (see also excludeId())

excludeId(Number|String:id) ProductSearch

Excludes a single Product from the search results using its ID supplied as either a Number or a String

excludeIds(Number[]|String[]:ids) ProductSearch

Excludes one or more Products from the search results using an Array or Product IDs - each supplied as either a Number or a String.

featured(Boolean isFeatured = true) ProductSearch

Find products that have been marked as featured. Supplying isFeatured as false, will exclude featured products.

inCategories(Array:categories [, Boolean:recursive = false]) ProductSearch

Find products within one or more Category objects either recursively within the categories or directly within the category. 

Defaults to a non-recursive search.

orderBy(String:order) ProductSearch

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
  • sku:asc
  • sku:desc
  • title:asc
  • title:desc
withIds(Array:ids) ProductSearch

Restrict results to one or more known Product IDs - each supplied as either a Number or a String.

withManufacturer(String:name) ProductSearch

Find products from a single manufacturer by name. Also accepts a Manufacturer object.

withManufacturers(String[]:names) ProductSearch

Find products from one or more manufacturers by name.

withManufacturerId(Number:id) ProductSearch

Find products from a single manufacturer by their system ID represented as a Number.

withManufacturerIds(Number[]:id) ProductSearch

Find products from one or more manufacturers by their system IDs represented as a Number.

withManufacturerRange(String:range) ProductSearch

Find products with a matching manufacturer range.

withManufacturerRanges(String[]:ranges) ProductSearch

Find products with one or more matching manufacturer ranges.

withPartNumbers(String[]:partNumbers) ProductSearch

Find products by one or more manufacturer part numebrs. Note, this is not the same as by SKU (see withSkus() below).

withQuickfindCodes(String[]:codes) ProductSearch

Find products by one or more Evance quickfind code reference numbers.

withSkus(String[]:skus) ProductSearch

Find products by one or more SKU reference strings.

withSpecValueIds(Number[]:ids) ProductSearch

Find products associated with one or more Specification Value IDs.



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) {
        // do something
    }
?>