1

I have written some helper functions, which does some database inserts The problem is I am calling all these functions from my phtml which gets loaded first time when My account is loaded for the first time.

Due to this, the changes on databases doesn't reflect on the first go, when I reload my page again then I see those changes.

There must be some block file which loads before My account phtml file so that I can call my helper function from that block file.

Where can I find those block files/ controller files of My Account and how can i call my helper function from those

Right now i am calling my helper function from my phtml like this:-

$temp_block = $this->getLayout()->createBlock('YX\Catalog\Block\OrderHelper');

$customerHelper = $this->helper('YX\Customer\Helper\CustomerHelper');

 if (!($customerHelper->isCustomer())){
     $customerID = $customerHelper->getCustomerId();
     $orderId = $customerHelper->getOrderId();
     $temp_block->guestToCustomer($orderId,$customerID);

 }

I am converting my guest checkout orders to my account order, When the user places an order as guest on success page he/she is asked to sign up to make an account, on signing up, the user is taken to my account page, so all the logic I wrote in phtml file in recent.phtml which is the first page so I wrote the above code in my recent.phtml , but it doesn't get reflected on the first go as the file is already been loaded, on the second reload I get to see the changes.

0

If you are talking about the dashboard page, Then please open on the layout filed

vendor/magento/module-customer/view/frontend/layout/customer_account_index.xml 
vendor/magento/module-customer/view/frontend/layout/customer_account.xml

Here Magento mention, it is a list of file which is loaded for the customer dashboard page.

Also, I don't understand, what you have tried to achieve. But on the fly update customer data and get that data update on the same execution is not a good idea.

And PHP is server-side language, So the content of the page is not updated yet until next execution of the same page. So suggest to update content using AJAX and Implement the private content.

  • well hi Amit, I am converting my guest checkout orders to my account order, When the user places an order as guest on success page he/she is asked to sign up to make an account, on signing up, the user is taken to my account page, so all the logic I wrote in phtml file in recent.phtml which is the first page so i wrote the above code in my recent.phtml , but it doesnt get reflected on the first go as the file is already been loaded, on the second reload I get to see the changes – summu Feb 18 at 7:05
  • Why you don't use any event like customer login. Do the logic like, on customer login update customer data with guest order that is best a feasible solution.OR use Cronjob for update order with customer – Amit Bera Feb 18 at 7:07
  • Thats why i am thinking it to call those helper functions from block files of My account before any of the phtml loads – summu Feb 18 at 7:07
  • Can you guide me through events or cron job thing, are you talking about javascript events on customer sign up – summu Feb 18 at 7:11
  • 1
    Hey, once the customer is signed up write an observer for this event customer_register_success and get this order to this customer placed. – Prathap Gunasekaran Feb 18 at 9:40

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.