CModule::IncludeModule("iblock");
CModule::IncludeModule('catalog');
........
$ppID = false;
$res = CCatalogStoreProduct::GetList(
array(),
array(
"PRODUCT_ID" => $productID
)
);
if ($arr = $res->Fetch()) {
$ppID = $arr["ID"];
}
$arFields = Array(
"PRODUCT_ID" => $productID,
"STORE_ID" => $storage_id,
"AMOUNT" => $storage["quantity"]
);
if(!$ppID){
echo '<pre>';
var_dump(CCatalogStoreProduct::Add($arFields));
echo '</pre>';
}
echo '<pre>';
var_dump($ppID);
echo '</pre>';
bool(false)
bool(false)
list($PRODUCT_ID, $STORE_ID) = array(53914, 5);
// класс для работы со остатками товара на складах. Не путать с CCatalogStore
$rsStore = CCatalogStoreProduct::GetList(
[],
[
"PRODUCT_ID" => $PRODUCT_ID,
"STORE_ID" => $STORE_ID,
],
false,
false,
[]
);
$arStore = $rsStore->Fetch();
$res = CCatalogStoreProduct::Update(
$arStore['ID'],
[
"PRODUCT_ID" => $PRODUCT_ID,
"STORE_ID" => $STORE_ID,
"AMOUNT" => 0,
]
);