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 = 7177 
WHERE 
  cscart_products_categories.product_id IN (
    95487, 95494, 95495, 95496, 95505, 95506, 
    95509, 95510, 96182, 96183, 96184, 
    96185, 96785, 96786, 96817, 96818, 
    96819, 96820, 96821, 96822, 96823, 
    96824, 96825, 96893, 96894, 96895, 
    96896, 96897, 96898, 96899, 96900, 
    96901, 96902, 96903, 96904, 96905, 
    96906, 96907, 96908, 96909, 96910, 
    96911, 96912, 96913, 96914, 96915, 
    96916, 96969, 96970, 96971, 96972, 
    96973, 96974, 96975, 96976, 96977, 
    96978, 96979, 96980, 98516, 98891, 
    98894, 98895, 98896, 100248, 100249, 
    100250, 100254, 100255, 100256, 100257, 
    100258, 100259, 100328, 100329, 100330, 
    100335, 100336, 100438, 100439, 100440, 
    100441, 100442, 100443, 100444, 101536, 
    101537, 101538, 101539
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01979

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "80.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": 89,
            "rows_produced_per_join": 89,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.19",
              "eval_cost": "8.90",
              "prefix_cost": "18.09",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (95487,95494,95495,95496,95505,95506,95509,95510,96182,96183,96184,96185,96785,96786,96817,96818,96819,96820,96821,96822,96823,96824,96825,96893,96894,96895,96896,96897,96898,96899,96900,96901,96902,96903,96904,96905,96906,96907,96908,96909,96910,96911,96912,96913,96914,96915,96916,96969,96970,96971,96972,96973,96974,96975,96976,96977,96978,96979,96980,98516,98891,98894,98895,98896,100248,100249,100250,100254,100255,100256,100257,100258,100259,100328,100329,100330,100335,100336,100438,100439,100440,100441,100442,100443,100444,101536,101537,101538,101539))"
          }
        },
        {
          "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": 89,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "22.25",
              "eval_cost": "8.90",
              "prefix_cost": "49.24",
              "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": "22.25",
              "eval_cost": "0.45",
              "prefix_cost": "80.39",
              "data_read_per_join": "11K"
            },
            "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
95487 7177M 0
95494 7177M 0
95495 7177M 0
95496 7177M 0
95505 7177M 0
95506 7177M 0
95509 7177M 0
95510 7177M 0
96182 7177M 0
96183 7177M 0
96184 7177M 0
96185 7177M 0
96785 7177M 0
96786 7177M 0
96817 7177M 0
96818 7177M 0
96819 7177M 0
96820 7177M 0
96821 7177M 0
96822 7177M 0
96823 7177M 0
96824 7177M 0
96825 7177M 0
96893 7177M 0
96894 7177M 0
96895 7177M 0
96896 7177M 0
96897 7177M 0
96898 7177M 0
96899 7177M 0
96900 7177M 0
96901 7177M 0
96902 7177M 0
96903 7177M 0
96904 7177M 0
96905 7177M 0
96906 7177M 0
96907 7177M 0
96908 7177M 0
96909 7177M 0
96910 7177M 0
96911 7177M 0
96912 7177M 0
96913 7177M 0
96914 7177M 0
96915 7177M 0
96916 7177M 0
96969 7177M 0
96970 7177M 0
96971 7177M 0
96972 7177M 0
96973 7177M 0
96974 7177M 0
96975 7177M 0
96976 7177M 0
96977 7177M 0
96978 7177M 0
96979 7177M 0
96980 7177M 0
98516 7177M 0
98891 7177M 0
98894 7177M 0
98895 7177M 0
98896 7177M 0
100248 7177M 0
100249 7177M 0
100250 7177M 0
100254 7177M 0
100255 7177M 0
100256 7177M 0
100257 7177M 0
100258 7177M 0
100259 7177M 0
100328 7177M 0
100329 7177M 0
100330 7177M 0
100335 7177M 0
100336 7177M 0
100438 7177M 0
100439 7177M 0
100440 7177M 0
100441 7177M 0
100442 7177M 0
100443 7177M 0
100444 7177M 0
101536 7177M 0
101537 7177M 0
101538 7177M 0
101539 7177M 0