Review

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
agatqapp
Posts: 13
Joined: 15 Jan 2022, 07:02

Review

Post by agatqapp » 21 Jan 2022, 09:30

Hello sir

I want to add review on product page
right now customer can add review on products which they are purchased.
but we need like anyone can post review on products, either they are login or not
How we can do that suggest me.

thanks

User avatar
aimeos
Administrator
Posts: 7889
Joined: 01 Jan 1970, 00:00

Re: Review

Post by aimeos » 22 Jan 2022, 11:20

You can add a decorator for the catalog detail HTML client that handles fetching and saving reviews in the detail page:
https://aimeos.org/docs/latest/frontend ... omponents/

You can't use the review frontend controller because it allows creating reviews only for logged in users:
https://github.com/aimeos/ai-controller ... andard.php

Instead, use the review manager directly to store new reviews:
- https://aimeos.org/docs/latest/models/managing-items/
- https://github.com/aimeos/aimeos-core/b ... andard.php

Please be aware that you will get a lot of fake reviews and vandalism if everyone can create reviews.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

agatqapp
Posts: 13
Joined: 15 Jan 2022, 07:02

Re: Review

Post by agatqapp » 23 Jan 2022, 13:50

Hello sir

I try to create its working fine
i create with these data
$data = array();
$data['review.domain'] = 'product';
$data['review.refid'] = '252570';
$data['review.name'] = 'Pratik Sharma';
$data['review.comment'] = 'Good Product';
$data['review.rating'] = '5';
$data['review.status'] = '1';

without order product id and customer id
this review display in admin panel and also in frontend

the issue is that when i try to add 2nd review with same product id then its show duplicate entry error
I need to add multiple review with one product


error is:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1.--product-252570' for key 'mshop_review.unq_msrev_sid_cid_dom_rid': INSERT INTO "mshop_review" ( "domain", "refid", "customerid", "ordprodid", "name", "comment", "response", "rating", "status", "mtime", "editor", "siteid", "ctime" ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) ["product","252570","","","Pratik Sharma","Good Product","",5,1,"2022-01-23 13:44:44","Admin","1.","2022-01-23 13:44:44"]

User avatar
aimeos
Administrator
Posts: 7889
Joined: 01 Jan 1970, 00:00

Re: Review

Post by aimeos » 24 Jan 2022, 14:29

The customer ID is required and adding more than one review without will result in a duplicate error from the database.

We've changed that in the current development version and you can use that as reference for own changes:
https://github.com/aimeos/aimeos-core/c ... 24eaf13074
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

agatqapp
Posts: 13
Joined: 15 Jan 2022, 07:02

Re: Review

Post by agatqapp » 01 Feb 2022, 06:22

Hello sir
I want to add review by api without customer id and order product id.

but in review database table add a unique column "unq_msrev_sid_cid_dom_rid" which are duplicate because there are not customer id
and i want to create 2 review with a single product like
1.--product-252570
1.--product-252570

you create this string unique with siteid - customer id - domain - product id

here if i change directly in database for that unique column like
siteid - id - domain - product id
1.-1-product-252570
1.-2-product-252570

then its working, we can add multiple review with single product without customer id
I want to confirm, it is ok, if i change this column pattern , see attachment
clumn.png
clumn.png (65.27 KiB) Viewed 1437 times
so here i change customer id to id, which will always unique

thanks

User avatar
aimeos
Administrator
Posts: 7889
Joined: 01 Jan 1970, 00:00

Re: Review

Post by aimeos » 01 Feb 2022, 07:58

This change is better:
aimeos wrote: 24 Jan 2022, 14:29 We've changed that in the current development version and you can use that as reference for own changes:
https://github.com/aimeos/aimeos-core/c ... 24eaf13074
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

agatqapp
Posts: 13
Joined: 15 Jan 2022, 07:02

Re: Review

Post by agatqapp » 02 Feb 2022, 10:37

Yes but in this case customer id null, and its show
Duplicate entry '1.--product-252570' for key 'mshop_review.unq_msrev_sid_cid_dom_rid'

duplicate error for unq_msrev_sid_cid_dom_rid column, i want to add multiple review with a single product
according to your change its create
1.--product-252570 for first review for product id 252570
1.--product-252570 for 2nd review for same product (here duplicate error)

so i ask to is it ok ? if i change in unq_msrev_sid_cid_dom_rid column customer id to review id , which will be always unique
and its not generate duplicate error.

User avatar
aimeos
Administrator
Posts: 7889
Joined: 01 Jan 1970, 00:00

Re: Review

Post by aimeos » 02 Feb 2022, 16:58

If you insert NULL into a column covered by an unique constraint, it's possible to insert multiple records with NULL values. Guess, the problem in your setup is that empty values are used instead.

Instead of using the id column in the unique constraint, you should leave out the second column completely.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply