Extend Magento's EAV Attribute Model

Extend Magento's EAV Attribute Model

August 29, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Extend Magento's EAV Attribute Model

Extending Magento’s EAV Attribute Model: A Comprehensive Guide

As a seasoned developer working with e-commerce platforms like Magento, you may find yourself needing to extend the built-in functionality of the platform. One common request is to add a new attribute to the Entity-Attribute-Value (EAV) model used by Magento, particularly for catalog product attributes.

Understanding Magento’s EAV Model

Before diving into how to extend it, let’s briefly recap what the EAV model is in Magento. It allows you to store data for an entity without knowing its structure beforehand. This flexibility helps handle complex data structures efficiently.

The main tables involved are catalog_eav_attribute, which stores attribute metadata, and catalog_product_entity_varchar (for string attributes), where the actual attribute values are stored.

Why Extend the EAV Model?

You might want to extend this model when you need a new setting for your products that isn’t already available in Magento’s core. For example, you could create an attribute like “Featured Product” or “On Sale” which would be unique to your store and not part of the standard product information.

Extending the EAV Attribute Model

To add a new attribute, follow these steps:

  1. Create the new attribute:

You can use the setup/upgrade script in your custom module for this purpose. Here’s an example of how to create a new boolean attribute called “Featured”:

$installer = $this;
$installer->startSetup();

$installer->addAttribute("catalog_product", "featured", array(
    "type" => "int",
    "backend" => "",
    "frontend" => "",
    "label" => "Featured Product",
    "input" => "boolean",
    "source" => "",
    "visible" => true,
    "required" => false,
    "global" => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));

$installer->endSetup();

In this code, we’re using the addAttribute method to create a new attribute with the following specifications:

  • Name: featured
  • Type: integer (though for boolean attributes, you can use “int”)
  • Input type: boolean
  • Label: Featured Product
  • Source: not needed for this simple boolean attribute
  1. Update the database schema:

After creating your module, don’t forget to update its install and uninstall scripts in app/code/local/YourCompany/YourModule/sql/yourmodule_setup/install-1.0.0.sql (and similarly for uninstall). This file should include a statement to add the new attribute column to the catalog_product_entity_varchar table, like so:

ALTER TABLE catalog_product_entity_varchar ADD featured INT(1) NOT NULL DEFAULT 0;
  1. Usage:

After setting this up, you can use your new “Featured Product” attribute in your product forms and backend functionality just like any other core Magento attribute.

Conclusion

As you’ve seen, it is indeed possible to extend Magento’s EAV model by adding a new attribute to the catalog_product_entity_varchar table. This allows you to create custom settings for your products without needing to modify the core codebase.

Remember that extending Magento should always be done in a way that maintains compatibility with updates and avoids conflicts with core files. Using custom modules is the recommended approach, as it keeps your changes separate from the core codebase.

For more advanced techniques like creating multi-select or date attributes, I recommend checking out our Magento Extensions Guide for a deeper dive into the subject.

Catalog Database Extensions Configuration

Our network