From b5218c1caa4631cc9703c631a83431005a4a4764 Mon Sep 17 00:00:00 2001 From: Volodymyr Kholoshenko Date: Thu, 17 Sep 2015 19:33:05 +0300 Subject: [PATCH 1/4] MAGETWO-42724: Import error: We can92t run the operation right now, see error log for details --- .../Model/Product/Plugin/Import.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php index 62adfeb58d529..83b5456d83db9 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php @@ -320,12 +320,14 @@ protected function canonicalUrlRewriteGenerate() $urls = []; foreach ($this->products as $productId => $productsByStores) { foreach ($productsByStores as $storeId => $product) { - $urls[] = $this->urlRewriteFactory->create() - ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) - ->setEntityId($productId) - ->setRequestPath($this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId)) - ->setTargetPath($this->productUrlPathGenerator->getCanonicalUrlPath($product)) - ->setStoreId($storeId); + if ($this->productUrlPathGenerator->getUrlPath($product) != '') { + $urls[] = $this->urlRewriteFactory->create() + ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) + ->setEntityId($productId) + ->setRequestPath($this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId)) + ->setTargetPath($this->productUrlPathGenerator->getCanonicalUrlPath($product)) + ->setStoreId($storeId); + } } } From 7658c91f9e0d53c21ca033527ec168fd472e6a06 Mon Sep 17 00:00:00 2001 From: Volodymyr Kholoshenko Date: Fri, 18 Sep 2015 12:58:20 +0300 Subject: [PATCH 2/4] MAGETWO-42724: Import error: We cant run the operation right now, see error log for details --- .../Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php index 83b5456d83db9..39be81d852264 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/Plugin/Import.php @@ -320,7 +320,7 @@ protected function canonicalUrlRewriteGenerate() $urls = []; foreach ($this->products as $productId => $productsByStores) { foreach ($productsByStores as $storeId => $product) { - if ($this->productUrlPathGenerator->getUrlPath($product) != '') { + if ($this->productUrlPathGenerator->getUrlPath($product)) { $urls[] = $this->urlRewriteFactory->create() ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($productId) From 9b288e71f2e4aa8da36063bbf6d7c434a080cd65 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov Date: Fri, 18 Sep 2015 16:12:59 +0300 Subject: [PATCH 3/4] =?UTF-8?q?MAGETWO-42724:=20Import=20error:=20"We=20ca?= =?UTF-8?q?n=E2=80=99t=20run=20the=20operation=20right=20now,=20see=20erro?= =?UTF-8?q?r=20log=20for=20details"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Unit/Model/Product/Plugin/ImportTest.php | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/Plugin/ImportTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/Plugin/ImportTest.php index b13bf56a5eaf3..1f07c92bd0cd9 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/Plugin/ImportTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/Plugin/ImportTest.php @@ -683,7 +683,7 @@ public function testClearProductUrls() /** * Cover canonicalUrlRewriteGenerate(). */ - public function testCanonicalUrlRewriteGenerate() + public function testCanonicalUrlRewriteGenerateWithUrlPath() { $productId = 'product_id'; $requestPath = 'simple-product.html'; @@ -704,6 +704,10 @@ public function testCanonicalUrlRewriteGenerate() ->expects($this->once()) ->method('getUrlPathWithSuffix') ->will($this->returnValue($requestPath)); + $this->productUrlPathGenerator + ->expects($this->once()) + ->method('getUrlPath') + ->will($this->returnValue('urlPath')); $this->productUrlPathGenerator ->expects($this->once()) ->method('getCanonicalUrlPath') @@ -747,6 +751,37 @@ public function testCanonicalUrlRewriteGenerate() ); } + /** + * Cover canonicalUrlRewriteGenerate(). + */ + public function testCanonicalUrlRewriteGenerateWithEmptyUrlPath() + { + $productId = 'product_id'; + $requestPath = 'simple-product.html'; + $storeId = 10; + $product = $this + ->getMockBuilder('Magento\Catalog\Model\Product') + ->disableOriginalConstructor() + ->getMock(); + $productsByStores = [$storeId => $product]; + $products = [ + $productId => $productsByStores, + ]; + + $this->setPropertyValue($this->import, 'products', $products); + + $this->productUrlPathGenerator + ->expects($this->once()) + ->method('getUrlPath') + ->will($this->returnValue('')); + $this->urlRewriteFactory + ->expects($this->never()) + ->method('create'); + + $actualResult = $this->invokeMethod($this->import, 'canonicalUrlRewriteGenerate'); + $this->assertEquals([], $actualResult); + } + /** * Cover categoriesUrlRewriteGenerate(). */ From 6d49920d643d1311905ada6b6c706e358966ee36 Mon Sep 17 00:00:00 2001 From: Stanislav Lopukhov Date: Fri, 18 Sep 2015 16:34:46 +0300 Subject: [PATCH 4/4] =?UTF-8?q?MAGETWO-42724:=20Import=20error:=20"We=20ca?= =?UTF-8?q?n=E2=80=99t=20run=20the=20operation=20right=20now,=20see=20erro?= =?UTF-8?q?r=20log=20for=20details"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Test/Unit/Model/Product/Plugin/ImportTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/Plugin/ImportTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/Plugin/ImportTest.php index 1f07c92bd0cd9..3a1d4bc4573b5 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/Plugin/ImportTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/Plugin/ImportTest.php @@ -757,7 +757,6 @@ public function testCanonicalUrlRewriteGenerateWithUrlPath() public function testCanonicalUrlRewriteGenerateWithEmptyUrlPath() { $productId = 'product_id'; - $requestPath = 'simple-product.html'; $storeId = 10; $product = $this ->getMockBuilder('Magento\Catalog\Model\Product')