예제 #1
0
def getAllProducts(category, brand):
	product_list = []
	brand_products = mongoProductmaster.find({'category':category, 'brand':brand})
	prodList = {}
	for prod in brand_products:
		prodList[prod['product_name']] = prod['product_id']
	
	return prodList
예제 #2
0
def getAllProduct_name(category, brand):
    product_list = []
    brand_products = mongoProductmaster.find({
        'category': category,
        'brand': brand
    })
    product_list = [prod['product_name'] for prod in brand_products]
    return product_list
예제 #3
0
def getProductAutoCompleteList(category, qu):

    if category is not "all":

        allProducts = mongoProductmaster.find({'category': category})
    else:

        allProducts = mongoProductmaster.find()
    productList = []
    for products in allProducts:
        producDict = {}
        if qu.lower() in products['product_name'].lower():
            producDict['name'] = products['product_name']
            producDict['type'] = products['category']
            producDict[
                'icon'] = "https://s3-ap-southeast-1.amazonaws.com/bazaarfunda/Website/static/ProductImage/" + products[
                    'product_id'] + ".jpg"
            productList.append(producDict)
    return productList
예제 #4
0
def getAllProducts():
    try:
        category = getArgAsList(request, 'category')[0]
    except:
        category = None
    if category:
        allProducts = mongoProductmaster.find({"category": category})
    else:
        allProducts = mongoProductmaster.find()

    csvStrings = []
    csvList = []
    for product in allProducts:
        product_id = product['product_id']
        priceDict, min_priceDict = getProductPrice(product_id)
        category = product['category']
        brand = product['brand']

        try:
            lowestprice = str(min_priceDict['price'])
        except:
            lowestprice = ""
        keywordsRating = getProductRating(product_id)
        rating = 0.0
        sumC = 0
        for keyword in keywordsRating:
            rating = rating + float(keyword['rating'])
            sumC = sumC + 1
        if sumC != 0:
            rating = rating / sumC
        rating = str(rating)
        rowList = [product_id, brand, lowestprice, category, rating]
        csvList.append(rowList)

    for csvLine in csvList:
        csvStrings += [",".join(csvLine)]
    csvStrings = "\n".join(csvStrings)
    response = make_response(csvStrings)
    # This is the key: Set the right header for the response
    # to be downloaded, instead of just printed on the browser
    response.headers[
        "Content-Disposition"] = "attachment; filename=" + category + "_allProducts.csv"
    return response
예제 #5
0
def getAllProducts():
	try:
		category = getArgAsList(request, 'category')[0]
	except:
		category = None
	if category:
		allProducts  = mongoProductmaster.find({"category":category})
	else:
		allProducts  = mongoProductmaster.find()

	csvStrings= []
	csvList = []
	for product in allProducts:
		product_id = product['product_id']
		priceDict, min_priceDict = getProductPrice(product_id)
		category = product['category']
		brand = product['brand']
		
		try:
			lowestprice = str(min_priceDict['price'])
		except:
			lowestprice = ""
		keywordsRating = getProductRating(product_id)
		rating = 0.0
		sumC = 0
		for keyword in keywordsRating:
			rating = rating + float(keyword['rating'])
			sumC = sumC + 1
		if sumC != 0:
			rating = rating/sumC
		rating = str(rating)
		rowList = [product_id, brand, lowestprice, category, rating]
		csvList.append(rowList)
	 
	for csvLine in csvList:
		csvStrings += [",".join(csvLine)]
	csvStrings =  "\n".join(csvStrings)
	response = make_response(csvStrings)
    # This is the key: Set the right header for the response
    # to be downloaded, instead of just printed on the browser
	response.headers["Content-Disposition"] = "attachment; filename=" + category + "_allProducts.csv"
	return response 
예제 #6
0
def getAllProducts(category, brand):
    product_list = []
    brand_products = mongoProductmaster.find({
        'category': category,
        'brand': brand
    })
    prodList = {}
    for prod in brand_products:
        prodList[prod['product_name']] = prod['product_id']

    return prodList
예제 #7
0
def getAllBrands(category):

    category_products = mongoProductmaster.find({'category': category})
    brand_list = [prod['brand'] for prod in category_products]
    brand_list = list(set(brand_list))
    return brand_list
예제 #8
0
def getAllProduct_name(category, brand):
	product_list = []
	brand_products = mongoProductmaster.find({'category':category, 'brand':brand})
	product_list = [prod['product_name'] for prod in brand_products]
	return product_list
예제 #9
0
def getAllBrands(category):
	
	category_products = mongoProductmaster.find({'category':category})
	brand_list = [prod['brand'] for prod in category_products]
	brand_list = list(set(brand_list))
	return brand_list