SELECT `e`.*, `cat_index`.`position` AS `cat_index_position`, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, IF(at_small_image.value_id > 0, at_small_image.value, at_small_image_default.value) AS `small_image`, `at_bestsellers`.`qty_ordered` AS `bestsellers`, `stock_status_index`.`stock_status` AS `is_salable` FROM `catalog_product_entity` AS `e` INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=4 AND cat_index.visibility IN(2, 4) AND cat_index.category_id='127' INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '5' AND price_index.customer_group_id = 0 LEFT JOIN `catalog_product_entity_varchar` AS `at_small_image_default` ON (`at_small_image_default`.`entity_id` = `e`.`entity_id`) AND (`at_small_image_default`.`attribute_id` = '88') AND `at_small_image_default`.`store_id` = 0 LEFT JOIN `catalog_product_entity_varchar` AS `at_small_image` ON (`at_small_image`.`entity_id` = `e`.`entity_id`) AND (`at_small_image`.`attribute_id` = '88') AND (`at_small_image`.`store_id` = 4) LEFT JOIN `amasty_sorting_bestsellers` AS `at_bestsellers` ON (at_bestsellers.`product_id`=e.entity_id) AND (at_bestsellers.store_id = '4') INNER JOIN `cataloginventory_stock_status` AS `stock_status_index` ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 INNER JOIN `search_tmp_6071860e853201_44874950` AS `search_result` ON e.entity_id = search_result.entity_id ORDER BY `stock_status_index`.`stock_status` DESC, `stock_status_index`.`stock_status` DESC, IF(IFNULL(small_image, 'no_selection')='no_selection', 1, 0) ASC, `at_bestsellers`.`qty_ordered` DESC LIMIT 24