Y
Y
Yuriy2019-08-28 14:51:57
1C-Bitrix
Yuriy, 2019-08-28 14:51:57

Bitrix product balance update?

We update the rest as follows:

$rsStoreProduct = \Bitrix\Catalog\StoreProductTable::getList(array(
          'filter' => array('=PRODUCT_ID'=>$arFields["ID"],'STORE.ACTIVE'=>'Y'),
      ));

      if($arStoreProduct=$rsStoreProduct->fetch()){

        $updateStore = \Bitrix\Catalog\StoreProductTable::update($arStoreProduct['ID'], Array('PRODUCT_ID'=>intval($arFields["ID"]),'STORE_ID'=>1,'AMOUNT' => $arData["PRODUCT_QUANTITY"]));

      }else{

        $addStore = \Bitrix\Catalog\StoreProductTable::add(Array('PRODUCT_ID'=>intval($arFields["ID"]),'STORE_ID'=>1,'AMOUNT' => $arData["PRODUCT_QUANTITY"]));
      
      }

      $updateQuantity = \Bitrix\Catalog\ProductTable::update($arFields["ID"], Array('QUANTITY' => $arData["PRODUCT_QUANTITY"]));

The goods have updates in the warehouse and the quantity is updated, everything is fine. but we noticed such a bug, if the product initially had a balance of 0 and after the update it changed to positive, then you still can’t buy it, the system writes
Ошибка добавления товара в корзину 
Товар отсутствует

If you go to the product through the admin panel and resave it, then everything becomes normal.
Assuming that we do not update the balance for all links, the question is how to do the correct update of the balance through the API?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pool, 2020-06-25
@pool

$updateQuantity = \Bitrix\Catalog\ProductTable::update($arFields["ID"], Array('QUANTITY' => $arData["PRODUCT_QUANTITY"], 'AVAILABLE' => 'Y' ));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question