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 = 7168 
WHERE 
  cscart_products_categories.product_id IN (
    96824, 96825, 96826, 96827, 96828, 96829, 
    96830, 96831, 96832, 96833, 96834, 
    96835, 96836, 96837, 96838, 96848, 
    96849, 96850, 96851, 96852, 96853, 
    96854, 96855, 96856, 96857, 96858, 
    96859, 96860, 96861, 96862, 96863, 
    96864, 96865, 96866, 96867, 96868, 
    96869, 96870, 96871, 96872, 96873, 
    96874, 96875, 96876, 96877, 96878, 
    96879, 96880, 96881, 96882, 96883, 
    96884, 96885, 96886, 96887, 96888, 
    96889, 96890, 96891, 96892, 96893, 
    96894, 96895, 96896, 96897, 96898, 
    96899, 96900, 96901, 96902, 96903, 
    96904, 96905, 96906, 96907, 96908, 
    96909, 96910, 96911, 96912, 96913, 
    96914, 96915, 96916, 96920, 96921, 
    96922, 96923, 96924, 96925, 96926, 
    96927, 96928, 96929, 96930, 96931
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00218

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 (96824,96825,96826,96827,96828,96829,96830,96831,96832,96833,96834,96835,96836,96837,96838,96848,96849,96850,96851,96852,96853,96854,96855,96856,96857,96858,96859,96860,96861,96862,96863,96864,96865,96866,96867,96868,96869,96870,96871,96872,96873,96874,96875,96876,96877,96878,96879,96880,96881,96882,96883,96884,96885,96886,96887,96888,96889,96890,96891,96892,96893,96894,96895,96896,96897,96898,96899,96900,96901,96902,96903,96904,96905,96906,96907,96908,96909,96910,96911,96912,96913,96914,96915,96916,96920,96921,96922,96923,96924,96925,96926,96927,96928,96929,96930,96931))"
          }
        },
        {
          "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
96824 7177M
96825 7177M
96826 7178M
96827 7178M
96828 7176M
96829 7176M
96830 7176M
96831 7176M
96832 7179M
96833 7179M
96834 7176M
96835 7176M
96836 7176M
96837 7176M
96838 7176M
96848 7172M
96849 7172M
96850 7172M
96851 7172M
96852 7172M
96853 7172M
96854 7172M
96855 7172M
96856 7172M
96857 7172M
96858 7172M
96859 7172M
96860 7172M
96861 7172M
96862 7172M
96863 7172M
96864 7172M
96865 7172M
96866 7169M
96867 7169M
96868 7169M
96869 7169M
96870 7169M
96871 7169M
96872 7169M
96873 7169M
96874 7169M
96875 7175M
96876 7175M
96877 7175M
96878 7175M
96879 7175M
96880 7175M
96881 7175M
96882 7175M
96883 7175M
96884 7175M
96885 7175M
96886 7175M
96887 7176M
96888 7176M
96889 7176M
96890 7176M
96891 7176M
96892 7176M
96893 7177M
96894 7177M
96895 7177M
96896 7177M
96897 7177M
96898 7177M
96899 7177M
96900 7177M
96901 7177M
96902 7177M
96903 7177M
96904 7177M
96905 7177M
96906 7177M
96907 7177M
96908 7177M
96909 7177M
96910 7177M
96911 7177M
96912 7177M
96913 7177M
96914 7177M
96915 7177M
96916 7177M
96920 7174M
96921 7174M
96922 7174M
96923 7174M
96924 7174M
96925 7174M
96926 7174M
96927 7174M
96928 7174M
96929 7174M
96930 7174M
96931 7176M