SELECT 
  cscart_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      cscart_products_categories.link_type = "M", 
      CONCAT(
        cscart_products_categories.category_id, 
        "M"
      ), 
      cscart_products_categories.category_id
    )
  ) AS category_ids 
FROM 
  cscart_products_categories 
  INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id 
  AND cscart_categories.storefront_id IN (0, 1) 
  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') 
WHERE 
  cscart_products_categories.product_id IN (
    8037, 8205, 8140, 8093, 6664, 10413, 
    8204, 10140, 8110, 8192, 8099, 7963, 
    8157, 10685, 8231, 10201, 8374, 7883, 
    7532, 7530, 10744, 9968, 7534, 8139
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00076

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "range",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "rows": 24,
          "filtered": 100,
          "index_condition": "cscart_products_categories.product_id in (8037,8205,8140,8093,6664,10413,8204,10140,8110,8192,8099,7963,8157,10685,8231,10201,8374,7883,7532,7530,10744,9968,7534,8139)"
        }
      },
      {
        "table": {
          "table_name": "cscart_categories",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": ["lillyshop_lillyshop.cscart_products_categories.category_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "cscart_categories.storefront_id in (0,1) 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')"
        }
      }
    ]
  }
}

Result

product_id category_ids
6664 892M
7530 892M
7532 892M
7534 510M
7883 892M
7963 431M
8037 447M
8093 892M
8099 507M
8110 447M
8139 506M
8140 892M
8157 507M
8192 447M
8204 431M
8205 447M
8231 507M
8374 506M
9968 407M
10140 431M
10201 892M
10413 431M
10685 507M
10744 892M