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 (
    415304, 415296, 415297, 415303, 415291, 
    415290, 415228, 415308, 415289, 415240, 
    427824, 415310, 415305, 427787, 415219, 
    415294, 415302, 415299, 415311, 415242, 
    415300, 415224, 415238, 415217, 415312, 
    415211, 427780, 415241, 415298, 415307, 
    415288, 415232, 415293, 427786, 427775, 
    427782, 427823, 415295, 415306, 415235, 
    427781, 428031, 427738, 427829, 415309, 
    428033, 428032, 427821, 427777, 415292, 
    427779, 427778, 427788, 427826, 427789, 
    415213, 435511, 435512, 435513, 435515, 
    435514, 435516, 435517
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00194

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "146.74"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 91,
            "rows_produced_per_join": 91,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "19.34",
              "eval_cost": "18.20",
              "prefix_cost": "37.54",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (415304,415296,415297,415303,415291,415290,415228,415308,415289,415240,427824,415310,415305,427787,415219,415294,415302,415299,415311,415242,415300,415224,415238,415217,415312,415211,427780,415241,415298,415307,415288,415232,415293,427786,427775,427782,427823,415295,415306,415235,427781,428031,427738,427829,415309,428033,428032,427821,427777,415292,427779,427778,427788,427826,427789,415213,435511,435512,435513,435515,435514,435516,435517))"
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "webmarco.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "91.00",
              "eval_cost": "0.91",
              "prefix_cost": "146.74",
              "data_read_per_join": "26K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`webmarco`.`cscart_categories`.`storefront_id` in (0,1)) and ((`webmarco`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`webmarco`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`webmarco`.`cscart_categories`.`usergroup_ids`)) and (`webmarco`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
415211 8229M
415213 5256M
415217 5014M
415219 3407M
415224 3185M
415228 10336M
415232 5270M
415235 3095M
415238 3185
415240 4299M
415241 6579M
415242 5522M
415288 2851M
415289 3487M
415290 4254M
415291 5821M
415292 7301M
415293 4746M
415294 7301M
415295 5821M
415296 9720M
415297 4254M
415298 7849M
415299 7849M
415300 3060M
415302 3087M
415303 4575M
415304 9720
415305 3631
415306 3631
415307 10438
415308 2985M
415309 3060M
415310 8823M
415311 4903M
415312 3407M
427738 4317,4418M
427775 8440,2910M
427777 6448,6928,7008,6975M
427778 2910,6897,7217M
427779 3087M
427780 2910,3224,6897M
427781 2910,7464M
427782 1516M
427786 2910,6809
427787 3087M
427788 3228,3231,5152M
427789 10300M
427821 9053M
427823 3933M
427824 5039M
427826 6426M
427829 5164,9434,9435M
428031 5597,5968M
428032 3048M
428033 3002,3144,5519M
435511 2601M
435512 2601M
435513 2601M
435514 2601M
435515 2601M
435516 2601M
435517 2601M