Solution by jasperE3.
We solve the general equation f(g(x)+yf(x))=f(x)2+f(xy).
If f(k)=0 for some k:
P(k,x)⇒f(g(k))=f(kx), so f is constant. The only constant solution is f(x)=0, which fits.
Otherwise, assume f(x)=0 for all x=0.
If f(k)=k for some k:
P(k,k−f(k)g(k))⇒f(k)=0, but then f(k)=k=0 contradiction.
So f(x)=x for all x.