Hi,
I'm trying to add the reviews addon to my products.
The problem is I'm trying to do all products at once (or at least the “applying the value to 100 products at a time then for the next 100” etc)but it does not work when I do it that way. There is no problem if I enable it individually for each product and it works fine but I cannot do the bulk edit for it. It simply does not work then. Would have been much better if they created a global update for it. I am using the new version 4.0.2 which I was hoping may resolve the issue that started with me in 4.0.1 but alas it has not.
Is there maybe a way I can force change it in the database or so?(I saw the other topic but unsure if it still relies on the same method:
UPDATE cscart_discussion
SET type='X' WHERE object_type='P';
Replacing X with:
C - Communication
R - Rating
B - Both
D - Disabled
Again though, I don't know why the bulk editing isnt working anyway.
Anyone know?
Thanks.
Hi crayzbag,
I am not sure and not remember but i think your products(without discussions) hasn't got a rows on cscart_discussion table.
I am using multi product addition bot and i forget to open discussions for my products. After that i created a little script.
I hope it helps.
// add this like a test.php and locate it yoursite.com/test.php?a=b
//it will fix your problem. script doing : look product's discussions status. if product didnt have, add new one.
// ****** please backup your cscart_discussions table before using this.
if($_GET['a'] == “b”){
    $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”;
        }
    }
}
Regards.
Hello crazybag!
In CS-Cart v.4 it is necessary to choose the store first, after that go to Products->Products, select the products (you can set the number per page 100), click the button in the top right corner, choose Edit selected. Click Unselect all, check Reviews, click the Modify selected button. Click “Apply values to all the selected products” link, set the necessary values and Save. It works fine.
Best regards, Alt-team
Umitkoc thanks but I created a test.php file and copy/pasted what you put, backed up the database etc but when I went to the link you showed to do (obviously exchanging it with my site) it just provided me all the text thats in the file and nothing happened.
To alt-team, I only have the one store which is always selected (shown by the top left) and I showed I've already tried that way with no success.
Umitkoc's method sounds like it would be the problem but again, the script did not work. Was there something wrong with it or something else I was meant to do?
Thanks.
You forgot the php open and closing tags. But strongly suggest you follow alt-team's instructions to do it through the admin instead of direct to the DB. It's a lot safer.
Hello crazybag!
It's strange that you can't enable Comments and Reviews using the method I've described. It's a standard procedure that should work fine. Could you please explain what is exactly the problem? Do you see a Reviews checkbox after pressing the Edit selected button?
You should choose “[color=#282828][font=arial, verdana, tahoma, sans-serif]Apply values to all the selected products” to set the necessary values and Save. No changes after that?[/font][/color]
[color=#282828][font=arial, verdana, tahoma, sans-serif]Also, make sure that the Comments and Reviews add-on is Active (Add-ons → Manage add-ons) and delete the cache folder in your CS-Cart directory (var/cache).[/font][/color]
[color=#282828][font=arial, verdana, tahoma, sans-serif]Best regards, Alt-team[/font][/color]
-I select the 100 products
-Click edit, unselect all then select reviews
-I click the apply values to all the selected products and set the reviews to “all”
-I apply it then now all the products have ALl next to it and I save again just for good measure.
-HOWEVER, as I have stated I go into any of the products and the reviews do not show up. I go into the product individually and it says the reviews is disabled. I don't really know why.
I am importing the products through csv so this may have something to do with it which is why umitkoc's answer makes sense as he mentions it.
I'm going try his method now that I realised about the php open/close tags duhhh
Also alt-team I apreciate anyones help but the method “you describe” is the method I said I tried already.
But I get you don't know me and don't know exactly what I know so best to say everything so thank you for your replies.
Hi again,
crazybag please do not forget to backup your original table
When my auto insertion bot trying to add new product;
mysql_query(“insert into cscart_discussion values(NULL,‘$produniq’,‘P’,‘B’,‘1’)”);
this line is also working.
So if you dont have rows for your product_ids in cscart_discussion, you must select product_ids first and add all of them to the discussion table.
I am not sure is there any relation with other tables but in my modification, this is working good.
And as i said before, i forgot to add that lines before. and i use this script to fix my self mistake
Right well I asked Cs-cart support about this and they helped me fix it.
For those that can't get it working and google this sort of thing the following was the fix for me (running version 4.0.2):
- Open the app/addons/discussion/func.php file.
- Replace the following line:
'type' => $product_data['discussion_type']
with these ones:
'type' => $product_data['discussion_type'],
'company_id' => $product_data['company_id']
3. Add the following part of code:
if (empty($product_data['company_id'])) {
$product_company_id = db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $product_id);
if (!empty($product_company_id)) {
$product_data['company_id'] = $product_company_id;
} else {
if (Registry::get('runtime.company_id')) {
$product_company_id = $product_data['company_id'] = Registry::get('runtime.company_id');
}
}
}
after this one:
if (empty($product_data['discussion_type'])) {
return false;
}
4. Save the file.
This allowed the bulk editing of reviews to work which was not before this fix.
I also had an issue of images not showing up when importing products that had a link to the location of the image. This fixed that:
- Open the app/controllers/backend/exim.php file.
- Replace the following line:
if (strpos($image_file, Registry::get('config.dir.root')) === 0) {
with these ones:
if ($type_image_detailed == 'url') {
$_REQUEST["file_import_image_icon"] = array($image_file);
} elseif (strpos($image_file, Registry::get('config.dir.root')) === 0) {
3. Replace the following line:
if (strpos($detailed_file, Registry::get('config.dir.root')) === 0) {
with these ones:
if ($type_image_detailed == 'url') {
$_REQUEST["file_import_image_detailed"] = array($detailed_file);
} elseif (strpos($detailed_file, Registry::get('config.dir.root')) === 0) {
4. Replace the following lines:
$content = fn_get_contents($file);
if (!empty($content)) {
$fname = fn_create_temp_file();
if (fn_put_contents($fname, $content)) {
return $fname;
}
}
with this one:
return $file;
5. Save the file.
Thanks for trying guys though to fix it. Hope this helps anyone else that has the same issue.