Answer the question
In order to leave comments, you need to log in
How to set random quantity for all products in Bitrix?
Warehouse accounting is disabled.
Import of goods. The quantity column is missing.
Import again for a long time and add a column.
GOODS NOT SIMPLE, but with offers.
You need to run some code, like in php_interface, which would sort through all product offers from the Products Offers catalog with a time step, and set a random number from 1 - 10.
The delay is about 20 seconds. Since the hosting has a time limit for the execution of the source code.
Answer the question
In order to leave comments, you need to log in
I would do all this on the crown, this can bypass the limits
<?
// увеличеваем лимиты сервера
@set_time_limit(30000);
ini_set('max_execution_time', 30000);
// грузим классы Битрикса
require_once($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php");
Cmodule::IncludeModule('catalog');
Cmodule::IncludeModule('iblock');
$$IBLOCKID = ''; // Задем Иблок с товармыми предложениями
// проходимся по всем товарам
$arFilter = Array("IBLOCK_ID"=>$IBLOCKID, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", 'INCLUDE_SUBSECTIONS'=>'Y', );
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, array());
while ($ob = $res->GetNextElement())
{
$arr = $ob->GetFields();
// задаем кол-во рандомное
$kolvo = rand(1,11);
// вставляем его
$arPrise = array('QUANTITY' => $kolvo);// зарезервированное количество
CCatalogProduct::Update($arr['ID'], $arPrise);
}
echo 'Скрип сработал все хорошо (:';
?>
I don’t know how for offers, but for ordinary goods it will work accurately and much faster than the standard Bitrix mechanism. This is if there is 1 directory on the site, if there are several, then you need additional. filtration
AddEventHandler('catalog', 'OnSuccessCatalogImport1C', 'customCatalogImportStep');
/**
* Устанавливаем случайное кол-во товаров
* @param $arParams
* @param $arFields
*/
function customCatalogImportStep($arParams, $arFields) {
global $DB;
$DB->Query('UPDATE b_catalog_product SET AVAILABLE = "Y", QUANTITY = FLOOR(1 + RAND() * 10);');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question