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 = 7257 
WHERE 
  cscart_products_categories.product_id IN (
    96121, 96494, 96495, 96496, 96497, 96498, 
    96499, 96500, 96501, 96502, 96503, 
    96504, 96505, 96506, 96507, 96508, 
    96509, 96530, 96570, 96571, 96572, 
    96573, 97574, 97575, 97581, 97608, 
    97609, 97610, 97611, 97612, 97613, 
    97614, 97615, 97616, 97617, 97618, 
    97619, 97620, 97621, 97622, 97623, 
    97624, 97625, 97626, 97627, 97629, 
    97630, 97631
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01548

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "89.39"
    },
    "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": 99,
            "rows_produced_per_join": 99,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "10.20",
              "eval_cost": "9.90",
              "prefix_cost": "20.10",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (96121,96494,96495,96496,96497,96498,96499,96500,96501,96502,96503,96504,96505,96506,96507,96508,96509,96530,96570,96571,96572,96573,97574,97575,97581,97608,97609,97610,97611,97612,97613,97614,97615,97616,97617,97618,97619,97620,97621,97622,97623,97624,97625,97626,97627,97629,97630,97631))"
          }
        },
        {
          "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": 99,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "24.75",
              "eval_cost": "9.90",
              "prefix_cost": "54.75",
              "data_read_per_join": "1K"
            },
            "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": [
              "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.75",
              "eval_cost": "0.50",
              "prefix_cost": "89.40",
              "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')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
96121 7258M
96494 7247M,7265
96495 7247M,7265
96496 7247M,7265
96497 7265,7247M
96498 7265,7247M
96499 7247M,7265
96500 7247M,7265
96501 7247M,7265
96502 7265,7247M
96503 7265,7247M
96504 7265,7247M
96505 7265,7247M
96506 7265,7247M
96507 7265,7247M
96508 7347,7259M,7345
96509 7265,7247M
96530 7345,7259M,7347
96570 7347,7345,7259M
96571 7258M
96572 7347,7345,7259M
96573 7320,7260M
97574 7208M,7241,7346,7309
97575 7241,7208M,7309,7346
97581 7247M,7265
97608 7320,7260M
97609 7261M,7349
97610 7260M,7320
97611 7260M,7320
97612 7260M,7320
97613 7320,7260M
97614 7320,7260M
97615 7320,7260M
97616 7349,7261M
97617 7320,7260M
97618 7320,7260M
97619 7258M
97620 7347,7259M,7345
97621 7258M
97622 7258M
97623 7345,7347,7259M
97624 7258M
97625 7345,7259M,7347
97626 7258M
97627 7258M
97629 7260M,7320
97630 7320,7260M
97631 7320,7260M