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 (
    19860, 19820, 19863, 19865, 19866, 20154, 
    19868, 19869, 19870, 19871, 19872, 
    19873, 19875, 19874, 19876, 20087, 
    19877, 19878, 19879, 19880, 19881, 
    19882, 19883, 19884, 19885, 19886, 
    19888, 19889, 19890, 19891, 19892, 
    19893, 19894, 19895, 19896, 19897, 
    19898, 19899, 19900, 19901, 19902, 
    19903, 19904, 19905, 19925, 19906, 
    19907, 19908, 19909, 19910, 19911, 
    20576, 20088, 20089, 20091, 20092, 
    20093, 20094, 18661, 18662, 19131, 
    18664, 20724, 20725, 20728, 20955, 
    20956, 20957, 20958, 20959, 22277, 
    20971, 21078, 21102, 20972, 20973, 
    20974, 21103, 21923, 21924, 21925, 
    21926, 19867, 20065, 19887, 21749, 
    20723, 20726, 20727
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00122

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": 89,
          "filtered": 100,
          "index_condition": "cscart_products_categories.product_id in (19860,19820,19863,19865,19866,20154,19868,19869,19870,19871,19872,19873,19875,19874,19876,20087,19877,19878,19879,19880,19881,19882,19883,19884,19885,19886,19888,19889,19890,19891,19892,19893,19894,19895,19896,19897,19898,19899,19900,19901,19902,19903,19904,19905,19925,19906,19907,19908,19909,19910,19911,20576,20088,20089,20091,20092,20093,20094,18661,18662,19131,18664,20724,20725,20728,20955,20956,20957,20958,20959,22277,20971,21078,21102,20972,20973,20974,21103,21923,21924,21925,21926,19867,20065,19887,21749,20723,20726,20727)"
        }
      },
      {
        "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
18661 1075M
18662 1075M
18664 1075M
19131 1075M
19820 1075M
19860 1075M
19863 1075M
19865 1075M
19866 1075M
19867 1075M
19868 1075M
19869 1075M
19870 1075M
19871 1075M
19872 1075M
19873 1075M
19874 1075M
19875 1075M
19876 1075M
19877 1075M
19878 1075M
19879 1075M
19880 1075M
19881 1075M
19882 1075M
19883 1075M
19884 1075M
19885 1075M
19886 1075M
19887 1075M
19888 1075M
19889 1075M
19890 1075M
19891 1075M
19892 1075M
19893 1075M
19894 1075M
19895 1075M
19896 1075M
19897 1075M
19898 1075M
19899 1075M
19900 1075M
19901 1075M
19902 1075M
19903 1075M
19904 1075M
19905 1075M
19906 1075M
19907 1075M
19908 1075M
19909 1075M
19910 1075M
19911 1075M
19925 1075M
20065 1075M
20087 1075M
20088 1075M
20089 1075M
20091 1075M
20092 1075M
20093 1075M
20094 1075M
20154 1075M
20576 1075M
20723 1075M
20724 1075M
20725 1075M
20726 1075M
20727 1075M
20728 1075M
20955 1075M
20956 1075M
20957 1075M
20958 1075M
20959 1075M
20971 1075M
20972 1075M
20973 1075M
20974 1075M
21078 1075M
21102 1075M
21103 1075M
21749 1075M
21923 1075M
21924 1075M
21925 1075M
21926 1075M
22277 1075M