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 = 664 
WHERE 
  cscart_products_categories.product_id IN (
    11508, 11147, 11306, 11446, 11472, 11531, 
    11086, 11126, 11166, 11291, 11337, 
    11348, 11411, 11477, 11167, 11256, 
    11309, 11430, 11479, 11600, 11362, 
    11414, 11520, 11633, 11128, 11390, 
    11535, 11199, 11399, 11530, 11236, 
    11289, 11462, 11136, 11193, 11352, 
    11458, 11267, 11293, 11308, 11388, 
    11143, 11152, 11231, 11238, 11453, 
    11439, 11202, 11274, 11360, 11522, 
    11198, 11272, 11300, 11500, 11168, 
    11217, 11233, 11287, 11364, 11218, 
    11226, 11232, 11271, 11164, 11288, 
    11526, 11024, 11220, 11080, 11204, 
    11200, 11270, 10991, 11003, 11211, 
    11216, 11240, 11084, 11210
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00291

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "326.57"
    },
    "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": 375,
            "rows_produced_per_join": 375,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (11508,11147,11306,11446,11472,11531,11086,11126,11166,11291,11337,11348,11411,11477,11167,11256,11309,11430,11479,11600,11362,11414,11520,11633,11128,11390,11535,11199,11399,11530,11236,11289,11462,11136,11193,11352,11458,11267,11293,11308,11388,11143,11152,11231,11238,11453,11439,11202,11274,11360,11522,11198,11272,11300,11500,11168,11217,11233,11287,11364,11218,11226,11232,11271,11164,11288,11526,11024,11220,11080,11204,11200,11270,10991,11003,11211,11216,11240,11084,11210))",
            "cost_info": {
              "read_cost": "151.26",
              "eval_cost": "37.50",
              "prefix_cost": "188.76",
              "data_read_per_join": "5K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "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": 18,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "93.75",
              "eval_cost": "1.88",
              "prefix_cost": "320.01",
              "data_read_per_join": "58K"
            },
            "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')))"
          }
        },
        {
          "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": 18,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "4.69",
              "eval_cost": "1.88",
              "prefix_cost": "326.57",
              "data_read_per_join": "300"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
10991 664M 0
11003 664M 0
11024 664M 0
11080 664M 0
11084 664M 0
11086 664M 0
11126 664M 0
11128 664M 0
11136 664M 0
11143 664M 0
11147 664M 0
11152 664M 0
11164 664M 0
11166 664M 0
11167 664M 0
11168 664M 0
11193 664M 0
11198 664M 0
11199 664M 0
11200 664M 0
11202 664M 0
11204 664M 0
11210 664M 0
11211 664M 0
11216 664M 0
11217 664M 0
11218 664M 0
11220 664M 0
11226 664M 0
11231 664M 0
11232 664M 0
11233 664M 0
11236 664M 0
11238 664M 0
11240 664M 0
11256 664M 0
11267 664M 0
11270 664M 0
11271 664M 0
11272 664M 0
11274 664M 0
11287 664M 0
11288 664M 0
11289 664M 0
11291 664M 0
11293 664M 0
11300 664M 0
11306 664M 0
11308 664M 0
11309 664M 0
11337 664M 0
11348 664M 0
11352 664M 0
11360 664M 0
11362 664M 0
11364 664M 0
11388 664M 0
11390 664M 0
11399 664M 0
11411 664M 0
11414 664M 0
11430 664M 0
11439 664M 0
11446 664M 0
11453 664M 0
11458 664M 0
11462 664M 0
11472 664M 0
11477 664M 0
11479 664M 0
11500 664M 0
11508 664M 0
11520 664M 0
11522 664M 0
11526 664M 0
11530 664M 0
11531 664M 0
11535 664M 0
11600 664M 0
11633 664M 0