/
bitrix-dev
/
Starter-kit
Обзор
Документация
Войти
/
bitrix-dev
/
Starter-kit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
main
local/ajax/favorite.php
41 строка
1 KB
Alexey Karizhenskiy
Первая сборка (из ранее используемого)
19 янв 2026, 21:00
19 янв 2026, 21:00
d843e36
Код
Авторство
О чём код?
<?php require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); use Bitrix\Main\Application; use Bitrix\Main\Web\Json; use MWI\Favorite; $response = [ 'success' => false ]; $request = Application::getInstance()->getContext()->getRequest(); $action = $request->getPost('action'); switch ($action) { case 'get': $response['success'] = true; $response['items'] = Favorite::getProductIds(); break; case 'add': $productId = intval($request->getPost('productId')); if ($productId > 0) { $response['success'] = Favorite::add($productId); } break; case 'remove': $productId = intval($request->getPost('productId')); if ($productId > 0) { $response['success'] = Favorite::remove($productId); } break; case 'clear': $response['success'] = Favorite::update([]); break; } echo \Bitrix\Main\Web\Json::encode($response); \Bitrix\Main\Application::getInstance()->end();