Performance Issues in Magento_Store
Findings
| # |
File |
Line(s) |
Issue |
Consensus Severity |
| 32 |
Model/StoreManager.php |
141 |
Missing Caching: hasSingleStore() loads full store collection on every call. Code has TODO: MAGETWO-39902 add cache. |
Medium-High |
| 33 |
Model/StoreManager.php |
179-192 |
N+1 Loading: getStores() calls storeRepository->getList() and post-filters in PHP loop instead of query-level filtering. |
Medium-High |
| 34 |
Model/StoreManager.php |
218-231 |
N+1 Loading: getWebsites() same pattern as #33 — calls websiteRepository->getList() and filters in PHP. |
Medium-High |
| 36 |
App/Action/Plugin/Context.php |
148 |
Plugin Overhead: getDefaultStoreView() called on EVERY frontend request via beforeDispatch() plugin without caching. |
Medium-High |
Review Note — Finding #36 (Context plugin getDefaultStoreView caching)
After code review, this specific optimization was rejected: Context::beforeDispatch() is called exactly once per HTTP request — there is no loop or repeated invocation. Caching getDefaultStoreView() inside this plugin provides zero performance benefit under normal operation. Additionally, getDefaultStoreView() can return null, and the null-safe memoization pattern would require a sentinel flag, adding complexity for no gain.
Performance Issues in
Magento_StoreFindings
Model/StoreManager.phphasSingleStore()loads full store collection on every call. Code has TODO:MAGETWO-39902 add cache.Model/StoreManager.phpgetStores()callsstoreRepository->getList()and post-filters in PHP loop instead of query-level filtering.Model/StoreManager.phpgetWebsites()same pattern as #33 — callswebsiteRepository->getList()and filters in PHP.App/Action/Plugin/Context.phpgetDefaultStoreView()called on EVERY frontend request viabeforeDispatch()plugin without caching.Review Note — Finding #36 (Context plugin getDefaultStoreView caching)
After code review, this specific optimization was rejected:
Context::beforeDispatch()is called exactly once per HTTP request — there is no loop or repeated invocation. CachinggetDefaultStoreView()inside this plugin provides zero performance benefit under normal operation. Additionally,getDefaultStoreView()can returnnull, and the null-safe memoization pattern would require a sentinel flag, adding complexity for no gain.