Skip to content

Fix Url Rewrite not generated for stores that have different url key and adds the deprecated message to CategoryBasedProductRewriteGenerator class #36360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d84fded
Remove CategoryBasedProductRewriteGenerator class as it is redundant …
TuVanDev Oct 22, 2022
295e7db
#36295: Fix Url rewrites not regenrated for stores that have differen…
TuVanDev Oct 22, 2022
7129b14
Revert "Remove CategoryBasedProductRewriteGenerator class as it is re…
TuVanDev Oct 28, 2022
55b1a46
Merge branch '2.4-develop' into fix-url-rewrite-not-generated-for-sto…
TuVanDev Nov 4, 2022
85fff83
Add deprecated message for CategoryBasedProductRewriteGenerator class
TuVanDev Nov 4, 2022
c683649
Merge branch origin/2.4-develop
TuVanDev Nov 12, 2022
02bd6d6
#36925: Correct deprecated message for CategoryBasedProductRewriteGen…
TuVanDev Nov 12, 2022
2127993
Merge branch 'magento:2.4-develop' into fix-url-rewrite-not-generated…
TuVanDev Feb 5, 2023
2dbb61e
magento#36295: Update Unit Test
TuVanDev Feb 5, 2023
7f87179
magento#36295: Update Unit Test - remove unused variable
TuVanDev Feb 5, 2023
429178a
Merge remote-tracking branch 'magento/2.4-develop' into fix-url-rewri…
engcom-Delta Feb 20, 2023
f07758f
PR:36360 fix for Static Tests failures
engcom-Delta Feb 22, 2023
8112daf
Merge remote-tracking branch 'magento/2.4-develop' into fix-url-rewri…
engcom-Delta Feb 27, 2023
3ea05aa
Merge remote-tracking branch 'magento/2.4-develop' into fix-url-rewri…
engcom-Delta Mar 7, 2023
e378858
PR-36360: fix for functional test failure
engcom-Delta Mar 8, 2023
e80b7f3
Removing .credential file
engcom-Delta Mar 9, 2023
d18aa69
fix for functional test failures
engcom-Delta Mar 9, 2023
3df9f61
Merge branch '2.4-develop' into fix-url-rewrite-not-generated-for-sto…
engcom-Lima Mar 15, 2023
1aa3862
Merge remote-tracking branch 'magento/2.4-develop' into fix-url-rewri…
engcom-Delta Mar 15, 2023
e679b73
fix for integration test failure
engcom-Delta Mar 15, 2023
b97666e
Merge branch '2.4-develop' into fix-url-rewrite-not-generated-for-sto…
TuVanDev Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<!-- Open second product -->
<click selector="{{StorefrontCategoryProductSection.ProductTitleByName($createSimpleProductSecond.name$)}}" stepKey="openSecondProduct"/>
<waitForPageLoad time="30" stepKey="waitForSecondProduct"/>
<seeInCurrentUrl url="{$simpleProductSecondNameLower}.html" stepKey="checkSecondSimpleProductUrlKey"/>
<seeInCurrentUrl url="u2.html" stepKey="checkSecondSimpleProductUrlKey"/>

<actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="switchToCustomStoreView">
<argument name="storeView" value="storeViewData"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -36,47 +37,55 @@ 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;

/**
* @deprecated 100.1.0
* @see not used
* @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203
* @var \Magento\CatalogUrlRewrite\Model\Product\CategoriesUrlRewriteGenerator
*/
protected $categoriesUrlRewriteGenerator;

/**
* @deprecated 100.1.0
* @see not used
* @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203
* @var \Magento\CatalogUrlRewrite\Model\Product\CanonicalUrlRewriteGenerator
*/
protected $canonicalUrlRewriteGenerator;

/**
* @deprecated 100.1.0
* @see not used
* @see https://github.com/magento/magento2/commit/6729b6e01368248abc33300208eb292c95050203
* @var \Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory
*/
protected $objectRegistryFactory;

/**
* @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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -154,23 +164,20 @@ 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);
}

/**
* Check is global scope
*
* @deprecated 100.1.4
* @see not used
* @see https://github.com/magento/magento2/commit/b2ce2a37d921b5ad88fc38663fc0ff3dd6c582d1
* @param int|null $storeId
* @return bool
*/
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@
<argument name="category" value="$$createCategory$$"/>
<argument name="product" value="$$createProductForUrlRewrite$$"/>
</actionGroup>
<actionGroup ref="StorefrontCheckProductUrlActionGroup" stepKey="checkProductWithChangedUrl">
<argument name="productUrl" value="$$createProductForUrlRewrite.custom_attributes[url_key]$$"/>
<actionGroup ref="AssertStorefrontProductRedirectActionGroup" stepKey="checkProductWithChangedUrl">
<argument name="productName" value="$$createProductForUrlRewrite.name$$"/>
<argument name="productSku" value="$$createProductForUrlRewrite.sku$$"/>
<argument name="productRequestPath" value="u2.html"/>
</actionGroup>
<!--Step 8. On Storefront switch on created Custom Store View -->
<actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="switchToCustomStoreViewOnStorefront">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
],
],
];
Expand Down