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 (
    339766, 339763, 339613, 339560, 339830, 
    339472, 339682, 339823, 339543, 339558, 
    339785, 339480, 339561, 339854, 339815, 
    339639, 339566, 339819, 339563, 339772, 
    339585, 339837, 339680, 339661, 339640, 
    339788, 381694, 381692, 339840, 339555, 
    339634, 339672, 339629, 339598, 339578, 
    339832, 339641, 339790, 339688, 220162, 
    339627, 339842, 381689, 381685, 339475, 
    339568, 339546, 339844, 339827, 339642, 
    339612, 265036, 339605, 381682, 220170, 
    339687, 339564, 339562, 430574, 271695, 
    339663, 339624, 339462, 271696, 339800, 
    431190, 339690, 392159, 381688, 381691, 
    339792, 381693, 339554, 339764, 431106, 
    339793, 435505, 220169, 431092, 339592, 
    381690, 339459, 339590, 220166, 431147, 
    220178, 339473, 339795, 339799, 339803, 
    339679, 339791, 339813, 339660, 339801, 
    339786, 430849, 339678, 339659, 339465
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00465

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 (339766,339763,339613,339560,339830,339472,339682,339823,339543,339558,339785,339480,339561,339854,339815,339639,339566,339819,339563,339772,339585,339837,339680,339661,339640,339788,381694,381692,339840,339555,339634,339672,339629,339598,339578,339832,339641,339790,339688,220162,339627,339842,381689,381685,339475,339568,339546,339844,339827,339642,339612,265036,339605,381682,220170,339687,339564,339562,430574,271695,339663,339624,339462,271696,339800,431190,339690,392159,381688,381691,339792,381693,339554,339764,431106,339793,435505,220169,431092,339592,381690,339459,339590,220166,431147,220178,339473,339795,339799,339803,339679,339791,339813,339660,339801,339786,430849,339678,339659,339465))"
          }
        },
        {
          "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
220162 443M
220166 443M
220169 1690M
220170 1690M
220178 1690M
265036 1907M
271695 2386M
271696 2386M
339459 9940M
339462 9940M
339465 9940M
339472 9940M
339473 9940M
339475 9940M
339480 9940M
339543 9940M
339546 9940M
339554 395M
339555 395M
339558 395M
339560 395M
339561 395M
339562 395M
339563 395M
339564 395M
339566 395M
339568 395M
339578 395M
339585 395M
339590 395M
339592 395M
339598 395M
339605 395M
339612 395M
339613 395M
339624 395M
339627 395M
339629 395M
339634 395M
339639 395M
339640 395M
339641 395M
339642 395M
339659 395M
339660 395M
339661 395M
339663 395M
339672 395M
339678 9940M
339679 9940M
339680 395M
339682 395M
339687 9940M
339688 9940M
339690 9940M
339763 395M
339764 395M
339766 395M
339772 395M
339785 9943M
339786 9943M
339788 9943M
339790 9943M
339791 9943M
339792 9943M
339793 9943M
339795 9943M
339799 9943M
339800 9943M
339801 9943M
339803 9943M
339813 9940M
339815 395M
339819 395M
339823 395M
339827 395M
339830 395M
339832 395M
339837 395M
339840 395M
339842 395M
339844 395M
339854 395M
381682 10411M
381685 10409M
381688 10413M
381689 10409M
381690 10409M
381691 10409M
381692 10411M
381693 10411M
381694 10411M
392159 2577M
430574 2601M
430849 2601M
431092 2601M
431106 2601M
431147 2601M
431190 2601M
435505 2599M