SELECT 
  SQL_CALC_FOUND_ROWS products.product_id, 
  IF(
    shared_descr.product_id IS NOT NULL, 
    shared_descr.product, descr1.product
  ) as product, 
  companies.company as company_name, 
  products.product_type, 
  products.parent_product_id 
FROM 
  cscart_products as products 
  LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id 
  AND descr1.lang_code = 'ru' 
  LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id 
  AND prices.lower_limit = 1 
  LEFT JOIN cscart_companies AS companies ON companies.company_id = products.company_id 
  INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id 
  INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id 
  AND (
    cscart_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
  AND cscart_categories.storefront_id IN (0, 1) 
  LEFT JOIN cscart_ult_product_descriptions shared_descr ON shared_descr.product_id = products.product_id 
  AND shared_descr.company_id = 1 
  AND shared_descr.lang_code = 'ru' 
  LEFT JOIN cscart_images_links as img_links ON img_links.object_id = products.product_id 
  AND img_links.object_type = 'product' 
  AND img_links.type = 'M' 
  LEFT JOIN cscart_warehouses_sum_products_amount as war_sum_amount ON war_sum_amount.product_id = products.product_id 
  LEFT JOIN cscart_warehouses_destination_products_amount AS warehouses_destination_products_amount ON warehouses_destination_products_amount.product_id = products.product_id 
  AND warehouses_destination_products_amount.destination_id = 116 
  AND warehouses_destination_products_amount.storefront_id = 1 
  LEFT JOIN cscart_product_popularity as popularity ON popularity.product_id = products.product_id 
WHERE 
  1 
  AND cscart_categories.category_id IN (
    3, 35, 4, 117, 158, 183, 190, 191, 192, 
    205, 248, 258, 281, 359
  ) 
  AND companies.status IN ('A') 
  AND (
    (
      CASE products.is_stock_split_by_warehouses WHEN 'Y' THEN warehouses_destination_products_amount.amount ELSE products.amount END
    ) > 0 
    OR products.tracking = 'D'
  ) 
  AND (
    products.usergroup_ids = '' 
    OR FIND_IN_SET(0, products.usergroup_ids) 
    OR FIND_IN_SET(1, products.usergroup_ids)
  ) 
  AND products.status IN ('A') 
  AND prices.usergroup_id IN (0, 0, 1) 
  AND products.company_id != 2 
  AND img_links.pair_id > 0 
  AND products.parent_product_id = 0 
GROUP BY 
  products.product_id 
ORDER BY 
  popularity.total desc, 
  products.product_id ASC 
LIMIT 
  0, 32

Query time 0.00350

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "20.98"
    },
    "ordering_operation": {
      "using_filesort": true,
      "grouping_operation": {
        "using_temporary_table": true,
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "shared_descr",
              "access_type": "system",
              "possible_keys": [
                "PRIMARY",
                "product_id",
                "company_id"
              ],
              "rows_examined_per_scan": 0,
              "rows_produced_per_join": 1,
              "filtered": "0.00",
              "const_row_not_found": true,
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.10",
                "prefix_cost": "0.00",
                "data_read_per_join": "4K"
              },
              "used_columns": [
                "product_id",
                "lang_code",
                "company_id",
                "product"
              ]
            }
          },
          {
            "table": {
              "table_name": "cscart_categories",
              "access_type": "range",
              "possible_keys": [
                "PRIMARY",
                "c_status",
                "p_category_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "rows_examined_per_scan": 14,
              "rows_produced_per_join": 0,
              "filtered": "4.00",
              "index_condition": "(`test_uchur_k`.`cscart_categories`.`category_id` in (3,35,4,117,158,183,190,191,192,205,248,258,281,359))",
              "cost_info": {
                "read_cost": "9.75",
                "eval_cost": "0.06",
                "prefix_cost": "9.81",
                "data_read_per_join": "2K"
              },
              "used_columns": [
                "category_id",
                "storefront_id",
                "usergroup_ids",
                "status"
              ],
              "attached_condition": "(((`test_uchur_k`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`test_uchur_k`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`test_uchur_k`.`cscart_categories`.`usergroup_ids`))) and (`test_uchur_k`.`cscart_categories`.`status` in ('A','H')) and (`test_uchur_k`.`cscart_categories`.`storefront_id` in (0,1)))"
            }
          },
          {
            "table": {
              "table_name": "companies",
              "access_type": "range",
              "possible_keys": [
                "PRIMARY"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "company_id"
              ],
              "key_length": "4",
              "rows_examined_per_scan": 2,
              "rows_produced_per_join": 0,
              "filtered": "50.00",
              "index_condition": "(`test_uchur_k`.`companies`.`company_id` <> 2)",
              "using_join_buffer": "hash join",
              "cost_info": {
                "read_cost": "0.73",
                "eval_cost": "0.06",
                "prefix_cost": "10.60",
                "data_read_per_join": "3K"
              },
              "used_columns": [
                "company_id",
                "status",
                "company"
              ],
              "attached_condition": "(`test_uchur_k`.`companies`.`status` = 'A')"
            }
          },
          {
            "table": {
              "table_name": "products_categories",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "pt"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "ref": [
                "test_uchur_k.cscart_categories.category_id"
              ],
              "rows_examined_per_scan": 18,
              "rows_produced_per_join": 10,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "0.20",
                "eval_cost": "1.01",
                "prefix_cost": "11.81",
                "data_read_per_join": "161"
              },
              "used_columns": [
                "product_id",
                "category_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "products",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "status",
                "idx_parent_product_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "test_uchur_k.products_categories.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "5.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.05",
                "prefix_cost": "12.82",
                "data_read_per_join": "5K"
              },
              "used_columns": [
                "product_id",
                "product_type",
                "status",
                "company_id",
                "amount",
                "usergroup_ids",
                "tracking",
                "parent_product_id",
                "is_stock_split_by_warehouses"
              ],
              "attached_condition": "((`test_uchur_k`.`products`.`company_id` = `test_uchur_k`.`companies`.`company_id`) and (`test_uchur_k`.`products`.`parent_product_id` = 0) and ((`test_uchur_k`.`products`.`usergroup_ids` = '') or (0 <> find_in_set(0,`test_uchur_k`.`products`.`usergroup_ids`)) or (0 <> find_in_set(1,`test_uchur_k`.`products`.`usergroup_ids`))) and (`test_uchur_k`.`products`.`status` = 'A'))"
            }
          },
          {
            "table": {
              "table_name": "descr1",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "product_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id",
                "lang_code"
              ],
              "key_length": "9",
              "ref": [
                "test_uchur_k.products_categories.product_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.05",
                "prefix_cost": "12.87",
                "data_read_per_join": "2K"
              },
              "used_columns": [
                "product_id",
                "lang_code",
                "product"
              ]
            }
          },
          {
            "table": {
              "table_name": "prices",
              "access_type": "ref",
              "possible_keys": [
                "usergroup",
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "key": "product_id",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "test_uchur_k.products_categories.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "75.77",
              "cost_info": {
                "read_cost": "0.13",
                "eval_cost": "0.04",
                "prefix_cost": "13.04",
                "data_read_per_join": "9"
              },
              "used_columns": [
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "attached_condition": "((`test_uchur_k`.`prices`.`lower_limit` = 1) and (`test_uchur_k`.`prices`.`usergroup_id` in (0,0,1)))"
            }
          },
          {
            "table": {
              "table_name": "img_links",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "object_id"
              ],
              "key": "object_id",
              "used_key_parts": [
                "object_id",
                "object_type",
                "type"
              ],
              "key_length": "81",
              "ref": [
                "test_uchur_k.products_categories.product_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 4,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "index_condition": "(`test_uchur_k`.`img_links`.`object_id` = `test_uchur_k`.`products_categories`.`product_id`)",
              "cost_info": {
                "read_cost": "0.38",
                "eval_cost": "0.15",
                "prefix_cost": "13.58",
                "data_read_per_join": "146"
              },
              "used_columns": [
                "pair_id",
                "object_id",
                "object_type",
                "type"
              ],
              "attached_condition": "(`test_uchur_k`.`img_links`.`pair_id` > 0)"
            }
          },
          {
            "table": {
              "table_name": "war_sum_amount",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "test_uchur_k.products_categories.product_id"
              ],
              "rows_examined_per_scan": 15,
              "rows_produced_per_join": 22,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "0.53",
                "eval_cost": "2.29",
                "prefix_cost": "16.39",
                "data_read_per_join": "366"
              },
              "used_columns": [
                "product_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "warehouses_destination_products_amount",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "idx_storefront_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id",
                "destination_id",
                "storefront_id"
              ],
              "key_length": "9",
              "ref": [
                "test_uchur_k.products_categories.product_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 22,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "2.29",
                "prefix_cost": "18.69",
                "data_read_per_join": "366"
              },
              "used_columns": [
                "destination_id",
                "storefront_id",
                "product_id",
                "amount"
              ],
              "attached_condition": "<if>(found_match(warehouses_destination_products_amount), (((case `test_uchur_k`.`products`.`is_stock_split_by_warehouses` when 'Y' then `test_uchur_k`.`warehouses_destination_products_amount`.`amount` else `test_uchur_k`.`products`.`amount` end) > 0) or (`test_uchur_k`.`products`.`tracking` = 'D')), true)"
            }
          },
          {
            "table": {
              "table_name": "popularity",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "total"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "test_uchur_k.products_categories.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 22,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "2.29",
                "prefix_cost": "20.98",
                "data_read_per_join": "733"
              },
              "used_columns": [
                "product_id",
                "total"
              ]
            }
          }
        ]
      }
    }
  }
}

