Jump to content

Product Comments


Peter.31

Recommended Posts

I would not worry about it at this time.  In screen shot you only have demo data.

rather than worry about comments, concentrate on building a catalog of products, shipping and checkout.

then get a quality theme that has core features you want and has capability to include more feature.

stop design, build functioning catalog, you will never make the default theme pretty or extend it's features....

Link to comment
Share on other sites

On the picture above is only the demo version of PrestaShop front office. My eshop is fully online a few months and now I need to fix this problem.

The module "Product Comments" by PrestaShop does not work properly because comments are visible at the end of product page. Comments should be visible together with a describtion and product details tabs. 

Link to comment
Share on other sites

On 7/23/2021 at 9:15 PM, Peter.31 said:

On the picture above is only the demo version of PrestaShop front office. My eshop is fully online a few months and now I need to fix this problem.

The module "Product Comments" by PrestaShop does not work properly because comments are visible at the end of product page. Comments should be visible together with a describtion and product details tabs. 

Can you show link to your store?

Link to comment
Share on other sites

Hi,

Use this code in your module but before using this code you need to register this hook in your module.

$this->registerHook('displayProductExtraContent');

public function hookDisplayProductExtraContent($params)
{
$array = array();
$array[] = (new PrestaShop\PrestaShop\Core\Product\ProductExtraContent())
->setTitle('tittle')
->setContent('content');
return $array;
}

Link to comment
Share on other sites

1 hour ago, uzishabab said:

Hi,

Use this code in your module but before using this code you need to register this hook in your module.

$this->registerHook('displayProductExtraContent');

public function hookDisplayProductExtraContent($params)
{
$array = array();
$array[] = (new PrestaShop\PrestaShop\Core\Product\ProductExtraContent())
->setTitle('tittle')
->setContent('content');
return $array;
}

Where exactly should I insert the code?

public function hookDisplayProductExtraContent($params)
{
$array = array();
$array[] = (new PrestaShop\PrestaShop\Core\Product\ProductExtraContent())
->setTitle('tittle')
->setContent('content');
return $array;
}

  • Like 1
Link to comment
Share on other sites

32 minutes ago, Peter.31 said:

On which line am I supposed to add that code?

Are you developer ? You need to customize this code according to your need . You need to add this inside the class. If you are not able to do this let us know in private . thanks

Link to comment
Share on other sites

1 minute ago, Peter.31 said:

Thanks for editing the file, but it doesn't work. After updating the file, the product web page crashes. A white page with the words "Write your review" will appear.

image.png

Enable debug mode and send me screenshot

Link to comment
Share on other sites

@Peter.31

I have modify the file you can now play here is the final output

 

    public function hookDisplayProductExtraContent($params)
    {
        $pro = $params['product'];
      
        $id_lang = $this->context->language->id;

         // Load Product object
        $id_product = $pro->id;
        $product = new Product($id_product, false, $id_lang);


        /** @var ProductCommentRepository $productCommentRepository */
        $productCommentRepository = $this->context->controller->getContainer()->get('product_comment_repository');

        $averageGrade = $productCommentRepository->getAverageGrade($id_product, Configuration::get('PRODUCT_COMMENTS_MODERATE'));
        $commentsNb = $productCommentRepository->getCommentsNumber($id_product, Configuration::get('PRODUCT_COMMENTS_MODERATE'));
        $isPostAllowed = $productCommentRepository->isPostAllowed($id_product, (int) $this->context->cookie->id_customer, (int) $this->context->cookie->id_guest);

        $this->context->smarty->assign(array(
            'post_allowed' => $isPostAllowed,
            'usefulness_enabled' => Configuration::get('PRODUCT_COMMENTS_USEFULNESS'),
            'average_grade' => $averageGrade,
            'nb_comments' => $commentsNb,
            'list_comments_url' => $this->context->link->getModuleLink('productcomments', 'ListComments', ['id_product' => $id_product]),
            'update_comment_usefulness_url' => $this->context->link->getModuleLink('productcomments', 'UpdateCommentUsefulness'),
            'report_comment_url' => $this->context->link->getModuleLink('productcomments', 'ReportComment'),
        ));

        $content = $this->context->smarty->fetch('module:productcomments/views/templates/hook/product-comments-list.tpl');

        $array = array();
        $array[] = (new PrestaShop\PrestaShop\Core\Product\ProductExtraContent())
                ->setTitle('Comments (0)')
                ->setContent($content);
        return $array;
    }

 

Now need some fine tune

 

Thank you

product-tab-comment.png

  • Thanks 1
Link to comment
Share on other sites

  • 5 months later...

Thanks, @SmartDataSoft. I've been fighting this 💩 whole day. It did load but also generated a ton of errors in the log about undefined index 'product' or using private methods. Your code finaly works as expected. You're a savior! ❤

 

...at least it's a good start. Unfortunately modal doesn't load. Reviews show inside product tabs, but are unsuable :(

 

How can I use these freakin'

{widget}

thing? 😡

Edited by Sharak (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...

@Sharak You need to edit one more line(918) in productcomments.php to fix your problem.

    public function hookDisplayFooterProduct($params)
    {
        return $this->renderProductCommentsList($params['product']) . $this->renderProductCommentModal($params['product']);
    }

This is hook which displays old product comment section and modal. We only want to disable the duplicate comment section and not touch the modal, so the final version should look like this:

    public function hookDisplayFooterProduct($params)
    {
        return $this->renderProductCommentModal($params['product']);
    }

This modification should keep the modal and allow to add new comments. I didn't test this solution extensively so let me know if it works.

Cheers

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...