How to get all the data about the product by its id?

Dear please tell me how to get all the information about the product knowing its id?
Preferably how to do it on the core D7

Documentation I have the feeling that there are a lot of things.

At the moment I could only obtain this.

$resProducts = Bitrix\Iblock\ElementTable::getList([
 'select' => ["*"],
 'filter' => [
 "IBLOCK_ID" => $arParams['IBLOCK_ID'],
 'ID' => $arParams['PRODUCT_ID'],
 "ACTIVE" => "Y",
],
]);

$products = [];

while ($item = $resProducts->fetch()){
 $item['PREVIEW_PICTURE'] = CFile::GetPath($item['PREVIEW_PICTURE']);
 $item['DETAIL_PICTURE'] = CFile::GetPath($item['DETAIL_PICTURE']);
 $products = $item;
}


The price of the goods to trade there, and function to get path to images and prices of old I am sure there are new d7
And as there is no information on the trade proposals.

I would be grateful for help.
June 10th 19 at 15:05
1 answer
June 10th 19 at 15:07
Documentation is read carefully.
On d7 for this is the classes.
Here's a function by ID

To retrieve related data using relationships between models.

Under d7 expect normal ORM, rather than rewriting all functions, so it is unclear what you do not like CFile::GetPath

In General, use d7 where there is a long time ago a complete working API makes no sense. Use CIBlockElement::GetList. Tell there required filters and select points and you will choose from and properties of the product as an element of the information block, and its properties as a commodity and its trade offers at once.
I saw it, but it's a lot of functions, methods and the like. Come drop d7.

That is, to obtain information on 4 commodities for example, you need to use CIBlockElement::GetList. Next to get the rest of the fields associated with the product to apply to each item from the sample CCatalogProduct::GetByID to get information about the number of such
CFile::GetPath to get path to images
CCatalogSKU::getOffersList For trade offers
CPrice::GetList - get a price, Pat still check if any discounts apply
Not to mention the properties, SEO settings, and even a pair of properties

And all this to get stupid information about 4 products? Do I understand correctly? - Oceane commented on June 10th 19 at 15:10
no , wrong.
CIBlockElement::GetList with the right select will give you everything you need.
And if you're for each product from the sample to use subqueries, this is the typical error juna N+1
Is that CFile::GetPath will have to call for each file ID - Gretchen40 commented on June 10th 19 at 15:13
OK I understand You, you have to understand while doing the right selects. Thank you! - Oceane commented on June 10th 19 at 15:16
not for that.
Please note that if any data still will not be able to get from one selekta, then in any case do not do subqueries in a loop.
at first, create a new filter based on the current available products, make a second query and in a loop a second query to fill missing data items.
Read more on SO - Gretchen40 commented on June 10th 19 at 15:19

Find more questions by tags 1C-Bitrix