Expression #33 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'bioman.T2.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
select T.yandex_market_category_id, T.yandex_market_name, T.is_main_package, T.video_code, T.html_title, T.html_keywords, T.html_description, T.id, T.folder_id, T.brand, T.model, T.visible, T.package, T.portion, T.portions_num, T.avail, T.rating, T.sale_rating, T.product_of_day, T.product_of_week, IF(T.discount=0,T.price,round(cast(T.price*(1-(T.discount/100)) as decimal))) as price, T.price as price_real, T.discount, T.is_stack, T.comments_num,FLD.name as section_name,FLD.url as folder_url,FLD.pos as section_pos,B.name as brand_name,B.url as brand_url,B.orig_ext as brand_orig_ext,B.country as brand_country,IFNULL(T2.id,T.id) as _main_package_id,IF(T2.id IS NULL, T.short_desc, T2.short_desc) as short_desc,IF(T2.id IS NULL, T.url, T2.url) as url,IF(ifnull(T2.yandex_market_category_id, "") = "", T.yandex_market_category_id, T2.yandex_market_category_id) as yandex_market_category_id,(select id from catalog_photos as CP where CP.item_id=IF(1, T.id, _main_package_id) order by pos limit 1) as photo_id from (catalog as T) left join brands as B on B.id=T.brand left join folders as FLD on FLD.id=T.folder_id left join catalog as T2 on T2.model=T.model and T2.brand=T.brand and T2.is_main_package=1 where T.visible=1 and T.brand=126 group by T.id order by T.avail=0 asc,IFNULL(T.pos, 0)=0,T.pos,T.rating desc