Answer the question
In order to leave comments, you need to log in
Why does getting a list of goods in Bitrix d7 not work?
You need to get a list of goods in the basket with section ID 114. To do this, I used the function from the office. documentation:
<? $dbRes = \Bitrix\Sale\Basket::getList([
'select' => ['NAME', 'QUANTITY'],
'filter' => [
'=IBLOCK_SECTION_ID' => '114',
'=FUSER_ID' => \Bitrix\Sale\Fuser::getId(),
'=ORDER_ID' => null,
'=LID' => \Bitrix\Main\Context::getCurrent()->getSite(),
'=CAN_BUY' => 'Y',
]
]);
while ($item = $dbRes->fetch())
{
var_dump($item);
}
?>
Unknown field definition `IBLOCK_SECTION_ID` (IBLOCK_SECTION_ID) for \Bitrix\Sale\Internals\Basket Entity. (100)
Answer the question
In order to leave comments, you need to log in
<?
require_once($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php");//подключить, если надо
use Bitrix\Sale;
$dbRes = \Bitrix\Sale\Basket::getList(array(
'filter' => array(
'FUSER_ID' => Sale\Fuser::getId(),
'ORDER_ID' => null,
'LID' => SITE_ID,
'CAN_BUY' => 'Y',
),
'select' => array('PRODUCT_ID', 'NAME'),
));
while ($item = $dbRes->fetch())
{
$res = CIBlockElement::GetByID($item);
if($arRes = $res->Fetch())
if ($arRes[IBLOCK_SECTION_ID] == '114') //покажем только из раздела с id 114
print_r ($item[NAME].'</br>');//выведем названия
}
?>
the IBLOCK_SECTION_ID column is not contained in b_sale_basket, it is
necessary to get it through join
, respectively, add runtime
'runtime' => [
'ELEMENT' => [
'data_type' => '\Bitrix\Iblock\ElementTable',
'reference' => ['=this.PRODUCT_ID' => 'ref.ID'],
'join_type' => 'left'
],
]
'=ELEMENT.IBLOCK_SECTION_ID' => 114
'=PRODUCT.IBLOCK_SECTION_ID' => 114
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question