Answer the question
In order to leave comments, you need to log in
How to clear a user's viewed items?
It is necessary to clear the (completely) viewed products of this user. CatalogViewedProductTable::clear();
This code does not delete. Is there really no way to clear the user's history without fiddling with the database? Thank you!
Answer the question
In order to leave comments, you need to log in
<?php
use Bitrix\Catalog\CatalogViewedProductTable;
use Bitrix\Sale\Fuser;
foreach (CatalogViewedProductTable::getList(['filter' => ['FUSER' => Fuser::getId()]])->fetchAll() as $item) {
CatalogViewedProductTable::delete($item['ID']);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question