Enable Reviews and Comments by default?

Is there a way to enable the Reviews and Comments for a product by default? That would be a lot easier than having to enable it every time you add a new product, or doing the mass product edit, which makes you sift through all the products to find just a few that you have missed.

I'm not sure if this is the best way or not, but it works.



In skins/basic/admin/addons/discussion/views/discussion_manager/components/allow_discussion.tpl



Change:






To:






This will make communication and rating selected by default. Of course you could change the selected part to the other rating if you wanted.



Hope that helps,



Brandon

Create a php file at the root of your store, eg. enablereviews.php



Place this code into enablereviews.php and alter the database details (which you will find in config.local.php if you are unsure):


<br />
<?php<br />
<br />
<br />
    // login to the cscart database<br />
<br />
    $username="";<br />
<br />
    $password="";<br />
<br />
    $cscartDB="";<br />
<br />
    mysql_connect('localhost', $username, $password);<br />
<br />
    @mysql_select_db($cscartDB) or die("Unable to select $cscartDB database");<br />
<br />
<br />
    // get all the active product_id's from the cscart_products table<br />
<br />
    $query = "SELECT product_id FROM cscart_products WHERE status='A'";<br />
<br />
    $productsResult = mysql_query($query);<br />
<br />
    $numRows = mysql_numrows($productsResult);<br />
<br />
    echo "Processing $numRows product id's...\n";<br />
<br />
<br />
    while ($row = mysql_fetch_assoc($productsResult)) {<br />
<br />
        $cscart_product_id = $row['product_id'];<br />
<br />
<br />
        // see if there is a row already for this cscart_product_id<br />
<br />
        $query="select object_id from cscart_discussion where object_id=$cscart_product_id AND object_type = 'P'";<br />
<br />
        $result=mysql_query($query);<br />
<br />
<br />
        // if not, add a row to cscart_discussion<br />
<br />
        if (mysql_num_rows($result) == 0) {<br />
<br />
            echo "Inserting record into cscart_discussion for $cscart_product_id\n";<br />
<br />
            $query="INSERT INTO cscart_discussion (object_id, object_type, type) VALUES ($cscart_product_id, 'P', 'B')";<br />
<br />
            $result=mysql_query($query);<br />
<br />
<br />
            if (!$result)<br />
<br />
               echo "Query failed: ($query): " . mysql_error(). "\n";<br />
<br />
        }<br />
<br />
    }<br />
<br />
?><br />

```<br />
<br />
Then browse to http://yourdomain.com/enablereviews.php and let the script do the hard work for you <img src="upload://tagmsFLhR9Ka1Qsz9bY91MY71wJ.gif" class="bbc_emoticon" alt=";)">

Thank you very much to both of you!

[quote name='kimsonco' timestamp='1344953591' post='142861']

Anyone know how to enable this on CS-Cart 3.0.2?

[/quote]



in cs-cart 3.0.2 open skins/basic/admin/addons/discussion/views/discussion_manager/components/allow_discussion.tpl



replace

```php

{$lang.communication} {$lang.and} {$lang.rating}
```

with
```php
{$lang.communication} {$lang.and} {$lang.rating}
```

now everytime you add a new product this option is enabled by default

StellarBytes, you saved my day after i tried to figure out why Reviews don't show up on any product after importing a csv…

Anyway, here i made small adjustments to your script to use connection from cs-cart config file and to update also existing configuration of products:




```php

define('AREA', 1);
require_once 'config.local.php';

mysql_connect($config['db_host'], $config['db_user'], $config['db_password']);
@mysql_select_db($config['db_name']) or die("Unable to select ".$config['db_name']." 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_num_rows($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";
} else {
$row = mysql_fetch_assoc($result);
mysql_query('UPDATE cscart_discussion SET `type` = "B" WHERE object_id = "'.$row['object_id'].'"');
}
}
?> ```

Great option :) Thanks for the tip !

Damn this is so usefull

thanks StellarBytes and jahggler :grin:





Edit:

jahggler version works perfectly on cs-cart 3.0.4 i havent testet on anything els

http://www.kb.digital-aurora.com/cs-cart/enable-comments-ratings-for-all-products/

In 3.0.6:

/skins/basic/admin/addons/discussion/views/discussion_manager/components/allow_discussion.tpl

Replace:

```php

{$lang.communication} {$lang.and} {$lang.rating}
```
With:
```php
{$lang.communication} {$lang.and} {$lang.rating}
```
And also Replace:
```php
{$lang.disabled}
```
With:
```php
{$lang.disabled}
```

Im having a problem of my own… If someone can help me out I would appreciate it.



When i want to enable discussion or comment on a page i selt it, but when i save the page it gets placed back into disabled… I cant enable nothing, any ideas?

Which version of the cart are you using? Try to clear your cache first, by adding ?cc to your admin URL, eg: yourstore.com/youradmin.php?cc Then try again.

Hi StellarBytes I have CS Cart 3.0.1. Professional running. I tried all of the cache stuff, but nothing helps… I just cant activate any communication or rating on pages nor on news… After save it turns back into disabled…

If clearing your cache, manually too (deleting /var/cache/ and /var/compiled/ via FTP) and clearing your browser cache does not help, then you may be effected by a bug.



There are a few bug fixes surrounding discussion/reviews in the changelog for 3.0.2, 3.0.3, 3.0.4, and 3.0.5 so it may be worthwhile upgrading. There were tons of bugs in 3.0.1, 3.0.6 is significantly more stable, but not perfect.

I think so too… Because done all you said but still I cant enablde comments on pages and/or news pages…



I'm trying to solve this issue so long and want it to work so badly. It's strange though because it worked in the past.



Thanks anyway Stellar Bytes

So you can enable it on products, but not categories and pages? I believe that one definitely was a bug resolved in an early V3 release.

Yeah… I really don't know whats going on but I'm pulling my hair out right now…

Ok, so you should look at as: Why haven't you upgraded to 3.0.6 yet? This was a known bug with user permissions, which was fixed in 3.0.3. I would upgrade, unless you have reasons for not doing so.

The reason is that my theme is so heavily modified that one mistake could ruin all my work. That’s the only reason. I would like to find the problem with some help IF possible, otherwise ill have to bite the bullet and upgrade… But again, I’d rather not… Is that strange? :)

If your modifications were done the right way - that is, using hooks - your upgrades would be plain sailing. If not, you're going to have to compare what you've changed with the latest releases files.



Your only other alternative would be to contact CS-Cart Help Desk and see if they can apply the fix on its own.