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 = 266 
WHERE 
  cscart_products_categories.product_id IN (
    339484, 339755, 430807, 431068, 339697, 
    431359, 430875, 431041, 430825, 430868, 
    431085, 431156, 339681, 339828, 430925, 
    431053, 431164, 381705, 430819, 430820, 
    430901, 431013, 431049, 339596, 430654, 
    430658, 431144, 431148, 430691, 430989, 
    430746, 430808, 430812, 430834, 430629, 
    430680, 431136, 339774, 339765, 430843, 
    339728, 339836, 339843, 431110, 339725, 
    339734, 339816, 431080, 339655, 339839, 
    339599, 431118, 431161, 339466, 430673, 
    430890, 339845, 430789, 430859, 430906, 
    430922, 339582, 339723, 431082, 431126, 
    430657, 430678, 339702, 430737, 430822, 
    430860, 431111, 339674, 430689, 431044, 
    339754, 381704, 430795, 430832, 430892, 
    430914, 430921, 430635, 339802, 339821, 
    430663, 430838, 430854, 431174, 339486, 
    430650, 430959, 431456, 430815, 339727, 
    381697, 431169, 430672, 430695, 430950
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00216

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "281.15"
    },
    "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": 100,
            "rows_produced_per_join": 100,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "21.15",
              "eval_cost": "20.00",
              "prefix_cost": "41.15",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (339484,339755,430807,431068,339697,431359,430875,431041,430825,430868,431085,431156,339681,339828,430925,431053,431164,381705,430819,430820,430901,431013,431049,339596,430654,430658,431144,431148,430691,430989,430746,430808,430812,430834,430629,430680,431136,339774,339765,430843,339728,339836,339843,431110,339725,339734,339816,431080,339655,339839,339599,431118,431161,339466,430673,430890,339845,430789,430859,430906,430922,339582,339723,431082,431126,430657,430678,339702,430737,430822,430860,431111,339674,430689,431044,339754,381704,430795,430832,430892,430914,430921,430635,339802,339821,430663,430838,430854,431174,339486,430650,430959,431456,430815,339727,381697,431169,430672,430695,430950))"
          }
        },
        {
          "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",
              "webmarco.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 100,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "100.00",
              "eval_cost": "20.00",
              "prefix_cost": "161.15",
              "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": [
              "webmarco.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 5,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "100.00",
              "eval_cost": "1.00",
              "prefix_cost": "281.15",
              "data_read_per_join": "29K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`webmarco`.`cscart_categories`.`storefront_id` in (0,1)) and ((`webmarco`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`webmarco`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`webmarco`.`cscart_categories`.`usergroup_ids`)) and (`webmarco`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
339466 9940M
339484 9940M
339486 9940M
339582 395M
339596 395M
339599 395M
339655 395M
339674 395M
339681 9943M
339697 395M
339702 395M
339723 395M
339725 395M
339727 395M
339728 395M
339734 395M
339754 395M
339755 395M
339765 395M
339774 395M
339802 9943M
339816 395M
339821 395M
339828 395M
339836 395M
339839 395M
339843 395M
339845 395M
381697 10410M
381704 10410M
381705 10410M
430629 2601M
430635 2601M
430650 2601M
430654 2601M
430657 2601M
430658 2601M
430663 2601M
430672 2601M
430673 2601M
430678 2601M
430680 2601M
430689 2601M
430691 2601M
430695 2601M
430737 2601M
430746 2601M
430789 2601M
430795 2601M
430807 2601M
430808 2601M
430812 2601M
430815 2601M
430819 2601M
430820 2601M
430822 2601M
430825 2601M
430832 2601M
430834 2601M
430838 2601M
430843 2601M
430854 2601M
430859 2601M
430860 2601M
430868 2601M
430875 2601M
430890 2601M
430892 2601M
430901 2601M
430906 2601M
430914 2601M
430921 2601M
430922 2601M
430925 2601M
430950 2601M
430959 2601M
430989 2601M
431013 2601M
431041 2601M
431044 2601M
431049 2601M
431053 2601M
431068 2601M
431080 2601M
431082 2601M
431085 2601M
431110 2601M
431111 2601M
431118 2601M
431126 2601M
431136 2601M
431144 2601M
431148 2601M
431156 2601M
431161 2601M
431164 2601M
431169 2601M
431174 2601M
431359 2601M
431456 2601M