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