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 = 7168 
WHERE 
  cscart_products_categories.product_id IN (
    87372, 89543, 82487, 89532, 89540, 82492, 
    87371, 89546, 89538, 89554, 91481, 
    85620, 85634, 91480, 89544, 85618, 
    89542, 85616, 85619, 85633, 82491, 
    89563, 85617, 82490, 85615, 82489, 
    91478, 82488, 91479, 85638, 85637, 
    85636, 85635, 92560, 92561, 92562, 
    92563, 92564, 92565, 92566, 92567, 
    92568, 92569, 92570, 92571, 92572, 
    92573, 92574, 92575, 92576, 92577, 
    92578, 92579, 92580, 92581, 92582, 
    92583, 92584, 92585, 92586, 92587, 
    92588, 92589, 92590, 92591, 92592, 
    93296, 93297, 93298, 93299, 93300, 
    93301, 93302, 93303, 93304, 93305, 
    93306, 93307, 93308, 93309, 93310, 
    93311, 93312, 93313, 93314, 93315, 
    93316, 93317, 93318, 93319, 93320, 
    93321, 93322, 93323, 93324, 93325
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00188

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 (87372,89543,82487,89532,89540,82492,87371,89546,89538,89554,91481,85620,85634,91480,89544,85618,89542,85616,85619,85633,82491,89563,85617,82490,85615,82489,91478,82488,91479,85638,85637,85636,85635,92560,92561,92562,92563,92564,92565,92566,92567,92568,92569,92570,92571,92572,92573,92574,92575,92576,92577,92578,92579,92580,92581,92582,92583,92584,92585,92586,92587,92588,92589,92590,92591,92592,93296,93297,93298,93299,93300,93301,93302,93303,93304,93305,93306,93307,93308,93309,93310,93311,93312,93313,93314,93315,93316,93317,93318,93319,93320,93321,93322,93323,93324,93325))"
          }
        },
        {
          "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
82487 7173M
82488 7173M
82489 7173M
82490 7173M
82491 7173M
82492 7174M
85615 7175M
85616 7175M
85617 7175M
85618 7175M
85619 7175M
85620 7175M
85633 7177M
85634 7177M
85635 7173M
85636 7173M
85637 7173M
85638 7173M
87371 7173M
87372 7173M
89532 7172M
89538 7174M
89540 7174M
89542 7175M
89543 7175M
89544 7175M
89546 7175M
89554 7177M
89563 7173M
91478 7173M
91479 7173M
91480 7173M
91481 7173M
92560 7173M
92561 7173M
92562 7173M
92563 7173M
92564 7173M
92565 7173M
92566 7173M
92567 7173M
92568 7173M
92569 7174M
92570 7174M
92571 7174M
92572 7174M
92573 7174M
92574 7174M
92575 7177M
92576 7177M
92577 7177M
92578 7177M
92579 7177M
92580 7177M
92581 7177M
92582 7177M
92583 7177M
92584 7176M
92585 7176M
92586 7176M
92587 7179M
92588 7179M
92589 7179M
92590 7176M
92591 7176M
92592 7176M
93296 7168M 0
93297 7168M 0
93298 7168M 0
93299 7168M 0
93300 7168M 0
93301 7168M 0
93302 7168M 0
93303 7168M 0
93304 7168M 0
93305 7168M 0
93306 7168M 0
93307 7168M 0
93308 7168M 0
93309 7168M 0
93310 7168M 0
93311 7168M 0
93312 7168M 0
93313 7168M 0
93314 7168M 0
93315 7168M 0
93316 7168M 0
93317 7168M 0
93318 7168M 0
93319 7168M 0
93320 7168M 0
93321 7168M 0
93322 7168M 0
93323 7168M 0
93324 7168M 0
93325 7168M 0