Class CatalogURLServiceImpl

java.lang.Object
org.broadleafcommerce.core.catalog.service.CatalogURLServiceImpl
All Implemented Interfaces:
CatalogURLService

@Service("blCatalogURLService") public class CatalogURLServiceImpl extends Object implements CatalogURLService
  • Field Details

    • appendIdToRelativeURI

      @Value("${catalogUriService.appendIdToRelativeURI:true}") protected boolean appendIdToRelativeURI
    • useUrlKey

      @Value("${catalogUriService.useUrlKey:false}") protected boolean useUrlKey
    • productIdParam

      @Value("${catalogUriService.productIdParam:productId}") protected String productIdParam
    • categoryIdParam

      @Value("${catalogUriService.categoryIdParam:categoryId}") protected String categoryIdParam
  • Constructor Details

    • CatalogURLServiceImpl

      public CatalogURLServiceImpl()
  • Method Details

    • buildRelativeProductURL

      public String buildRelativeProductURL(String currentUrl, Product product)
      Description copied from interface: CatalogURLService
      Provides 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:
      buildRelativeProductURL in interface CatalogURLService
      Returns:
    • buildRelativeCategoryURL

      public String buildRelativeCategoryURL(String currentUrl, Category category)
      Description copied from interface: CatalogURLService
      Specified by:
      buildRelativeCategoryURL in interface CatalogURLService
      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

      protected String getProductUrlFragment(Product product)
    • getCategoryUrlFragment

      protected String getCategoryUrlFragment(Category category)
    • getLastFragment

      protected String getLastFragment(String url)