VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/8.3-attributes-and-attribute-sets

⇱ Attributes and Attribute Sets | MahoCommerce/maho | DeepWiki


Loading...
Last indexed: 15 May 2026 (ea8ab8)
Menu

Attributes and Attribute Sets

Purpose and Scope

This document details the attribute system within Maho's catalog module, focusing on flexible product and category metadata management using the Entity-Attribute-Value (EAV) model. It covers attribute definitions, attribute sets, attribute groups, attribute scopes, attribute loading and caching, and specialized attribute handling.

For broader context, see EAV System for architecture details, Product Types for product-specific features, and Category Management for categories.


Attribute Architecture

EAV Attribute Model

Attributes in Maho are defined once in the eav_attribute table but can be assigned to multiple entity types such as products and categories. Mage_Eav_Model_Entity_Attribute_Abstract (defined at app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php47-243) is the base attribute model, extended by catalog-specific class Mage_Catalog_Model_Resource_Eav_Attribute (app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php56-145) which adds catalog-specific behavior and properties.

Attributes map to data stored in backend tables depending on their backend_type (e.g., int, varchar, text). For product and category attributes, these backend data values are stored in entity-specific tables such as catalog_product_entity_int, catalog_product_entity_varchar, etc.


Sources:
app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php56-64
app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php47-243
app/code/core/Mage/Eav/Model/Entity/Abstract.php72-110

Attribute Properties

Attributes are defined by metadata fields mainly in eav_attribute and extended in entity-specific tables. The catalog attribute model (Mage_Catalog_Model_Resource_Eav_Attribute) manages additional properties and validation logic.

Key attribute properties include:

PropertyTypeDescriptionGetter Method / Location
attribute_codevarcharUnique code (e.g. name, price)getAttributeCode() Entity/Attribute/Abstract.php211
entity_type_idintEntity type reference (product/category)getTypeId() Entity/Abstract.php284
backend_typevarcharStorage type (int, varchar, text, etc.)getBackendType() Entity/Attribute/Abstract.php245
frontend_inputvarcharInput form type (e.g., text, select)getFrontendInput() Entity/Attribute/Abstract.php21
is_requiredintWhether this is mandatorygetIsRequired() Entity/Attribute/Abstract.php29
is_user_definedintSystem (0) vs user-defined (1)getIsUserDefined() Entity/Attribute/Abstract.php32

Attribute scope constants, defined in Mage_Catalog_Model_Resource_Eav_Attribute:

ConstantValueDescription
SCOPE_STORE0Scoped per store view
SCOPE_GLOBAL1Global single value
SCOPE_WEBSITE2Scoped per website

Sources:
app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php58-60
app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php209-246


Attribute Sets and Groups

Attribute Set Structure

Attributes are organized into attribute sets, which group attributes logically and determine the attributes available for particular entities. Entity types (like catalog_product) have attribute sets identified by attribute_set_id. Each attribute set contains attribute groups which hold individual attributes for admin UI grouping and sorting.


Each attribute is mapped to a group within the set defining its position and organization. Attribute sets control which attributes apply to products or categories.

Sources:
app/code/core/Mage/Eav/Model/Entity/Type.php151-158
app/code/core/Mage/Eav/Model/Config.php57-69


System vs User-Defined Attributes

System Attributes

System attributes (is_user_defined = 0) are core platform attributes created during setup scripts. They are protected against deletion and often have specialized handling. For example, the price attribute is automatically assigned a specific backend model during the _beforeSave phase if unset (app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php107-111).

User-Defined Attributes

User-defined attributes (is_user_defined = 1) can be created, modified, or deleted by store administrators programmatically or via the admin UI.

Sources:
app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php94-118
app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php32


Attribute Scope

Attributes can have values scoped to different levels to support multi-store.


The scope is checked using methods like isScopeGlobal(), isScopeWebsite(), and isScopeStore() in Mage_Catalog_Model_Resource_Eav_Attribute (app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php179-202).

Sources:
app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php58-60
app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php179-202


Attribute Loading and Caching

Mage_Eav_Model_Config acts as the central EAV configuration registry managing attribute type and attribute data caching, entity types, and attribute sets. This class loads and caches EAV metadata to avoid repeated database lookups during requests (app/code/core/Mage/Eav/Model/Config.php133-173).

Cache Invalidation

Updating or deleting an attribute clears the EAV configuration cache to ensure changes propagate immediately. This is done explicitly in _afterSave and _afterDeleteCommit hooks in Mage_Catalog_Model_Resource_Eav_Attribute (app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php121-129 app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php154-162 respectively).

Attribute Data Flow


This system guarantees attribute data consistency and efficient retrieval.

Sources:
app/code/core/Mage/Eav/Model/Config.php133-173
app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php121-129
app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php120-145


Specialized Attribute Handling

Price and Rule Attributes

Attributes with frontend input type price are automatically assigned the backend model catalog/product_attribute_backend_price if none is explicitly set during save (app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php107-111).

Attributes can be flagged for inclusion in price rules (is_used_for_promo_rules), customer segmentation (is_used_for_customer_segment), or target rules (app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php48-51) enabling advanced promotional and segment functionality.

Dynamic Category Rules

Maho supports dynamic categories that select products via attribute-based rules leveraging the Mage_Rule subsystem. Mage_Catalog_Model_Category_Dynamic_Rule validates product attributes against conditions defined by Mage_Rule_Model_Condition_Abstract (app/code/core/Mage/Catalog/Model/Category/Dynamic/Rule.php150-165).

Rule-Based Condition Logic

Mage_Rule models define reusable, composable conditions on attributes. The abstract condition Mage_Rule_Model_Condition_Abstract allows specifying attribute, operator (e.g., is, contains, in list), and value (app/code/core/Mage/Rule/Model/Condition/Abstract.php141-157). Complex logical combinations are modeled by Mage_Rule_Model_Condition_Combine, allowing AND/OR nesting (app/code/core/Mage/Rule/Model/Condition/Combine.php40-50).

URL and SEO Attributes

Product and category SEO-friendly URLs are managed using attributes like url_key and url_path. The Mage_Catalog_Model_Url class handles URL path generation and rewriting (app/code/core/Mage/Catalog/Model/Url.php129-151). If a category's url_path is empty, it is generated dynamically from its hierarchy.


Sources:
app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php107-111
app/code/core/Mage/Catalog/Model/Category/Dynamic/Rule.php150-165
app/code/core/Mage/Rule/Model/Condition/Abstract.php141-157
app/code/core/Mage/Rule/Model/Condition/Combine.php40-50
app/code/core/Mage/Catalog/Model/Url.php129-151


Summary Diagram: Natural Language to Code Entities for Attributes


Sources: Combination of all above source files


Summary Diagram: Data Flow from Attribute Definition to Usage


Sources: Synthesized from all relevant source files in EAV and Catalog modules


References


This page details the low-level workings of Maho's flexible attribute system, essential for catalog extensibility and powering complex rules and SEO-friendly URLs.