Closed
Description
Preconditions (*)
Related to issue #2993. When investigating issue #3055, I was able to create a new attribute in ver 20.0.16 with this:
$store = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$eavConfig = Mage::getSingleton('eav/config');
$attributes = array(
'select_invoice_type' => array(
'frontend_label' => 'Identification for Electronic Invoicing',
'label' => 'Ident Type Billing',
'backend_type' => 'text',
'frontend_input' => 'select',
'source' => 'eav/entity_attribute_source_table',
'is_user_defined' => 1,
'is_system' => 0,
'is_visible' => 1,
'is_required' => 0,
)
);
foreach ($attributes as $attributeCode => $data) {
$attribute = $eavConfig->getAttribute('customer_address', $attributeCode);
$attribute->setWebsite($store->getWebsite());
$attribute->addData($data);
$usedInForms = array(
'adminhtml_customer_address',
'customer_address_edit',
'customer_register_address',
'customer_account_create'
);
$attribute->setData('used_in_forms', $usedInForms);
$attribute->save();
}
However, with ver 20.1.0-rc2 I get
Fatal error: Uncaught Error: Call to a member function setWebsite() on bool in .../Celera/Crib/controllers/PxController.php:55
The line is $attribute->setWebsite($store->getWebsite());
.
Steps to reproduce (*)
- As described.
- Or just examine the output of
Mage::getSingleton('eav/config')->getAttribute('customer_address', 'select_invoice_type')
.
Expected result (*)
- To be able to create new attributes as older version without error.
Mage::getSingleton('eav/config')->getAttribute('customer_address', 'select_invoice_type')
returnsMage_Customer_Model_Attribute
Actual result (*)
- Fatal error in latest ver.
Mage::getSingleton('eav/config')->getAttribute('customer_address', 'select_invoice_type')
returnsfalse