Я пытаюсь написать URL Resolver в Hybris, но сталкиваюсь с несколькими ошибками;
Метод getBaseProduct(ProductModel)
не определен для типа TrialProductModelUrlResolver
Метод getCategoryPath(CategoryModel)
в типе DefaultCategoryModelUrlResolver
не применим для аргументов (ProductModel)
Метод getProductForCode (String) в типе ProductService не применим для аргументов (ProductModel)
public class TrailerProductModelUrlResolver extends DefaultCategoryModelUrlResolver {
private TrailerURLNormalizationStrategy trailerURLNormalizationStrategy;
@Autowired
private ProductService productService;
@Override
protected String resolveInternal(final ProductModel source) {
final ProductModel baseProduct = getBaseProduct(source);
final BaseSiteModel currentBaseSite = getBaseSiteService().getCurrentBaseSite();
String url = getPattern();
if ((currentBaseSite != null) && (url.contains("{baseSite-uid}"))) {
url = url.replace("{baseSite-uid}", currentBaseSite.getUid());
}
if (url.contains("{category-path}")) {
url = url.replace("{category-path}", trailerURLNormalizationStrategy.normalizeString(buildPathString(getCategoryPath(source))));
}
if (url.contains("{product-name}")) {
String productName = source.getName(TrailerCoreConstants.LOCALE_TR);
if (StringUtils.isEmpty(productName)) {
productName = baseProduct.getName(TrailerCoreConstants.LOCALE_TR);
}
CategoryModel categoryModel = productService.getProductForCode(baseProduct);
if (categoryModel != null) {
if (categoryModel.getName() != null) {
if (!categoryModel.getName(TrailerCoreConstants.LOCALE_TR).isEmpty()) {
productName = categoryModel.getName(TrailerCoreConstants.LOCALE_TR) + " " + productName;
}
}
}
url = url.replace("{product-name}", trailerURLNormalizationStrategy.normalizeString(productName));
}
if (url.contains("{product-code}")) {
url = url.replace("{product-code}", trailerURLNormalizationStrategy.normalizeString(source.getCode()));
}
return url;
}
@Override
protected String buildPathString(final List<CategoryModel> path) {
if ((path == null) || (path.isEmpty())) {
return "c";
}
final StringBuilder result = new StringBuilder();
for (int i = 0; i < path.size(); ++i) {
if (i != 0) {
result.append('/');
}
result.append(path.get(i).getName());
}
return result.toString();
}
public TrailerURLNormalizationStrategy getTrailerURLNormalizationStrategy() {
return trailerURLNormalizationStrategy;
}
public void setTrailerURLNormalizationStrategy(TrailerURLNormalizationStrategy trailerURLNormalizationStrategy) {
this.trailerURLNormalizationStrategy = trailerURLNormalizationStrategy;
}
}
любая помощь
С уважением