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 = 7229 
WHERE 
  cscart_products_categories.product_id IN (
    95163, 95164, 95246, 95247, 95248, 95249, 
    95250, 95251, 95252, 95253, 95254, 
    95255, 95256, 95257, 95258, 95259, 
    95260, 95261, 95262, 95263, 95264, 
    95265, 95266, 95267, 95268, 95269, 
    95270, 95271, 95272, 95273, 95274, 
    95275, 95276, 95277, 95278, 95279, 
    95280, 95281, 95282, 95283, 95284, 
    95285, 95286, 95287, 95288, 95289, 
    95290, 95291, 95292, 95293, 95294, 
    95295, 95296, 95297, 95298, 95299, 
    95300, 95301, 95302, 95303, 95304, 
    95305, 95306, 95307, 95308, 95947, 
    95948, 95949, 95950, 95951, 95952, 
    95953, 95954, 95955, 95956, 95957, 
    95958, 95959, 95960, 95961, 95962, 
    95963, 95964, 95965, 95966, 95967, 
    95968, 95969, 95977, 95978, 95979, 
    95980, 95981, 95982, 95983, 95984
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00170

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "54.77"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 96,
            "rows_produced_per_join": 96,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.89",
              "eval_cost": "9.60",
              "prefix_cost": "19.49",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (95163,95164,95246,95247,95248,95249,95250,95251,95252,95253,95254,95255,95256,95257,95258,95259,95260,95261,95262,95263,95264,95265,95266,95267,95268,95269,95270,95271,95272,95273,95274,95275,95276,95277,95278,95279,95280,95281,95282,95283,95284,95285,95286,95287,95288,95289,95290,95291,95292,95293,95294,95295,95296,95297,95298,95299,95300,95301,95302,95303,95304,95305,95306,95307,95308,95947,95948,95949,95950,95951,95952,95953,95954,95955,95956,95957,95958,95959,95960,95961,95962,95963,95964,95965,95966,95967,95968,95969,95977,95978,95979,95980,95981,95982,95983,95984))"
          }
        },
        {
          "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": [
              "nuie_scalesta_net.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "24.00",
              "eval_cost": "0.48",
              "prefix_cost": "53.09",
              "data_read_per_join": "12K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`nuie_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`nuie_scalesta_net`.`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",
              "nuie_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.20",
              "eval_cost": "0.48",
              "prefix_cost": "54.77",
              "data_read_per_join": "76"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
95163 7229M 0
95164 7229M 0
95246 7229M 0
95247 7229M 0
95248 7229M 0
95249 7229M 0
95250 7229M 0
95251 7229M 0
95252 7229M 0
95253 7229M 0
95254 7229M 0
95255 7229M 0
95256 7229M 0
95257 7229M 0
95258 7229M 0
95259 7229M 0
95260 7229M 0
95261 7229M 0
95262 7229M 0
95263 7229M 0
95264 7229M 0
95265 7229M 0
95266 7229M 0
95267 7229M 0
95268 7229M 0
95269 7229M 0
95270 7229M 0
95271 7229M 0
95272 7229M 0
95273 7229M 0
95274 7229M 0
95275 7229M 0
95276 7229M 0
95277 7229M 0
95278 7229M 0
95279 7229M 0
95280 7229M 0
95281 7229M 0
95282 7229M 0
95283 7229M 0
95284 7229M 0
95285 7229M 0
95286 7229M 0
95287 7229M 0
95288 7229M 0
95289 7229M 0
95290 7229M 0
95291 7229M 0
95292 7229M 0
95293 7229M 0
95294 7229M 0
95295 7229M 0
95296 7229M 0
95297 7229M 0
95298 7229M 0
95299 7229M 0
95300 7229M 0
95301 7229M 0
95302 7229M 0
95303 7229M 0
95304 7229M 0
95305 7229M 0
95306 7229M 0
95307 7229M 0
95308 7229M 0
95947 7229M 0
95948 7229M 0
95949 7229M 0
95950 7229M 0
95951 7229M 0
95952 7229M 0
95953 7229M 0
95954 7229M 0
95955 7229M 0
95956 7229M 0
95957 7229M 0
95958 7229M 0
95959 7229M 0
95960 7229M 0
95961 7229M 0
95962 7229M 0
95963 7229M 0
95964 7229M 0
95965 7229M 0
95966 7229M 0
95967 7229M 0
95968 7229M 0
95969 7229M 0
95977 7229M 0
95978 7229M 0
95979 7229M 0
95980 7229M 0
95981 7229M 0
95982 7229M 0
95983 7229M 0
95984 7229M 0