I am creating a review site. There are 2 content types, product & review. Reviews contain fivestar fields to cast votes on products using a nodereference field.

I have a custom module, which imports lot of reviews. Reviews are displayed correctly (with expected rating values), but the aggregation which is displayed on product node contains ratings from last review.

Aggregation code used:

$r = votingapi_select_results(array('content_id' => $node->nid, 'tag' => 'trustworthy', 'function' => 'average'));
print theme('fivestar_static', $r[0]['value'], '5');

Author of all these imported users are set to Anonymous user.

Code used to save nodes in import module:

if ($node->type == 'review') {
                $result = db_query("SELECT node.nid AS nid FROM dr_node node LEFT JOIN dr_content_type_lawyer node_data_field_importid ON node.vid = node_data_field_importid.vid WHERE node_data_field_importid.field_importid_value = %s",(int) $xmlnode->lawyer);
                while ($row = db_fetch_array($result)) {
                    $lawyer = $row[nid];
                }
                $node->field_review_lawyer[0]['nid'] = $lawyer;
                $node->field_review_trustworthy[0]['rating'] = (((int) $xmlnode->trustworthy)/5)*100;
                $node->field_review_trustworthy[0]['axis'] = 'trustworthy';
                $node->field_review_responsive[0]['rating'] = (((int) $xmlnode->responsive)/5)*100;
                $node->field_review_responsive[0]['axis'] = 'responsive';
                $node->field_review_knowledgeable[0]['rating'] = (((int) $xmlnode->knowledgable)/5)*100;
                $node->field_review_knowledgeable[0]['axis'] = 'knowledgeable';
                $node->field_review_informed[0]['rating'] = (((int) $xmlnode->informed)/5)*100;
                $node->field_review_informed[0]['axis'] = 'informed';
                $node->field_review_overall[0]['rating'] = (((int) $xmlnode->overall)/5)*100;
                $node->field_review_overall[0]['axis'] = 'overall';
                $node->field_review_usetime[0]['value'] = (string) $xmlnode->used;
                $node->field_review_casetype[0]['value'] = (string) $xmlnode->casetype;
                $node->field_review_lawyercount[0]['value'] = (string) $xmlnode->lawyercount;
                $node->field_review_text[0]['value'] = (string) $xmlnode->reviewtext;
            }
            node_save($node);
            unset($node);

Comments

prabhakarsun’s picture

Actually it is lawyer and review content types, not product & review.

khalor’s picture

Having the same issue but using the Node import module.

legolasbo’s picture

Status: Active » Closed (won't fix)

Drupal 6 is no longer supported. Closing old issues to clean up the issue queue.

Please reopen and update this issue if this is still an issue in the D7 or D8 version.