@@ -61,11 +61,7 @@ public function checkForIncorrectUrlPathAttributeValues(): array
61
61
$ allCategories = $ this ->getAllVisibleCategoriesWithStoreId ($ storeId );
62
62
63
63
foreach ($ allCategories as $ category ) {
64
- $ isOverridden = $ this
65
- ->attributeScopeOverriddenValueFactory
66
- ->create ()
67
- ->containsValue (CategoryInterface::class, $ category , self ::URL_PATH_ATTRIBUTE , $ storeId )
68
- ;
64
+ $ isOverridden = $ this ->getIsUrlPathOverridden ($ category , $ storeId );
69
65
70
66
// we don't care about non overwritten values
71
67
if (!$ isOverridden && $ storeId !== Store::DEFAULT_STORE_ID ) {
@@ -90,6 +86,43 @@ public function checkForIncorrectUrlPathAttributeValues(): array
90
86
return $ problems ;
91
87
}
92
88
89
+ private function getIsUrlPathOverridden (Category $ category , int $ storeId ): bool
90
+ {
91
+ $ isOverridden = $ this
92
+ ->attributeScopeOverriddenValueFactory
93
+ ->create ()
94
+ ->containsValue (CategoryInterface::class, $ category , self ::URL_PATH_ATTRIBUTE , $ storeId )
95
+ ;
96
+
97
+ // if the current category isn't using an overridden url path, the parent category's still could,
98
+ // so we need to check those as well ...
99
+ if ($ isOverridden === false ) {
100
+ // phpcs:disable Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
101
+ try {
102
+ $ isParentOverridden = false ;
103
+ $ parentCat = $ category ;
104
+
105
+ do {
106
+ $ parentCat = $ parentCat ->getParentCategory ();
107
+ $ isParentOverridden = $ this
108
+ ->attributeScopeOverriddenValueFactory
109
+ ->create ()
110
+ ->containsValue (CategoryInterface::class, $ parentCat , self ::URL_PATH_ATTRIBUTE , $ storeId )
111
+ ;
112
+ } while ($ isParentOverridden === false && $ parentCat ->getLevel () > 1 );
113
+
114
+ if ($ isParentOverridden === true ) {
115
+ $ isOverridden = true ;
116
+ }
117
+ } catch (\Throwable $ ex ) {
118
+ // do nothing
119
+ }
120
+ // phpcs:enable Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
121
+ }
122
+
123
+ return $ isOverridden ;
124
+ }
125
+
93
126
/**
94
127
* @return CategoryCollection<Category>
95
128
*/
0 commit comments