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 (
    431456, 339702, 387049, 339593, 430751, 
    431148, 430660, 430825, 431127, 430680, 
    430691, 430820, 431013, 430678, 339849, 
    430875, 430959, 431194, 431035, 431041, 
    431044, 431049, 431109, 339483, 339484, 
    431083, 339820, 430737, 430756, 430989, 
    431080, 431161, 430635, 339734, 381698, 
    381699, 430650, 430922, 430808, 430819, 
    430843, 430629, 430657, 430807, 339596, 
    430868, 430921, 431126, 431144, 430795, 
    430928, 431073, 431082, 430789, 430812, 
    430950, 339725, 430658, 430758, 430901, 
    431110, 339674, 430818, 431156, 339774, 
    339728, 339754, 430673, 430689, 430822, 
    430860, 431114, 339821, 339836, 430684, 
    430664, 430769, 430892, 431043, 431066, 
    431169, 339466, 381705, 430842, 430628, 
    430834, 431064, 339843, 339802, 430859, 
    431459, 430906, 381697, 430768, 430890, 
    430962, 431118, 431250, 430703, 430988
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00333

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 (431456,339702,387049,339593,430751,431148,430660,430825,431127,430680,430691,430820,431013,430678,339849,430875,430959,431194,431035,431041,431044,431049,431109,339483,339484,431083,339820,430737,430756,430989,431080,431161,430635,339734,381698,381699,430650,430922,430808,430819,430843,430629,430657,430807,339596,430868,430921,431126,431144,430795,430928,431073,431082,430789,430812,430950,339725,430658,430758,430901,431110,339674,430818,431156,339774,339728,339754,430673,430689,430822,430860,431114,339821,339836,430684,430664,430769,430892,431043,431066,431169,339466,381705,430842,430628,430834,431064,339843,339802,430859,431459,430906,381697,430768,430890,430962,431118,431250,430703,430988))"
          }
        },
        {
          "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
339483 9940M
339484 9940M
339593 395M
339596 395M
339674 395M
339702 395M
339725 395M
339728 395M
339734 395M
339754 395M
339774 395M
339802 9943M
339820 395M
339821 395M
339836 395M
339843 395M
339849 395M
381697 10410M
381698 10410M
381699 10410M
381705 10410M
387049 2578M
430628 2601M
430629 2601M
430635 2601M
430650 2601M
430657 2601M
430658 2601M
430660 2601M
430664 2601M
430673 2601M
430678 2601M
430680 2601M
430684 2601M
430689 2601M
430691 2601M
430703 2601M
430737 2601M
430751 2601M
430756 2601M
430758 2601M
430768 2601M
430769 2601M
430789 2601M
430795 2601M
430807 2601M
430808 2601M
430812 2601M
430818 2601M
430819 2601M
430820 2601M
430822 2601M
430825 2601M
430834 2601M
430842 2601M
430843 2601M
430859 2601M
430860 2601M
430868 2601M
430875 2601M
430890 2601M
430892 2601M
430901 2601M
430906 2601M
430921 2601M
430922 2601M
430928 2601M
430950 2601M
430959 2601M
430962 2601M
430988 2601M
430989 2601M
431013 2601M
431035 2601M
431041 2601M
431043 2601M
431044 2601M
431049 2601M
431064 2601M
431066 2601M
431073 2601M
431080 2601M
431082 2601M
431083 2601M
431109 2601M
431110 2601M
431114 2601M
431118 2601M
431126 2601M
431127 2601M
431144 2601M
431148 2601M
431156 2601M
431161 2601M
431169 2601M
431194 2601M
431250 2601M
431456 2601M
431459 2601M