Обновление остатков в Aspro

Статья на оформлении

<?php

exit;
if($_GET['key']!=='mfdjnJKaxVS333') exit;
if (!empty($_SERVER["DOCUMENT_ROOT"])) $DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
else $DOCUMENT_ROOT = '<ПАПКА НА СЕРВЕРЕ>';
require_once($DOCUMENT_ROOT."/bitrix/modules/main/include/prolog.php");
CModule::IncludeModule('iblock');
$i = 0;

$obE = new CIBlockElement();
$arSelectWin = Array("ID", "NAME","QUANTITY","PROPERTY_IN_STOCK");
$arFilterWin = Array("IBLOCK_ID"=>46, ">QUANTITY"=>"0","=PROPERTY_IN_STOCK"=>false);
$resWin = CIBlockElement::GetList(Array("sort"=>"asc"), $arFilterWin, false, false, $arSelectWin);
while($obWin = $resWin->Fetch()){
    print_r($obWin);
    echo '<br>';
    $i++;
    CIBlockElement::SetPropertyValuesEx($obWin["ID"], 46, array("IN_STOCK" => 168));
}

$obE = new CIBlockElement();
$arSelectWin = Array("ID", "NAME","QUANTITY","PROPERTY_IN_STOCK");
$arFilterWin = Array("IBLOCK_ID"=>46, "QUANTITY"=>"0","=PROPERTY_IN_STOCK"=>168);
$resWin = CIBlockElement::GetList(Array("sort"=>"asc"), $arFilterWin, false, false, $arSelectWin);
while($obWin = $resWin->Fetch()){
    print_r($obWin);
    echo '<br>';
    $i++;
    CIBlockElement::SetPropertyValuesEx($obWin["ID"], 46, array("IN_STOCK" => false));
}

/*
$obE = new CIBlockElement();
$arSelectWin = Array("ID", "NAME","QUANTITY","PROPERTY_IN_STOCK");
$arFilterWin = Array("IBLOCK_ID"=>46,"PROPERTY_IN_STOCK");
$resWin = CIBlockElement::GetList(Array("sort"=>"asc"), $arFilterWin, false, false, $arSelectWin);
while($obWin = $resWin->Fetch()){
    //print_r($obWin);
    //echo '<br>';
    $i++;
    CIBlockElement::SetPropertyValuesEx($obWin["ID"], 46, array("IN_STOCK" => false));
}
*/
echo $i;
?>