How to enable ratings/comments on all products in CS-Cart

I compared a lot of shopping cart systems, and finally settled down with CS-Cart. If I have time (I wish) I would like to write down some of my comparison of these e-commerce system (Free Open Source ones and paid one). But even with CS-Cart which is not perfect, I had to do some extra work to get it work in the way we need. Today I just wanted to share one of tips I found to do something CS-Cart doesn’t have by default.

In CS-Cart, the review/comments addon has not been enabled by default. So you either do it one by one, or do it in a mass editing way as the below.

1) In the CS-Cart back-end, click Products from the top menu. Then set the “Total items” in the upper-right to 100 or any numbers you want to view in total.
2) Search products you would like to enable reviews.
3) Select all products by clicking the checkbox on the top row.
4) Choose ‘Edit selected’ at the “Choose action” link in the lower-left
5) Hit the”Unselect all” link
6) Check “Reviews” and hot the “Modify selected” button
7) Hit the “apply values to all selected products” link
8) Check “Reviews” and choose your preference (Communication, Rating or All)
9) Hit the “Apply” button
10) Hit the “save” button

Repeat steps 3-10 for each page of searched products.

Another way to enable rating/review for all products

If you don’t have any reviews in the system like you just installed the CS-Cart, you can try the following code to enable review for all products. Just copy & paste the code below, save as a PHP file, and upload to your system and run.

<?php

    // login to the cscart database

    $username="";

    $password="";

    $cscartDB="";

    mysql_connect('localhost', $username, $password);

    @mysql_select_db($cscartDB) or die("Unable to select $cscartDB database");

    // get all the active product_id's from the cscart_products table

    $query = "SELECT product_id FROM cscart_products WHERE status='A'";

    $productsResult = mysql_query($query);

    $numRows = mysql_numrows($productsResult);

    echo "Processing $numRows product id's...\n";

    while ($row = mysql_fetch_assoc($productsResult)) {

        $cscart_product_id = $row['product_id'];

        // see if there is a row already for this cscart_product_id

        $query="select object_id from cscart_discussion where object_id=$cscart_product_id AND object_type = 'P'";

        $result=mysql_query($query);

        // if not, add a row to cscart_discussion

        if (mysql_num_rows($result) == 0) {

            echo "Inserting record into cscart_discussion for $cscart_product_id\n";

            $query="INSERT INTO cscart_discussion (object_id, object_type, type) VALUES ($cscart_product_id, 'P', 'B')";

            $result=mysql_query($query);

            if (!$result)

               echo "Query failed: ($query): " . mysql_error(). "\n";

        }

    }

?>

Of course, remember to modify with your own $username, $password, and $cscartDB variables from your installation. Good luck.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Answer: * Time limit is exhausted. Please reload the CAPTCHA.