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 = 7184 
WHERE 
  cscart_products_categories.product_id IN (
    98102, 98103, 98104, 98105, 98106, 98107, 
    98108, 98109, 98110, 98111, 98112, 
    98113, 98114, 98115, 98116, 98117, 
    98118, 98119, 98120, 98121, 98122, 
    98123, 98124, 98125, 98126, 98127, 
    98128, 98129, 98130, 98131, 98132, 
    98133, 98134, 98135, 98136, 98137, 
    98169, 98170, 98171, 98172, 98173, 
    98174, 98175, 98176, 98177, 98178, 
    98179, 98180, 98181, 98182, 98183, 
    98184, 98185, 98186, 98187, 98188, 
    98189, 98190, 98191, 98200, 98201, 
    98202, 98203, 98204, 98205, 98206, 
    98207, 98327, 98328, 98329, 98330, 
    98331, 98332, 98333, 98334, 98335, 
    98336, 98337, 98338, 98339, 98340, 
    98341, 98342, 98343, 98344, 98345, 
    98346, 98347, 98348, 98349, 98350, 
    98351, 98352, 98353, 98354, 98355
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00267

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "95.66"
    },
    "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": 168,
            "rows_produced_per_join": 168,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "17.12",
              "eval_cost": "16.80",
              "prefix_cost": "33.92",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (98102,98103,98104,98105,98106,98107,98108,98109,98110,98111,98112,98113,98114,98115,98116,98117,98118,98119,98120,98121,98122,98123,98124,98125,98126,98127,98128,98129,98130,98131,98132,98133,98134,98135,98136,98137,98169,98170,98171,98172,98173,98174,98175,98176,98177,98178,98179,98180,98181,98182,98183,98184,98185,98186,98187,98188,98189,98190,98191,98200,98201,98202,98203,98204,98205,98206,98207,98327,98328,98329,98330,98331,98332,98333,98334,98335,98336,98337,98338,98339,98340,98341,98342,98343,98344,98345,98346,98347,98348,98349,98350,98351,98352,98353,98354,98355))"
          }
        },
        {
          "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": 8,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "42.00",
              "eval_cost": "0.84",
              "prefix_cost": "92.72",
              "data_read_per_join": "21K"
            },
            "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": 8,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.10",
              "eval_cost": "0.84",
              "prefix_cost": "95.66",
              "data_read_per_join": "134"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
98102 7186M
98103 7186M
98104 7186M
98105 7186M
98106 7186M
98107 7188M
98108 7188M
98109 7188M
98110 7188M
98111 7188M
98112 7188M
98113 7188M
98114 7188M
98115 7186M
98116 7186M
98117 7186M
98118 7186M
98119 7186M
98120 7186M
98121 7186M
98122 7185M
98123 7185M
98124 7185M
98125 7185M
98126 7185M
98127 7185M
98128 7185M
98129 7185M
98130 7186M
98131 7186M
98132 7186M
98133 7186M
98134 7186M
98135 7186M
98136 7186M
98137 7186M
98169 7185M
98170 7186M
98171 7185M
98172 7185M
98173 7186M
98174 7185M
98175 7186M
98176 7341,7342,7343,7157M
98177 7341,7342,7343,7157M
98178 7341,7342,7343,7157M
98179 7341,7342,7343,7157M
98180 7341,7342,7343,7157M
98181 7341,7342,7343,7157M
98182 7341,7342,7343,7157M
98183 7341,7342,7343,7157M
98184 7341,7342,7343,7157M
98185 7341,7342,7343,7157M
98186 7341,7342,7343,7157M
98187 7341,7342,7343,7157M
98188 7341,7342,7343,7157M
98189 7341,7342,7343,7157M
98190 7341,7342,7343,7157M
98191 7341,7342,7343,7157M
98200 7341,7342,7343,7157M
98201 7341,7342,7343,7157M
98202 7341,7342,7343,7157M
98203 7341,7342,7343,7157M
98204 7341,7342,7343,7157M
98205 7341,7342,7343,7157M
98206 7341,7342,7343,7157M
98207 7341,7342,7343,7157M
98327 7185M
98328 7185M
98329 7185M
98330 7185M
98331 7185M
98332 7185M
98333 7185M
98334 7185M
98335 7185M
98336 7185M
98337 7185M
98338 7185M
98339 7185M
98340 7185M
98341 7185M
98342 7185M
98343 7186M
98344 7186M
98345 7186M
98346 7186M
98347 7186M
98348 7186M
98349 7186M
98350 7186M
98351 7188M
98352 7188M
98353 7188M
98354 7188M
98355 7188M