Wow, those magnetic caps are pretty rare. I heard the US authorities didn't like them, so the design was quickly changed to a mechanical latch. Too easy for the magnet to let go in a crash, or something.
I believe it was just glued in place. Not sure what the best glue would be to replace it, but JB Weld would probably do. Wipe the surfaces with acetone after cleaning away any dirt or traces of the old glue; then clamp it some way (maybe close the cap and put a weight on top ??) and let it sit overnight.