Class CatalogURLServiceImpl
- All Implemented Interfaces:
CatalogURLService
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildRelativeCategoryURL(String currentUrl, Category category) See similar description forCatalogURLService.buildRelativeProductURL(String, Product)buildRelativeProductURL(String currentUrl, Product product) Provides relative URLs.protected StringbuildRelativeUrlWithParam(String currentUrl, String fragment, String idParam, String idValue) Adds the fragment to the end of the path and optionally adds an id param depending upon the value of appendIdToRelativeURI.protected StringgetCategoryUrlFragment(Category category) protected StringgetLastFragment(String url) protected StringgetProductUrlFragment(Product product)
-
Field Details
-
appendIdToRelativeURI
@Value("${catalogUriService.appendIdToRelativeURI:true}") protected boolean appendIdToRelativeURI -
useUrlKey
@Value("${catalogUriService.useUrlKey:false}") protected boolean useUrlKey -
productIdParam
-
categoryIdParam
-
-
Constructor Details
-
CatalogURLServiceImpl
public CatalogURLServiceImpl()
-
-
Method Details
-
buildRelativeProductURL
Description copied from interface:CatalogURLServiceProvides relative URLs. This is useful for cases where a site wants to build a dynamic URL to get to a product or category where multiple navigation paths are provided.For example, consider a product with URL (/equipment/tennis-ball) that is in two categories which have the following URLs (/sports and /specials).
For some implementations, it is desirable to have two semantic URLs such as "/sports/tennis-ball" and "/specials/tennis-ball".
This method will take the last fragment of the product URL and append it to the passed in URL to make a relative URL.
This default implementation of this interface uses two system properties to control its behavior.
catalogUriService.appendIdToRelativeURI - If true (default), a query param will be appended to the URL with the productId.
catalogUriService.useUrlKey - If true (default is false), the implementation will call the ProductImpl.getUrlKey() to obtain the url fragment. If false, it will parse the last part of the ProductImpl.getUrl().
Returns the URL as a string including query parameters.
- Specified by:
buildRelativeProductURLin interfaceCatalogURLService- Returns:
-
buildRelativeCategoryURL
Description copied from interface:CatalogURLServiceSee similar description forCatalogURLService.buildRelativeProductURL(String, Product)- Specified by:
buildRelativeCategoryURLin interfaceCatalogURLService- Returns:
-
buildRelativeUrlWithParam
protected String buildRelativeUrlWithParam(String currentUrl, String fragment, String idParam, String idValue) Adds the fragment to the end of the path and optionally adds an id param depending upon the value of appendIdToRelativeURI. -
getProductUrlFragment
-
getCategoryUrlFragment
-
getLastFragment
-