From 5a8e3938b71b98af41d5a306af21b3e86a87903e Mon Sep 17 00:00:00 2001 From: Maksym Aposov Date: Mon, 8 Jun 2015 17:22:26 +0300 Subject: [PATCH] MAGETWO-36369: [GitHub] Unable to save product per website wise #1245 --- .../Model/ProductUrlPathGenerator.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php index cd798278fc9c6..5e7cd4714d342 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php @@ -77,15 +77,9 @@ public function getUrlPath($product, $category = null) */ protected function _prepareProductDefaultUrlKey(\Magento\Catalog\Model\Product $product) { - $storedProduct = $this->productRepository->getById($product->getId(), false, Store::DEFAULT_STORE_ID); + $storedProduct = $this->productRepository->getById($product->getId(), false, Store::DEFAULT_STORE_ID, true); $storedUrlKey = $storedProduct->getUrlKey(); - $result = null; - if ($storedUrlKey !== false) { - $result = $storedUrlKey; - } else { - $result = $product->formatUrlKey($storedProduct->getName()); - } - return $result; + return $storedUrlKey ?: $product->formatUrlKey($storedProduct->getName()); } /**