0

First Block:

app\code\Zero\Storelocator\Block\view\Attributes.php

function name : getLocationAttributes()

Second Block:

app\code\Zero\Storelocator\Block\Customerreview.php

How to get the first block function values ?

1 Answer 1

0

You can get this file in customerreview.php and call function from that file.

<?php
namespace Zero\Storelocator\Block;

class Customerreview extends \Magento\Framework\View\Element\Template
{     
     public function __construct(
        \Zero\Storelocator\Block\view\Attributes $attributes,
        \Magento\Framework\View\Element\Template\Context $context,        
        array $data = []
     ) {
        $this->$attributes = $attributes;
        parent::__construct($context, $data);
    }   

    public function getCustomerReview(){    

       echo $this->$attributes->getLocationAttributes();
        
    }    
}
5
  • Hi, i am getting this error : Error: Object of class Zero\Storelocator\Block\View\Attributes could not be converted to string in C:\xampp\htdocs\m3\app\code\Zero\Storelocator\Block\Customerreview.php:21 Screenshot : snipboard.io/URcLt3.jpg
    – zus
    May 3, 2021 at 11:55
  • attribute.php paste.ofcode.org/ZXffpxtY5wHDjNkn6SaciZ
    – zus
    May 3, 2021 at 11:58
  • 1
    remove echo from line no.21 and use print_r() to print the value of attributes.
    – Mital Shah
    May 3, 2021 at 12:04
  • In attribute.php log return values, when i print values in Customerreview.php log not generated and return Error: Call to a member function getAttributes() on null, Can you pls help me on that, i posted new post : magento.stackexchange.com/q/336603/57334
    – zus
    May 4, 2021 at 3:46
  • FYI I am trying to pass the value third-party module block to the custom module block.
    – zus
    May 4, 2021 at 3:55

Your Answer

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

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