Sabidussi proved that if a finite graph $X$ is isomorphic to a Cartesian product of connected graphs $X_1,\ldots,X_m$ which are pairwise relatively prime with respect to Cartesian multiplication, then the automorphism group of $X$ is isomorphic to the direct product of the automorphism groups of $X_1,\ldots,X_m$.
My question is: is there a version of this theorem where one replaces the automorphism group of $X$ by the endomorphism monoid of $X$ (defined as the set of graph morphisms $X \mapsto X$ endowed with composition of maps) ?
Variation: let $\mathrm{hom}(X,Y)$ be the set of graph morphisms from the graph $X$ to the graph $Y$. Let $Z$ be a graph relatively prime to $X$ and $Y$; what is $\mathrm{hom}(X \times Z,Y \times Z)$ ?