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 = 7170 
WHERE 
  cscart_products_categories.product_id IN (
    91132, 91135, 91136, 91138, 91139, 91140, 
    91217, 91218, 91221, 91222, 91224, 
    91225, 91226, 91272, 91273, 91276, 
    91277, 91279, 91280, 91281, 83569, 
    83571, 90580, 90581, 90851, 90853, 
    90930, 90932, 89497, 89498, 89505, 
    89506, 89513, 89514, 89521, 89522, 
    91162, 91163, 91166, 91167, 91169, 
    91170, 91171, 83060, 84679, 84680, 
    84683, 84684, 90896, 90975, 84622, 
    84623, 89203, 89216, 89229, 84500, 
    84501, 84566, 84567, 84631, 84549, 
    84550, 84553, 84554, 84615, 84616, 
    84619, 84620, 84621, 86481, 86483, 
    86757, 86759, 90585, 90919, 90998, 
    85069, 85155, 85201, 85247, 82614, 
    82616, 83417, 83419, 84677, 84652, 
    84653, 91011, 91012, 91013, 91023, 
    91024, 91025, 91035, 91036, 91037
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00287

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "93.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": 165,
            "rows_produced_per_join": 165,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "16.82",
              "eval_cost": "16.50",
              "prefix_cost": "33.32",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (91132,91135,91136,91138,91139,91140,91217,91218,91221,91222,91224,91225,91226,91272,91273,91276,91277,91279,91280,91281,83569,83571,90580,90581,90851,90853,90930,90932,89497,89498,89505,89506,89513,89514,89521,89522,91162,91163,91166,91167,91169,91170,91171,83060,84679,84680,84683,84684,90896,90975,84622,84623,89203,89216,89229,84500,84501,84566,84567,84631,84549,84550,84553,84554,84615,84616,84619,84620,84621,86481,86483,86757,86759,90585,90919,90998,85069,85155,85201,85247,82614,82616,83417,83419,84677,84652,84653,91011,91012,91013,91023,91024,91025,91035,91036,91037))"
          }
        },
        {
          "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": "41.25",
              "eval_cost": "0.83",
              "prefix_cost": "91.07",
              "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.06",
              "eval_cost": "0.83",
              "prefix_cost": "93.96",
              "data_read_per_join": "132"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82614 7170,7171M 0
82616 7170,7171M 0
83060 7192M
83417 7170,7171M 0
83419 7170,7171M 0
83569 7170,7191M 0
83571 7170,7191M 0
84500 7223M
84501 7223M
84549 7223M
84550 7223M
84553 7223M
84554 7223M
84566 7223M
84567 7223M
84615 7223M
84616 7223M
84619 7223M
84620 7223M
84621 7170,7200M 0
84622 7223M
84623 7223M
84631 7170,7200M 0
84652 7223M
84653 7223M
84677 7170,7200M 0
84679 7223M
84680 7223M
84683 7223M
84684 7223M
85069 7192M
85155 7192M
85201 7192M
85247 7192M
86481 7170,7171M 0
86483 7170,7171M 0
86757 7170,7171M 0
86759 7170,7171M 0
89203 7170,7171M 0
89216 7170,7171M 0
89229 7170,7171M 0
89497 7170,7171M 0
89498 7170,7171M 0
89505 7170,7171M 0
89506 7170,7171M 0
89513 7170,7171M 0
89514 7170,7171M 0
89521 7170,7171M 0
89522 7170,7171M 0
90580 7170,7191M 0
90581 7170,7191M 0
90585 7170,7191M 0
90851 7191,7170M 0
90853 7191,7170M 0
90896 7192M
90919 7191,7170M 0
90930 7191,7170M 0
90932 7191,7170M 0
90975 7192M
90998 7191,7170M 0
91011 7191,7170M 0
91012 7191,7170M 0
91013 7191,7170M 0
91023 7191,7170M 0
91024 7191,7170M 0
91025 7191,7170M 0
91035 7191,7170M 0
91036 7191,7170M 0
91037 7191,7170M 0
91132 7171,7170M 0
91135 7171,7170M 0
91136 7171,7170M 0
91138 7171,7170M 0
91139 7171,7170M 0
91140 7171,7170M 0
91162 7171,7170M 0
91163 7171,7170M 0
91166 7171,7170M 0
91167 7171,7170M 0
91169 7171,7170M 0
91170 7171,7170M 0
91171 7171,7170M 0
91217 7171,7170M 0
91218 7171,7170M 0
91221 7171,7170M 0
91222 7171,7170M 0
91224 7171,7170M 0
91225 7171,7170M 0
91226 7171,7170M 0
91272 7171,7170M 0
91273 7171,7170M 0
91276 7171,7170M 0
91277 7171,7170M 0
91279 7171,7170M 0
91280 7171,7170M 0
91281 7171,7170M 0