Result

product_id product company_name product_type parent_product_id
51480 Термокружка UCHUR Ethno v2 цв. Черный 620ml UCHUR(Астана) P 0
51479 Термокружка UCHUR TERRA цв. Черный 400ml UCHUR(Астана) P 0
132 Кружка туристическая UCHUR PEAK цв. Белый UCHUR(Астана) P 0
3 Термокружка UCHUR Итии цв. Черный 580ml UCHUR(Астана) P 0
2 Термокружка UCHUR Ceramic Thermo цв. Черный 500ml с кожаной вставкой UCHUR(Астана) P 0
66 Термокружка UCHUR Discovery цв. Черный 500ml UCHUR(Астана) P 0
133 Термокружка UCHUR Ethno цв. Черный 600ml UCHUR(Астана) P 0
51471 Термос STANLEY CLASSIC 1,4L (10-12417-001) тёмно-зелёный UCHUR(Астана) P 0
51472 Термос STANLEY CLASSIC 1,4L (10-12417-006) черный UCHUR(Астана) P 0
51470 Термобутылка STANLEY The Wellspring Bottle 709ML (10-13338-0011) белый UCHUR(Астана) P 0
51459 Термокружка STANLEY Quencher H2.0 0,88L (10-11912-081) с трубочкой, бежевая UCHUR(Астана) P 0
51529 Чайник из авиационного алюминия Hispeed LHJG-05 2L 17.5*11cm UCHUR(Астана) P 0
51457 Термокружка STANLEY Quencher H2.0 0,59L (10-11911-024) с трубочкой, бежевая UCHUR(Астана) P 0
51460 Термокружка STANLEY Quencher H2.0 0,88L (10-11912-083) с трубочкой, белая UCHUR(Астана) P 0
51501 Набор посуды Hispeed LHJG-04 (2 Кастрюли и сковорода) UCHUR(Астана) P 0
51464 Термокружка STANLEY Quencher H2.0 1,18L (10-11913-077) с трубочкой, белая UCHUR(Астана) P 0
51478 Термос STANLEY CLASSIC 1,9L (10-11969-001) темно-зеленый UCHUR(Астана) P 0
51469 Термобутылка STANLEY The Wellspring Bottle 709ML (10-13338-0009) черная UCHUR(Астана) P 0
51486 Термокружка COSTA JTL-2001K-L 380 мл., цв. черный UCHUR(Астана) P 0
51461 Термокружка STANLEY Quencher H2.0 0,88L (10-11912-094) с трубочкой, светло-розовая UCHUR(Астана) P 0
51467 Термокружка STANLEY Protour 0,89L (10-12981-009) белая UCHUR(Астана) P 0
51475 Термос STANLEY Adventure 0,75L (10-10818-014) зелёный UCHUR(Астана) P 0
51477 Набор стопок STANLEY Adventure 59ML с флягой 0,23L (10-01883-058) зеленый UCHUR(Астана) P 0
51473 Термос STANLEY Adventure 0,5L (10-10816-015) зелёный UCHUR(Астана) P 0
51463 Термокружка STANLEY Quencher H2.0 1,18L (10-11913-075) с трубочкой, светло-серая UCHUR(Астана) P 0
51516 Ланчбокс Hispeed FH-03 1000ml 19*13*7.5cm (Алюмиевый) UCHUR(Астана) P 0
51532 Набор столовых приборов Hispeed CJ-09 (нож,вилка,ложка) UCHUR(Астана) P 0
51458 Термокружка STANLEY Quencher H2.0 0,88L (10-11912-079) с трубочкой, серая UCHUR(Астана) P 0
51492 Термос COSTA HC03JPB-17-H 800 мл., цв. розовый UCHUR(Астана) P 0
51514 Ланчбокс Hispeed FH-01 500ml 15*8*5cm (Алюминиевый) UCHUR(Астана) P 0
51468 Термокружка STANLEY Protour 0,89L (10-12981-010) черная UCHUR(Астана) P 0
51476 Термос STANLEY Adventure 0,75L (10-10818-051) белый UCHUR(Астана) P 0