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 (
    4109, 4032, 4033, 4034, 4035, 4036, 4164, 
    4161, 4162, 4175, 4176, 4177, 4178, 
    4179, 4180, 4181, 4182, 4183, 4184, 
    4185, 4186, 4187, 4188, 4192, 4193, 
    4194, 4195, 4199, 4200, 4201, 4202, 
    4367, 4020, 4021, 4022, 4023, 3934, 
    3932, 3970, 4024, 4014, 4065, 4113, 
    4086, 4089, 4092, 4093, 4097, 4018, 
    4028, 3929, 4052, 4010, 3955, 4150, 
    4151, 4050, 3930, 4189, 4037, 4038, 
    4039, 4040, 4025, 4119, 4126, 4127, 
    4072, 4145, 4146, 4147, 4060, 3974, 
    4041, 4103, 4148, 4102, 4366, 4064, 
    4062, 4101, 4063, 4074, 4075, 4076, 
    4077, 4078, 4079, 4080
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00154

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 91,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (4109,4032,4033,4034,4035,4036,4164,4161,4162,4175,4176,4177,4178,4179,4180,4181,4182,4183,4184,4185,4186,4187,4188,4192,4193,4194,4195,4199,4200,4201,4202,4367,4020,4021,4022,4023,3934,3932,3970,4024,4014,4065,4113,4086,4089,4092,4093,4097,4018,4028,3929,4052,4010,3955,4150,4151,4050,3930,4189,4037,4038,4039,4040,4025,4119,4126,4127,4072,4145,4146,4147,4060,3974,4041,4103,4148,4102,4366,4064,4062,4101,4063,4074,4075,4076,4077,4078,4079,4080)"
    },
    "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": ["ymonline_livedata.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
3929 335M
3930 335M
3932 335M
3934 335M
3955 335M
3970 335M
3974 335M
4010 335M
4014 335M
4018 335M
4020 335M
4021 335M
4022 335M
4023 335M
4024 335M
4025 335M
4028 335M
4032 335M
4033 335M
4034 335M
4035 335M
4036 335M
4037 335M
4038 335M
4039 335M
4040 335M
4041 335M
4050 335M
4052 335M
4060 335M
4062 335M
4063 335M
4064 335M
4065 335M
4072 335M
4074 335M
4075 335M
4076 335M
4077 335M
4078 335M
4079 335M
4080 335M
4086 335M
4089 335M
4092 335M
4093 335M
4097 335M
4101 335M
4102 335M
4103 335M
4109 335M
4113 335M
4119 335M
4126 335M
4127 335M
4145 335M
4146 335M
4147 335M
4148 335M
4150 335M
4151 335M
4161 335M
4162 335M
4164 335M
4175 335M
4176 335M
4177 335M
4178 335M
4179 335M
4180 335M
4181 335M
4182 335M
4183 335M
4184 335M
4185 335M
4186 335M
4187 335M
4188 335M
4189 335M
4192 335M
4193 335M
4194 335M
4195 335M
4199 335M
4200 335M
4201 335M
4202 335M
4366 335M
4367 335M