SELECT 
  SQL_CALC_FOUND_ROWS products.product_id, 
  descr1.product as product, 
  companies.company as company_name, 
  products.product_type, 
  products.parent_product_id, 
  cscart_product_review_prepared_data.average_rating average_rating, 
  cscart_product_review_prepared_data.reviews_count product_reviews_count 
FROM 
  cscart_products as products 
  LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id 
  AND descr1.lang_code = 'vi' 
  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 
  LEFT JOIN cscart_product_review_prepared_data ON cscart_product_review_prepared_data.product_id = products.product_id 
  AND cscart_product_review_prepared_data.storefront_id = 0 
  LEFT JOIN cscart_product_popularity as popularity ON popularity.product_id = products.product_id 
WHERE 
  1 
  AND companies.status IN ('A') 
  AND (
    products.amount > 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 (
    (
      1 
      AND products.product_id IN (
        49185, 44951, 47657, 40761, 36272, 49290, 
        3287, 43825, 1586, 6544, 33310, 34548, 
        40929, 2870, 35730, 6091, 2961, 2135, 
        45587, 49360
      )
    ) 
    AND companies.status IN ('A') 
    AND prices.usergroup_id IN (0, 0, 1)
  ) 
GROUP BY 
  products.product_id 
ORDER BY 
  popularity.total desc, 
  products.product_id ASC

Query time 0.02596

JSON explain

{
  "query_block": {
    "select_id": 1,
    "filesort": {
      "sort_key": "popularity.total desc, products.product_id",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "products",
              "access_type": "range",
              "possible_keys": ["PRIMARY", "status"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "rows": 20,
              "filtered": 52.06833649,
              "index_condition": "products.product_id in (49185,44951,47657,40761,36272,49290,3287,43825,1586,6544,33310,34548,40929,2870,35730,6091,2961,2135,45587,49360)",
              "attached_condition": "(products.amount > 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` = 'A'"
            }
          },
          {
            "table": {
              "table_name": "descr1",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "product_id"],
              "key": "PRIMARY",
              "key_length": "11",
              "used_key_parts": ["product_id", "lang_code"],
              "ref": ["dev_db.products.product_id", "const"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "trigcond(descr1.lang_code = 'vi')"
            }
          },
          {
            "table": {
              "table_name": "companies",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "4",
              "used_key_parts": ["company_id"],
              "ref": ["dev_db.products.company_id"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "companies.`status` = 'A'"
            }
          },
          {
            "table": {
              "table_name": "cscart_product_review_prepared_data",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "7",
              "used_key_parts": ["product_id", "storefront_id"],
              "ref": ["dev_db.products.product_id", "const"],
              "rows": 1,
              "filtered": 100
            }
          },
          {
            "table": {
              "table_name": "popularity",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "total"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["dev_db.products.product_id"],
              "rows": 1,
              "filtered": 100
            }
          },
          {
            "table": {
              "table_name": "prices",
              "access_type": "ref",
              "possible_keys": [
                "usergroup",
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "key": "product_id",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["dev_db.products.product_id"],
              "rows": 1,
              "filtered": 99.9960556,
              "attached_condition": "prices.lower_limit = 1 and prices.usergroup_id in (0,0,1) and prices.usergroup_id in (0,0,1)"
            }
          },
          {
            "table": {
              "table_name": "products_categories",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "pt"],
              "key": "pt",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["dev_db.products.product_id"],
              "rows": 1,
              "filtered": 100
            }
          },
          {
            "table": {
              "table_name": "cscart_categories",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "p_category_id"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["category_id"],
              "ref": ["dev_db.products_categories.category_id"],
              "rows": 1,
              "filtered": 100,
              "using_index": true
            }
          }
        ]
      }
    }
  }
}

Result

