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.

  • Are you want to get product name in review tab in details page – Rakesh Jesadiya Dec 16 '16 at 12:16
  • yes, In place of ''customers review' I need '[product name] review'. – shankar boss Dec 16 '16 at 12:20
  • We can get product data directly on our template: $block->getProduct() in our template. – Khoa TruongDinh Dec 16 '16 at 12:32
  • ok @KhoaTruongDinh, Will try this – shankar boss Dec 16 '16 at 12:36
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();
  • ok, @Fme I wil try this. – shankar boss Dec 16 '16 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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