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 = 7211 
WHERE 
  cscart_products_categories.product_id IN (
    99115, 99116, 99118, 99119, 99122, 99124, 
    99126, 99129, 99130, 99132, 99134, 
    99143, 99163, 99164, 99166, 99172, 
    99173, 99175, 99178, 99180, 99184, 
    99192, 99194, 99197, 99200, 99204, 
    99207, 99209, 99223, 99224, 99225, 
    99226, 99228, 99229, 99230, 99231, 
    99232, 99244, 99245, 99246, 99247, 
    99253, 99260, 99261, 99271, 99272, 
    99273, 99274
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00172

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "66.13"
    },
    "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": 116,
            "rows_produced_per_join": 116,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "11.90",
              "eval_cost": "11.60",
              "prefix_cost": "23.50",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (99115,99116,99118,99119,99122,99124,99126,99129,99130,99132,99134,99143,99163,99164,99166,99172,99173,99175,99178,99180,99184,99192,99194,99197,99200,99204,99207,99209,99223,99224,99225,99226,99228,99229,99230,99231,99232,99244,99245,99246,99247,99253,99260,99261,99271,99272,99273,99274))"
          }
        },
        {
          "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": 5,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "29.00",
              "eval_cost": "0.58",
              "prefix_cost": "64.10",
              "data_read_per_join": "15K"
            },
            "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": 5,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.45",
              "eval_cost": "0.58",
              "prefix_cost": "66.13",
              "data_read_per_join": "92"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
99115 7320,7260M
99116 7320,7260M
99118 7320,7260M
99119 7320,7260M
99122 7345,7347,7259M
99124 7345,7347,7259M
99126 7345,7347,7259M
99129 7345,7347,7259M
99130 7320,7260M
99132 7320,7260M
99134 7320,7260M
99143 7320,7260M
99163 7345,7347,7259M
99164 7320,7260M
99166 7320,7260M
99172 7345,7347,7259M
99173 7320,7260M
99175 7320,7260M
99178 7345,7347,7259M
99180 7320,7260M
99184 7345,7347,7259M
99192 7320,7260M
99194 7320,7260M
99197 7320,7260M
99200 7320,7260M
99204 7345,7347,7259M
99207 7345,7347,7259M
99209 7320,7260M
99223 7345,7347,7259M
99224 7345,7347,7259M
99225 7345,7347,7259M
99226 7345,7347,7259M
99228 7345,7347,7259M
99229 7345,7347,7259M
99230 7320,7260M
99231 7320,7260M
99232 7320,7260M
99244 7345,7347,7259M
99245 7320,7260M
99246 7320,7260M
99247 7320,7260M
99253 7345,7347,7259M
99260 7345,7347,7259M
99261 7320,7260M
99271 7345,7347,7259M
99272 7320,7260M
99273 7320,7260M
99274 7320,7260M