Yes. The sun has got magnetic field like the earth. The structure of the sun includes the core at its centre. There is a radiative zone above the core and then an outermost convective zone. Like our earth, sun has also got its own atmosphere called solar atmosphere which are the outermost layers. The three main parts of solar atmosphere are photosphere, chromosphere and the corona.
The core of the sun is made of electrically charged gas called plasma. This plasma generates some magnetic field inside. But it is kind of a complex field because it has been found that this field alters every 11 years. That is the North Pole becomes the South Pole and South Pole becomes the North Pole.
Sun is a mere bunch of gas with heavy nuclear reactions taking place at the centre. Storminess builds up to a maximum, then settles back down to a minimum. This repeated behavior is called solar cycle. When sun is highly stormy is when its magnetic field flips. Scientists doubt that whether this storminess has to do with the magnetic field flipping at all.
The magnetic lines of forces are clumsier when the sun reaches its most active part of its 11 year cycle. These constantly moving magnetic fields lead to solar flares. The solar flares are powerful radiations sent into space due to speedy motion of particles inside the hot plasma. When the solar cycle is at minimum, solar flares do not occur very often.