A
A
AlenaZaika2021-10-25 10:04:02
1C-Bitrix
AlenaZaika, 2021-10-25 10:04:02

How to display goods and trade offers in 1C-Bitrix?

Good afternoon!
Please help, I started working with 1C-Bitrix not long ago and I can’t figure out how to display the product and trade offers for the product, if any.
There is a product in the infoblock and not all products have trade offers.

I was able to understand how to withdraw only the goods but not the trade ones from them, you need to withdraw both options.

CModule::IncludeModule("catalog");
$my_slider = CIBlockElement::GetList (
    Array("NAME" => "ASC"),
    Array("IBLOCK_ID" => 1),
    false,
    false,
    Array(
        'ID',
        'NAME',
    'PROPERTY_G_ART', //Артикул
    'PROPERTY_G_FULL', //Полное название товара
    'PROPERTY_UKLON', //Уклон типа
    'PROPERTY_G_SHORT', //Краткое наименование товара
    )
);
while($ar_fields = $my_slider->GetNext())
{
  echo"<pre><b>";
  print_r($ar_fields);
  echo"<b/></pre>";
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
no_one_safe, 2021-10-25
@no_one_safe

0. For starters, you should not use the direct non-cached methods of the deprecated api. To start, the standard components of Bitrix are enough for you. When you study caching, database structure and D7 - then you can play around with direct queries.
Abusing these CIBlockElement::GetList will put you on the site. These methods from 2010 and in modern development are not used by anyone (in their right mind).
1. Try to understand everything that you write, and not stupidly copy-paste code from examples from somewhere. What is this line doing here? What is she responsible for? Answer these questions for yourself. 2. Name variables with meaningful names, not like in the examples
CModule::IncludeModule("catalog");
$my_slider = CIBlockElement::GetList
And here is the slider, when do you have goods? You will have the whole site in one sliders. After half a year, you won’t figure out where you have what. Don't shoot yourself in the foot.
3.

Array("NAME" => "ASC"),
    Array("IBLOCK_ID" => 1),
    false,
    false,

And if there are 4 million goods? Are you all going to leave?
4.
I was able to understand how to withdraw only goods but not trade ones from them,

Trade offers and goods are stored in different infoblocks and are linked through the TP property binding to elements, usually CML2_LINK.
It seems to me that you, as a beginner, cannot yet master joining tables or elements by binding (although this is all, of course, in the documentation).
I advise you to start using the catalog.section component (or any other for the "list" of products with the catalog prefix) and transform the result in the result_modifier.php file of the component template. Of course, this is the practice of 2010, but at least it is more correct, clean and easier to work with in the future than with a bunch of code accumulated from the network and scattered around the site in a chaotic manner.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question