Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/components/bitrix/catalog.item/ |
Upload File : |
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die(); } use Bitrix\Main\Engine\ActionFilter\Authentication; use Bitrix\Main\Engine\ActionFilter\Scope; use Bitrix\Main\Config\Option; use Bitrix\Main\Error; use Bitrix\Catalog; use Bitrix\Main\Loader; use Bitrix\Main\Engine\Controller; class CatalogItemController extends Controller { public function configureActions() { return [ 'addViewedProduct' => [ '-prefilters' => [ Authentication::class ], '+prefilters' => [new Scope(Scope::AJAX)] ], ]; } /** * @param int $skuId * @param string $siteId * @param int $productId * @return void */ public function addViewedProductAction(int $skuId, string $siteId, int $productId = 0): void { if (!Loader::includeModule('catalog')) { $this->addError(new Error("Catalog isn't included", 'MODULE_CATALOG_IS_NOT_INCLUDED' )); return; } if (!Loader::includeModule('sale')) { $this->addError(new Error("Sale isn't included", 'MODULE_SALE_IS_NOT_INCLUDED' )); return; } if (!Catalog\Product\Basket::isNotCrawler()) { $this->addError(new Error("Not allowed", 'SEARCHER' )); return; } if (Option::get('catalog', 'enable_viewed_products') === 'N') { return; } $request = \Bitrix\Main\Context::getCurrent()->getRequest(); $recommendationCookie = $request->getCookie(Bitrix\Main\Analytics\Catalog::getCookieLogName()); $recommendationId = ''; if (!empty($recommendationCookie) && $productId) { $recommendations = \Bitrix\Main\Analytics\Catalog::decodeProductLog($recommendationCookie); if (is_array($recommendations) && isset($recommendations[$productId])) { $recommendationId = $recommendations[$productId][0]; } } Catalog\CatalogViewedProductTable::refresh( $skuId, (int)\Bitrix\Sale\Fuser::getId(), $siteId, $productId, $recommendationId ); } }