- Theme Engine
- Design Principles
- Templates
- EVML Reference
- Output
- Comments
- Operators
- Statements and Declarations
- Built-in Functions
- Built-in Objects
- Account
- Address
- Array
- Boolean
- Branch
- Cart
- CartLine
- Category
- CategoryCollection
- CategoryFilter
- CategoryFilterCollection
- CategoryFilterOption
- CategorySearch
- Collection
- Color
- Contact
- Currency
- Date
- Discount
- Dom
- Event
- EventCollection
- EventSlot
- Image
- Layout
- Locale
- Money
- Number
- Object
- Page
- PageCollection
- PageSearch
- PageSharer
- Pagination
- Postage
- Price
- PriceDiscount
- Product
- ProductCollection
- ProductCustomisation
- ProductDownload
- ProductMedia
- ProductMediaFrame
- ProductPrice
- ProductSearch
- ProductSpecification
- ProductSpecificationValue
- ProductVariation
- ProductVariationOption
- RecentlyViewed
- RegExp
- Request
- Review
- ReviewCollection
- Search
- SearchCollection
- SearchResult
- String
- Tag
- Template
- Url
- Website
- EV Tags
- CSS Pre-processor
- Ajax API
/product/search.json
Query searchable Product objects via Ajax returned as JSON.
For familiarity we have tried to ensure consistency in terminology with ProductSearch and Pagination objects.
Example using JQuery
jQuery.getJSON('/product/search.json', function(returnValue) {
console.log(returnValue);
} );
Internationalisation
If your website has multiple languages you will want to ensure search results are returned in the language, country and currency of your locales. To achieve this you can localise the URL as follows.
In your EVML view file:
<div id="myDiv" data-url="@/product/search.json"></div>
Within your view's JavaScript file:
var myDiv = jQuery('#myDiv');
jQuery.getJSON(myDiv.attr('data-url'), function(returnValue) {
console.log(returnValue);
} );
With the code above it won't matter which locale you visit the URL and results will be correct.
Accepted Parameters
The search script allows you to define the following optional parameters.
fragment |
An EVML include/partial to render per result. You may supply one fragment to render only.
The fragment path should be supplied in the format |
orderBy |
Column and direction to sort results. Adheres to orderable values of ProductSearch.orderBy().
Defaults to 'title:asc'.
|
page |
The page of results to return.
|
perPage |
The number of results to show per page. Defaults to 10.
|
q |
Define a search string.
|
Returned Object
The search script returns an object with the following properties.
code |
|
fragments |
If you specify a |
isFirstPage |
|
isLastPage |
|
nextPage |
The number of the next page in the result set, or |
nextPageUrl |
The URL of the next page in the result set, or |
orderBy |
The sort order of the results. Adheres to orderable values of ProductSearch.orderBy(). |
page |
The number of the current page (starts at 1 for first page). |
perPage |
The number of results returned per page. |
phrase |
The search phrase supplied by the |
previousPage |
The number of the previous page in the result set, or |
previousPageUrl |
The URL of the previous page in the result set, or |
results |
A JSON array with each element (if any) containing an flattended representation of a Product object. Note that only basic settings may be available by comparison to the full Product Object. |
success |
|
total |
The total number of matching results for the search across all pages. |
totalPages |
The total number of pages available in the result set. |