M
M
m4rty2018-08-23 17:21:25
1C-Bitrix
m4rty, 2018-08-23 17:21:25

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

2 answer(s)
S
serginhold, 2018-08-23
@serginhold

delete from b_catalog_viewed_product where как-тебе хочется

S
Sergey Panteleev, 2018-08-23
@s_panteleev

<?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 question

Ask a Question

731 491 924 answers to any question