Skip to content

EAV Config Cache Bug: getAttribute() returns false at creating new attribute #3057

Closed
@kiatng

Description

@kiatng

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 (*)

  1. As described.
  2. Or just examine the output of Mage::getSingleton('eav/config')->getAttribute('customer_address', 'select_invoice_type').

Expected result (*)

  1. To be able to create new attributes as older version without error.
  2. Mage::getSingleton('eav/config')->getAttribute('customer_address', 'select_invoice_type') returns Mage_Customer_Model_Attribute

Actual result (*)

  1. Fatal error in latest ver.
  2. Mage::getSingleton('eav/config')->getAttribute('customer_address', 'select_invoice_type') returns false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions