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 = 16 
WHERE 
  cscart_products_categories.product_id IN (
    397, 511, 1023, 1022, 847, 525, 577, 576, 
    658, 659, 932, 656, 657, 376, 540, 592, 
    1015, 767, 1088, 572, 619, 355, 342, 
    547, 591, 902, 323, 757, 1236, 1225, 
    294, 47, 48, 356, 1293, 1242, 846, 593, 
    616, 1087, 520, 548, 899
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00190

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": 44,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (397,511,1023,1022,847,525,577,576,658,659,932,656,657,376,540,592,1015,767,1088,572,619,355,342,547,591,902,323,757,1236,1225,294,47,48,356,1293,1242,846,593,616,1087,520,548,899)"
    },
    "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": ["bacpvdev_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')"
    },
    "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", "bacpvdev_db.cscart_products_categories.product_id"],
      "rows": 1,
      "filtered": 100
    }
  }
}

Result

product_id category_ids position
47 16M 0
48 16M 0
294 16M 0
323 16M 0
342 16M 0
355 16M 0
356 16M 0
376 16M 0
397 16M 0
511 16M 0
520 16M 0
525 16M 0
540 16M 0
547 16M 0
548 16M 0
572 16M 0
576 16M 0
577 16M 0
591 16M 0
592 16M 0
593 16M 0
616 16M 0
619 16M 0
656 16M 0
657 16M 0
658 16M 0
659 16M 0
757 16M 0
767 16M 0
846 16M 0
847 16M 0
899 16M 0
902 16M 0
932 16M 0
1015 16M 0
1022 16M 0
1023 16M 0
1087 16M 0
1088 16M 0
1225 16M 0
1236 16M 0
1242 16M 0
1293 16M 0