Outland NO wrote:(we update our products from an ERP system, so that might be the culprit to the problem)
Product category mappings are cached by default for performance reasons so it would depend on how you're syncing nop from your ERP system. The 'proper' way to do it would be to call same methods that nop uses from the
CategoryService which contain code for invalidating the necessary cache objects.
If you're updating the database directly then you're going to be bypassing all the cache invalidation code so you won't see the changes until the cached object expires. I think the default cache duration is 1 hour so you could be waiting anything from 1 second to 1 hour depending on when the relevant cached objects were last generated.
Outland NO wrote:So,is there a service or script that i can run to basically make all categories update/reindex?
You can just use the
Clear cache option from the admin interface. Obviously there's a performance penalty associated with this as it will clear the entire cache so all required objects will need to be recreated on the next request to the website.
If you're looking for something that can be automated there's a Clear cache
scheduled task which you could possibly trigger from your ERP sync process.
Or you could use the CacheManager to invalidate the cache in the same way that nop does:
private const string CATEGORIES_PATTERN_KEY = "Nop.category.";
private const string PRODUCTCATEGORIES_PATTERN_KEY = "Nop.productcategory.";
//cache
_cacheManager.RemoveByPattern(CATEGORIES_PATTERN_KEY);
_cacheManager.RemoveByPattern(PRODUCTCATEGORIES_PATTERN_KEY);