SELECT mp.bundle_flag, (SELECT GROUP_CONCAT(DISTINCT StandardColor,',',tbl_products.SKU,',',CONCAT( UCASE( SUBSTRING( ColorDescription, 1, 1 )), LCASE( SUBSTRING( ColorDescription, 2 )), ',', IF((ModelPrice.Sale = 0),ModelPrice.MSRP,IF((ModelPrice.MSRP = 0),ModelPrice.Sale,IF((ModelPrice.Sale > ModelPrice.MSRP), ModelPrice.MSRP, ModelPrice.Sale ))), ',', IF((ModelPrice.MSRP > 0 AND ModelPrice.MSRP > ModelPrice.Sale), ModelPrice.MSRP, '0.00')) ORDER BY FIELD( StandardColor, 'Queen', 'Twin', 'Twin XL', 'Full', 'Full XL', 'California King', 'King', 'SplitKing', 'Split California King' ) SEPARATOR '|' ) FROM tbl_products INNER JOIN ModelPrice ON (tbl_products.pkID = ModelPrice.pkProduct AND tbl_products.SKU = ModelPrice.SKU AND ModelPrice.Available = 1) WHERE tbl_products.RootModelNumber = p.RootModelNumber AND tbl_products.pkBrand = p.pkBrand) AS AvailableColors, IF(p.thumb LIKE 'http%%',p.thumb,concat( 'https://snoozemattresscompany.com/uploads/products/', p.thumb )) AS thumb, IF(p.large LIKE 'http%%',p.large, concat( 'https://snoozemattresscompany.com/uploads/products/', p.large )) AS large, p.SKU, p.ModelStatus, p.mhSlug, p.mhDescription, p.cgSlug, p.cSlug, IF(p.CustomDescription <> '' AND p.CustomDescription IS NOT NULL ,p.CustomDescription, p.ModelDescription) AS ModelDescription, p.id, IF(p.CommonBrandName = 'LG Appliances','LG',p.CommonBrandName) AS CommonBrandName, p.KeyFeature1, p.KeyFeature2, p.KeyFeature3, p.KeyFeature4, p.KeyFeature5, bd.CommonBrandID, IF(p.StandardColor = 'Other',CONCAT(UCASE(SUBSTRING(p.ColorDescription, 1, 1)),LCASE(SUBSTRING(p.ColorDescription, 2))),p.StandardColor) AS ModelColor, mp.MSRP, mp.Sale, mp.Available, mp.in_store, mp.Featured, IF((mp.outlet = 1 AND 'search' = 'outlet'), mp.OutletPrice, IF((mp.Sale = 0), mp.MSRP, IF( (mp.MSRP = 0), mp.Sale, IF((mp.Sale > mp.MSRP), mp.MSRP, mp.Sale)))) AS calcPrice, IF(mp.MSRP > 0 AND mp.MSRP > mp.Sale, mp.MSRP, '0.00') AS RegPrice, mp.OutletPrice, mp.PromoPrice, mp.start_date, mp.end_date, mp.quick_ship, mp.PowerBuy, if(bd.cart_price_message = '' OR bd.cart_price_message IS NULL,'See price in cart', cart_price_message) AS cart_message, (mp.MSRP - mp.Sale) AS Discount, IF(bd.MAP = 1 OR p.is_package = 1, 1, .90) AS MapDiscount, mp.in_stock, mp.free_shipping, p.Sale AS MinTargetPrice, p.RootModelNumber, mp.FreeShip, bd.UMRP, (SELECT COUNT(pbm.pkID) FROM PromotionsByModel AS pbm INNER JOIN Rebates ON (Rebates.PromotionName = pbm.PromotionName AND Rebates.FileName <> '') WHERE pbm.pkProduct = p.pkID AND pbm.EffectiveDate <= CURDATE() AND pbm.ExpirationDate > CURDATE() GROUP BY pbm.pkProduct) AS rwsPromotion, (SELECT COUNT(rbm.pkID) FROM rebatesbymodel AS rbm INNER JOIN Rebates AS r ON r.pkID = rbm.pkRebates WHERE rbm.pkProduct = p.pkID AND r.ExpirationDate > CURDATE() AND r.EffectiveDate < CURDATE() GROUP BY rbm.PromotionName) AS rwsRebates, (p.Sale * (IF(bd.MAP = 1 OR p.is_package = 1, 1,.90))) AS MAP, c.ConsumerDescription AS cDescription, IF(bd.no_cart =1 OR mp.on_line = 0,1,0) AS no_cart FROM Categories AS c INNER JOIN Category_Groups AS cg ON (c.Category_Group = cg.CategoryCode) INNER JOIN menu_heading AS mh ON (cg.MenuHeading = mh.id) INNER JOIN(SELECT tbl_products.* FROM tbl_products INNER JOIN tbl_store_brands ON tbl_store_brands.brandID = tbl_products.pkBrand AND tbl_store_brands.categoryID = tbl_products.pkCategory ORDER BY FIELD(StandardColor, 'Queen', 'Twin', 'Twin XL', 'Full', 'Full XL', 'California King' ,'King' ,'SplitKing', 'Split California King') ASC LIMIT 1000000) AS p ON (p.cSlug = c.slug AND p.cgSlug = cg.slug AND p.mhSlug = mh.slug) INNER JOIN Brand_Data AS bd ON (bd.pkID = p.pkBrand) INNER JOIN tbl_store_brands AS sb ON (sb.brandID = bd.pkID AND sb.categoryID = c.pkID ) INNER JOIN ModelPrice AS mp ON (mp.pkProduct = p.pkID AND mp.SKU = p.SKU AND mp.Available = 1 ) WHERE 0=0 GROUP BY p.RootModelNumber ORDER BY IF(calcPrice = 0,99999, calcPrice) ASC
Query execution was interrupted