SnowdogApps / magento2-menu

Provides powerful menu editor to replace category based menus in Magento 2
MIT License
299 stars 105 forks source link

Performance issues on large menus, model loaded via repository #341

Open ilnytskyi opened 2 months ago

ilnytskyi commented 2 months ago

Hello,

We noticed that for bigger menus the GraphQL response is too slow. After some investigation we found that this method https://github.com/SnowdogApps/magento2-menu/blob/develop/Model/GraphQl/Resolver/DataProvider/Node/TypeModel.php#L49 loads whole model via its repository, and later only uses it to get UrlKey. See https://github.com/SnowdogApps/magento2-menu/blob/develop/Model/GraphQl/Resolver/DataProvider/Node/TypeModel.php#L68

Selection_20240903_012 Selection_20240903_013

That would be great improvement if we could only load one or a few needed attributes like magento does on product listing with collection (there is option to specify if attribute should be loaded on listing). So the MenuEntityLoader can be introduced with posibility to specify what attributes to load; url_key can be set as default, in case anyone would need more data form the model, they would implement custom loaders, so default menu implementation would not affect the performance.

andrzejborkowski commented 2 months ago

@ilnytskyi thank you for reporting the issue, I created an internal ticket SMM-18 and our dev team will take a look at that soon. However, it will much faster if you can create a PR with the mentioned improvements and then we can review your code and include to one of the next releases