- Enable
OOTB Inventory Index
- Make
it usable by Store Front Pages
Enable Inventory Index
Enable Inventory Index for Store Front pages
- Define
a Search resource Handler to accept Inventory fetch requests.
- SOLR
Index Customization, if required
- Define
a search Profile to expose Inventory Schema fields to Response
- Map
SOLR schema fields to External Response fields
- Custom
Expression Provider to get default fulfillment center Id.
- Create
a new SOLR Search Post Processor to format the solr fields in Response
ready format.
Inventory Search Resource Handler
A
new search resource handler needs to be mapped with a unique path using which a
REST service can be invoked from Store Front Pages..
Handler: XInventorySearchResourceHandler
Extends: AbstractSearchResourceHandler
Class level path annotation: @Path ("store/{storeId}/inventoryview")
Method level path annotation: @Path ("byCatentryId/{catentryId}")
@GET
@Path("byCatentryId/{catentryId}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response fetchInventoryStatusByCatalogEntryId(
@QueryParam("responseFormat") String responseFormat,
@PathParam("storeId") String storeId,
@PathParam("catentryId") String catentryId,
@QueryParam("searchProfile") String searchProfile) {
Response result = null;
SearchCriteria searchCriteria = null;
try {
searchCriteria = prepareSearchCriteria(storeId, null, "inventoryview",
"store/10501/inventoryview/byCatentryId/{catentryId}", searchProfile);
throwRestExceptionIfErrorsAreDetected();
searchCriteria.setControlParameterValue(
"_wcf.search.internal.optional.query",
"catentry_id:" + catentryId);
result = performSearch(searchCriteria);
} catch (Exception e) {
result = generateResponseFromRespData(searchCriteria, null, e);
} // EndTryCatch
LOGGER.debug("Exit");
return result;
} //EndMethod
Handler: XInventorySearchResourceHandler
Extends: AbstractSearchResourceHandler
Class level path annotation: @Path ("store/{storeId}/inventoryview")
Method level path annotation: @Path ("byCatentryId/{catentryId}")
@GET
@Path("byCatentryId/{catentryId}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response fetchInventoryStatusByCatalogEntryId(
@QueryParam("responseFormat") String responseFormat,
@PathParam("storeId") String storeId,
@PathParam("catentryId") String catentryId,
@QueryParam("searchProfile") String searchProfile) {
Response result = null;
SearchCriteria searchCriteria = null;
try {
searchCriteria = prepareSearchCriteria(storeId, null, "inventoryview",
"store/10501/inventoryview/byCatentryId/{catentryId}", searchProfile);
throwRestExceptionIfErrorsAreDetected();
searchCriteria.setControlParameterValue(
"_wcf.search.internal.optional.query",
"catentry_id:" + catentryId);
result = performSearch(searchCriteria);
} catch (Exception e) {
result = generateResponseFromRespData(searchCriteria, null, e);
} // EndTryCatch
LOGGER.debug("Exit");
return result;
} //EndMethod
Search Profile for Inventory Index
<!-- Search Profile to get Inventory SOLR response for a given catentryId --><_config:profile indexName="Inventory" name="X_findInventoryByCatentryId"> <_config:query> <_config:param name="maxRows" value="50" /> <_config:param name="maxTimeAllowed" value="15000" /> <!--Add Providers --> <!--Add Post Processors --> </_config:query> <_config:result> <_config:field name="catentry_id"/> <_config:field name="inv_strlocqty_*"/> <_config:field name="inv_inventoryflag_*"/> </_config:result></_config:profile>
Comments
Post a Comment