Let $\bar M=M_1\times_f M_2$ be a warped product manifold, $X_1, Y_1$ be two lifts of two vector fields on $M_1$ to slides $M_1\times p_2$ and $X_2, Y_2$ be two lifts of two vector fields on $M_2$ to slides $p_1 \times M_2$. Then  
$$\bar Ric(X_1,Y_1)= Ric^1(X_1,Y_1)-\frac{dimM_2}{f}Hess^f(X_1,Y_1)$$  
$$\bar Ric(X_2,Y_2)= Ric^1(X_2,Y_2)-f^*g_2(X_2,Y_2)$$  
where $f^*=f\Delta f-(dimM_2-1)g_1(grad f, grad f)$, $Ric^i$ is the lift of the Ricci curvatire tensor to $M_i$ and $\bar Ric$ is the Ricci curvature of $\bar M$. Now assume that $\bar M$ and $M_1$ are Ricci flat, then  
$$0= -\frac{dimM_2}{f}Hess^f(X_1,Y_1)$$  
$$0= Ric^2(X_2,Y_2)-f^*g_2(X_2,Y_2)$$   
The first equation implies that $Hess^f$ is zero i.e. the gradient of $f$ is a constant say $c$ and consequently  
$$f^*=f\Delta f-(dimM_2-1)g_1(grad f, grad f)=-(dimM_2-1)c^2$$  
Thus the second factor is Einstein.
Now assume that $\bar M$ and $M_2$ are Ricci flat, then  
$$0= Ric^1(X_1,Y_1)-\frac{dimM_2}{f}Hess^f(X_1,Y_1)$$  
$$0= -f^*g_2(X_2,Y_2)$$  
Then the first equation yields by tracing 
$$r_1=\frac{dimM_2}{f}\Delta f$$ 
and consequently the second equation implies  
$$ f^*=f\Delta f-(dimM_2-1)g_1(grad f, grad f)=0$$  
i.e. 
$$r_1f^2=dimM_2(dimM_2-1)g_1(grad f, grad f)$$