Answer the question
In order to leave comments, you need to log in
Class 'Bitrix\Catalog\CatalogViewedProductTable' not found in agent.php?
Hello!
I'm still scratching my head and can't figure it out: from time to time the site crashes fatal error
PHP Fatal error: Class 'Bitrix\Catalog\CatalogViewedProductTable' not found in /var/www/bitrix/modules/main/classes/mysql/agent.php(162) : eval()'d code on line 1
Answer the question
In order to leave comments, you need to log in
In general, I fixed the problem with this class by adding the missing file (it is not clear why it was not there):
<?php
// /bitrix/modules/catalog/lib/catalogviewedproduct.php
namespace Bitrix\Catalog;
use Bitrix\Main\Config\Option;
use Bitrix\Main\Application;
class CatalogViewedProductTable{
public static function clearAgent()
{
self::clear((int)Option::get('catalog', 'viewed_time'));
return '\Bitrix\Catalog\CatalogViewedProductTable::clearAgent();';
}
public static function clear($liveTime = 10)
{
$connection = Application::getConnection();
$helper = $connection->getSqlHelper();
$liveTime = (int)$liveTime;
$liveTo = $helper->addSecondsToDateTime($liveTime * 24 * 3600, "DATE_VISIT");
$now = $helper->getCurrentDateTimeFunction();
$deleteSql = "delete from b_catalog_viewed_product where ".$now." > ".$liveTo;
$connection->query($deleteSql);
}
}
?>
Perhaps some agent is missing CModule::IncludeModule('catalog')
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question