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 = 9942 
WHERE 
  cscart_products_categories.product_id IN (
    339511, 339515, 339527, 339513, 339519, 
    339510, 339518, 339508, 339713, 339525, 
    339505, 339530, 339514, 339521, 339551, 
    339501, 339499, 339721, 339495, 339494, 
    339503, 339531, 339516, 339637, 339539, 
    339509, 339636, 339538, 339492, 339506, 
    339724, 339635, 339502, 339537, 339491, 
    339540, 339524, 339493, 339536, 339520, 
    339517, 339522, 339526, 339490, 339498, 
    339528, 339497, 339507, 339512, 339523, 
    339504, 339500, 339532, 339535, 339534, 
    339496, 339533, 339529
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00282

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "163.49"
    },
    "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": 58,
            "rows_produced_per_join": 58,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "12.69",
              "eval_cost": "11.60",
              "prefix_cost": "24.29",
              "data_read_per_join": "928"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (339511,339515,339527,339513,339519,339510,339518,339508,339713,339525,339505,339530,339514,339521,339551,339501,339499,339721,339495,339494,339503,339531,339516,339637,339539,339509,339636,339538,339492,339506,339724,339635,339502,339537,339491,339540,339524,339493,339536,339520,339517,339522,339526,339490,339498,339528,339497,339507,339512,339523,339504,339500,339532,339535,339534,339496,339533,339529))"
          }
        },
        {
          "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": 58,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "58.00",
              "eval_cost": "11.60",
              "prefix_cost": "93.89",
              "data_read_per_join": "928"
            },
            "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": 2,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "58.00",
              "eval_cost": "0.58",
              "prefix_cost": "163.49",
              "data_read_per_join": "17K"
            },
            "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
339490 9942M 0
339491 9942M 0
339492 9942M 0
339493 9942M 0
339494 9942M 0
339495 9942M 0
339496 9942M 0
339497 9942M 0
339498 9942M 0
339499 9942M 0
339500 9942M 0
339501 9942M 0
339502 9942M 0
339503 9942M 0
339504 9942M 0
339505 9942M 0
339506 9942M 0
339507 9942M 0
339508 9942M 0
339509 9942M 0
339510 9942M 0
339511 9942M 0
339512 9942M 0
339513 9942M 0
339514 9942M 0
339515 9942M 0
339516 9942M 0
339517 9942M 0
339518 9942M 0
339519 9942M 0
339520 9942M 0
339521 9942M 0
339522 9942M 0
339523 9942M 0
339524 9942M 0
339525 9942M 0
339526 9942M 0
339527 9942M 0
339528 9942M 0
339529 9942M 0
339530 9942M 0
339531 9942M 0
339532 9942M 0
339533 9942M 0
339534 9942M 0
339535 9942M 0
339536 9942M 0
339537 9942M 0
339538 9942M 0
339539 9942M 0
339540 9942M 0
339551 9942M 0
339635 9942M 0
339636 9942M 0
339637 9942M 0
339713 9942M 0
339721 9942M 0
339724 9942M 0