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 (
    49309, 49306, 49304, 49302, 49300, 49297, 
    49290, 49289, 49288, 49287, 49281, 
    49265, 49256, 49251, 49230, 49225, 
    49221, 49204, 49205, 49199, 49192, 
    49191, 49186, 49185, 49182, 49183, 
    49169, 49164, 49148, 49149
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00624

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": 122,
          "filtered": 100,
          "index_condition": "cscart_products_categories.product_id in (49309,49306,49304,49302,49300,49297,49290,49289,49288,49287,49281,49265,49256,49251,49230,49225,49221,49204,49205,49199,49192,49191,49186,49185,49182,49183,49169,49164,49148,49149)"
        }
      },
      {
        "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": ["dev_db.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
49148 193,213M
49149 213,193M
49164 412,550,110,315,197M
49169 409,160M
49182 209,211,215M
49183 211,210,215M
49185 315,213,95,412,119M
49186 409,160M
49191 210M
49192 213,210,412,169M
49199 412,169M
49204 340M
49205 340M
49221 211,210,209,409,412,119M
49225 145M
49230 412,166,313M
49251 409,209,149,160M
49256 409,210,160M
49265 409,160M
49281 313M
49287 315,120,96M
49288 213,315,120,96M
49289 213,315,120,96M
49290 412,315,213,96M
49297 118,95M
49300 166,313M
49302 166,313M
49304 166,313M
49306 409,209,210,154M
49309 160M