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 = 7229 
WHERE 
  cscart_products_categories.product_id IN (
    86262, 86280, 86867, 86261, 86271, 86281, 
    86283, 86272, 86282, 86277, 86310, 
    87753, 86276, 86353, 86865, 87742, 
    87752, 86275, 86274, 87741, 86242, 
    86240, 87739, 87740, 86239, 86241, 
    87737, 87738, 93401, 93402, 93403, 
    93404, 93405, 93406, 94678, 94679, 
    94680, 94681, 94682, 94683, 94684, 
    94685, 95101, 95102, 95103, 95104, 
    95105, 95106, 95107, 95108, 95109, 
    95110, 95111, 95112, 95113, 95114, 
    95115, 95116, 95117, 95118, 95119, 
    95120, 95121, 95122, 95123, 95124, 
    95125, 95126, 95127, 95128, 95129, 
    95130, 95131, 95132, 95133, 95134, 
    95135, 95136, 95137, 95138, 95139, 
    95140, 95141, 95142, 95143, 95144, 
    95145, 95146, 95147, 95148, 95149, 
    95150, 95151, 95159, 95161, 95162
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00298

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "54.77"
    },
    "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": 96,
            "rows_produced_per_join": 96,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.89",
              "eval_cost": "9.60",
              "prefix_cost": "19.49",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (86262,86280,86867,86261,86271,86281,86283,86272,86282,86277,86310,87753,86276,86353,86865,87742,87752,86275,86274,87741,86242,86240,87739,87740,86239,86241,87737,87738,93401,93402,93403,93404,93405,93406,94678,94679,94680,94681,94682,94683,94684,94685,95101,95102,95103,95104,95105,95106,95107,95108,95109,95110,95111,95112,95113,95114,95115,95116,95117,95118,95119,95120,95121,95122,95123,95124,95125,95126,95127,95128,95129,95130,95131,95132,95133,95134,95135,95136,95137,95138,95139,95140,95141,95142,95143,95144,95145,95146,95147,95148,95149,95150,95151,95159,95161,95162))"
          }
        },
        {
          "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": [
              "nuie_scalesta_net.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "24.00",
              "eval_cost": "0.48",
              "prefix_cost": "53.09",
              "data_read_per_join": "12K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`nuie_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`nuie_scalesta_net`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "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",
              "nuie_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.20",
              "eval_cost": "0.48",
              "prefix_cost": "54.77",
              "data_read_per_join": "76"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
86239 7229M 0
86240 7229M 0
86241 7229M 0
86242 7229M 0
86261 7229M 0
86262 7229M 0
86271 7229M 0
86272 7229M 0
86274 7229M 0
86275 7229M 0
86276 7229M 0
86277 7229M 0
86280 7229M 0
86281 7229M 0
86282 7229M 0
86283 7229M 0
86310 7229M 0
86353 7229M 0
86865 7229M 0
86867 7229M 0
87737 7229M 0
87738 7229M 0
87739 7229M 0
87740 7229M 0
87741 7229M 0
87742 7229M 0
87752 7229M 0
87753 7229M 0
93401 7229M 0
93402 7229M 0
93403 7229M 0
93404 7229M 0
93405 7229M 0
93406 7229M 0
94678 7229M 0
94679 7229M 0
94680 7229M 0
94681 7229M 0
94682 7229M 0
94683 7229M 0
94684 7229M 0
94685 7229M 0
95101 7229M 0
95102 7229M 0
95103 7229M 0
95104 7229M 0
95105 7229M 0
95106 7229M 0
95107 7229M 0
95108 7229M 0
95109 7229M 0
95110 7229M 0
95111 7229M 0
95112 7229M 0
95113 7229M 0
95114 7229M 0
95115 7229M 0
95116 7229M 0
95117 7229M 0
95118 7229M 0
95119 7229M 0
95120 7229M 0
95121 7229M 0
95122 7229M 0
95123 7229M 0
95124 7229M 0
95125 7229M 0
95126 7229M 0
95127 7229M 0
95128 7229M 0
95129 7229M 0
95130 7229M 0
95131 7229M 0
95132 7229M 0
95133 7229M 0
95134 7229M 0
95135 7229M 0
95136 7229M 0
95137 7229M 0
95138 7229M 0
95139 7229M 0
95140 7229M 0
95141 7229M 0
95142 7229M 0
95143 7229M 0
95144 7229M 0
95145 7229M 0
95146 7229M 0
95147 7229M 0
95148 7229M 0
95149 7229M 0
95150 7229M 0
95151 7229M 0
95159 7229M 0
95161 7229M 0
95162 7229M 0