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 (
    89759, 90742, 91149, 91150, 86480, 86756, 
    82799, 82800, 82872, 82873, 82945, 
    82946, 83255, 83257, 83262, 83264, 
    85348, 86655, 86656, 86724, 86725, 
    84494, 84560, 85073, 85159, 85205, 
    85251, 82613, 83416, 82797, 82870, 
    82943, 83252, 83259, 84804, 84805, 
    84822, 84823, 84834, 84835, 86516, 
    86792, 91089, 91175, 91230, 83031, 
    83033, 83588
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00163

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "49.10"
    },
    "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": 86,
            "rows_produced_per_join": 86,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "8.89",
              "eval_cost": "8.60",
              "prefix_cost": "17.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 (89759,90742,91149,91150,86480,86756,82799,82800,82872,82873,82945,82946,83255,83257,83262,83264,85348,86655,86656,86724,86725,84494,84560,85073,85159,85205,85251,82613,83416,82797,82870,82943,83252,83259,84804,84805,84822,84823,84834,84835,86516,86792,91089,91175,91230,83031,83033,83588))"
          }
        },
        {
          "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": "21.50",
              "eval_cost": "0.43",
              "prefix_cost": "47.59",
              "data_read_per_join": "11K"
            },
            "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.08",
              "eval_cost": "0.43",
              "prefix_cost": "49.10",
              "data_read_per_join": "68"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82613 7170,7171M 0
82797 7170,7191M 0
82799 7170,7191M 0
82800 7170,7191M 0
82870 7170,7191M 0
82872 7170,7191M 0
82873 7170,7191M 0
82943 7170,7191M 0
82945 7170,7191M 0
82946 7170,7191M 0
83031 7170,7171M 0
83033 7170,7171M 0
83252 7170,7191M 0
83255 7170,7191M 0
83257 7170,7191M 0
83259 7170,7191M 0
83262 7170,7191M 0
83264 7170,7191M 0
83416 7170,7171M 0
83588 7170,7171M 0
84494 7223M
84560 7223M
84804 7170,7191M 0
84805 7170,7191M 0
84822 7170,7191M 0
84823 7170,7191M 0
84834 7170,7191M 0
84835 7170,7191M 0
85073 7170,7171M 0
85159 7170,7171M 0
85205 7170,7171M 0
85251 7170,7171M 0
85348 7192M
86480 7170,7171M 0
86516 7192M
86655 7192M
86656 7192M
86724 7192M
86725 7192M
86756 7170,7171M 0
86792 7192M
89759 7192M
90742 7170,7191M 0
91089 7191,7170M 0
91149 7171,7170M 0
91150 7171,7170M 0
91175 7191,7170M 0
91230 7191,7170M 0