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 (
    431615, 431616, 431617, 431618, 431619, 
    431620, 431621, 431622, 431623, 431624, 
    431625, 431626, 431627, 431628, 431629, 
    431630, 431631, 431632, 431633, 431634, 
    431635, 431636, 431637, 431638, 431639, 
    431640, 431641, 431642, 431643, 431644, 
    431645, 431646, 431647, 431648, 431649, 
    431650, 431651, 431652, 431653, 431654, 
    431655, 431656, 431657, 431658
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00122

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "141.94"
    },
    "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": 88,
            "rows_produced_per_join": 88,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "18.74",
              "eval_cost": "17.60",
              "prefix_cost": "36.34",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (431615,431616,431617,431618,431619,431620,431621,431622,431623,431624,431625,431626,431627,431628,431629,431630,431631,431632,431633,431634,431635,431636,431637,431638,431639,431640,431641,431642,431643,431644,431645,431646,431647,431648,431649,431650,431651,431652,431653,431654,431655,431656,431657,431658))"
          }
        },
        {
          "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": "88.00",
              "eval_cost": "0.88",
              "prefix_cost": "141.94",
              "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
431615 9986,2722M
431616 9986,2722M
431617 9986,2722M
431618 9986,2722M
431619 9986,2722M
431620 9986,2722M
431621 9986,2722M
431622 9986,2722M
431623 9986,2722M
431624 9986,2722M
431625 9986,2722M
431626 9986,2722M
431627 9986,2722M
431628 9986,2722M
431629 9986,2722M
431630 9986,2722M
431631 9986,2722M
431632 9986,2722M
431633 9986,2722M
431634 9986,2722M
431635 9986,2722M
431636 9986,2722M
431637 9986,2722M
431638 9986,2722M
431639 9986,2722M
431640 9986,2722M
431641 9986,2722M
431642 9986,2722M
431643 9986,2722M
431644 9986,2722M
431645 9986,2722M
431646 9986,2722M
431647 9986,2722M
431648 9986,2722M
431649 9986,2722M
431650 9986,2722M
431651 9986,2722M
431652 9986,2722M
431653 9986,2722M
431654 9986,2722M
431655 9986,2722M
431656 9986,2722M
431657 9986,2722M
431658 9986,2722M