A
A
Artem2016-05-26 12:28:01
PHP
Artem, 2016-05-26 12:28:01

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

I thought it was about the agents that need to be transferred to the cron, but the error in the script itself crashes.
Can anyone come across? Help me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem, 2016-05-30
@beardedman

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);
}
}
?>

Thanks DevMan for the help.
https://bxapi.ru - the resource helped a lot. If you have something missing - look at this site for information about this class and in which file it is declared.

A
Alexey Ukolov, 2016-05-26
@alexey-m-ukolov

Perhaps some agent is missing CModule::IncludeModule('catalog').

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question