Methods
-
getUrl( [ search_filters ] ) → {String}
-
Description
Retrieves the URL of the item search API of the SuiteCommerce website. Note that this method only retrieves the item search API URL; it does not execute the search.
You can append parameters to the returned URL by passing in an object of property/value pairs to the method. The property name can be any parameter accepted by the item search API. For example, to specify a list of fields, use the property name 'fields' with the field names as a comma separated list of fields:
{fields: "dimensions,finish"}. For comprehensive information about item search parameters, see the Item Search API Input Parameters topic in the Help Center.You can also append a special property called
apiMasterOptions, which lets you use search API fieldsets as defined on the SuiteCommerce configuration page in the NetSuite account. The value ofapiMasterOptionsis the ID of a search API fieldset. WhengetUrlis called, it gets the values of the Fieldset and Includes columns for the specified ID and appends them to the URL in the format fieldset=[Fieldset]&include=[Includes]. See Search Results Subtab in the Help Center for more information.If you include both
apiMasterOptionsand the property name 'fieldset' as parameters, theapiMasterOptionsparameters takes preference and sets the value of 'fieldset' in the returned URL.The following example shows how to get the item search URL with search parameters for a keyword (
q), additional fields (fieldset), and a facet field name (dimensions). The returned URL includes the specified parameters and might look like the following:/api/items?language=en&country=US¤cy=USD&pricelevel=5&use_pcv=F&q=frames&fieldset=relateditems&dimensions=52x30var search = container.getComponent("Search"); var searchParams = { q: "frames", fieldset: "relateditems", dimensions: "52x30" }; var searchUrl = search.getUrl(searchParams);The following example shows how to get the item search URL with search parameters for a keyword (
q), additional fields (fieldset), and a facet field name (dimensions). We have also included theapiMasterOptionsparameter, which will take preference over thefieldsetparameter. The returned URL might look like the following:/api/items?language=en&country=US¤cy=USD&pricelevel=5&use_pcv=F&q=frames&dimensions=52x30&fieldset=details&includes=facetsvar search = container.getComponent("Search"); var searchParams = { q: "frames", fieldset: "relateditems", dimensions: "52x30", apiMasterOptions: "itemDetails" }; var searchUrl = search.getUrl(searchParams);Some parameters, which correspond to data from the user session such as the language and country, may be automatically appended to the URL.
language,country,currency,pricelevel, anduse_pcvfrom the two sample URLs above are examples of user session data.Parameters
Name Type Attributes Description search_filtersObject <optional> One or more filters to append to the item search URL.
Name Type Attributes Description *Boolean | Number | String <optional> The name of any valid search API input parameter.
apiMasterOptionsString <optional> The ID of a search API fieldset.
Returns
Details