select p.item_id,IF(LENGTH(p.item_name)>40 ,CONCAT(SUBSTRING(p.item_name, 1, 40),"..."),p.item_name) as item_name,IF(p.selling_price>0,p.selling_price,p.regular_price) as price,p.selling_price as sale_price,p.regular_price,"LKR" as currency,CONCAT(m.folder_path,"/thumb/",m.thumbnail_img) as image,m.full_url as ori_image, c.des as category,short_description, p.product_type,p.delivery_hours,p.working_days, CONCAT("https://testm.tudo.lk/product/",p.product_slug,"'I'ic=",p.item_code) as product_url,IF(p.stock_status="I",p.product_qty,0) as product_qty, CONCAT(fetured_img,IF(gallery_img!="",",",""),gallery_img) as img_ids,p.gallery_img as gallery_img_ids , CONCAT("https://testm.tudo.lk/category","/",c.category_slug) as cat_url, IF(LENGTH(c.des)>20 ,CONCAT(SUBSTRING(c.des, 1, 20),"..."),c.des) as cat_text,p.item_name as item_name_full, v.shop_name,p.pak_inc,p.warranty,p.warranty_policy,REPLACE(p.sku,CONCAT(p.vendor_id,"-"),"") as sku, CONCAT("https://testm.tudo.lk/store/",v.vendor_slug) as vendor_url, p.stock_status,IF(FIND_IN_SET("adult-only",c.slug_hy)>0,"1","0") is_adult, IF(p.promo_start_date ISNOTNULLand p.promo_end_date ISNOTNULLand "2025-07-23 11:30:16" between p.promo_start_date and p.promo_end_date and p.promo_price ISNOTNULL , p.promo_price,"" ) as promo_price, IF(p.promo_start_date ISNOTNULLand p.promo_end_date ISNOTNULLand "2025-07-23 11:30:16" between p.promo_start_date and p.promo_end_date and p.promo_cover ISNOTNULL , p.promo_cover,"" ) as promo_cover, IFNULL(IF(p.review_count >0, CAST((p.star_count / p.review_count) AS UNSIGNED), 0), 0) as product_rating from m_003_1_item p innerjoin m_006_category c on `c`.`cat_id` = SUBSTRING_INDEX(p.cat_id, ",", -1) innerjoin m_002_vendor v on `v`.`supplier_id` = `p`.`vendor_id` leftjoin m_010_media m on `p`.`fetured_img` = `m`.`id` where `p`.`stock_status` =0and `p`.`product_qty` >0and `v`.`vation_mode` =1and `p`.`item_status` =0and `v`.`is_disabled` =1and `p`.`approval_status` =0and `p`.`review_count` isnotnulland `p`.`review_count` != ? orderby rand() asc limit 24
select p.item_id,IF(LENGTH(p.item_name)>40 ,CONCAT(SUBSTRING(p.item_name, 1, 40),"..."),p.item_name) as item_name,IF(p.selling_price>0,p.selling_price,p.regular_price) as price,p.selling_price as sale_price,p.regular_price, "LKR" as currency,CONCAT(m.folder_path,"/thumb/",m.thumbnail_img) as image,m.full_url as ori_image, c.des as category,short_description, p.product_type,p.delivery_hours,p.working_days, CONCAT("https://testm.tudo.lk/product/",p.product_slug,"'I'ic=",p.item_code) as product_url,IF(p.stock_status="I",p.product_qty,0) as product_qty, CONCAT(fetured_img,IF(gallery_img!="",",",""),gallery_img) as img_ids,p.gallery_img as gallery_img_ids, CONCAT("https://testm.tudo.lk/category","/",c.category_slug) as cat_url, IF(LENGTH(c.des)>20 ,CONCAT(SUBSTRING(c.des, 1, 20),"..."),c.des) as cat_text,p.item_name as item_name_full , v.shop_name,p.pak_inc,p.warranty,p.warranty_policy,REPLACE(p.sku,CONCAT(p.vendor_id,"-"),"") as sku, CONCAT("https://testm.tudo.lk/store/",v.vendor_slug) as vendor_url, p.stock_status,IF(FIND_IN_SET("adult-only",c.slug_hy)>0,"1","0") is_adult, IF(p.promo_start_date ISNOTNULLand p.promo_end_date ISNOTNULLand "2025-07-23 11:30:25" between p.promo_start_date and p.promo_end_date and p.promo_price ISNOTNULL , p.promo_price,"" ) as promo_price, IF(p.promo_start_date ISNOTNULLand p.promo_end_date ISNOTNULLand "2025-07-23 11:30:25" between p.promo_start_date and p.promo_end_date and p.promo_cover ISNOTNULL , p.promo_cover,"" ) as promo_cover, IFNULL(IF(p.review_count >0, CAST((p.star_count / p.review_count) AS UNSIGNED), 0), 0) as product_rating from m_003_1_item p innerjoin m_006_category c on `c`.`cat_id` = SUBSTRING_INDEX(p.cat_id, ",", -1) and `p`.`stock_status` ='I'and `p`.`product_qty` >0and `p`.`selling_price` >0and `p`.`item_status` =1innerjoin m_002_vendor v on `v`.`supplier_id` = `p`.`vendor_id` and `v`.`vation_mode` =0and `v`.`is_disabled` =0leftjoin m_010_media m on `p`.`fetured_img` = `m`.`id` where `p`.`stock_status` =0and `p`.`product_qty` >1and `p`.`approval_status` =0and `p`.`review_count` isnotnulland `p`.`review_count` != ? orderby rand() asc limit 12