Due to the inclusion of the QR Scanner in Pokémon Sun & Moon, a new feature has been announced which allows for you to scan these QR Codes, and rather than get them registered as seen in your Pokédex, you can actually get the Pokémon itself. This process is currently limited entirely to Magearna. The QR Codes never expire
To get the QR Code for Magearna in Japan, you need to go to see the movie, Volcanion & The Ingenious Magearna, then you will get given a special disc for the arcade game, Pokémon Ga-Olé. This disc contains the QR Code which, when scanned, will give you the Pokémon Magearna. The US received the code on the official site and Europe in the Pokémon TV app.
To successfully scan the code, you need to have defeated the Elite Four and become the Alola Region Champion. Then, go to Hau'oli City Mall's Antique Shop and you will be given the Magearna.