SELECT 
  products.product_id, 
  descr1.product as product, 
  companies.company as company_name, 
  products.kl_erp_inventory_id, 
  products.product_type, 
  products.parent_product_id, 
  products.master_product_offers_count, 
  products.master_product_id, 
  products.company_id, 
  products.kl_enable_qc, 
  products.kl_qc_amount 
FROM 
  cscart_products as products 
  LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id 
  AND descr1.lang_code = 'en' 
  LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id 
  AND prices.lower_limit = 1 
  AND prices.usergroup_id IN (0, 1) 
  LEFT JOIN cscart_companies AS companies ON companies.company_id = products.company_id 
  INNER JOIN cscart_products_categories as products_categories USE INDEX (
    idx_products_categories_composite
  ) ON products_categories.product_id = products.product_id 
  INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id 
  AND cscart_categories.status IN ('A', 'H') 
  AND cscart_categories.storefront_id IN (0, 1) 
  LEFT JOIN cscart_product_sales USE INDEX (
    idx_product_sales_category_amount
  ) ON cscart_product_sales.product_id = products.product_id 
  AND cscart_product_sales.category_id = products_categories.category_id 
WHERE 
  1 
  AND cscart_categories.category_id IN (2671) 
  AND (
    companies.status IN ('A') 
    OR products.company_id = 0
  ) 
  AND products.company_id IN (13, 0) 
  AND (
    products.amount > 0 
    OR products.tracking = 'D'
  ) 
  AND products.status IN ('A') 
  AND products.parent_product_id = 0 
  AND products.master_product_status IN ('A') 
  AND products.master_product_id = 0 
  AND products.company_id > 0 
GROUP BY 
  products.product_id 
ORDER BY 
  cscart_product_sales.amount desc, 
  products.product_id ASC 
LIMIT 
  0, 96

Query time 0.05853

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1611.66"
    },
    "ordering_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "grouping_operation": {
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "cscart_categories",
              "access_type": "const",
              "possible_keys": [
                "PRIMARY",
                "p_category_id",
                "idx_categories_storefront_status",
                "idx_categories_usergroup_status",
                "idx_categories_status_id_path"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "ref": [
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.10",
                "prefix_cost": "0.00",
                "data_read_per_join": "2K"
              },
              "used_columns": [
                "category_id",
                "status",
                "storefront_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "products",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "age_verification",
                "status",
                "idx_parent_product_id",
                "idx_master_product_id",
                "youtube_link",
                "idx_products_parent_lookup",
                "idx_products_status_company",
                "idx_products_master_status",
                "idx_products_inventory",
                "idx_products_status_company_master",
                "idx_products_main_query",
                "idx_products_query_opt",
                "idx_products_composite_query",
                "idx_kl_qc_enabled"
              ],
              "key": "status",
              "used_key_parts": [
                "status"
              ],
              "key_length": "3",
              "ref": [
                "const"
              ],
              "rows_examined_per_scan": 8877,
              "rows_produced_per_join": 5,
              "filtered": "0.07",
              "cost_info": {
                "read_cost": "710.68",
                "eval_cost": "0.59",
                "prefix_cost": "1598.38",
                "data_read_per_join": "30K"
              },
              "used_columns": [
                "product_id",
                "kl_erp_inventory_id",
                "product_type",
                "status",
                "company_id",
                "amount",
                "kl_enable_qc",
                "kl_qc_amount",
                "tracking",
                "parent_product_id",
                "master_product_id",
                "master_product_status",
                "master_product_offers_count"
              ],
              "attached_condition": "((`cscart_db`.`products`.`master_product_id` = 0) and (`cscart_db`.`products`.`parent_product_id` = 0) and (`cscart_db`.`products`.`company_id` in (13,0)) and ((`cscart_db`.`products`.`amount` > 0) or (`cscart_db`.`products`.`tracking` = 'D')) and (`cscart_db`.`products`.`master_product_status` = 'A') and (`cscart_db`.`products`.`company_id` > 0))"
            }
          },
          {
            "table": {
              "table_name": "descr1",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "product_id",
                "idx_product_desc_lang",
                "idx_product_name_search",
                "idx_product_desc_sort"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id",
                "lang_code"
              ],
              "key_length": "9",
              "ref": [
                "cscart_db.products.product_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 5,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "4.02",
                "eval_cost": "0.59",
                "prefix_cost": "1602.99",
                "data_read_per_join": "27K"
              },
              "used_columns": [
                "product_id",
                "lang_code",
                "product"
              ]
            }
          },
          {
            "table": {
              "table_name": "prices",
              "access_type": "ref",
              "possible_keys": [
                "usergroup",
                "product_id",
                "lower_limit",
                "usergroup_id",
                "idx_product_prices_usergroup_limit",
                "idx_prices_discount_lookup",
                "idx_prices_min_calc",
                "idx_prices_usergroup_lookup",
                "idx_prices_usergroup_product"
              ],
              "key": "idx_prices_min_calc",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "cscart_db.products.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 5,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "1.55",
                "eval_cost": "0.59",
                "prefix_cost": "1605.13",
                "data_read_per_join": "142"
              },
              "used_columns": [
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "attached_condition": "<if>(is_not_null_compl(prices), ((`cscart_db`.`prices`.`lower_limit` = 1) and (`cscart_db`.`prices`.`usergroup_id` in (0,1))), true)"
            }
          },
          {
            "table": {
              "table_name": "companies",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "company_id"
              ],
              "key_length": "4",
              "ref": [
                "cscart_db.products.company_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 5,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "1.48",
                "eval_cost": "0.59",
                "prefix_cost": "1607.20",
                "data_read_per_join": "41K"
              },
              "used_columns": [
                "company_id",
                "status",
                "company"
              ],
              "attached_condition": "<if>(found_match(companies), ((`cscart_db`.`companies`.`status` = 'A') or (`cscart_db`.`products`.`company_id` = 0)), true)"
            }
          },
          {
            "table": {
              "table_name": "products_categories",
              "access_type": "ref",
              "possible_keys": [
                "idx_products_categories_composite"
              ],
              "key": "idx_products_categories_composite",
              "used_key_parts": [
                "product_id",
                "category_id"
              ],
              "key_length": "6",
              "ref": [
                "cscart_db.products.product_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 5,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "1.77",
                "eval_cost": "0.60",
                "prefix_cost": "1609.57",
                "data_read_per_join": "95"
              },
              "used_columns": [
                "product_id",
                "category_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "cscart_product_sales",
              "access_type": "ref",
              "possible_keys": [
                "idx_product_sales_category_amount"
              ],
              "key": "idx_product_sales_category_amount",
              "used_key_parts": [
                "category_id",
                "product_id"
              ],
              "key_length": "6",
              "ref": [
                "const",
                "cscart_db.products.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 5,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "1.50",
                "eval_cost": "0.60",
                "prefix_cost": "1611.66",
                "data_read_per_join": "95"
              },
              "used_columns": [
                "category_id",
                "product_id",
                "amount"
              ]
            }
          }
        ]
      }
    }
  }
}

