-
For that length of time will likely be better to buy directly in Spain.
I haven’t bought one in Spain but did so in Italy and it was super easy.
Agree that Google Fi could be good as well but they do have limits on how long you can be out of the country before you have issues, Google Fi international benefits are meant for travel but not extended living abroad