A
A
Alexander2021-07-16 11:10:55
1C-Bitrix
Alexander, 2021-07-16 11:10:55

How to divide orders by user group in the Bitrix admin panel - Orders?

You need to add ordering clearance for wholesalers as well as for all users, through the site. It's clear here.
How to split the display in the admin panel, in orders?
those. for "IM managers retail" - all orders are visible, all users except for the "OPT" user group,
and for "IM managers wholesale" - orders are visible, only the "OPT" user groups

It seems like everything is simple, but I don’t understand what and how.
Can anyone come across, or knows and can share thoughts?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2021-07-16
@winer

You can add a filter on the OnSaleAdminOrderList event. I give an example based on the retail and wholesaler user groups. Can be easily adapted to payer types.
In the $getListParams example, this is what will be passed to the request for OrderTable.

<?php

\Bitrix\Main\EventManager::getInstance()->addEventHandler( 
    'sale', 
    'OnSaleAdminOrderList', 
    'OnSaleAdminOrderListHandler'
); 


function OnSaleAdminOrderListHandler(\Bitrix\Main\Event $event) 
{
    $getListParams = $event->getParameters();
    $reailManagerGroupId = 1; //ID группы менеджеров розницы
    $wholesaleManagerGroupId = 2; //ID группы менеджеров оптовиков
    $optUserGroup = 3; //ID группы оптовых покупателей
    $reatilUserGroup = 4; //ID группы розничных покупателей
    global $USER;

    $userGroups = \CUser::GetUserGroup($USER);
    if (in_array($reailManagerGroupId, $userGroups)) {
        $getListParams["filter"]["USER_GROUP.GROUP_ID"] = $reatilUserGroup;
    } else if(in_array($wholesaleManagerGroupId, $userGroups)) {
        $getListParams["filter"]["USER_GROUP.GROUP_ID"] = $optUserGroup;
    }


    $result = new \Bitrix\Main\EventResult(\Bitrix\Main\EventResult::SUCCESS, $getListParams);
    return $result;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question