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 = 305 
WHERE 
  cscart_products_categories.product_id IN (
    460888, 433987, 409759, 406480, 437686, 
    423559, 424334, 460558, 456062, 432907, 
    404813, 447269, 409338, 403991, 456256, 
    420163, 453916, 414087, 424432, 428079, 
    401029, 456055, 445068, 418346, 407735, 
    436615, 428503, 417977, 418226, 423333, 
    449562, 401443, 449507, 433832, 409821, 
    434815, 418429, 428304, 454998, 401192, 
    420138, 420200, 411483, 433250, 448259, 
    456498, 453797, 440607
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00123

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.243691242,
    "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": 48,
          "cost": 0.08683616,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (460888,433987,409759,406480,437686,423559,424334,460558,456062,432907,404813,447269,409338,403991,456256,420163,453916,414087,424432,428079,401029,456055,445068,418346,407735,436615,428503,417977,418226,423333,449562,401443,449507,433832,409821,434815,418429,428304,454998,401192,420138,420200,411483,433250,448259,456498,453797,440607)",
          "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": 48,
          "rows": 1,
          "cost": 0.04375232,
          "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": 48,
          "rows": 1,
          "cost": 0.08225472,
          "filtered": 100
        }
      }
    ]
  }
}

Result

product_id category_ids position
401029 305M 0
401192 305M 0
401443 305M 0
403991 305M 0
404813 305M 0
406480 305M 0
407735 305M 0
409338 305M 0
409759 305M 0
409821 305M 0
411483 305M 0
414087 305M 0
417977 305M 0
418226 305M 0
418346 305M 0
418429 305M 0
420138 305M 0
420163 305M 0
420200 305M 0
423333 305M 0
423559 305M 0
424334 305M 0
424432 305M 0
428079 305M 0
428304 305M 0
428503 305M 0
432907 305M 0
433250 305M 0
433832 305M 0
433987 305M 0
434815 305M 0
436615 305M 0
437686 305M 0
440607 305M 0
445068 305M 0
447269 305M 0
448259 305M 0
449507 305M 0
449562 305M 0
453797 305M 0
453916 305M 0
454998 305M 0
456055 305M 0
456062 305M 0
456256 305M 0
456498 305M 0
460558 305M 0
460888 305M 0