Answer the question
In order to leave comments, you need to log in
How to get a list of products for a certain infoblock using \Bitrix\Catalog\ProductTable::getList?
I'm trying to get a list of products for a specific Bitrix infoblock using the D7 method \Bitrix\Catalog\ProductTable::getList with the following code:
<?php
require $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php';
$result = \Bitrix\Catalog\ProductTable::getList(array(
'filter' => array("=ELEMENT_IBLOCK_ID"=>46),
));
if($product=$result->fetch()) {
var_dump($product);
}
Answer the question
In order to leave comments, you need to log in
It's weird to use d7 and rely on the documentation for the old kernel method.
If you open the b_catalog_product table (to which you are making a query), you will see that there is no such field there.
If you need information on the fields of the infoblock element (without fields that refer to the catalog), then you need to use the methods of the corresponding module \Bitrix\Iblock\ElementTable::getList - there is an IBLOCK_ID field.
In your case, if you open the file with the description of the entity /bitrix/modules /catalog/lib/product.php in the getMap method you can see the description of the relationship
'IBLOCK_ELEMENT' => new Main\Entity\ReferenceField(
'IBLOCK_ELEMENT',
'\Bitrix\Iblock\Element',
array('=this.ID' => 'ref.ID'),
array('join_type' => 'LEFT')
),
'filter' => array("IBLOCK_ELEMENT.IBLOCK_ID"=>46),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question