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 = 600 
WHERE 
  cscart_products_categories.product_id IN (
    6521, 6508, 6419, 6519, 6420, 6517, 6458, 
    6597, 6565, 6566, 6570, 6599, 6568, 
    6596, 6598, 6595, 6273, 6265, 6329, 
    6357, 6350, 6348, 6285, 6322, 6284, 
    6327, 6283, 6326, 6363, 6351, 6324, 
    6409, 6325, 6349, 6863, 6328, 6352, 
    6353, 6410, 6418
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00138

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "56.01"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 40,
            "rows_produced_per_join": 40,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (6521,6508,6419,6519,6420,6517,6458,6597,6565,6566,6570,6599,6568,6596,6598,6595,6273,6265,6329,6357,6350,6348,6285,6322,6284,6327,6283,6326,6363,6351,6324,6409,6325,6349,6863,6328,6352,6353,6410,6418))",
            "cost_info": {
              "read_cost": "24.01",
              "eval_cost": "4.00",
              "prefix_cost": "28.01",
              "data_read_per_join": "640"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "product_position_source",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "product_id"
            ],
            "key_length": "6",
            "ref": [
              "const",
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 40,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "10.00",
              "eval_cost": "4.00",
              "prefix_cost": "42.01",
              "data_read_per_join": "640"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 2,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "10.00",
              "eval_cost": "0.20",
              "prefix_cost": "56.01",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`storefront_id` in (0,1)) and ((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`))) and (`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
6265 602M
6273 602M
6283 602M
6284 602M
6285 602M
6322 602M
6324 602M
6325 602M
6326 602M
6327 602M
6328 602M
6329 602M
6348 602M
6349 602M
6350 602M
6351 602M
6352 602M
6353 602M
6357 602M
6363 602M
6409 602M
6410 602M
6418 602M
6419 601M
6420 601M
6458 601M
6508 601M
6517 601M
6519 601M
6521 601M
6565 601M
6566 601M
6568 601M
6570 601M
6595 601M
6596 601M
6597 601M
6598 601M
6599 601M
6863 603M