2

How can I get product details like product type and name in particular product reviews list page.

Actually I want to Display "Product-Name reviews" Instead of "Customer Reviews" in product detail page.

Any help would be appreciated, Thanks.

4
  • Are you want to get product name in review tab in details page Commented Dec 16, 2016 at 12:16
  • yes, In place of ''customers review' I need '[product name] review'. Commented Dec 16, 2016 at 12:20
  • We can get product data directly on our template: $block->getProduct() in our template. Commented Dec 16, 2016 at 12:32
  • ok @KhoaTruongDinh, Will try this Commented Dec 16, 2016 at 12:36

2 Answers 2

2

Copy product/view/list.phtml to your custom theme. We get product data directly on our template: $block->getProduct().

app/design/frontend/Vendor/Theme/Magento_Review/templates/product/view/list.phtml

<?php $productName = $block->getProduct()->getName(); ?>

 <div class="block-title">
    <!--        <strong>--><?php ///* @escapeNotVerified */ echo __('Customer Reviews') ?><!--</strong>-->
    <strong><?php  echo $productName; ?></strong>
 </div>
3

you can get product id from review block

Magento\Review\Block\Product\View\ListView.php

public function getProductId()
    {
        $product = $this->_coreRegistry->registry('product');
        return $product ? $product->getId() : null;
    }

in phtml get id of product

$block->getProductId();
1
  • ok, @Fme I wil try this. Commented Dec 16, 2016 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.