#CSaleOrderPropsValue::Update

Bitrix d7 getList runtime

27.07.2016 Bitrix , , ,

Два разных способа записи runtime сущностей

            if(!class_exists('Bitrix\Sale\Internals\OrderPropsValueTable')){
                CModule::AddAutoloadClasses(
                    "",
                    array(
                        'Bitrix\Sale\Internals\OrderPropsValueTable' => "/bitrix/modules/sale/distr/lib/internals/orderprops_value.php",
                        'Bitrix\Sale\Internals\OrderPropsTable' => "/bitrix/modules/sale/distr/lib/internals/orderprops.php",
                    )
                );
            }

            $arOrder = Bitrix\Sale\OrderTable::getRow(
                array(
                    'filter' => array(
                        '=ID' => 36835, 'LID' => 's1'
                    ),
                    'select' => array(
                        'ID', 'PRICE',
                        'ADDRESS' => 'ADDRESS_ORDER.VALUE'
                    ),
                    'runtime' => array(
                        'ADDRESS_ORDER' => array(
                            'data_type' => 'Bitrix\Sale\Internals\OrderPropsValueTable',
                            'reference' => array(
                                '=ref.CODE' => new Bitrix\Main\DB\SqlExpression('?s', 'ADDRESS'),
                                '=this.ID' => 'ref.ORDER_ID',
                            )
                        ),
                        new Bitrix\Main\Entity\ReferenceField(
                            'ADDRESS_ORDER',
                            'Bitrix\Sale\Internals\OrderPropsValueTable',
                            array(
                                '=ref.CODE' => new Bitrix\Main\DB\SqlExpression('?s', 'ADDRESS'),
                                '=this.ID' => 'ref.ORDER_ID',
                            )
                        )
                    )
                )
            );

bitrix изменить значение свойства заказ

13.10.2014 Bitrix , , ,

Bitrix\Main\Loader::includeModule('sale');
Bitrix\Main\Loader::includeModule('iblock');
Bitrix\Main\Loader::includeModule('catalog');
$ORDER_ID = 23;
$db_order = CSaleOrder::GetList(
	array("DATE_UPDATE" => "DESC"),
	array("ID" => $ORDER_ID),
	false,
	false,
	array('ID', 'PERSON_TYPE_ID')
);
if ($arOrder = $db_order->Fetch())
{
   $db_props = CSaleOrderProps::GetList(
        array("SORT" => "ASC"),
        array(
			"PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"], // тип плательщика
			"CODE"			=>	"PAY_SUMM" // код свойства который надо изменить
		)
    );
   while ($arProps = $db_props->Fetch())
   {
		$db_vals = CSaleOrderPropsValue::GetList(
            array("SORT" => "ASC"),
            array(
                    "ORDER_ID" => $ORDER_ID,
                    "ORDER_PROPS_ID" => $arProps["ID"]
                )
        );
		while ($arVals = $db_vals->Fetch()){
			if(!$arVals['VALUE'])
				CSaleOrderPropsValue::Update($arVals['ID'], array("ORDER_ID"=>$arVals['ORDER_ID'], "VALUE"=>"140")); 
		}
   }
}