product_id product company_name product_type parent_product_id average_rating product_reviews_count
6091 The Touch Of Nature, Bộ Quà Tặng Gia Vị Hữu Cơ Và Tinh Dầu Thiên Nhiên Vina Samex P 0 5.00 1
3287 Set Hộp Gỗ Các Loại Gia Vị, Hộp Quà Gia Vị Bếp, Gia Vị Hữu Cơ, Gia Vị Cao Cấp, Thực Phẩm Hữu Cơ, Set Quà Tặng Gia Đình The Hồ Tiêu P 0 5.00 2
35730 Bộ Tượng Gia Đình Mèo Bằng Gốm, Tượng Mèo Trang Trí, Tượng Mèo Gốm Sứ Thủ Công, Tượng Mèo Đẹp, Quà Tặng Mèo Độc Đáo, Quà Tân Gia, Quà Sinh Nhật HCERAMIC P 0 5.00 6
43825 Set Quà 2 Hộp Trà Shan Tuyết Cổ Thụ, Trà Cổ, Trà Xanh, Trà Việt Nam, Quà Tặng Việt Nam, Quà Tặng Lý Tưởng, Không Hoá Chất ShanLuv-Vietnamesetea P 0 5.00 15
36272 Hộp Quà Atiso Hữu Cơ - Combo 1, Trà Atiso Túi Lọc, Cao Atiso, Atiso Đà Lạt, Quà Tặng Sức Khỏe, Quà Tặng Cho Người Thân, Quà Tặng Ý Nghĩa LArti's Farm P 0 4.68 22
47657 Hộp Quà 'Vị Tết' Mộc Truly Huế 2023, Hương Vị Đặc Sản Cố Đô, Thiết Kế Việt Vẽ Tay, Quà Tặng Đặc Sản, Quà Việt Nam Mộc Truly Huế P 0 5.00 14
1586 Bộ Mứt Nón 3 Miền, Mứt Huế, Đặc Sản Việt, Quà Tặng Việt, Mứt Thanh Trà, Mứt Gừng, Hạt Sen Sấy, Set Quà Mứt Mộc Truly Huế P 0 5.00 16
40761 Nước Mắm Cốt Nhĩ Cá Cơm 750ml, Hộp Gỗ, Nước Mắm Cá Cơm, Đặc Sản Bình Thuận, Quà Tặng Đặc Sản, Nước Chấm Cao Cấp Nước mắm Hoàng Gia P 0 5.00 9
2961 Bia Craft Tê Tê Serious IPA, Vị Đắng Đậm Đà Nhưng Không Gay Gắt, Hương Vị Nhẹ Nhàng, Bia Cổ Điển, Thành Phần Chất Lượng TÊ TÊ BREWING P 0 4.30 10
2135 Bia Craft Belgo Wit (17 Ibu), Bia Ủ Thủ Công Theo Công Thức Truyền Thống, Vị Cân Bằng Giữa Ngọt - Chát Và Cay Nhẹ Belgo & Origin P 0 5.00 5
2870 Bộ Chén Bát Đĩa Sứ Ocean Waves (Bộ 10 Món) Cho 1 Người, Sứ Tráng Men Bóng, Men Hỏa Biến Cao Cấp, Sang Trọng, Nâng Tầm Không Gian Gốm Đông Gia P 0 5.00 9
34548 Set Quà Ngũ Cốc & Kombucha, Hương Vị Tự Nhiên, Dinh Dưỡng Đủ Đầy, Quà Tặng Ngày Lễ, Gói Gọn Yêu Thương Happi Oha P 0
40929 Hộp Quà Nến Thơm Hũ Gốm Tráng Men OnaTree - Vietnamese Cosmetics P 0 5.00 7
45587 Bia Craft Chai Kombucha Tê Tê Kick - Bia Kombucha Ít Calo, Hương Bia Đức Cổ, Thức Uống Lợi Khuẩn, Tốt Cho Tiêu Hóa TÊ TÊ BREWING P 0 5.00 1
49185 Hộp Quà Dừa Sáp "Vàng Trắng Trà Vinh", Tinh Hoa Đặc Sản Trà Vinh, Món Quà Tinh Tế & Sang Trọng, Thơm Ngon & Bổ Dưỡng, Quà Biếu Ý Nghĩa Vicosap - Dừa sáp Cầu Kè Trà Vinh P 0
44951 Set Quà 2 Hũ Bơ Đậu Phộng & Bơ Hạt Điều, Quà Tặng Thực Phẩm, Quà Tặng Sức Khỏe, Hộp Quà Tặng Healhy Life, Món Quà Tinh Tế SPOON it UP P 0 0
6544 Hộp Quà “An Lành 2” (Tôm Đất Sông Khô, Củ Kiệu, Bánh Phồng Tôm), Quà Tặng Đặc Sản Việt Nam, Món Ăn Ngày Tết, Hộp Quà Tết Ý Nghĩa NaGi - Tôm khô Cà Mau P 0 5.00 1
49290 Hộp Quà Mùa Craft Sake 3 Chai Sake (Vị Cổ Điển, Vị Dứa Ớt, Vị Chanh Dây Tiêu Thất), Sake Việt Nam, Quà Tặng Tinh Tế, Quà Tặng Sang Trọng, Quà Đối Tác Mùa Craft Sake P 0