PHP code example of serginhold / bitrix-favorites

1. Go to this page and download the library: Download serginhold/bitrix-favorites library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

serginhold / bitrix-favorites example snippets


use SerginhoLD\Favorites;

$storage = Favorites\Factory::getStorageForCurrentUser();

$storage->add(5);
$storage->add(22);
$storage->add(33);

$storage->delete(22);

$items = $storage->getList();

print_r($items);

use SerginhoLD\Favorites\FavoritesTable;

$items = FavoritesTable::getList([
    'filter' => [
        '=USER_ID' => 1,
        '=ENTITY_TYPE' => FavoritesTable::TYPE_IBLOCK_ELEMENT,
    ],
    'select' => [
        '*',
        'USER_LOGIN' => 'USER.LOGIN',
    ],
])->fetchAll();

print_r($items);