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

  • SEARCH
  • Home
  • 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 6960357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:23:32+00:00 2026-05-27T15:23:32+00:00

I have the following code where I need to check whether the attribute in

  • 0

I have the following code where I need to check whether the attribute in question is a customer attribute or customer address attribute. How do I check that?


private $custom_columns = array();

public function __construct() 
{
    parent::__construct();
    $this->setId('customerGrid');
    $this->setUseAjax(true);
    $this->setDefaultSort('email');
    $this->setDefaultLimit('200');
    $this->setSaveParametersInSession(true);
    $attributeIds = Mage::getStoreConfig('sectionname/group/field');
    $this->custom_columns = array($attributeIds); 
}

$attributeIds return attribute codes like street if I select Street Address, gender if I select Gender and so on. Now what condition should be put in order to know whether a given attribute is customer or address attribute.

// Prepare Collection addition to store custom fields
foreach ($this->custom_columns as $col) 
{
   //Some Condition if its a Customer attribute
   collection->addAttributeToSelect($col);  
   //else some condition if its a Customer address attribute
   $collection->joinAttribute($col, "customer_address/$col", 'default_billing', null, 'left');
 }
 $this->setCollection($collection);
 return parent::_prepareCollection();
}

I just want to know what those conditions would be. Hope this is a little clearer

  • 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-27T15:23:33+00:00Added an answer on May 27, 2026 at 3:23 pm

    You can use magic has*() calls with each class extending Varien_Object to check whether a given property does, or does not exist.

    Additionally, Varien_Object offers a non-magic hasData('property_name') method.

    The hasData() method basically does the same thing, just indirectly – i.e. by passing the property name as argument to the method, instead of using it as camel-cased part of the methods name.

    Mage_Customer_Model_Customer and Mage_Customer_Model_Address actually do extend Varien_Object, so you could call hasData('street') on an object instance to check for the existence of such property and use the result for your if/else scenario.

    You could also magically call hasStreet(), but in your case the hasData() variant will definitely serve better (as you’re looping thru an array with variable property names).

    Note that hasData() can only help you distinguish unique property names. Of course you cannot use hasData() to distinguish properties of the same name existing in both classes (e.g. 'entity_id').

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that I need to add an additonal object to
i have the following code ..i need to loop through end of the file
I have the following FORTRAN code which I need to convert to C or
I need syntax help with the following code logic: I have a code block
I need to have a checkbox which ajax-submits a form. The following code throws
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following code and now I have type, but I need to have
I have the following code: public class DataReader<T> where T : class { public
In relation to my previous question , I need to check whether a component
I have a winform app that requires me to check whether a page exists

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.