Reindexing Categories (Pavillione Template)

2 years ago
Hi,

We have a couple hundred "Categories", and we seem to have a problem that:

When me make changes on Product on info that a given catalogue uses to map a product to that catalogue, often the product is either not taken out of old category or put into the given new "Category".

Eksample:
Produkt1 has "123" in field X
Field X is mapped in Cataegory1 to value "123"

Product resides in Category1

Change field X on Produkt1 to "456".
Field X is mapped to Category2 to value "456

Product eiher now resides in both Categrory, but often it does not appear in its new catergory.

If i go on each category and hit the "Update" on every category it updates, but that is a job i cant do every time we update.


So,is there a service or script that i can run to basically make all categories update/reindex?



(we update our products from an ERP system, so that might be the culprit to the problem)
2 years ago
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);
2 years ago
Hi,
Thanks for your reply.

It seems that clearing cache did not solve it. I think those that programed this for uss have done some strange things int he backgrund to get the sync to work.

And this is one of the results.
2 years ago
Hi again,

When i think about it, it seems i must specify.

What happens is that when i do changes the postition of the products in their categoris is not uppdated tne the product ("card/page"??)

So when i "move" a product its old postion is still visbile on the product info page. And even if i manually update the relevant category, the product still is placed in that category.

So what i am after is a way to purge all placements on products, and then ask all categories to reindex where products are supposed to be plaecd.

petemitch wrote: