copy_from_fields_to_propertys_values( 824);
/*для торговых предложений*/
function copy_from_fields_to_propertys_values($SECTION_ID){
Cmodule::IncludeModule("catalog");
if ( CModule::IncludeModule ( "iblock" ) ){
$arOrder = array(
"sort" => "ASC",
);
$arFilter = array(
//"IBLOCK_ID" => $IBLOCK_ID,
"SECTION_ID" => $SECTION_ID
);
$arSelect = array(
"NAME",
"ID",
);
$arSelect = array_merge ($arSelect);
$db_elemens = CIBlockElement::GetList ( $arOrder, $arFilter, false, false, $arSelect );
while ( $arElement = $db_elemens->Fetch () ) {
$PRODUCT_ID = $arElement["ID"];
$el = new CIBlockElement;
/*для торговых предложений*/
$arSKU = CCatalogSKU::getOffersList(
$PRODUCT_ID,
0,
array('ACTIVE' => 'Y'),
array('ID', 'NAME'),
array()
);
foreach ($arSKU as $key =>$prod) {
foreach ($prod as $key =>$torgpred) {
/*первый типоразмер*/
if( $torgpred["SIZE_IMG_SIGN"] === "I"){
$UpdatedPrice = $torgpred["PRICE"] * 1.05; // Здесь мы меняем цену
CPrice::Update($torgpred["ID"], Array("PRICE" => $UpdatedPrice));}
}
}
}
} else {
die( "Модуль iblock не установлен" );
}
}
<?php
//Пример увеличения цены
//Задача поднять цены у товаров с 9500 до 10500
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("catalog");
$arSelect = Array("ID", "IBLOCK_ID", "CATALOG_PRICE_1");
$arFilter = Array("IBLOCK_ID"=>8, "CATALOG_PRICE_1" => '9500');
//ID инфоблока с ТП, а не с простыми товарами
$resw = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>1000000), $arSelect);
while($ob = $resw->GetNextElement()){
$arFields = $ob->GetFields();
$arProps = $ob->GetProperties();
{
echo $arFields[ID].' - '.$arFields['CATALOG_PRICE_1'].'</br>';
$PRODUCT_ID = $arFields[ID];
$PRICE_TYPE_ID = 1;
//Тип цены смотрим в админке, обычно 1
$arFields = Array(
"PRODUCT_ID" => $PRODUCT_ID,
"CATALOG_GROUP_ID" => $PRICE_TYPE_ID,
"PRICE" => '10500',
"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);
}
else
{
CPrice::Add($arFields);
};
}
};
<?
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
/*для торговых предложений*/
function copy_from_fields_to_propertys_values($SECTION_ID){
if ( CModule::IncludeModule ( "iblock" ) && Cmodule::IncludeModule("catalog")){
$arOrder = array(
"sort" => "ASC",
);
$arFilter = array(
//"IBLOCK_ID" => $IBLOCK_ID,
"SECTION_ID" => $SECTION_ID
);
$arSelect = array(
"NAME",
"ID",
);
$arSelect = array_merge ($arSelect);
$db_elemens = CIBlockElement::GetList ( $arOrder, $arFilter, false, false, $arSelect );
while ( $arElement = $db_elemens->Fetch () ) {
$PRODUCT_ID = $arElement["ID"];
$el = new CIBlockElement;
/*для торговых предложений*/
$arSKU = CCatalogSKU::getOffersList(
$PRODUCT_ID,
0,
array('ACTIVE' => 'Y'),
array('ID', 'NAME','PROPERTY_SIZE_IMG_SIGN','CATALOG_PRICE_1'),
array()
);
foreach ($arSKU as $key =>$prod) {
foreach ($prod as $key =>$torgpred) {
/*первый типоразмер*/
if( $torgpred["PROPERTY_SIZE_IMG_SIGN_VALUE"] === "I") {
$UpdatedPrice = $torgpred["CATALOG_PRICE_1"]*1.05; // Здесь мы меняем цену
echo "__I__";
echo '__ID__'.$torgpred["ID"]."__";
echo '__PRODUCT_ID__'.$torgpred["PARENT_ID"]."__";
echo '__PRICE__'.$torgpred["CATALOG_PRICE_1"];
echo '__';
echo $UpdatedPrice;
echo '__///';
echo '<br />';
$arFields = Array(
"PRODUCT_ID" => $torgpred["ID"],
"CATALOG_GROUP_ID" => 1,
"PRICE" => $UpdatedPrice,
"CURRENCY" => "RUB"
);
CPrice::Update($torgpred["ID"], $arFields);
}
if( $torgpred["PROPERTY_SIZE_IMG_SIGN_VALUE"] === "II"){
$UpdatedPrice = $torgpred["CATALOG_PRICE_1"]*1.12; // Здесь мы меняем цену
echo "__II__";
echo '__ID__'.$torgpred["ID"]."__";
echo '__PRODUCT_ID__'.$torgpred["PARENT_ID"]."__";
echo '__PRICE__'.$torgpred["CATALOG_PRICE_1"];
echo '__';
echo $UpdatedPrice;
echo '__///';
echo '<br />';
$arFields = Array(
"PRODUCT_ID" => $torgpred["ID"],
"CATALOG_GROUP_ID" => 1,
"PRICE" => $UpdatedPrice,
"CURRENCY" => "RUB"
);
CPrice::Update($torgpred["ID"], $arFields);
}
if( $torgpred["PROPERTY_SIZE_IMG_SIGN_VALUE"] === "III"){
$UpdatedPrice = $torgpred["CATALOG_PRICE_1"]*1.05; // Здесь мы меняем цену
echo "__III__";
echo '__ID__'.$torgpred["ID"]."__";
echo '__PRODUCT_ID__'.$torgpred["PARENT_ID"]."__";
echo '__PRICE__'.$torgpred["CATALOG_PRICE_1"];
echo '__';
echo $UpdatedPrice;
echo '__///';
echo '<br />';
$arFields = Array(
"PRODUCT_ID" => $torgpred["ID"],
"CATALOG_GROUP_ID" => 1,
"PRICE" => $UpdatedPrice,
"CURRENCY" => "RUB"
);
CPrice::Update($torgpred["ID"], $arFields);
}
if( $torgpred["PROPERTY_SIZE_IMG_SIGN_VALUE"] === "IV"){
$UpdatedPrice = $torgpred["CATALOG_PRICE_1"]*1.04; // Здесь мы меняем цену
echo "__IV__";
echo '__ID__'.$torgpred["ID"]."__";
echo '__PRODUCT_ID__'.$torgpred["PARENT_ID"]."__";
echo '__PRICE__'.$torgpred["CATALOG_PRICE_1"];
echo '__';
echo $UpdatedPrice;
echo '__///';
echo '<br />';
$arFields = Array(
"PRODUCT_ID" => $torgpred["ID"],
"CATALOG_GROUP_ID" => 1,
"PRICE" => $UpdatedPrice,
"CURRENCY" => "RUB"
);
CPrice::Update($torgpred["ID"], $arFields);
}
}
}
}
} else {
die( "Модуль iblock не установлен" );
}
}
//copy_from_fields_to_propertys_values(821);
?>