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

Query time 0.00385

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