Php 检查属性是客户属性还是客户地址属性

Php 检查属性是客户属性还是客户地址属性,php,zend-framework,magento,Php,Zend Framework,Magento,我有下面的代码,需要检查所讨论的属性是customer属性还是customer address属性。我怎么检查 private$custom_columns=array() $attributeIds选择街道地址时返回街道、选择性别时返回性别等属性代码。现在应该设置什么条件才能知道给定的属性是customer属性还是address属性 // Prepare Collection addition to store custom fields foreach ($this->custom_

我有下面的代码,需要检查所讨论的属性是customer属性还是customer address属性。我怎么检查


private$custom_columns=array()

$attributeIds
选择街道地址时返回街道、选择性别时返回性别等属性代码。现在应该设置什么条件才能知道给定的属性是customer属性还是address属性

// 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(); }
//准备集合添加以存储自定义字段 foreach($this->custom\u列为$col) { //如果是客户属性,则为某个条件 集合->添加属性选择($col); //如果是客户地址属性,则为其他条件 $collection->joinAttribute($col,“客户地址/$col”,'default\u账单',null,'left'); } $this->setCollection($collection); 返回父项::_prepareCollection(); } 我只想知道那些条件是什么。希望这更清楚一点

您可以使用
has*()
调用扩展
Varien_对象的每个类来检查给定属性是否存在

另外,
Varien\u对象
提供了一个非魔法的
hasData('property\u name')
方法

hasData()
方法基本上做同样的事情,只是间接地——即通过将属性名称作为参数传递给方法,而不是将其作为方法名称的大小写部分

Mage\u Customer\u Model\u Customer
Mage\u Customer\u Model\u Address
实际上扩展了
Varien\u对象
,因此您可以在对象实例上调用
hasData('street')
,检查是否存在此类属性,并将结果用于
if/else
场景

您还可以神奇地调用
hasStreet()
,但在您的情况下,
hasData()
变量肯定会更好(因为您正在通过一个具有变量属性名的数组进行循环)


请注意,
hasData()
只能帮助您区分唯一的属性名称。当然,您不能使用
hasData()
来区分两个类中存在的同名属性(例如
'entity\u id'
)。

很难理解您的要求。请尝试澄清您的问题所在,并发布您已经尝试过的代码,以及您收到的任何错误消息。感谢您的详细解释。这有助于我更好地理解事情。所以我可以使用类似if(Mage::getModel('customer/entity_attribute_collection)->hasData($col)){dosomething…}else{something…} // 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(); }