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 (
    11964, 18422, 11851, 11814, 11672, 11852, 
    12946, 11919, 11853, 11673, 13219, 
    13349, 11815, 11674, 12421, 13087, 
    11675, 7778, 6943, 11854, 13382, 13168, 
    11731, 13383, 12516, 12517, 7278, 11941, 
    11942, 11676, 8062, 11677, 11678, 11732, 
    12947, 7995, 11733, 12214, 13073, 13384, 
    13385, 11734, 11943, 13350, 12518, 
    7896, 11855, 11679, 11856, 13386, 7541, 
    11850, 11680, 13074, 11681, 12215, 
    9699, 11857, 12948, 12949, 11682, 11683, 
    11805, 11684, 11735, 11858, 12216, 
    11685, 11736, 11686, 11687, 11688, 
    8159, 11859, 11737, 11689, 12950, 11944, 
    11860, 12217, 11738, 13262, 13387, 
    11816, 11861, 7658, 8377, 11862, 11863, 
    13089, 11690, 12073, 11864, 11739, 
    13169, 7161, 18099, 11865, 12519, 12520
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00192

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": 100,
          "filtered": 100,
          "index_condition": "cscart_products_categories.product_id in (11964,18422,11851,11814,11672,11852,12946,11919,11853,11673,13219,13349,11815,11674,12421,13087,11675,7778,6943,11854,13382,13168,11731,13383,12516,12517,7278,11941,11942,11676,8062,11677,11678,11732,12947,7995,11733,12214,13073,13384,13385,11734,11943,13350,12518,7896,11855,11679,11856,13386,7541,11850,11680,13074,11681,12215,9699,11857,12948,12949,11682,11683,11805,11684,11735,11858,12216,11685,11736,11686,11687,11688,8159,11859,11737,11689,12950,11944,11860,12217,11738,13262,13387,11816,11861,7658,8377,11862,11863,13089,11690,12073,11864,11739,13169,7161,18099,11865,12519,12520)"
        }
      },
      {
        "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
6943 468M
7161 468M
7278 468M
7541 468M
7658 468M
7778 468M
7896 468M
7995 468M
8062 468M
8159 468M
8377 468M
9699 468M
11672 468M
11673 468M
11674 468M
11675 468M
11676 468M
11677 468M
11678 468M
11679 468M
11680 468M
11681 468M
11682 468M
11683 468M
11684 468M
11685 468M
11686 468M
11687 468M
11688 468M
11689 468M
11690 468M
11731 468M
11732 468M
11733 468M
11734 468M
11735 468M
11736 468M
11737 468M
11738 468M
11739 468M
11805 468M
11814 468M
11815 468M
11816 468M
11850 468M
11851 468M
11852 468M
11853 468M
11854 468M
11855 468M
11856 468M
11857 468M
11858 468M
11859 468M
11860 468M
11861 468M
11862 468M
11863 468M
11864 468M
11865 468M
11919 468M
11941 468M
11942 468M
11943 468M
11944 468M
11964 468M
12073 468M
12214 468M
12215 468M
12216 468M
12217 468M
12421 468M
12516 468M
12517 468M
12518 468M
12519 468M
12520 468M
12946 468M
12947 468M
12948 468M
12949 468M
12950 468M
13073 468M
13074 468M
13087 468M
13089 468M
13168 468M
13169 468M
13219 468M
13262 468M
13349 468M
13350 468M
13382 468M
13383 468M
13384 468M
13385 468M
13386 468M
13387 468M
18099 468M
18422 468M