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 = 234 
WHERE 
  cscart_products_categories.product_id IN (
    5750, 7013, 5739, 5727, 944, 478, 985, 
    525, 2478, 10284, 2527, 2490, 1406, 
    508, 1266, 1428, 1263, 2471, 2576, 2620, 
    1256, 1319, 1273, 4526, 2502, 2473, 
    2565, 2580, 2550, 2599, 2503, 2602, 
    3049, 2540, 3046, 3053, 4767, 2685, 
    2623, 5037, 8398, 4744, 2499, 3055, 
    2581, 2631, 2519, 8399, 5053, 8397, 
    4789, 8395, 5027, 5045, 5051, 10140, 
    5048, 10222, 10228, 10435, 10395, 10233
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00351

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "170.76"
    },
    "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": 135,
            "rows_produced_per_join": 135,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (5750,7013,5739,5727,944,478,985,525,2478,10284,2527,2490,1406,508,1266,1428,1263,2471,2576,2620,1256,1319,1273,4526,2502,2473,2565,2580,2550,2599,2503,2602,3049,2540,3046,3053,4767,2685,2623,5037,8398,4744,2499,3055,2581,2631,2519,8399,5053,8397,4789,8395,5027,5045,5051,10140,5048,10222,10228,10435,10395,10233))",
            "cost_info": {
              "read_cost": "62.76",
              "eval_cost": "13.50",
              "prefix_cost": "76.26",
              "data_read_per_join": "2K"
            },
            "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": 135,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "33.75",
              "eval_cost": "13.50",
              "prefix_cost": "123.51",
              "data_read_per_join": "2K"
            },
            "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": 6,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "33.75",
              "eval_cost": "0.68",
              "prefix_cost": "170.76",
              "data_read_per_join": "21K"
            },
            "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
478 166,234,235M 0
508 234,166,235M 0
525 234,166,235M 0
944 166,234,235M 0
985 166,234,235M 0
1256 234,166,326M 0
1263 234,166,326M 0
1266 234,166,326M 0
1273 234,166,326M 0
1319 166,234,326M 0
1406 234,166,326M 0
1428 234,166,326M 0
2471 234,166,236M 0
2473 166,234,236M 0
2478 166,234,236M 0
2490 166,234,236M 0
2499 166,234,236M 0
2502 166,234,236M 0
2503 166,234,236M 0
2519 166,234,236M 0
2527 234,166,236M 0
2540 166,234,236M 0
2550 166,234,236M 0
2565 166,234,236M 0
2576 234,166,236M 0
2580 166,234,236M 0
2581 166,234,236M 0
2599 166,234,236M 0
2602 166,234,236M 0
2620 166,234,236M 0
2623 166,234,236M 0
2631 166,234,236M 0
2685 234,166,236M 0
3046 234,166,470M 0
3049 166,234,470M 0
3053 234,166,470M 0
3055 166,234,470M 0
4526 234,166,326M 0
4744 234,166,326M 0
4767 234,166,326M 0
4789 234,166,326M 0
5027 166,234,559M 0
5037 234,166,559M 0
5045 234,166,559M 0
5048 234,166,559M 0
5051 234,166,559M 0
5053 234,166,559M 0
5727 234,166,235M 0
5739 234,166,235M 0
5750 235M
7013 235M
8395 236M
8397 236M
8398 236M
8399 236M
10140 234,166,236M 0
10222 236M
10228 236M
10233 236M
10284 235M
10395 234M 0
10435 234M 0