I am new in the magento. If anyone have idea how to do this then please let me know. I have two files in different module in in that two .phtml file will be there. From First .phtml file to another .phtml file i want pass array variable I am not getting how to pass that.

First file path as follows with php variable:


In this file i have $transaction variable that i want to send another info.phtml

/** @var \Magento\Customer\Block\Account\Dashboard\Address $block */

$helper = $this->helper("Lof\CustomerMembership\Helper\Data");
$transactions = $block->getTransactions();

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
$customerId =$customerSession->getCustomer()->getId();

Another file path will be:


In the info.php file i want that $transactions array variable

Anyone have idea how to do this then please let me know

1 Answer 1


I am assuming that you want $transactions = $block->getTransactions(); in another PHTML File What we can do

  1. Create a view model (recommended) and check the block \Magento\Customer\Block\Account\Dashboard\Address and figure out how getTransactions() is defined and do the same in the view model and then attach that view model with the Magedelight block using layout https://devhooks.in/blog/how-to-use-viewmodels-in-magento2 - how to create view model
  2. Create a helper and do mention in point 1

Thanks and Happy coding

  • Yes you understand my questions. But getting your answer. I am just new in the magento2 . Can u explain more..
    – Praful
    Commented May 23, 2022 at 4:35

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.