V
V
Volkssssss2019-04-09 18:56:52
1C-Bitrix
Volkssssss, 2019-04-09 18:56:52

What should be the content of the file for cron?

set up cron hosting. so that the values ​​are updated every minute. but not updated. hosters write that the script is executed successfully. turned on the display of errors to come to the mail. came. I found on the Internet how to write the contents of a file. corrected. errors stopped coming. but the values ​​are still not updated. what should the contents of the cron file really be? here is my file

<?

if ($_SERVER['REMOTE_ADDR']!='127.0.0.1') die(); // Защита от постороннего запуска

define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);


require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules­/main/include/prolog_before.php");
set_time_limit(0);


CModule::IncludeModule("iblock");
CModule::IncludeModule("catalog");
CModule::IncludeModule("sale");


$arSelect = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM","PROPERTY_*");//IBLOCK_ID и ID обязательно должны быть указаны, см. описание arSelectFields выше
$arFilter = Array("IBLOCK_ID"=>18, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>5000), $arSelect);
while($ob = $res->GetNextElement()){ 

 $arFields = $ob->GetFields();  
//print_r($arFields);


 $arProps = $ob->GetProperties();


//print_r($arProps);
//echo $arProps["TSENA_ZA_KG][VALUE"];

// предполагаем, что валюты RUB и EUR существуют в базе
$val = $arProps["TSENA_ZA_KG"]["VALUE"]; // сумма в EUR
$newval = round(CCurrencyRates::ConvertCurrency($val, "EUR", "RUB"), 2);
//echo $newval;


// добавление в свойство "по цене"



$final = CIBlockElement::SetPropertyValueCode($arFields["ID"], "PRICE_FILTER", $newval);


//echo $arFields["ID"];




if ($final) {
echo "ok";
}
else {
echo "not ok";
}


}

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules­/main/include/epilog_after.php");?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitsliputsli, 2019-04-09
@Vitsliputsli

At a minimum, remove the line: And always check the php logs first.

A
Anton, 2019-04-10
@anton99zel

1. And where is the authorization under a user with admin rights?
2. How does your code work on a single page?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question