Answer the question
In order to leave comments, you need to log in
Change of price and available quantity at unloading?
There are 2 infoblocks on the site: Main (with structure and products) and auxiliary (only products here)
.
When importing into the service infoblock, I need to take the price and the balance of the goods from it and find the same in the main article by the article and substitute these values for it
AddEventHandler("iblock", "OnAfterIBlockElementUpdate", "OrelBase");
function OrelBase(&$arFields)
{
$price = CPrice::GetBasePrice($arFields['ID']);
$count = CCatalogProduct::GetByID($arFields['ID']);
$item_orel = array(
'NAME' => $arFields['NAME'],
'ID' => $arFields['ID'],
'ARTICUL' => $arFields['PROPERTY_VALUES']['9728']['271613275']['VALUE'],
'PRICE_VALUE' => $price['PRICE'],
'COUNT' => $count['QUANTITY']
);
AddMessage2Log("<br/><br/><pre>".print_r($item_orel,true)."</pre><br/><br/>", "test");
$res_tula = CIBlockElement::GetList(array("SORT"=>"ASC"),array('IBLOCK_ID' => 21,'PROPERTY_CML2_ARTICLE' => $item_orel['ARTICUL']), false,false, array("NAME", "ID", "PROPERTY_CML2_ARTICLE"));
while($ob = $res_tula->GetNextElement())
{
$arFields = $ob->GetFields();
//print_r($arFields);
$price = CPrice::GetBasePrice($arFields['ID']);
$count = CCatalogProduct::GetByID($arFields['ID']);
/*меням цену*/
$PRODUCT_ID = $arFields['ID'];
$PRICE_TYPE_ID = 1;
$arFields_price = Array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID,
"PRICE" => $item_orel['PRICE_VALUE'],
"CURRENCY" => "RUB"
);
$res = CPrice::GetList(
array(),
array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID
)
);
if ($arr = $res->Fetch())
{
CPrice::Update($arr["ID"], $arFields_price);
}
else
{
CPrice::Add($arFields_price);
}
/*меням цену конец*/
/*меняем количество*/
CCatalogProduct::Update($arFields['ID'], array('QUANTITY' => $item_orel['COUNT']));
/*меняем количество конец*/
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question