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 = 574 
WHERE 
  cscart_products_categories.product_id IN (
    5474, 5452, 5453, 5446, 5435, 5454, 5449, 
    5444, 5429, 5430, 5448, 5436, 5522, 
    5451, 5478, 5442, 5437, 5441, 5434, 
    6219, 6670, 5455, 5428, 5440, 6664, 
    5438, 5443, 5476, 6533, 6576, 5447, 
    6795, 5439, 6218, 6777, 6244, 5475, 
    6691, 5433, 6797, 5432, 6681, 6790, 
    6246, 6682, 5431, 6211, 6536, 6808, 
    6238, 6544, 6547, 6532, 6572, 6543, 
    6534, 6545, 6684, 6792, 6666, 10012, 
    6571, 6551, 6683, 6573, 6714, 6680, 
    6789, 6796, 6694, 6778, 6793, 10420, 
    6575, 6718, 6816, 6548, 6809, 6715, 
    6717
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00293

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "192.51"
    },
    "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": 150,
            "rows_produced_per_join": 150,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (5474,5452,5453,5446,5435,5454,5449,5444,5429,5430,5448,5436,5522,5451,5478,5442,5437,5441,5434,6219,6670,5455,5428,5440,6664,5438,5443,5476,6533,6576,5447,6795,5439,6218,6777,6244,5475,6691,5433,6797,5432,6681,6790,6246,6682,5431,6211,6536,6808,6238,6544,6547,6532,6572,6543,6534,6545,6684,6792,6666,10012,6571,6551,6683,6573,6714,6680,6789,6796,6694,6778,6793,10420,6575,6718,6816,6548,6809,6715,6717))",
            "cost_info": {
              "read_cost": "72.51",
              "eval_cost": "15.00",
              "prefix_cost": "87.51",
              "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": 150,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "37.50",
              "eval_cost": "15.00",
              "prefix_cost": "140.01",
              "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": 7,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "37.50",
              "eval_cost": "0.75",
              "prefix_cost": "192.51",
              "data_read_per_join": "23K"
            },
            "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
5428 466,372,574M 0
5429 466,372,574M 0
5430 466,372,574M 0
5431 466,372,574M 0
5432 466,372,574M 0
5433 466,372,574M 0
5434 466,372,574M 0
5435 466,372,574M 0
5436 466,372,574M 0
5437 466,372,574M 0
5438 466,372,574M 0
5439 466,372,574M 0
5440 466,372,574M 0
5441 466,372,574M 0
5442 466,372,574M 0
5443 466,372,574M 0
5444 466,372,574M 0
5446 466,372,574M 0
5447 466,372,574M 0
5448 466,372,574M 0
5449 466,372,574M 0
5451 466,372,574M 0
5452 466,372,574M 0
5453 466,372,574M 0
5454 466,372,574M 0
5455 466,372,574M 0
5474 466,372,574M 0
5475 466,372,574M 0
5476 466,372,574M 0
5478 466,372,574M 0
5522 466,372,574M 0
6211 574M 0
6218 574M 0
6219 574M 0
6238 574M 0
6244 574M 0
6246 574M 0
6532 466,574M 0
6533 466,574M 0
6534 466,574M 0
6536 466,574M 0
6543 466,574M 0
6544 466,574M 0
6545 466,574M 0
6547 466,574M 0
6548 466,574M 0
6551 466,574M 0
6571 466,574M 0
6572 466,574M 0
6573 466,574M 0
6575 466,574M 0
6576 466,574M 0
6664 466,574M 0
6666 466,574M 0
6670 466,574M 0
6680 466,574M 0
6681 466,574M 0
6682 466,574M 0
6683 466,574M 0
6684 466,574M 0
6691 466,574M 0
6694 466,574M 0
6714 466,574M 0
6715 466,574M 0
6717 466,574M 0
6718 466,574M 0
6777 372,574M 0
6778 372,574M 0
6789 466,574M 0
6790 466,574M 0
6792 466,574M 0
6793 466,574M 0
6795 466,574M 0
6796 466,574M 0
6797 466,574M 0
6808 466,574M 0
6809 466,574M 0
6816 466,574M 0
10012 574M 0
10420 574M 0