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.company_id = 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 (
    1233005, 1233008, 1233011, 1233012, 
    1233004, 1233001, 1232994, 1232998, 
    1232999, 1233020, 1233022, 1238147, 
    1238155, 1238164, 1238132, 1238131, 
    1233023, 1238120, 1238126, 1232993, 
    1232979, 1232940, 1232935, 1232906, 
    1232897, 1232946, 1232908, 1232977, 
    1232975, 1232947, 1232971, 1232966, 
    1232953, 1232965, 1232973
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.06792

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "87.50"
    },
    "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": 72,
            "rows_produced_per_join": 72,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "8.30",
              "eval_cost": "7.20",
              "prefix_cost": "15.50",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`maniamall_cscart`.`cscart_products_categories`.`product_id` in (1233005,1233008,1233011,1233012,1233004,1233001,1232994,1232998,1232999,1233020,1233022,1238147,1238155,1238164,1238132,1238131,1233023,1238120,1238126,1232993,1232979,1232940,1232935,1232906,1232897,1232946,1232908,1232977,1232975,1232947,1232971,1232966,1232953,1232965,1232973))"
          }
        },
        {
          "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": [
              "maniamall_cscart.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 3,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "64.80",
              "eval_cost": "0.36",
              "prefix_cost": "87.50",
              "data_read_per_join": "9K"
            },
            "used_columns": [
              "category_id",
              "company_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`maniamall_cscart`.`cscart_categories`.`company_id` = 1) and ((`maniamall_cscart`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`maniamall_cscart`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`maniamall_cscart`.`cscart_categories`.`usergroup_ids`))) and (`maniamall_cscart`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
1232897 4528,16878M
1232906 4528,16886M
1232908 4528,16886M
1232935 4528,16890M
1232940 4528,16890M
1232946 4528,16840M
1232947 4528,42632,16840M
1232953 4528,42632,16840M
1232965 4528,16840M
1232966 4528,42632,16840M
1232971 4528,16895M
1232973 4528,16895M
1232975 4528,16895M
1232977 16895M
1232979 42632,16900M
1232993 42632,16894M
1232994 16894M
1232998 42632,16894M
1232999 42632,16840M
1233001 42632,16840M
1233004 42632,16840M
1233005 42632,16840M
1233008 42632,16840M
1233011 42632,16840M
1233012 16840M
1233020 16840M
1233022 16892M
1233023 42632,16892M
1238120 4528,42632,16893M
1238126 4528,16868M
1238131 4528,16894M
1238132 4528,16863,42632,16867M
1238147 4528,16840,16863M
1238155 4528,16863M
1238164 4528,16863M