0

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:

/var/www/html/MyProject/app/design/frontend/Megnor/mag110246_4/Lof_CustomerMembership/templates/customer/membership/transactions.phtml 

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

<?php /** @var \Magento\Customer\Block\Account\Dashboard\Address $block */ $helper = $this->helper("Lof\CustomerMembership\Helper\Data"); $transactions = $block->getTransactions(); $address=$block->getPrimaryBillingAddress(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerSession = $objectManager->get('Magento\Customer\Model\Session'); $customerId =$customerSession->getCustomer()->getId(); $activeOrNot=""; ?> 

Another file path will be:

/var/www/html/MyProject/app/design/frontend/Megnor/mag110246_4/Magedelight_SMSProfile/templates/account/dashboard/info.php 

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

0

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

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.