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 = 550 
WHERE 
  cscart_products_categories.product_id IN (
    5215, 5303, 5360, 5311, 5231, 5292, 5219, 
    5341, 5217, 5230, 5301, 5222, 5318, 
    5216, 5224, 5302, 5342, 5317, 5324, 
    5298, 5305, 5227, 5293, 5322, 5343, 
    5310, 5320, 5229, 5299, 5319, 5294, 
    5306, 5325, 5220, 5321, 5221, 5362, 
    5226, 5300, 5225, 5223, 5345, 5351, 
    5295, 5323, 5228, 5347, 5218, 5314, 
    5304, 5357, 5296, 5355, 5232, 5361, 
    5327, 5340, 5354, 5315, 5353, 5308, 
    5312, 5326, 5316, 5344, 5356, 5359, 
    5339, 5350, 5313, 5349, 5352, 5358, 
    5307, 5348, 5337, 5338, 5297
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00335

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "242.61"
    },
    "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": 194,
            "rows_produced_per_join": 194,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (5215,5303,5360,5311,5231,5292,5219,5341,5217,5230,5301,5222,5318,5216,5224,5302,5342,5317,5324,5298,5305,5227,5293,5322,5343,5310,5320,5229,5299,5319,5294,5306,5325,5220,5321,5221,5362,5226,5300,5225,5223,5345,5351,5295,5323,5228,5347,5218,5314,5304,5357,5296,5355,5232,5361,5327,5340,5354,5315,5353,5308,5312,5326,5316,5344,5356,5359,5339,5350,5313,5349,5352,5358,5307,5348,5337,5338,5297))",
            "cost_info": {
              "read_cost": "87.41",
              "eval_cost": "19.40",
              "prefix_cost": "106.81",
              "data_read_per_join": "3K"
            },
            "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": 194,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "48.50",
              "eval_cost": "19.40",
              "prefix_cost": "174.71",
              "data_read_per_join": "3K"
            },
            "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": 9,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "48.50",
              "eval_cost": "0.97",
              "prefix_cost": "242.61",
              "data_read_per_join": "30K"
            },
            "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
5215 372,550M 0
5216 372,550M 0
5217 372,550M 0
5218 372,550M 0
5219 372,550M 0
5220 372,550M 0
5221 372,550M 0
5222 372,550M 0
5223 372,550M 0
5224 372,550M 0
5225 372,550M 0
5226 372,550M 0
5227 372,550M 0
5228 372,550M 0
5229 372,550M 0
5230 372,550M 0
5231 372,550M 0
5232 372,550M 0
5292 372,552,550M 0
5293 372,552,550M 0
5294 372,552,550M 0
5295 372,552,550M 0
5296 372,552,550M 0
5297 372,552,550M 0
5298 372,552,550M 0
5299 372,552,550M 0
5300 372,552,550M 0
5301 372,552,550M 0
5302 372,552,550M 0
5303 372,552,550M 0
5304 372,552,550M 0
5305 372,552,550M 0
5306 372,552,550M 0
5307 372,552,550M 0
5308 372,552,550M 0
5310 372,552,550M 0
5311 372,552,550M 0
5312 372,552,550M 0
5313 372,552,550M 0
5314 372,552,550M 0
5315 372,552,550M 0
5316 372,552,550M 0
5317 372,552,550M 0
5318 372,552,550M 0
5319 372,552,550M 0
5320 372,552,550M 0
5321 372,552,550M 0
5322 372,552,550M 0
5323 372,552,550M 0
5324 372,552,550M 0
5325 372,552,550M 0
5326 372,552,550M 0
5327 372,552,550M 0
5337 372,552,550M 0
5338 372,552,550M 0
5339 372,552,550M 0
5340 372,552,550M 0
5341 372,552,550M 0
5342 372,552,550M 0
5343 372,552,550M 0
5344 372,552,550M 0
5345 372,552,550M 0
5347 372,552,550M 0
5348 372,552,550M 0
5349 372,552,550M 0
5350 372,552,550M 0
5351 372,552,550M 0
5352 372,552,550M 0
5353 372,552,550M 0
5354 372,552,550M 0
5355 372,552,550M 0
5356 372,552,550M 0
5357 372,552,550M 0
5358 372,552,550M 0
5359 372,552,550M 0
5360 552,372,550M 0
5361 372,552,550M 0
5362 372,552,550M 0