Result

product_id product company_name kl_erp_inventory_id product_type parent_product_id master_product_offers_count master_product_id company_id kl_enable_qc kl_qc_amount
36470 Pleaser Delay Wipes for Men| Pack of 10 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
36823 Pleaser Topical Spray | Non-Transferrable Spray For Men | 20 gm | Pack of 1 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
36354 ALPHA BOOSTER OF TESTO | 60 Vegetarian Tablets | Supports Testosterone Levels and Male Vitality Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69202 Reload Erexon | Pack of 1 (60 Tablets) | With Horny Goat Weed, Muira Puama & Vitamin B12 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69204 Reload Sparq 60 Tablets For Vitality Support, Stamina Boost, Supports Metabolism & Relaxation Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69205 Tease Ultra Thin Condoms for Men, Pack of 3 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
13478 Premium Shilajit 20gm Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
36824 Pleaser Topical Spray | Non-Transferrable Spray For Men | 40 gm | Pack of 2 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
11185 Gokshura Tablets For Men's Wellness - Boost Stamina - 60 Tablets Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
35874 Shilajit Capsules for Strength, Stamina, Vigour & Vitality - 60 Capsules Pack of 3 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
35897 Natural & Pure Shilajit Resin, Ayurvedic Energy Booster & Stamina Enhancer - 15gm and Testo Boost for Men, Testosterone Booster Tablets - 60 Veg Tablets Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
36353 ALPHA BOOSTER OF TESTO | 30 Vegetarian Tablets | Supports Testosterone Levels and Vitality Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
36825 Pleaser Topical Spray | Non-Transferrable Spray For Men | 60 gm | Pack of 3 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
36826 Pleaser Topical Spray | Non-Transferrable Spray For Men | 80 gm | Pack of 4 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
66445 Exygra Chocolate Flavoured Condom - Pack of 10 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69208 Tease Ultra Thin Condoms for Men, Pack of 10 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69209 Tease Ultra Thin Chocolate flavour Condoms for Men, Pack of 10 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69212 Tease Chocolate Favoured Lubes for Men 100ml Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
11191 Shilajit Capsules - For Strength & Stamina - 60 Tablets Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
11193 Gokshura and Multivitamins For Men - Improves Men's Performance & Strength - 120 Tablets Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
11195 Sexual Wellness Kit with Shilajit Capsules and Testos Boost - Ayurvedic Supplement to improve Stamina & Strength- 60 Capsules Each Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
11196 Testo Boost & Gokshura For Men - For Improved Performance - Combo Pack - 60 Capsules each Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
24605 Premium Shilajit 20gm each Pack of 2 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
35858 Gokshura Tablets for Men - 60 Veg Tablets Pack of 2 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
35873 Shilajit Capsules for Strength, Stamina, Vigour & Vitality - 60 Capsules Pack of 2 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
35888 Natural & Pure Shilajit Resin, Ayurvedic Energy Booster & Stamina Enhancer - 15gm Pack of 2 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
35893 Natural & Pure Shilajit Resin, Ayurvedic Energy Booster & Stamina Enhancer - 15gm and Shilajit Capsules - 60 Capsules Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
35912 Testo Boost for Men, Testosterone Booster Tablets for Energy, Stamina & Muscle Growth - 60 Veg Tablets Pack of 2 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
66443 Exygra Longlast Bubblegum Flavoured Condom - Pack of 10 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
66444 Exygra Strawberry Flavoured Condom - Pack of 10 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69203 Reload D-Lay Vitality & Prolong Release Tablets | 60 Count | Supplements for Men Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69206 Tease Ultra Thin Chocolate flavour Condoms for Men, Pack of 3 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69207 Tease Ultra Thin Strawberry flavour Condoms for Men, Pack of 3 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69210 Tease Ultra Thin Strawberry flavour Condoms for Men, Pack of 10 Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0
69211 Tease Natural Lubes for Men 100ml Roadskye Tradecom Pvt. Ltd. P 0 0 0 13 0 0