Рецепты
Стейк из лосося дома - легко! Показываем, как сделать правильно.
28 декабря 2020
Table './u206051_12/catalog' is marked as crashed and should be repaired
select T.*,BR.name as brand_name,BR.logo as brand_logo,CNTR.name as brand_country_name,CITY.name as brand_city_name,BR.geo as brand_geo,FLD.name as section_name,FLD.url as folder_url,FLD.pos as section_pos,B.name as brand_name,ST.name as cst_name,ST.id as cst_id,(select PH.id from catalog_photos as PH where PH.item_id=T.id order by PH.pos limit 1) as photo_id,T.is_stack,1 as avail_in_region,@count_variants := IFNULL( ( select count(CIV.id) from catalog_item_variants as CIV where CIV.item_id = T.id AND CIV.active = 1 ), 0 ),IFNULL(@count_variants, 0) as count_variants,@price := ifnull( ( select CPR.price from catalog_prices as CPR where CPR.price_type_id = 3 and CPR.product_id = T.id and IFNULL(CPR.variant_id, 0) = 0 limit 1 ), T.price ),@product_discount := ifnull( ( select CPR.discount from catalog_prices as CPR where CPR.price_type_id=3 and CPR.product_id=T.id and IFNULL(CPR.variant_id, 0) = 0 limit 1 ), IF (T.is_stack, T.discount, 0) ),@folder_discount := IF( FLD.discount > 0, FLD.discount, ifnull( (select discount from folders as FP where FP.id = FLD.parent), 0 ) ),@discount := GREATEST( if(T.no_discount_folder = 0, @folder_discount, 0), if(T.no_discount_brand = 0, IFNULL(B.discount, 0), 0), IFNULL(T.discount, 0), @product_discount ),IF( @discount = 0, @price, round( cast( @price * (1 - (@discount / 100)) as decimal ) ) ) as price, @price as price_real,@discount as discount,@quantity := ifnull( ( select sum(STOCK.quantity) from catalog_stocks_products as STOCK where STOCK.stock_id = 1 and STOCK.product_id = T.id ), 0 ),@avail := IF(@quantity > 0, 1, 0),@quantity as quantity,IF(T.is_stack = 0, @avail, T.avail) as avail,( CASE WHEN T.is_stack = 0 AND IFNULL(delivery_time, "") = "" THEN @avail ELSE 1 END ) as avail_order from ((catalog as T,articles_products,folders as FLD) left join brands as B on B.id=T.brand left join brands as BR on BR.id = T.brand left join countries as CNTR on CNTR.id = BR.country_id left join countries_cities as CITY on CITY.id = BR.city_id left join currency as CR on CR.id=T.currency left join catalog_special_products as CST on T.id=CST.product_id and (select count(AST.affiliate_id) from affiliates_special_types as AST where AST.type_id=CST.special_type and AST.affiliate_id=1 limit 1) = 1 left join catalog_special_types as ST on CST.special_type=ST.id) where T.active=1 and (T.id=articles_products.product_id and articles_products.article_id=172) and FLD.id=T.folder_id and (select count(AFF.affiliate_id) from affiliates_catalog as AFF where AFF.affiliate_id=1 and AFF.product_id=T.id) > 0 and (1) group by T.id order by avail_order desc,T.pos