It's not the same photon though. The fusion happens in the core, then takes millennia for the energy to escape. During that time photons are emitted and absorbed by the atoms, until the surface emits one that finally travels to the earth in 8 minutes. Anyway that's taking you from the ELI5 to the ELI9 version. I'm sure someone on here can correct it further.
I haven’t tried to look up the history of this claim, but here are some guesses:
1. There’s a sort of diffusion process going on. Photons from the core have some mean free path as a function of radial position (and, obnoxiously, of wavelength as well, so maybe we ignore that). You could calculate the mean time for a hypothetical object emitted from the core and traveling according to those mean free paths to escape.
2. You could imagine you have marked a photon and watched it travel. This is quite problematic. First, photons in thermal equilibrium obey Bose-Einstein statistics because they are indistinguishable bosons, and anything that could mark them would change the statistics to that of distinguishable particles. But whatever, the temperature is high and maybe this doesn’t matter. Also never mind that those core photons are mostly much shorter wavelength than the photons we see. But you can still imagine. (The answer is probably quite similar to #1 since this is sort of the same problem depending on how you think about the interactions with matter in the sun.)
3. You could calculate how long it would take to notice anything if the core suddenly stopped fusing.
Any interaction between light and matter can be modeled as absorption and re-emission (stimulated or spontaneous) of photons. In this picture, there is not much difference between a photon traveling through the sun or through a piece of glass, and the analog makes physical sense. Since photons are massless elementary particles, they are indistinguishable and their number is not conserved. The notion of "the same photon" is questionable in any case.
Similar to how infrared radiation works in our atmosphere, minus the timescale?
Photons are generated in the star’s core but the core is dense. The photons move around the core, bouncing off other particles, a random walk. It takes a vast amount of time for that photon to escape the sun and reach the Earth, as per monte-carlo simulations of this random walk.
However, as the photon collides with other particles during its random walk, some of its energy is transmitted to those other particles. Sometimes a collision transfers energy to it too.
In a simple model, the energy that originally belonged to the photon gets transmitted from particle to particle through convection, and can escape the star through radiation long before the original photon reaches the surface. I don’t think that model is supposed to be physically accurate, rather to be an illustration about the convention process inside a star.