Я использую расширение, которое переключает группы клиентов на основе некоторых правил.Я добавил атрибут клиента как EAV, используя этот код.
$setup->addAttribute('customer', 'autoswitchgroup', array(
'type' => 'varchar',
'input' => 'select',
'label' => 'Autoswitch Group',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'default' => 'yes',
'visible_on_front' => 1,
'source' => 'bitstream_all/entity_autoswitchgroup',
));
Просматривая код расширения, я вижу, что он получает атрибут клиента, используя этот код:
$customerAttributeValue = $this->_getCustomer()->getDataUsingMethod($attribute);
где _getCustomer () определяется как объект.(@return Varien_Object).
Если я посмотрю на объект клиента, я увижу эту информацию:
[_resourceCollectionName:protected] => customer/customer_collection
[_cacheTag:protected] =>
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[entity_id] => 1
[entity_type_id] => 1
[attribute_set_id] => 0
[website_id] => 1
[email] => ****
[group_id] => 11
[increment_id] => 000000001
[store_id] => 1
[created_at] => 2011-06-04 15:11:50
[updated_at] => 2012-03-05 14:04:54
[is_active] => 1
[created_in] => Lenjerii
[prefix] =>
[firstname] => Ovidiu
[middlename] =>
[lastname] => Ungureanu
[suffix] =>
[password_hash] => ****
[taxvat] =>
[facebook_uid] => ****
[gender] => 1
[dob] =>
[autoswitchgroup] => yes
[is_subscribed] => 1
[parent_id] => 0
[dob_is_formated] => 1
[confirmation] =>
)
[_hasDataChanges:protected] => 1
[_origData:protected] => Array
(
[entity_id] => 1
[entity_type_id] => 1
[attribute_set_id] => 0
[website_id] => 1
[email] => ****
[group_id] => 11
[increment_id] => 000000001
[store_id] => 1
[created_at] => 2011-06-04 15:11:50
[updated_at] => 2012-03-05 13:49:46
[is_active] => 1
[created_in] => Lenjerii
[prefix] =>
[firstname] => Ovidiu
[middlename] =>
[lastname] => Ungureanu
[suffix] =>
[password_hash] => ****
[taxvat] =>
[facebook_uid] => ****
[gender] => 1
)
[_idFieldName:protected] => entity_id
[_isDeleted:protected] =>
Во внешнем интерфейсе я хочу получить ту же информацию, получая ее с помощью этого: $ customer = Mage :: getSingleton ('customer / session') -> getCustomer ();
Вот результат:
[_resourceCollectionName:protected] => customer/customer_collection
[_cacheTag:protected] =>
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[website_id] => 1
[entity_id] => 1
[entity_type_id] => 1
[attribute_set_id] => 0
[email] => ***
[group_id] => 11
[increment_id] => 000000001
[store_id] => 1
[created_at] => 2011-06-04 15:11:50
[updated_at] => 2012-03-05 13:49:46
[is_active] => 1
[created_in] => Lenjerii
[prefix] =>
[firstname] => Ovidiu
[middlename] =>
[lastname] => Ungureanu
[suffix] =>
[password_hash] => ***
[taxvat] =>
[facebook_uid] => ***
[gender] => 1
[tax_class_id] => 3
)
[_hasDataChanges:protected] => 1
[_origData:protected] => Array
(
[website_id] => 1
[entity_id] => 1
[entity_type_id] => 1
[attribute_set_id] => 0
[email] => ***
[group_id] => 11
[increment_id] => 000000001
[store_id] => 1
[created_at] => 2011-06-04 15:11:50
[updated_at] => 2012-03-05 13:49:46
[is_active] => 1
[created_in] => Lenjerii
[prefix] =>
[firstname] => Ovidiu
[middlename] =>
[lastname] => Ungureanu
[suffix] =>
[password_hash] => ****
[taxvat] =>
[facebook_uid] => ****
[gender] => 1
)
Что мне интереснополучить его [autoswitchgroup] - атрибут создан.Этот файл не сохраняется в простоте базы данных для всех пользователей, поэтому у меня есть значение по умолчанию.Теперь я не понимаю, как в модуле я получаю его в данных клиента, но во внешнем интерфейсе я его не вижу.
Более того, модуль отображается в [_data: protected], но не в [_origData: protected].
В обоих местах объект является _resourceCollectionName: protected] => customer / customer_collection ...
Надеюсь, это не слишком долго для чтения.