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, 
  product_position_source.position AS position 
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') 
  LEFT JOIN cscart_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 265 
WHERE 
  cscart_products_categories.product_id IN (
    12648, 12611, 12596, 12607, 12608, 12610, 
    12643, 12649, 12609, 12644, 12650, 
    12652, 12653, 12654, 12646, 12655, 
    12656, 12645, 12651, 12597, 12615, 
    12603, 12629, 12604, 9776, 9777, 9781, 
    9775, 9778, 9779, 9780, 9782, 9790, 
    9787, 9791, 9792, 9795, 9784, 9785, 
    9783, 9786, 9788, 13031, 13032, 13033, 
    13034, 13035, 13036, 13037, 13038, 
    13039, 13040, 13041, 13042, 13043, 
    13044, 10840, 10841, 10842, 10843, 
    10844, 10845, 10846, 10847, 13152
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00148

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": 89,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (12648,12611,12596,12607,12608,12610,12643,12649,12609,12644,12650,12652,12653,12654,12646,12655,12656,12645,12651,12597,12615,12603,12629,12604,9776,9777,9781,9775,9778,9779,9780,9782,9790,9787,9791,9792,9795,9784,9785,9783,9786,9788,13031,13032,13033,13034,13035,13036,13037,13038,13039,13040,13041,13042,13043,13044,10840,10841,10842,10843,10844,10845,10846,10847,13152)"
    },
    "table": {
      "table_name": "product_position_source",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "PRIMARY",
      "key_length": "6",
      "used_key_parts": ["category_id", "product_id"],
      "ref": [
        "const",
        "noframes_angrybeaver.cscart_products_categories.product_id"
      ],
      "rows": 1,
      "filtered": 100
    },
    "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": ["noframes_angrybeaver.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 position
9775 308M
9776 308M
9777 308M
9778 308M
9779 308M
9780 308M
9781 308M
9782 308M
9783 308M
9784 308M
9785 308M
9786 308M
9787 308M
9788 308M
9790 308M
9791 308M
9792 308M
9795 308M
10840 667M
10841 667M
10842 667M
10843 667M
10844 667M
10845 667M
10846 667M
10847 667M
12596 277,267,270M
12597 277,267,270M
12603 267,277,270M
12604 267,270,277M
12607 270,267,277M
12608 270,277,267M
12609 270,267,277M
12610 270,277,267M
12611 270,267,277M
12615 270,267,277M
12629 267,277,270M
12643 267,270,285,277M
12644 267,277,285,270M
12645 285,270,277,267M
12646 268,270,267M
12648 267,285,277,270M
12649 277,270,285,267M
12650 270,277,285,267M
12651 270,277,285,267M
12652 270,268,267M
12653 268,270,267M
12654 268,267,270M
12655 270,268,267M
12656 270,268,267M
13031 313,301M
13032 313,301M
13033 313,301M
13034 313,301M
13035 313,301M
13036 313,301M
13037 313,301M
13038 313,301M
13039 313,301M
13040 313,301M
13041 313,301M
13042 313,301M
13043 313,301M
13044 313,301M
13152 667M