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 = 7165 
WHERE 
  cscart_products_categories.product_id IN (
    96953, 96954, 96955, 96956, 96957, 96958, 
    96959, 96960, 96961, 96962, 96963, 
    96964, 96965, 96966, 96967, 96968, 
    96969, 96970, 96971, 96972, 96973, 
    96974, 96975, 96976, 96977, 96978, 
    96979, 96980, 96981, 96982, 96983, 
    96984, 96998, 98192, 98193, 98194, 
    98195, 98196, 98197, 98198, 98199, 
    98208, 98209, 98210, 98211, 98212, 
    98213, 98214, 98215, 98216, 98217, 
    98218, 98219, 98220, 98221, 98222, 
    98223, 98322, 98323, 98482, 98509, 
    98510, 98511, 98512, 98513, 98514, 
    98516, 98517, 98518, 98519, 98520, 
    98538, 98539, 98540, 98541, 98542, 
    98543, 98544, 98545, 98546, 98547, 
    98548, 98549, 98563, 98564, 98565, 
    98566, 98567, 98568, 98569, 98758, 
    98889, 98890, 98891, 98892, 98893
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01776

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "130.09"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "6.18"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 208,
            "rows_produced_per_join": 8,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "20.72",
              "eval_cost": "0.83",
              "prefix_cost": "21.55",
              "data_read_per_join": "21K"
            },
            "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": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "nuie_scalesta_net.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 117,
            "rows_produced_per_join": 6,
            "filtered": "0.63",
            "cost_info": {
              "read_cost": "2.33",
              "eval_cost": "0.62",
              "prefix_cost": "121.75",
              "data_read_per_join": "98"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (96953,96954,96955,96956,96957,96958,96959,96960,96961,96962,96963,96964,96965,96966,96967,96968,96969,96970,96971,96972,96973,96974,96975,96976,96977,96978,96979,96980,96981,96982,96983,96984,96998,98192,98193,98194,98195,98196,98197,98198,98199,98208,98209,98210,98211,98212,98213,98214,98215,98216,98217,98218,98219,98220,98221,98222,98223,98322,98323,98482,98509,98510,98511,98512,98513,98514,98516,98517,98518,98519,98520,98538,98539,98540,98541,98542,98543,98544,98545,98546,98547,98548,98549,98563,98564,98565,98566,98567,98568,98569,98758,98889,98890,98891,98892,98893))"
          }
        },
        {
          "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": 6,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.55",
              "eval_cost": "0.62",
              "prefix_cost": "123.91",
              "data_read_per_join": "98"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
96953 7176M
96954 7179M
96955 7179M
96956 7179M
96957 7179M
96958 7179M
96959 7173M
96960 7173M
96961 7173M
96962 7173M
96963 7173M
96964 7173M
96965 7173M
96966 7173M
96967 7173M
96968 7173M
96969 7177M
96970 7177M
96971 7177M
96972 7177M
96973 7177M
96974 7177M
96975 7177M
96976 7177M
96977 7177M
96978 7177M
96979 7177M
96980 7177M
96981 7166M
96982 7166M
96983 7166M
96984 7166M
96998 7167M,7183,7283
98192 7225M,7226
98193 7225M,7226
98194 7225M,7226
98195 7225M,7226
98196 7225M,7226
98197 7225M,7226
98198 7225M,7226
98199 7225M,7226
98208 7225M,7226
98209 7225M,7226
98210 7225M,7226
98211 7225M,7226
98212 7225M,7226
98213 7225M,7226
98214 7225M,7226
98215 7225M,7226
98216 7225M,7226
98217 7225M,7226
98218 7225M,7226
98219 7225M,7226
98220 7225M,7226
98221 7225M,7226
98222 7225M,7226
98223 7225M,7226
98322 7225M,7226
98323 7225M,7226
98482 7149M,7182,7300
98509 7172M
98510 7172M
98511 7169M
98512 7175M
98513 7175M
98514 7175M
98516 7177M
98517 7173M
98518 7173M
98519 7173M
98520 7173M
98538 7167M,7183,7283
98539 7167M,7183,7283
98540 7167M,7183,7283
98541 7167M,7183,7283
98542 7167M,7183,7283
98543 7167M,7183,7283
98544 7167M,7183,7283
98545 7167M,7183,7283
98546 7167M,7183,7283
98547 7167M,7183,7283
98548 7167M,7183,7283
98549 7167M,7183,7283
98563 7225M,7226
98564 7225M,7226
98565 7225M,7226
98566 7225M,7226
98567 7225M,7226
98568 7225M,7226
98569 7225M,7226
98758 7149M,7182,7300
98889 7176M
98890 7176M
98891 7177M
98892 7179M
98893 7173M