Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6247547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:53:49+00:00 2026-05-24T12:53:49+00:00

I have a file (js.phtml) where my code executes. I need to access some

  • 0

I have a file (js.phtml) where my code executes. I need to access some user data. When I error_log($this) in js.phtml, it displays, “Mage_Core_Block_Template” – which is confusing to me. I would expect that to be the parent class, not the value of the class getting passed to my .phtml file.

So, how do I supply the .phtml file with custom objects or methods? I’m super new to Magento and I’ve just been dropped into a task, so I apologize for possibly using incorrect terminology.

Edit:
My full file path is:

  • /app/design/frontend//default/template/customer/welcome/js.phtml

There is also a full module dir here:

  • /app/code/local//Customer/

Edit:
I need access to the users country and userid. It’s ok if country is null.

Edit:
I’ve been doing additional research, it looks like I can do something like this:
Current user in Magento?

But I haven’t tried it in code yet ….

Edit: Figured it out:

error_log(print_r(Mage::getSingleton('customer/session')->getCustomer()->getEntityId(), true));
error_log(print_r(Mage::getSingleton('customer/session')->getCustomer()->getCountry(), true));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:53:49+00:00Added an answer on May 24, 2026 at 12:53 pm

    To get customer ID:

    echo Mage::getSingleton('customer/session')->getCustomer()->getId();
    

    To get country – depends from which address. Here’s an example of getting the country code from the default billing address:

    echo Mage::getSingleton('customer/session')->getCustomer()->getDefaultBillingAddress()->getCountry();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file which is an XML representation of some data that is
I have this code on my products view.phtml file: I am getting a shipping
I have one java script definition in view(.phtml) file. This java script has dynamic
I am in the template file price.phtml . I would like to have some
I have the following code to upload a file to the server. For some
I have this code in a xml layout file: <reference name=left> <block type=blog/blog name=left.blog.menu
Say I have file A, in middle of which have a tag string #INSERT_HERE#.
I have a variable in code that can have file path or url as
I have a file in the following format: Data Data Data [Start] Data I
I have a main category and some sub-categories for this category and I wanted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.