protected void addMetaData( final Model model, final String metaPrefixKey, final String searchText, final String metaPostfixKey, final PageType pageType, final String robotsBehaviour) { final String metaDescription = MetaSanitizerUtil.sanitizeDescription( getMessageSource().getMessage(metaPrefixKey, null, getCurrentLocale()) + " " + searchText + " " + getMessageSource().getMessage(metaPostfixKey, null, getCurrentLocale()) + " " + getSiteName()); final String metaKeywords = MetaSanitizerUtil.sanitizeKeywords(searchText); setUpMetaData(model, metaKeywords, metaDescription); model.addAttribute("pageType", pageType.name()); model.addAttribute("metaRobots", robotsBehaviour); }
@RequestMapping(value = "/advanced", method = RequestMethod.GET) public String advanceSearchResults( @RequestParam(value = "keywords", required = false, defaultValue = StringUtils.EMPTY) String keywords, @RequestParam( value = "searchResultType", required = false, defaultValue = ADVANCED_SEARCH_RESULT_TYPE_CATALOG) final String searchResultType, @RequestParam(value = "inStockOnly", required = false, defaultValue = "false") final boolean inStockOnly, @RequestParam(value = "onlyProductIds", required = false, defaultValue = "false") final boolean onlyProductIds, @RequestParam(value = "isCreateOrderForm", required = false, defaultValue = "false") final boolean isCreateOrderForm, @RequestParam(value = "q", defaultValue = StringUtils.EMPTY) String searchQuery, @RequestParam(value = "page", defaultValue = "0") final int page, @RequestParam(value = "show", defaultValue = "Page") final ShowMode showMode, @RequestParam(value = "sort", required = false) final String sortCode, final Model model) throws CMSItemNotFoundException { if (StringUtils.isNotBlank(keywords)) { searchQuery = keywords; } else { if (StringUtils.isNotBlank(searchQuery)) { keywords = StringUtils.split(searchQuery, ":")[0]; } } // check if it is order form (either order form was selected or "Create Order Form" final PageableData pageableData = createPageableData(page, getSearchPageSize(), sortCode, showMode); final SearchStateData searchState = createSearchStateData(searchQuery, isPopulateVariants(searchResultType, isCreateOrderForm)); final SearchPageData<ProductData> searchPageData = performSearch( searchState, pageableData, isUseFlexibleSearch(onlyProductIds, isCreateOrderForm)); populateModel(model, searchPageData, showMode); String metaInfoText = null; if (StringUtils.isEmpty(keywords)) { metaInfoText = MetaSanitizerUtil.sanitizeDescription( getMessageSource() .getMessage("search.advanced.meta.description.title", null, getCurrentLocale())); } else { metaInfoText = MetaSanitizerUtil.sanitizeDescription(keywords); } model.addAttribute( WebConstants.BREADCRUMBS_KEY, searchBreadcrumbBuilder.getBreadcrumbs(null, metaInfoText, false)); final AdvancedSearchForm form = new AdvancedSearchForm(); form.setOnlyProductIds(Boolean.valueOf(onlyProductIds)); form.setInStockOnly(Boolean.valueOf(inStockOnly)); form.setKeywords(keywords); form.setCreateOrderForm(isCreateOrderForm); if (isCreateOrderForm) { form.setSearchResultType(ADVANCED_SEARCH_RESULT_TYPE_ORDER_FORM); final List<String> filterSkus = splitSkusAsList(keywords); form.setFilterSkus(filterSkus); form.setCreateOrderForm(Boolean.valueOf(false)); form.setOnlyProductIds(Boolean.valueOf(true)); } else { form.setSearchResultType(searchResultType); } model.addAttribute("advancedSearchForm", form); model.addAttribute( "futureStockEnabled", Boolean.valueOf(Config.getBoolean(FUTURE_STOCK_ENABLED, false))); storeCmsPageInModel(model, getContentPageForLabelOrId(NO_RESULTS_ADVANCED_PAGE_ID)); addMetaData( model, "search.meta.description.results", metaInfoText, "search.meta.description.on", PageType.PRODUCTSEARCH, "no-index,follow"); return getViewForPage(model); }