There is a module for that on undirected graphs: http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/graph_decompositions/graph_products.html . However, how to differentiate situations where P1 might be Poset({0:[1, 2]}) or Poset({0: [1], 1: [2]})? They have isomorphic cover relations graph.
-- Jori Mäntysalo