diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml index f7a073a163366..6f4fb4a3827bb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml @@ -101,7 +101,7 @@ - + diff --git a/app/code/Magento/CatalogUrlRewrite/Model/CategoryBasedProductRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/CategoryBasedProductRewriteGenerator.php index 105ca290a0721..8e599f915ba39 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/CategoryBasedProductRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/CategoryBasedProductRewriteGenerator.php @@ -11,8 +11,9 @@ /** * Class ProductUrlRewriteGenerator - * @package Magento\CatalogUrlRewrite\Model * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated 101.0.0 please use \Magento\CatalogUrlRewrite\Model\CategoryProductUrlPathGenerator instead. + * @see https://github.com/magento/magento2/commit/c7d6324fe84766ddd9ab9710f19b5923fcbac09a */ class CategoryBasedProductRewriteGenerator { diff --git a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php index c6d72c9f8f11b..b40f54cb3cd3f 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php @@ -6,12 +6,12 @@ namespace Magento\CatalogUrlRewrite\Model; use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Visibility; use Magento\CatalogUrlRewrite\Model\Product\CanonicalUrlRewriteGenerator; use Magento\CatalogUrlRewrite\Model\Product\CategoriesUrlRewriteGenerator; use Magento\CatalogUrlRewrite\Model\Product\CurrentUrlRewritesRegenerator; use Magento\CatalogUrlRewrite\Service\V1\StoreViewService; use Magento\Framework\App\ObjectManager; -use Magento\Catalog\Model\Product\Visibility; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; @@ -28,6 +28,7 @@ class ProductUrlRewriteGenerator /** * @deprecated 100.1.0 * @see not used + * @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203 * @var \Magento\CatalogUrlRewrite\Service\V1\StoreViewService */ protected $storeViewService; @@ -36,12 +37,14 @@ class ProductUrlRewriteGenerator * @var \Magento\Catalog\Model\Product * @see not used * @deprecated 100.1.0 + * @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203 */ protected $product; /** * @deprecated 100.1.0 * @see not used + * @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203 * @var \Magento\CatalogUrlRewrite\Model\Product\CurrentUrlRewritesRegenerator */ protected $currentUrlRewritesRegenerator; @@ -49,6 +52,7 @@ class ProductUrlRewriteGenerator /** * @deprecated 100.1.0 * @see not used + * @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203 * @var \Magento\CatalogUrlRewrite\Model\Product\CategoriesUrlRewriteGenerator */ protected $categoriesUrlRewriteGenerator; @@ -56,6 +60,7 @@ class ProductUrlRewriteGenerator /** * @deprecated 100.1.0 * @see not used + * @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203 * @var \Magento\CatalogUrlRewrite\Model\Product\CanonicalUrlRewriteGenerator */ protected $canonicalUrlRewriteGenerator; @@ -63,6 +68,7 @@ class ProductUrlRewriteGenerator /** * @deprecated 100.1.0 * @see not used + * @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203 * @var \Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory */ protected $objectRegistryFactory; @@ -70,13 +76,16 @@ class ProductUrlRewriteGenerator /** * @deprecated 100.1.0 * @see not used + * @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203 * @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry */ protected $productCategories; /** * @deprecated 100.1.0 + * @var \Magento\Store\Model\StoreManagerInterface * @see not used + * @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203 * @var StoreManagerInterface */ protected $storeManager; @@ -123,6 +132,7 @@ public function __construct( * * @deprecated 100.1.4 * @see not used + * @see https://github.com/magento/magento2/commit/b2ce2a37d921b5ad88fc38663fc0ff3dd6c582d1 * @return ProductScopeRewriteGenerator|mixed */ private function getProductScopeRewriteGenerator() @@ -154,16 +164,12 @@ public function generate(Product $product, $rootCategoryId = null) } } - $storeId = $product->getStoreId(); $productCategories = $product->getCategoryCollection() ->addAttributeToSelect('url_key') ->addAttributeToSelect('url_path'); - $urls = $this->isGlobalScope($storeId) - ? $this->generateForGlobalScope($productCategories, $product, $rootCategoryId) - : $this->generateForSpecificStoreView($storeId, $productCategories, $product, $rootCategoryId); - - return $urls; + // Generate url rewrites for all store views to ensure store views with different url-key are generated as well. + return $this->generateForGlobalScope($productCategories, $product, $rootCategoryId); } /** @@ -171,6 +177,7 @@ public function generate(Product $product, $rootCategoryId = null) * * @deprecated 100.1.4 * @see not used + * @see https://github.com/magento/magento2/commit/b2ce2a37d921b5ad88fc38663fc0ff3dd6c582d1 * @param int|null $storeId * @return bool */ @@ -184,6 +191,7 @@ protected function isGlobalScope($storeId) * * @deprecated 100.1.4 * @see not used + * @see https://github.com/magento/magento2/commit/b2ce2a37d921b5ad88fc38663fc0ff3dd6c582d1 * @param \Magento\Framework\Data\Collection $productCategories * @param \Magento\Catalog\Model\Product|null $product * @param int|null $rootCategoryId @@ -203,6 +211,7 @@ protected function generateForGlobalScope($productCategories, $product = null, $ * * @deprecated 100.1.4 * @see not used + * @see https://github.com/magento/magento2/commit/b2ce2a37d921b5ad88fc38663fc0ff3dd6c582d1 * @param int $storeId * @param \Magento\Framework\Data\Collection $productCategories * @param Product|null $product @@ -220,10 +229,14 @@ protected function generateForSpecificStoreView( } /** + * Checking the category is generating correctly + * + * @deprecated 100.1.4 * Check if category should have url rewrites * * @deprecated 100.1.4 * @see not used + * @see https://github.com/magento/magento2/commit/b2ce2a37d921b5ad88fc38663fc0ff3dd6c582d1 * @param \Magento\Catalog\Model\Category $category * @param int $storeId * @return bool diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php index ea957a0d36c51..8f5f02cfde1cc 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php @@ -134,15 +134,11 @@ public function testGenerate() $productMock = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->getMock(); - $storeId = 1; $urls = ['dummy-url.html']; $productMock->expects($this->once()) ->method('getVisibility') ->willReturn(2); - $productMock->expects($this->once()) - ->method('getStoreId') - ->willReturn($storeId); $productCategoriesMock = $this->getMockBuilder(Collection::class) ->disableOriginalConstructor() ->getMock(); @@ -156,7 +152,7 @@ public function testGenerate() ->method('getCategoryCollection') ->willReturn($productCategoriesMock); $this->productScopeRewriteGenerator->expects($this->once()) - ->method('generateForSpecificStoreView') + ->method('generateForGlobalScope') ->willReturn($urls); $this->assertEquals($urls, $this->productUrlRewriteGenerator->generate($productMock, 1)); } diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminProductCreateUrlRewriteForCustomStoreViewTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminProductCreateUrlRewriteForCustomStoreViewTest.xml index 4577dcf1dcd4e..e3c0f0053cad3 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminProductCreateUrlRewriteForCustomStoreViewTest.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminProductCreateUrlRewriteForCustomStoreViewTest.xml @@ -90,8 +90,10 @@ - - + + + + diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteTest.php index ba5d0695873b6..91301bd4779a4 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteTest.php @@ -175,11 +175,6 @@ public static function productEditProvider(): array 'request_path' => 'new-url-key%suffix%', 'target_path' => 'catalog/product/view/id/%id%', ], - [ - 'request_path' => 'simple-product%suffix%', - 'target_path' => 'new-url-key%suffix%', - 'redirect_type' => OptionProvider::PERMANENT, - ], ], ], ];