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 (
    10846, 7515, 20538, 9721, 20433, 20539, 
    19129, 20732, 19024, 19471, 20733, 
    20729, 9286, 18885, 19707, 19417, 19039, 
    19710, 8670, 19046, 19548, 8669, 19047, 
    19537, 20525, 20512, 20770, 20526, 
    20514, 19072, 7608, 20515, 9539
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00071

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": 33,
          "filtered": 100,
          "index_condition": "cscart_products_categories.product_id in (10846,7515,20538,9721,20433,20539,19129,20732,19024,19471,20733,20729,9286,18885,19707,19417,19039,19710,8670,19046,19548,8669,19047,19537,20525,20512,20770,20526,20514,19072,7608,20515,9539)"
        }
      },
      {
        "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
7515 1090M
7608 1090M
8669 1090M
8670 1090M
9286 1090M
9539 1090M
9721 1090M
10846 1090M
18885 1090M
19024 1090M
19039 1090M
19046 1090M
19047 1090M
19072 1090M
19129 1090M
19417 1090M
19471 1090M
19537 1090M
19548 1090M
19707 1090M
19710 1090M
20433 1090M
20512 1090M
20514 1090M
20515 1090M
20525 1090M
20526 1090M
20538 1090M
20539 1090M
20729 1090M
20732 1090M
20733 1090M
20770 1090M