Answer the question
In order to leave comments, you need to log in
How to make all items in stock?
Good afternoon.
I got an online store on Bitrix with 4000 products, all products are "out of stock",
In the product settings - trade catalog - Allow purchase in the absence of goods (including allowing a negative quantity of goods): NO.
How can I bulk-enable all items to "in stock" and allow a purchase with a negative quantity?
Answer the question
In order to leave comments, you need to log in
Something like this, you can make a better request, but it will do for once - this code will set the default value
\Bitrix\Main\Loader::includeModule('iblock');
\Bitrix\Main\Loader::includeModule('catalog');
$iblocksId = [2, 3];
$iterator = \Bitrix\Iblock\ElementTable::getList([
'select' => ['IBLOCK_ID', 'ID'],
'filter' => ['IBLOCK_ID' => $iblocksId, '!PRODUCT.CAN_BUY_ZERO' => 'D', '!PRODUCT.TYPE' => \Bitrix\Catalog\ProductTable::TYPE_SKU],
'runtime' => [
'PRODUCT' => [
'data_type' => '\Bitrix\Catalog\ProductTable',
'reference' => ['=this.ID' => 'ref.ID']
]
]
]);
$elements = [];
while($row = $iterator->fetch()) {
$elements[] = $row;
}
foreach($elements as $element) {
CCatalogProduct::Update($element['ID'], ['CAN_BUY_ZERO' => 'D']);
}
echo 'Количество = '.count($elements);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question