Return to Snippet

Revision: 52349
at October 21, 2011 19:57 by simsevu


Updated Code
// AVERAGE SAVINGS ON SIMPLE PRODUCTS
SELECT (1-AVG(t1.final_price /t1.price))*100  
	FROM catalog_product_index_price AS t1
	JOIN catalog_product_entity AS t2
		ON t1.entity_id = t2.entity_id
	WHERE (t1.customer_group_id = 0 AND t1.website_id = 1)
		AND (t1.final_price > 0 AND t1.price > 0)
		AND t2.type_id = 'simple'
				
				
// AVERAGE PRICE ON SIMPLE PRODUCTS
SELECT AVG(t1.final_price) 
	FROM catalog_product_index_price AS t1
	JOIN catalog_product_entity AS t2
		ON t1.entity_id = t2.entity_id
	WHERE (t1.customer_group_id = 0 AND t1.website_id = 1)
		AND (t1.final_price > 0 AND t1.price > 0)
		AND t2.type_id = 'simple'
		
// AVERAGE PRICE ON BUNDLED PRODUCTS
SELECT AVG(t1.min_price) 
	FROM catalog_product_index_price AS t1
	JOIN catalog_product_entity AS t2
		ON t1.entity_id = t2.entity_id
	WHERE (t1.customer_group_id = 0 AND t1.website_id = 1)
		AND (t1.final_price > 0 AND t1.price > 0)
		AND t2.type_id = 'bundle'

Revision: 52348
at October 20, 2011 19:31 by simsevu


Updated Code
SELECT (1-AVG(final_price /price))*100  
	FROM catalog_product_index_price
	WHERE (customer_group_id = 0 AND website_id = 1)
		AND (final_price > 0 AND price > 0)

Revision: 52347
at October 20, 2011 19:20 by simsevu


Initial Code
SELECT (1-AVG(t1.final_price / t1.price))*100  
	FROM catalog_product_index_price AS t1 
		JOIN
		cataloginventory_stock_item AS t3
		ON t1.entity_id = t3.product_id
	WHERE (t1.customer_group_id = 0 AND t1.website_id = 1)
		AND (t1.final_price > 0 AND t1.price > 0)
		AND t3.qty > 0

Initial URL
avg-magento-discount

Initial Description

                                

Initial Title
Average discount in magento 1.4.1

Initial Tags
mysql, magento

Initial Language
MySQL