6
6
namespace Magento \CatalogUrlRewrite \Model ;
7
7
8
8
use Magento \Catalog \Api \CategoryRepositoryInterface ;
9
+ use Magento \Catalog \Api \Data \CategoryInterface ;
9
10
use Magento \Catalog \Model \Category ;
10
11
use Magento \Catalog \Model \Product ;
11
12
use Magento \CatalogUrlRewrite \Model \Product \AnchorUrlRewriteGenerator ;
15
16
use Magento \CatalogUrlRewrite \Service \V1 \StoreViewService ;
16
17
use Magento \Framework \App \Config \ScopeConfigInterface ;
17
18
use Magento \Framework \App \ObjectManager ;
19
+ use Magento \Framework \Exception \NoSuchEntityException ;
18
20
use Magento \Store \Model \Store ;
19
21
use Magento \Store \Model \StoreManagerInterface ;
20
22
use Magento \UrlRewrite \Model \MergeDataProviderFactory ;
21
23
22
24
/**
23
- * Class ProductScopeRewriteGenerator
24
- *
25
25
* Generates Product/Category URLs for different scopes
26
26
*
27
27
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -237,14 +237,18 @@ public function isCategoryProperForGenerating(Category $category, $storeId)
237
237
}
238
238
239
239
/**
240
- * Check if URL key has been changed
241
- *
242
240
* Checks if URL key has been changed for provided category and returns reloaded category,
243
241
* in other case - returns provided category.
244
242
*
243
+ * Category should be loaded per appropriate store at all times. This is because whilst the URL key on the
244
+ * category in focus might be unchanged, parent category URL keys might be. If the category store ID
245
+ * and passed store ID are the same then return current category as it is correct but may have changed in memory
246
+ *
245
247
* @param int $storeId
246
248
* @param Category $category
247
- * @return Category
249
+ *
250
+ * @return CategoryInterface
251
+ * @throws NoSuchEntityException
248
252
*/
249
253
private function getCategoryWithOverriddenUrlKey ($ storeId , Category $ category )
250
254
{
@@ -254,11 +258,7 @@ private function getCategoryWithOverriddenUrlKey($storeId, Category $category)
254
258
Category::ENTITY
255
259
);
256
260
257
- // Category should be loaded per appropriate store at all times. This is because whilst the URL key on the
258
- // category in focus might be unchanged, parent category URL keys might be. If the category store ID
259
- // and passed store ID are the same then return current category as it is correct but may have changed in memory
260
-
261
- if (!$ isUrlKeyOverridden && $ storeId == $ category ->getStoreId ()) {
261
+ if (!$ isUrlKeyOverridden && $ storeId === $ category ->getStoreId ()) {
262
262
return $ category ;
263
263
}
264
264
0 commit comments