diff --git a/src/Observers/UrlRewriteObserver.php b/src/Observers/UrlRewriteObserver.php index 9b0773e..dcaa3aa 100644 --- a/src/Observers/UrlRewriteObserver.php +++ b/src/Observers/UrlRewriteObserver.php @@ -315,7 +315,29 @@ protected function process() try { // persist the URL rewrite if ($this->hasChanges($urlRewrite)) { - $this->urlRewriteId = $this->persistUrlRewrite($urlRewrite); + try { + $this->urlRewriteId = $this->persistUrlRewrite($urlRewrite); + } catch (\PDOException $pdoe) { + $message = sprintf('%s with Urlrewrite Data %s "', $pdoe->getMessage(), $urlRewrite); + if (!$this->getSubject()->isStrictMode()) { + $this->getSubject() + ->getSystemLogger() + ->warning($this->getSubject()->appendExceptionSuffix($message)); + $this->mergeStatus( + array( + RegistryKeys::NO_STRICT_VALIDATIONS => array( + basename($this->getFilename()) => array( + $this->getLineNumber() => array( + ColumnKeys::URL_KEY => $message + ) + ) + ) + ) + ); + } else { + throw new \PDOException($pdoe); + } + } } else { $this->urlRewriteId = $urlRewrite[MemberNames::URL_REWRITE_ID]; } @@ -335,7 +357,29 @@ protected function process() // persist the URL rewrite product category relation if ($this->hasChanges($urlRewriteProductCategory)) { - $this->persistUrlRewriteProductCategory($urlRewriteProductCategory); + try { + $this->persistUrlRewriteProductCategory($urlRewriteProductCategory); + } catch (\PDOException $pdoe) { + $message = sprintf('%s with Urlrewrite Data %s "', $pdoe->getMessage(), $urlRewriteProductCategory); + if (!$this->getSubject()->isStrictMode()) { + $this->getSubject() + ->getSystemLogger() + ->warning($this->getSubject()->appendExceptionSuffix($message)); + $this->mergeStatus( + array( + RegistryKeys::NO_STRICT_VALIDATIONS => array( + basename($this->getFilename()) => array( + $this->getLineNumber() => array( + ColumnKeys::URL_KEY => $message + ) + ) + ) + ) + ); + } else { + throw new \PDOException($pdoe); + } + } } } catch (\Exception $e) { if (!$this->getSubject()->isStrictMode()) { diff --git a/src/Observers/UrlRewriteUpdateObserver.php b/src/Observers/UrlRewriteUpdateObserver.php index 6c36b44..7abb7f9 100644 --- a/src/Observers/UrlRewriteUpdateObserver.php +++ b/src/Observers/UrlRewriteUpdateObserver.php @@ -14,6 +14,7 @@ namespace TechDivision\Import\Product\UrlRewrite\Observers; +use TechDivision\Import\Utils\RegistryKeys; use TechDivision\Import\Utils\StoreViewCodes; use TechDivision\Import\Product\Utils\CoreConfigDataKeys; use TechDivision\Import\Product\UrlRewrite\Utils\MemberNames; @@ -129,8 +130,30 @@ protected function process() // merge and return the prepared URL rewrite $existingUrlRewrite = $this->mergeEntity($existingUrlRewrite, $attr); - // create the URL rewrite - $this->persistUrlRewrite($existingUrlRewrite); + try { + // create the URL rewrite + $this->persistUrlRewrite($existingUrlRewrite); + } catch (\PDOException $pdoe) { + if (!$this->getSubject()->isStrictMode()) { + $message = sprintf('%s with Urlrewrite Data %s "', $pdoe->getMessage(), $existingUrlRewrite); + $this->getSubject() + ->getSystemLogger() + ->warning($this->getSubject()->appendExceptionSuffix($message)); + $this->mergeStatus( + array( + RegistryKeys::NO_STRICT_VALIDATIONS => array( + basename($this->getFilename()) => array( + $this->getLineNumber() => array( + ColumnKeys::URL_KEY => $message + ) + ) + ) + ) + ); + } else { + throw new \PDOException($pdoe); + } + } } else { // query whether or not the URL rewrite has to be removed if ($this->getSubject()->getConfiguration()->hasParam(ConfigurationKeys::CLEAN_UP_URL_REWRITES) &&