Different prices for warehouses in multistore. Revision 1C-Bitrix

    Were online store and b2b platform from one company on the system 1c-Bitrix. The company grew and appeared its own warehouses and added warehouses of partners that needed to be displayed. There was a need to display balances in several warehouses.

    And what Bitrix says to us: Please go to the Business editorial board and everything will be fine and immediately. They went to the editorial office and it turned out that multi-value and multi-warehouse in 1C-Bitrix live a separate life. The first is needed to display different prices for different groups of users, and the second to display balances in different warehouses.

    We needed to withdraw the balances with its price for each warehouse, since the price of the partners and ours may differ by the same position. It turned out that there was no staff of such a functional.

    It was here that the idea to remake the standard templates came up and on the site side to make a warehouse-price bundle.

    The first thing I had to do was remake the catalog.section and catalog.element templates. The catalog.store.amount component was inserted into them:

    1. For the product card, a list of warehouses with prices was displayed.

    Code snippet
    if ($arResult['CATALOG_QUANTITY']!=0){ //не отображать если не на одном складе нет остатков
          $APPLICATION->IncludeComponent("bitrix:catalog.store.amount","finnit_buy",
              array("ELEMENT_ID"  => $arResult["ID"] //фильтрация по ID элемента


    2. For the list of products through the component, only one price was selected (either the lowest price or the minimum delivery time).

    Code snippet
    $APPLICATION->IncludeComponent( "bitrix:catalog.store.amount", "finnit_1sk",
    	 array( "ELEMENT_ID"   => $arElement["ID"]//фильтрация по ID элемента


    So for each type of its own template was created, in addition to this, several more templates were created. For example, a template for a quick purchase in which the optimal warehouse is displayed with the price for making a purchase.

    The work on the catalog.store.amount component went in 3 stages.

    1. Manual comparison in the warehouse code - price (conveniently with a small number of warehouses). In this case, the code is written indicating the type of price for a particular warehouse.

    Code snippet
    if ($arProperty['ID'] == 29){// Идентификатор склада
                            $db_res = CPrice::GetList( array(),  array("PRODUCT_ID" => $arParams['ELEMENT_ID'],"CATALOG_GROUP_ID" => '28')); // 28 - это идентификатор необходимого типа ценыif ($ar_res = $db_res->Fetch()){
                                if($min_price > (ceil(($ar_res["PRICE"] + ($ar_res["PRICE"]/100))/10)* 10))
                                    $min_price = ceil(($ar_res["PRICE"] + ($ar_res["PRICE"]/100))/10)* 10; // получаем минимальную цену по всем складам по данному товару и округляем
                                $amount = $arProperty["AMOUNT"]; // получаем количество по складу
                                $title = $arProperty["ID"]; // изначально передалось Наименование в переменную, но при смене наименования в 1С при обмене склад переименовывался и на сайте - по этому привязку сделали по ID, а название переменной не трогали.
                            }


    2. After the warehouses began to be connected, the first option turned out to be unsuitable and it was decided to keep the warehouse-price bundles in a separate information block.

    screenshot


    Code snippet
    <?// запрос инфоблока со списком сопоставления
                                    $arSelectEquals = Array("ID", "IBLOCK_ID");
                                    $arFilterEquals = Array("IBLOCK_ID"=>18); //ID инфоблока сопоставления
                                    $equals = CIBlockElement::GetList(Array(), $arFilterEquals, false, Array(), $arSelectEquals);
                                    while($equal = $equals->GetNextElement()){
                                        $arPropsEquals = $equal->GetProperties();
                                        if ($arProperty["ID"] == $arPropsEquals["SKLAD_ID"]["VALUE"]){// если склад сопоставлен
                                            $db_res = CPrice::GetList(
                                                array(),  array("PRODUCT_ID" => $arParams['ELEMENT_ID'],"CATALOG_GROUP_ID" => $arPropsEquals["PRICE_ID"]["VALUE"]));
                                            if ($ar_res = $db_res->Fetch()){
                                                if (!isset($ar_res["PRICE"])){
                                                    echo GetMessage('FINN_PRICE_MANAGER');//вывод сообщения если нет цены
                                                }else{ // если цена есть по сопоставленным данным
                                                        $pricen = ceil( $ar_res["PRICE"] );// получение данных для дальнейшего заказа
                                                        $price_id = $ar_res["CATALOG_GROUP_ID"];// получение данных для дальнейшего заказа
                                                        $price_name = $ar_res["CATALOG_GROUP_NAME"];// получение данных для дальнейшего заказа
                                                    }
                                                    //echo number_format( $pricen, 0, ',', ' ' );
                                                    $torgId  = $ar_res["ID"]; // получение данных для дальнейшего заказа
                                                    $torgGId = $ar_res["CATALOG_GROUP_ID"];// получение данных для дальнейшего заказа
                                                }
                                            } else{}}
                                    }
                                    ?>


    Thus, a sufficiently large volume of warehouses can be maintained.

    3. Using custom fields directly in warehouses for comparison with price types.

    This option was not originally considered. And only after the store opened alongside Chelyabinsk, it was also necessary in St. Petersburg to indicate the delivery time of the goods depending on the warehouse, for this purpose they used custom fields in the warehouses.

    Screenshot


    I consider this option the most optimal. And at the moment, several templates have already been transferred to the same version of the comparison of warehouses and prices.

    PS If you know a more suitable option - write in the comments, I will be grateful.

    PPS If you have any comments or questions, please write - I will answer.

    Also popular now: