Answer the question
In order to leave comments, you need to log in
How to update the quantity of goods in stock in the Bitrix Small Business edition?
Bitrix edition - Small business. Warehouse 1.
Task. When adding / updating a product, take "Parameters - available quantity" that comes from 1s and insert it into Warehouses - quantity of goods.
I tried to do it with various events, it did not work.
$arFieldsStoreAmount = Array(
"PRODUCT_ID" => $arFields['ID'],
"STORE_ID" => STORE_ID,
"AMOUNT" => $arFields["QUANTITY"]
);
$amount = \CCatalogStoreProduct::Add($arFieldsStoreAmount);
$arFieldsStoreAmount = Array(
"PRODUCT_ID" => 544,
"STORE_ID" => 1,
"AMOUNT" => 33
);
$amount = \CCatalogStoreProduct::Add($arFieldsStoreAmount);
Answer the question
In order to leave comments, you need to log in
In general, I agreed that instead of incomprehensible crutches, the easiest way would be to set the external code of the warehouse in Bitrix from 1c, and in the unload settings, check the box "Unload leftovers from warehouses". Should earn.
APD. In 1s, I made an unloading with a checkmark "Upload balances by warehouses" to a file on your computer. In this file, I found the Warehouse ID and entered it in the "External code" field on the site. Everything worked.
So there is no need to invent anything in terms of code, everything has already been invented before us.
Here is a working example for you, add a warehouse and fire from 1s get requests
$iOstatok - Quantity in stock
$iElementID - product id
$iBlock - infoblock
if (isset($iOstatok)) {
if ($iOstatok > 0) {
$el = new CIBlockElement;
/*активировать, если деактивирована*/
if ($ar_res["ACTIVE"] == "N") {
/*активировать*/
$arLoadProductArray = Array(
"IBLOCK_SECTION_ID" => false,
"IBLOCK_ID" => $iBlock,
"ACTIVE" => "Y"
);
$el->Update($iElementID, $arLoadProductArray);
}
Cmodule::IncludeModule('catalog');
$arFields = array("QUANTITY" => $iOstatok);
CCatalogProduct::Update($iElementID, $arFields);
//$el->SetPropertyValues($iElementID, $iBlock, $iOstatok, "QUANTITY");
/*обновление остатков*/
} else {
/*обновление остатков*/
Cmodule::IncludeModule('catalog');
$el = new CIBlockElement;
$arFields = array("QUANTITY" => $iOstatok);
CCatalogProduct::Update($iElementID, $arFields);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question