Exemplo n.º 1
0
    def product(self):
        product_id = self.request.matchdict.get("product_id")
        if not util.is_uuid(product_id):
            # it's not really a product ID, but a search string from a bot.
            raise HTTPFound("/ecom/search?search=%s" % product_id)
        prod = Product.load(product_id)
        self.redir_if(not prod or not prod.enabled or not prod.web_visible)

        page = self.request.matchdict.get(
            "page", util.nvl(prod.render_template, "product")
        )  # /product/{product_id}/{page}

        self.session["last_product_id"] = product_id
        self.session["back_link"] = "/product/%s" % product_id
        params = self.params()
        self._add_to_recent_products(prod)

        params["product"] = prod
        params["products_also_liked"] = SmartCatalog.also_liked_product_list(prod, params["campaign"])
        params["products_related"] = SmartCatalog.related_product_list(prod, params["campaign"])
        params["product_attributes"] = self._prep_product_attributes(prod.get_product_attributes())
        params["attrs"] = prod.get_attrs()
        params["price"] = SmartPricing.product_price(prod, params["campaign"])
        (params["seo_title"], params["seo_keywords"], params["seo_description"]) = SmartSeo.product_seo(
            prod, self.request.ctx.site
        )
        return self.render(page, params)
Exemplo n.º 2
0
 def params(self):
     campaign = self.request.ctx.campaign
     site = self.request.ctx.site
     if not "cart" in self.session:
         self.session["cart"] = Cart(site)
     cart = self.session["cart"]
     events = Appointment.find_public(self.enterprise_id)
     return {
         "site": site,
         #'base' : '%s/%s/' % (self.request.host_url.replace('http', 'https') if util.is_production() else self.request.host_url , site.namespace),
         "base": "%s/%s/" % (self.request.host_url, site.namespace),
         "user": self.request.ctx.user,
         "product": None,
         "products_related": None,
         "category": None,
         "cart": cart,
         "events": events,
         "seo_title": site.seo_title,
         "seo_keywords": site.seo_keywords,
         "seo_description": site.seo_description,
         "campaign": campaign,
         "categories": SmartCatalog.category_list(campaign),
         "customer": load_customer(self.request, True),  # this way customer is always there, just may be empty
         "matchdict": self.request.matchdict,
         "back_link": self.session.get("back_link"),
         "specials": self.specials_product_list(self.request.GET.get("specials_category_id"), 0, 4),
         "recent_products": self.session["recent_products"] if "recent_products" in self.session else {},
     }
Exemplo n.º 3
0
 def category(self):
     # /category/{category_id}/{page}
     page = self.request.matchdict.get("page", "category")
     category_id = util.to_uuid(self.request.matchdict.get("category_id"))
     category = ProductCategory.load(category_id)
     self.redir_if(not category)
     self.session["back_link"] = "/category/%s" % category_id
     params = self.params()
     params["products"] = util.page_list(
         SmartCatalog.category_product_list(self.request.ctx.campaign, category_id),
         self.request.GET.get("offset"),
         self.request.GET.get("limit"),
     )
     params["category"] = category
     (params["seo_title"], params["seo_keywords"], params["seo_description"]) = SmartSeo.category_seo(
         category, self.request.ctx.site
     )
     return self.render(page, params)
Exemplo n.º 4
0
 def featured_product_list(self, offset=None, limit=None):
     return SmartCatalog.featured_product_list(self.request.ctx.campaign, offset, limit)
Exemplo n.º 5
0
 def specials_product_list(self, specials_category_id, offset=None, limit=None):
     """ KB: [2012-12-24]: You can pass "specials_category_id=qwerqewfzdsxfdsfg" in the URL anywhere and the specials will show up as that category. """
     if specials_category_id:
         return SmartCatalog.category_product_list(self.request.ctx.campaign, specials_category_id, offset, limit)
     else:
         return SmartCatalog.specials_product_list(self.request.ctx.campaign, offset, limit)
Exemplo n.º 6
0
 def cart(self):
     page = self.request.matchdict.get('page', 'cart')
     params = self.params()
     params['products_related'] = SmartCatalog.related_product_list_cart(params['cart'], params['campaign'])
     return self.render(page, params)