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 = 7158 
WHERE 
  cscart_products_categories.product_id IN (
    95928, 95929, 95930, 95931, 96490, 96491, 
    96492, 96493, 96494, 96495, 96496, 
    96497, 96498, 96499, 96500, 96501, 
    96502, 96503, 96504, 96505, 96506, 
    96507, 96509, 96531, 96532, 96533, 
    96534, 96535, 96536, 96562, 96563, 
    96630, 96631, 96632, 96633, 96634, 
    96635, 96636, 96637, 96638, 96639, 
    96640, 96641, 96642, 96643, 96644, 
    96645, 96646
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01589

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "60.58"
    },
    "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": 67,
            "rows_produced_per_join": 67,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "6.98",
              "eval_cost": "6.70",
              "prefix_cost": "13.68",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (95928,95929,95930,95931,96490,96491,96492,96493,96494,96495,96496,96497,96498,96499,96500,96501,96502,96503,96504,96505,96506,96507,96509,96531,96532,96533,96534,96535,96536,96562,96563,96630,96631,96632,96633,96634,96635,96636,96637,96638,96639,96640,96641,96642,96643,96644,96645,96646))"
          }
        },
        {
          "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": 67,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "16.75",
              "eval_cost": "6.70",
              "prefix_cost": "37.13",
              "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": 3,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "16.75",
              "eval_cost": "0.34",
              "prefix_cost": "60.58",
              "data_read_per_join": "8K"
            },
            "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
95928 7265,7247M
95929 7247M,7265
95930 7247M,7265
95931 7265,7247M
96490 7263M
96491 7263M
96492 7263M
96493 7263M
96494 7247M,7265
96495 7247M,7265
96496 7247M,7265
96497 7247M,7265
96498 7247M,7265
96499 7247M,7265
96500 7247M,7265
96501 7247M,7265
96502 7247M,7265
96503 7265,7247M
96504 7265,7247M
96505 7265,7247M
96506 7265,7247M
96507 7247M,7265
96509 7265,7247M
96531 7263M
96532 7263M
96533 7263M
96534 7263M
96535 7263M
96536 7263M
96562 7263M
96563 7263M
96630 7263M
96631 7263M
96632 7263M
96633 7263M
96634 7263M
96635 7263M
96636 7263M
96637 7263M
96638 7263M
96639 7263M
96640 7263M
96641 7263M
96642 7263M
96643 7263M
96644 7263M
96645 7263M
96646 7263M