diff --git a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php index d8e699322..fbe64378c 100644 --- a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php +++ b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php @@ -225,8 +225,9 @@ trait UrlRewritingTrait { } /* deprecate the old one if needed */ - $oldRewritingUrl = RewritingUrlQuery::create()->findOneByUrl($currentUrl); - $oldRewritingUrl->setRedirected($rewritingUrl->getId())->save(); + if (null !== $oldRewritingUrl = RewritingUrlQuery::create()->findOneByUrl($currentUrl)) { + $oldRewritingUrl->setRedirected($rewritingUrl->getId())->save(); + } return $this; }