Hello!
The problem is as follows:
1) it is necessary to add a rating to the product through the API.Bitrix, if this is possible;
2) or in which table the data of the product rating is stored in the database.
This is about iblock.vote.
Neither the search nor the documentation did not answer :(

    1 answer 1

    You have almost answered your own question =)

    The rating uses a standard component - bitrix.vote

    In order to make it work, it’s enough to call it in the template with the list of goods (for example, bitrix.section) and transfer the ID товара, ID инфоблока и код товара . All these values ​​are already in $ arResult if you use a standard component. If you have a samopisny component, then add the missing values.

    Example of calling the component:

     <?$APPLICATION->IncludeComponent("bitrix:iblock.vote","stars",Array( "IBLOCK_TYPE" => "", "IBLOCK_ID" => $arItem['IBLOCK_ID'], //ID инфоболка "ELEMENT_ID" => $arItem['ID'], //ID товара "ELEMENT_CODE" => $arItem['CODE'], //код товара "MAX_VOTE" => "5", "VOTE_NAMES" => array("0","1","2","3","4"), "SET_STATUS_404" => "N", "MESSAGE_404" => "", "CACHE_TYPE" => "A", "CACHE_TIME" => "3600" ) );?> 

    The bitrix.vote component has several standard templates (well, or you can write your own):

    • .default - scary template with select and vote button (doesn’t work via ajax)
    • ajax - select rating by squares
    • ajax_photo - xs, I did not earn
    • flat - star rating template
    • stars - the most awesome template (IMHO), also with starlets

    UPD: Regarding the second question: Where are all the ratings for the goods in the database. If you look at the code of the component iblock.vote, you can see that it operates with the properties of the information block.

    Those. The following PROPERTY added to the information block:

    • vote_count - The number of voters
    • vote_sum - Sum of ratings
    • rating - rating

    And further, when adding a rating, the following logic works:

     <? $arProperties["vote_count"]["VALUE"] = intval($arProperties["vote_count"]["VALUE"])+1; $arProperties["vote_sum"]["VALUE"] = intval($arProperties["vote_sum"]["VALUE"])+$RATING; $arProperties["rating"]["VALUE"] = round(($arProperties["vote_sum"]["VALUE"]+31.25/5*$arParams["MAX_VOTE"])/($arProperties["vote_count"]["VALUE"]+10),2); ?> 

    You can use it to add a rating for example through the comments component.

    • Thank you) But the problem is not with the component. And the fact that the customer needs a slightly different implementation. Namely - to vote without clicking on the stars of the product, but when writing a review (iblock.comments like). Maybe I missed something, but I didn’t find anything similar (Although the comments template seems to contain fragments of the call-back code, but I can’t even force them by correcting the conditions of the call). - Andrey
    • Well, there was nothing about the comments in the question))) By asking the right questions, you will get the correct answers as they say)) In bitrix:catalog.comments parameter SHOW_RATING used to evaluate the comments themselves (after adding the comment) so you need to finish the logic and template yourself Component - Jekys
    • @Andrey slightly updated the answer, all of a sudden it will help) - Jekys
    • @Andrey Write a module for the order. If you need, you can write me in VK, if we agree on the price - you will have the necessary module. - Vladimir Rodichev 7:14 pm