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 (
    394196, 114756, 81595, 265003, 149755, 
    264991, 262367, 286468, 387085, 265175, 
    80451, 262401, 387100, 387101, 277549, 
    286472, 277552, 265004, 262376, 265174, 
    277550, 286478, 277548, 387099, 149820, 
    81523, 286465, 277547, 387097, 387102, 
    149750, 286467, 339527, 264986, 286475, 
    391790, 387103, 286479, 359819, 286473, 
    286469, 391787, 391791, 31800, 286466, 
    435216, 286470, 391792, 286471, 277551, 
    391739, 286474, 286, 391740, 262374, 
    381645, 359629, 264695, 262391, 535, 
    359628, 381653, 391793, 381646, 381643, 
    391795, 392213, 225059, 387091, 391794, 
    387043, 264694, 262397, 264699, 381647, 
    391788, 391797, 381644, 339513, 391796, 
    282476, 151903, 381642, 81654, 387038, 
    339519, 81637, 282477, 264697, 264700, 
    339510, 339508, 265002, 339518, 339713, 
    339505, 265235, 339525, 81590, 262396
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00283

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "297.96"
    },
    "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": 106,
            "rows_produced_per_join": 106,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "22.36",
              "eval_cost": "21.20",
              "prefix_cost": "43.56",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (394196,114756,81595,265003,149755,264991,262367,286468,387085,265175,80451,262401,387100,387101,277549,286472,277552,265004,262376,265174,277550,286478,277548,387099,149820,81523,286465,277547,387097,387102,149750,286467,339527,264986,286475,391790,387103,286479,359819,286473,286469,391787,391791,31800,286466,435216,286470,391792,286471,277551,391739,286474,286,391740,262374,381645,359629,264695,262391,535,359628,381653,391793,381646,381643,391795,392213,225059,387091,391794,387043,264694,262397,264699,381647,391788,391797,381644,339513,391796,282476,151903,381642,81654,387038,339519,81637,282477,264697,264700,339510,339508,265002,339518,339713,339505,265235,339525,81590,262396))"
          }
        },
        {
          "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": 106,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "106.00",
              "eval_cost": "21.20",
              "prefix_cost": "170.76",
              "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": "106.00",
              "eval_cost": "1.06",
              "prefix_cost": "297.96",
              "data_read_per_join": "31K"
            },
            "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
286 267M
535 267M
31800 267M
80451 266,6866M 0
81523 266,6866M 0
81590 2404M
81595 2404M
81637 2404M
81654 2404M
114756 342M
149750 1907M
149755 1907M
149820 1907M
151903 1907M
225059 2578M
262367 2578M
262374 2578M
262376 2578M
262391 2578M
262396 2578M
262397 2578M
262401 2578M
264694 9944M
264695 9945M
264697 9946M
264699 9943M
264700 9940M
264986 2374M
264991 266M 0
265002 9921M
265003 9921M
265004 9921M
265174 9958M
265175 9958M
265235 2604M
277547 443M
277548 443M
277549 443M
277550 443M
277551 443M
277552 443M
282476 443M
282477 443M
286465 1516M
286466 1516M
286467 1516M
286468 1516M
286469 1516M
286470 1516M
286471 1516M
286472 1516M
286473 1516M
286474 1516M
286475 1516M
286478 1516M
286479 1516M
339505 9942M
339508 9942M
339510 9942M
339513 9942M
339518 9942M
339519 9942M
339525 9942M
339527 9942M
339713 9942M
359628 1691M
359629 1691M
359819 266M 0
381642 1498M
381643 1498M
381644 1498M
381645 1498M
381646 1498M
381647 1498M
381653 1498M
387038 10425M
387043 10425M
387085 1505M
387091 10425M
387097 1505M
387099 10425,1505M
387100 1505M
387101 10425,1505M
387102 10425,1505M
387103 10425,1505M
391739 443M
391740 443M
391787 443M
391788 443M
391790 443M
391791 443M
391792 443M
391793 443M
391794 443M
391795 443M
391796 443M
391797 443M
392213 443M
394196 2601M
435216 10247M