Reputation: 1235
I have a class named MenuNavigatin and use it for top menu
class MenuNavigation extends DefaultNavigationFactory
Is it a good practice to query and add 500 products to this class to use this navigation for sitemap ?
Or should I have another class for sitemap and breadcrumbs ?
Or maybe add sitemap specific urls when generating sitemap
Upvotes: 0
Views: 387
Reputation: 13558
Zend\Navigation tends to be slow for many pages. I would definitely not add all 500 pages to your navigation on every request. I'd add those pages only on a need-to-know base, which might be:
For the third case, you could do various things to speed up this rendering:
Furthermore, adding pages to the sitemap is a perfectly valid reason to enable an event manager. Your sitemap controller will trigger an event and your product module listens to the event. Next, it adds all those pages. This helps you to decouple your application and when you want to incorporate something alike (say, add 500 events as well), you could simply add a listener for your sitemap controller and have them added as pages as well.
Upvotes: 1