Alokai

searchStores

Method executing a store search in Salesforce Commerce Cloud.

This method communicates with the searchStores endpoint of the Vue Storefront API Middleware. In turn, it receives data from the Get nearest stores endpoint exposed by OCAPI.

Retrieves a list of stores, for the active site, that are within a configured distance of a location on the earth. The stores and their distance from the specified location are returned as a result set of Store objects. The distance is interpreted either in miles or kilometers depending on the distanceUnit input parameter. The location can be specified by either directly providing a latitude/longitude coordinate pair or by providing a country and a postal code: - If a postal code is passed, the resource looks in the system's geolocation mappings to find the coordinates for this postal code. If no matching geolocation is found, the resource will return an empty list of stores. - If coordinates are passed, the values for country and postal code are ignored.

Signature

export declare function searchStores(
	props: StoreSearchParams
): Promise<StoreSearchResult>;

Parameters

NameRequiredTypeDescription
propsRequiredStoreSearchParamsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.

Returns

Returns a stores search result.

Referenced Types

  • StoreSearchParams
  • StoreSearchResult

Examples

Executing a cross-site coordinates-based search using the longitude and latitude parameters. Returns all stores within 500km of the coordinates.

import { sdk } from '~/sdk.config.ts';

const searchResults = await sdk.commerce.searchStores({
  distanceUnit: 'km',
  maxDistance: 500,
  longitude: 41.40338,
  latitude: 2.17403,
});

Executing a postal code-based search for the third page of 10 stores using the countryCode and postalCode parameters.

import { sdk } from '~/sdk.config.ts';

const searchResults = await sdk.commerce.searchStores({
  limit: 10,
  offset: 20,
  countryCode: 'US',
  postalCode: '01801',
});

On this page