Ejemplo n.º 1
0
  @RequestMapping("/shop/store/contactus.html")
  public String displayContact(
      Model model, HttpServletRequest request, HttpServletResponse response, Locale locale)
      throws Exception {

    MerchantStore store = (MerchantStore) request.getAttribute(Constants.MERCHANT_STORE);

    Language language = (Language) request.getAttribute("LANGUAGE");

    ContactForm contact = new ContactForm();
    model.addAttribute("contact", contact);

    model.addAttribute(
        "recapatcha_public_key", coreConfiguration.getProperty(Constants.RECAPATCHA_PUBLIC_KEY));

    Content content = contentService.getByCode(Constants.CONTENT_CONTACT_US, store, language);
    ContentDescription contentDescription = null;
    if (content != null && content.isVisible()) {
      contentDescription = content.getDescription();
    }

    if (contentDescription != null) {

      // meta information
      PageInformation pageInformation = new PageInformation();
      pageInformation.setPageDescription(contentDescription.getMetatagDescription());
      pageInformation.setPageKeywords(contentDescription.getMetatagKeywords());
      pageInformation.setPageTitle(contentDescription.getTitle());
      pageInformation.setPageUrl(contentDescription.getName());

      request.setAttribute(Constants.REQUEST_PAGE_INFORMATION, pageInformation);

      model.addAttribute("content", contentDescription);
    }

    /** template * */
    StringBuilder template =
        new StringBuilder()
            .append(ControllerConstants.Tiles.Content.contactus)
            .append(".")
            .append(store.getStoreTemplate());
    return template.toString();
  }
Ejemplo n.º 2
0
  @RequestMapping(
      value = {"/shop/home.html", "/shop/", "/shop"},
      method = RequestMethod.GET)
  public String displayLanding(
      Model model, HttpServletRequest request, HttpServletResponse response, Locale locale)
      throws Exception {

    Language language = (Language) request.getAttribute(Constants.LANGUAGE);

    MerchantStore store = (MerchantStore) request.getAttribute(Constants.MERCHANT_STORE);

    Content content = contentService.getByCode("LANDING_PAGE", store, language);

    /** Rebuild breadcrumb * */
    BreadcrumbItem item = new BreadcrumbItem();
    item.setItemType(BreadcrumbItemType.HOME);
    item.setLabel(messages.getMessage(Constants.HOME_MENU_KEY, locale));
    item.setUrl(Constants.HOME_URL);

    Breadcrumb breadCrumb = new Breadcrumb();
    breadCrumb.setLanguage(language);

    List<BreadcrumbItem> items = new ArrayList<BreadcrumbItem>();
    items.add(item);

    breadCrumb.setBreadCrumbs(items);
    request.getSession().setAttribute(Constants.BREADCRUMB, breadCrumb);
    request.setAttribute(Constants.BREADCRUMB, breadCrumb);
    /** * */
    if (content != null) {

      ContentDescription description = content.getDescription();

      model.addAttribute("page", description);

      PageInformation pageInformation = new PageInformation();
      pageInformation.setPageTitle(description.getName());
      pageInformation.setPageDescription(description.getMetatagDescription());
      pageInformation.setPageKeywords(description.getMetatagKeywords());

      request.setAttribute(Constants.REQUEST_PAGE_INFORMATION, pageInformation);
    }

    ReadableProductPopulator populator = new ReadableProductPopulator();
    populator.setPricingService(pricingService);

    // featured items
    List<ProductRelationship> relationships =
        productRelationshipService.getByType(
            store, ProductRelationshipType.FEATURED_ITEM, language);
    List<ReadableProduct> featuredItems = new ArrayList<ReadableProduct>();
    for (ProductRelationship relationship : relationships) {

      Product product = relationship.getRelatedProduct();
      ReadableProduct proxyProduct =
          populator.populate(product, new ReadableProduct(), store, language);

      featuredItems.add(proxyProduct);
    }

    model.addAttribute("featuredItems", featuredItems);

    /** template * */
    StringBuilder template =
        new StringBuilder().append("landing.").append(store.getStoreTemplate());

    return template.toString();
  }