D
D
Denis99992020-10-15 13:34:05
1C-Bitrix
Denis9999, 2020-10-15 13:34:05

How to get all data about a product by product id in Bitrix?

I worked with Bitrix only for 1 day. You need to get a list of all products and data about them. In the GetList method, you can specify the fields that need to be returned, but the fact is that not everything that is needed is there. For example, you can only get one product image, but how do you get all of them? Is there a way to do this by item id?

- one more thing, the fields PREVIEW_TEXT and DETAIL_TEXT are empty for all products, shouldn't they contain a description of the product?

if (CModule::IncludeModule("iblock")):

  $iblock_id = 14;
  $my_elements = CIBlockElement::GetList (
    Array("ID" => "ASC"),
    Array("IBLOCK_ID" => $iblock_id),
    false,
    false,
    Array('ID', 'NAME', 'DETAIL_PAGE_URL', 'PREVIEW_PICTURE', 'DETAIL_PICTURE', 'CODE', 'EXTERNAL_ID', 'XML_ID', 'IBLOCK_SECTION' )
  );



  while($ar_fields = $my_elements->GetNext())
  {
    $img_path = CFile::GetPath($ar_fields["DETAIL_PICTURE"]);
    $code = $ar_fields["CODE"];
    $external_id = $ar_fields["EXTERNAL_ID"];
    $xml_id = $ar_fields["XML_ID"];
    $iblock_section = $ar_fields["IBLOCK_SECTION"];
    $active = $ar_fields["ACTIVE"];

    $preview_text = $ar_fields["PREVIEW_TEXT"];
    $detail_text = $ar_fields["DETAIL_TEXT"];

    echo '<br>aaa999 <br> name: <a href="'.$ar_fields["DETAIL_PAGE_URL"].'">'.$ar_fields["NAME"].'</a><br> img: <a href="https://www.tmanshlag.ru' . $img_path.'" >url</a> <br>';
    echo 'code: '. $code . '<br>';
    echo 'external_id: '. $external_id . '<br>';
    echo 'xml_id: '. $xml_id . '<br>';
    echo 'iblock_section: <br>';
    print_r($iblock_section);
    // echo '<br>';
    echo 'active: '. $active . '<br>';
    echo 'preview_text: '. $preview_text . '<br>';
    echo 'detail_text: '. $detail_text . '<br>';
  }
endif;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2020-10-15
@Denis9999

$my_elements = CIBlockElement::GetList (
  Array("ID" => "ASC"),
  Array("IBLOCK_ID" => $iblock_id),
  false,
  false,
  Array( )
);

while($obElement = $my_elements->GetNextElement()) {
    // это массив полей товара
    $fields = $obElement->GetFields();
    // это массив свойств товара
    $properties = $obElement->GetProperties();
}

If the required data is not in these two arrays, then you need to thoroughly study the project and look for places where they can be (and they can be anywhere =) )

A
Alexey Emelyanov, 2020-10-15
@babarun

GetByID
or
GetIBlockElement

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question