Solution by anakinwang.
Let P(x,y) denote the assertion
f(x2+f(x)f(y))=x2+yf(x).
Clearly f(x)=x works. We prove it is the only solution.
First,
P(0,0):f(f(0)2)=0.
Then
P(0,f(0)2):f(0)=f(0)3,
so f(0)2=f(0)4. Also,
P(f(0)2,y):f(f(0)4)=f(0)4.
Thus
f(0)4=f(f(0)4)=f(f(0)2)=0,
so f(0)=0.
Now P(x,0) gives
f(x2)=x2.
Hence f(t)=t for every t≥0.
Fix x>0. If f(y)≥0, then x2+xf(y)>0, and therefore
x2+xf(y)=f(x2+xf(y))=x2+yf(x)=x2+xy.
Thus f(y)=y. In particular, if y<0, then f(y)<0.
Now fix y<0. Choose x>−f(y) with x>0. Then x2+xf(y)>0, so again
x2+xf(y)=f(x2+xf(y))=x2+xy.
Thus f(y)=y for every y<0. Together with the nonnegative case,
f(x)=x for all x∈R.