on 2022 Nov 07 11:23 AM
HI,
we would like to change the category url from the standard one ({category-name}/c/{category-id}) to a custom one ({category-name}~{category-id}. This change should support category in all level. for example - if we have category A with id 1 and sub-category B with id 2, the url for them will be:
A url: ..../a~1
B url: ..../a~1/b~2
is this something that can be done?
Request clarification before answering.
it's possible to change the URL format of your PLP, all you need to do is override OOTB class: DefaultCategoryModelUrlResolver.resolveInternal
This is the OOTB code for PLP, you can build and return your custom URL in this method, if you want to remove the /c/ and change it to something else, you need to also modify the controller
@Override
protected String resolveInternal(final CategoryModel source)
{
// Work out values
// Replace pattern values
String url = getPattern();
if (url.contains("{baseSite-uid}"))
{
url = url.replace("{baseSite-uid}", urlEncode(getBaseSiteUid().toString()));
}
if (url.contains("{category-path}"))
{
final String categoryPath = buildPathString(getCategoryPath(source));
url = url.replace("{category-path}", categoryPath);
}
if (url.contains("{category-code}"))
{
final String categoryCode = urlEncode(source.getCode()).replace("+", "%20");
url = url.replace("{category-code}", categoryCode);
}
if (url.contains("{catalog-id}"))
{
url = url.replace("{catalog-id}", urlEncode(source.getCatalogVersion().getCatalog().getId()));
}
if (url.contains("{catalogVersion}"))
{
url = url.replace("{catalogVersion}", urlEncode(source.getCatalogVersion().getVersion()));
}
return url;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
19 | |
5 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.