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 = 223 
WHERE 
  cscart_products_categories.product_id IN (
    391002, 390979, 390978, 391013, 391014, 
    390986, 112217, 391009, 400923, 391023, 
    312417, 312421, 390994, 312426, 312427, 
    312428, 312429, 312430, 312431, 312432, 
    312433, 390974, 391026, 391008, 393787, 
    400916, 312423, 390980, 400921, 400925, 
    400922, 400924, 312420, 460961, 390977, 
    390984, 390981, 391005, 391003, 390987, 
    391006, 391004, 391007, 391028, 460952, 
    391015, 391021, 312434, 400915, 400918, 
    391024, 400919, 390991, 390990, 390992, 
    390975, 391011, 391010, 391025, 390985, 
    390996, 390997, 391012, 400920, 391000, 
    391001, 391020, 461008, 390993, 390989, 
    390988, 390999, 390998, 278, 390982, 
    390983, 400917, 390995, 400914, 391022, 
    312422
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00117

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.420494714,
    "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"],
          "loops": 1,
          "rows": 84,
          "cost": 0.14643218,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (391002,390979,390978,391013,391014,390986,112217,391009,400923,391023,312417,312421,390994,312426,312427,312428,312429,312430,312431,312432,312433,390974,391026,391008,393787,400916,312423,390980,400921,400925,400922,400924,312420,460961,390977,390984,390981,391005,391003,390987,391006,391004,391007,391028,460952,391015,391021,312434,400915,400918,391024,400919,390991,390990,390992,390975,391011,391010,391025,390985,390996,390997,391012,400920,391000,391001,391020,461008,390993,390989,390988,390999,390998,278,390982,390983,400917,390995,400914,391022,312422)",
          "using_index": true
        }
      },
      {
        "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": ["u985510652_ecartify.cscart_products_categories.category_id"],
          "loops": 84,
          "rows": 1,
          "cost": 0.07595216,
          "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')"
        }
      },
      {
        "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",
            "u985510652_ecartify.cscart_products_categories.product_id"
          ],
          "loops": 84,
          "rows": 1,
          "cost": 0.14394576,
          "filtered": 100
        }
      }
    ]
  }
}

Result

product_id category_ids position
278 224M
112217 225,288
312417 224M
312420 224M
312421 223,224M 0
312422 224M
312423 224M
312426 225M
312427 225M
312428 225M
312429 225M
312430 225M
312431 225M
312432 225M
312433 225M
312434 223M 0
390974 223M 0
390975 223M 0
390977 223M 0
390978 223M 3
390979 223M 1
390980 223M 0
390981 223M 0
390982 223M 0
390983 223M 0
390984 223M 0
390985 223M 0
390986 223M 2
390987 223M 0
390988 223M 0
390989 223M 0
390990 223M 0
390991 223M 0
390992 223M 0
390993 223M 0
390994 223M 0
390995 223M 0
390996 223M 0
390997 223M 0
390998 223M 0
390999 223M 0
391000 223M 0
391001 223M 0
391002 223M 0
391003 223M 0
391004 223M 0
391005 223M 0
391006 223M 0
391007 223M 0
391008 223M 0
391009 223M 0
391010 223M 0
391011 223M 0
391012 223M 0
391013 223M 0
391014 223M 0
391015 223M 0
391020 223M 0
391021 223M 0
391022 223M 0
391023 223M 0
391024 223M 0
391025 223M 0
391026 223M 0
391028 227M
393787 223M 0
400914 223M 0
400915 223M 0
400916 223M 0
400917 223M 0
400918 223M 0
400919 223M 0
400920 223M 0
400921 223M 0
400922 223M 0
400923 223M 0
400924 223M 0
400925 223M 0
460952 227M
460961 223M 0
461008 223M 0