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:

Relevant code:

Subscribing to the event

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

Receiving updated category IDs


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;