From 2ba569d5fa662a172580b0b22431d7502f2166bf Mon Sep 17 00:00:00 2001 From: cbmarcum Date: Sat, 26 Oct 2019 17:55:57 -0400 Subject: [PATCH] Refs #81 - changes copied from master branch commit 0f2898f --- .../mybusiness/ProductController.groovy | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/grails-app/controllers/net/codebuilders/mybusiness/ProductController.groovy b/grails-app/controllers/net/codebuilders/mybusiness/ProductController.groovy index 1363c42..5b29c80 100644 --- a/grails-app/controllers/net/codebuilders/mybusiness/ProductController.groovy +++ b/grails-app/controllers/net/codebuilders/mybusiness/ProductController.groovy @@ -39,6 +39,8 @@ import grails.plugins.hibernate.search.HibernateSearchGrailsPlugin import grails.plugin.springsecurity.SpringSecurityUtils +import net.codebuilders.mybusiness.ProductCategory + /** * Controller class for Product @@ -61,12 +63,12 @@ class ProductController { /* before search params.max = Math.min(max ?: 10, 100) - if (params.category) { - def products = productService.getProductsByProdCatAndDisplay(params) - respond products, model: [productCount: products.size()] - } else { - respond Product.list(params), model: [productCount: Product.count()] - } + if (params.category) { + def products = productService.getProductsByProdCatAndDisplay(params) + respond products, model: [productCount: products.size()] + } else { + respond Product.list(params), model: [productCount: Product.count()] + } */ // using search @@ -125,8 +127,8 @@ class ProductController { def command = [ - dateTo : new Date(), - keyword: params.keyword // was keyword: params.list('q').join() + dateTo : new Date(), + keyword: params.keyword // was keyword: params.list('q').join() ] @@ -226,7 +228,7 @@ class ProductController { } else { def command = [ - dateTo: new Date() + dateTo: new Date() ] productList = Product.search().list { @@ -287,21 +289,28 @@ class ProductController { // for debugging missing photos /* productList.each { - log.info "${it.number} ${it.name}" - // log.info "photos[0].photo.name = ${it.photos[0].photo.name}" - if (it.photos) { - log.info "has ${it.photos.size()} photos." - } else { - log.info "has no photos." - } + log.info "${it.number} ${it.name}" + // log.info "photos[0].photo.name = ${it.photos[0].photo.name}" + if (it.photos) { + log.info "has ${it.photos.size()} photos." + } else { + log.info "has no photos." } - */ + } + */ + log.info("params.category= ${params.category}") + def productCategory = params.category ? ProductCategory.findById(params.category)?.description : "All Products" + log.info("productCategory = ${productCategory}") + def notices = noticeService.getCurrentNoticesByPage("Product") + // used for no-image if a product is missing one. + def noImage = Photo.findByName("no-image")?.photo?.getCloudFile("large") + // render(view:'index', model: [message: 'Hello world', result: result, fieldsList: indexedProperties.keySet()]) - respond productList, model: [productCount: productCount, noticeList: notices] + respond productList, model: [productCategory: productCategory, productCount: productCount, noticeList: notices, noImage: noImage] } @@ -422,7 +431,7 @@ class ProductController { } def ajaxUpdateCartQty() { -// TODO: remove println + // TODO: remove println println "entered ajaxUpdateCartQty" log.info "entered ajaxUpdateCartQty" def cartQty = shoppingCartService.getItems().size()