Clearing category caches after Tagalys updates product positions

Tagalys automatically dispatches the clean_cache_by_tags event for categories after updating positions. If the front-end is not updated after this, one more caching level may not be listening to this event.

In this case, you can listen to Tagalys' tagalys_category_positions_updated event to implement custom code to clear the caches.

Example implementation:

https://www.dropbox.com/s/34y0xmv350dzzhp/Tagalys-M2-Customizations.zip?dl=0

Relevant code:

Subscribing to the event

<event name="tagalys_category_positions_updated">
<observer name="tagalys_category_positions_updated" instance="Tagalys\Customizations\Observer\CategoryPositionsUpdated" />
</event>

Receiving updated category IDs

<?php

namespace Tagalys\Customizations\Observer;

class CategoryPositionsUpdated implements \Magento\Framework\Event\ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$categoryIdObj = $observer->getData('tgls_data');
$categoryIds = $categoryIdObj->getCategoryIds();

// clear cache for $categoryIds
// NOTE: $categoryIds may be an array of category IDs or a single category ID (not inside an array)

return $this;
}
}