/** * @param Product $product */ private function saveRelated($product) { if ($product->isRelatedModified()) { foreach ($product->getRelated() as $related) { $this->getDb()->query("\n DELETE FROM product_related\n WHERE\n (product_id = :productId AND related_id = :relatedId)\n OR (related_id = :productId AND product_id = :relatedId)\n ", [':productId' => $product->getId(), ':relatedId' => $related->getId()]); $this->getDb()->query("INSERT INTO product_related VALUES (:productId, :relatedId), (:relatedId, :productId)", [':productId' => $product->getId(), ':relatedId' => $related]); } } }