Answer the question
In order to leave comments, you need to log in
How to display the number of comments on Bitrix?
There is a third-party review component, everything works fine, but I don't know how to display the number of comments in products.
marketplace.1c-bitrix.ru/solutions/parnas.khayrcom... - Link to the component in the marketplace.
Here is what the developer of the module wrote to me: everything is done on the basis of infoblocks, it is enough to count the number of elements associated with this product. But I don't know what code to use.
I tried to use this code:
CModule::IncludeModule('iblock');
$arFilter = array(
'IBLOCK_ID' => 123, // ID инфоблока
// любые другие параметры, например 'ACTIVE' => 'Y'
);
$res = CIBlockElement::GetList(false, $arFilter, array('IBLOCK_ID'));
if ($el = $res->Fetch())
echo 'Записей: '.$el['CNT'];
Answer the question
In order to leave comments, you need to log in
CModule::IncludeModule('iblock');
$arFilter = array(
'IBLOCK_ID' => 123, // ID инфоблока
'PROPERTY_PRODUCT_ID' => $id, //ID товара, для которого нужно получить количество отзывов. $arResult["ID"], если находимся в шаблоне catalog.element. PRODUCT_ID - это код свойства, в котором хранятся привязки отзывов к товарам (нужно посмотреть в настройках инфоблока, как это свойство называется у вас)
// любые другие параметры, например 'ACTIVE' => 'Y'
);
$qty = CIBlockElement::GetList(array(), $arFilter, array()); //если третий параметр пустой массив, то GetList возвращает количество элементов, удовлетворяющих фильтру
echo 'Записей: '.$qty;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question