A
A
Andrey2017-07-25 17:28:26
PHP
Andrey, 2017-07-25 17:28:26

How to get the id of all products on 1c bitrix?

Good afternoon!
How to get the id of all products on the site
, I need to put down the id in the articles on the site, for the revenge of the existing article, but I need to pull out the id of all positions, how can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
makedev, 2017-07-25
@Andrey_Tech

https://dev.1c-bitrix.ru/api_help/iblock/classes/c...
Returns elements of infoblocks by filter
https://dev.1c-bitrix.ru/api_help/catalog/classes/...
Returns elements product catalog (module catalog)
Use case for your specific task:

CModule::IncludeModule('iblock');
$iIblockID = 1; //тут вставить ИД инфоблока
/*Получаем все ИД товара*/
$resIblock = CIBlockElement::GetList(
   array('ID' => 'ASC'), 
   array(
   'IBLOCK_ID' => iIblockID  
   ),
   false, 
   false,
   array("ID")
);

while($arID = $resIblock->Fetch())
    CIBlockElement::SetPropertyValuesEx($arID['ID'], iIblockID , array('ARTICLE' => $arID['ID'])); //присваиваем коду свойству ARTICLE ИД элемента. вместо ARTICLE поставьте свой код свойства

This is how you can replace the article with an ID in Bitrix. But I will pay attention to the fact that the method is resource-intensive. Each change to the "ARTICLE" property is a new request! If there are a lot of elements and the server breaks, then either sawing a step-by-step download, or sawing queries directly to the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question