![]() |
VOOZH | about |
The Pricing System in Maho manages product price indexing, tier pricing, group pricing, special prices, and the overall price calculation process. It integrates with catalog rules and sales rules to determine the final customer-facing price. This page provides an in-depth technical view of the pricing system implementation, highlighting data flow, key classes, functions, and index maintenance.
This pricing system covers:
It is tightly integrated with the EAV model, catalog rules, and the checkout quote system to ensure accurate and efficient pricing.
Price indexing is critical for performance in product collection loading and sorting.
catalog_product_index_price stores indexed final prices for combinations of product, website, and customer group.catalogrule/rule_product and contributes to index updates.This indexing workflow ensures that rule-based discounts and base prices are normalized into a fast lookup table for pricing queries.
Sources:
app/code/core/Mage/CatalogRule/Model/Resource/Rule.php163-200
app/code/core/Mage/CatalogRule/Model/Resource/Rule.php116-160
Tier pricing provides quantity-based discounts.
catalog_product_entity_tier_priceTier prices are loaded and merged into the price index during reindexing, enabling fast retrieval without complex calculations at runtime.
Group pricing enables customer group-specific prices.
catalog_product_entity_group_priceThe final price calculation considers group price before applying catalog rules or tier pricing.
Special prices are promotional prices valid within a date range.
catalog_product_entity_decimal attribute with attribute code special_pricespecial_from_date and special_to_date date attributes define validity periodDuring price calculation, if the special price is valid and less than the base price, it is used as the price basis.
The final price calculation integrates all price types to determine the customer-facing price.
Mage_CatalogRule_Model_Observer::processFrontFinalPrice applies catalog price rules to product final price retrieval events app/code/core/Mage/CatalogRule/Model/Observer.php131-170Mage_Core_Helper_Data::currency() formats prices for store currencies and locales app/code/core/Mage/Core/Helper/Data.php88-115Sources:
app/code/core/Mage/CatalogRule/Model/Observer.php131-170
app/code/core/Mage/Core/Helper/Data.php88-115
Catalog Price Rules are discounts applied dynamically based on conditions.
Mage_CatalogRule_Model_Rule and persisted via Mage_CatalogRule_Model_Resource_RulebindRuleToEntity app/code/core/Mage/CatalogRule/Model/Resource/Rule.php106-167Rules associate to various entities (website/customer group) through the _associatedEntitiesMap configuration. The resource model handles insertion, deletion, and retrieval of these associations.
Sales rules with coupons are handled separately:
Mage_SalesRule_Model_Resource_CouponFrontend price display relies on helper and store formatting.
Mage_Core_Helper_Data::currency() and ::formatPrice() provide currency conversion and formatting based on store settings app/code/core/Mage/Core/Helper/Data.php88-139Mage_Core_Model_LocaleSources:
app/code/core/Mage/Core/Helper/Data.php88-139
Mage_Core_Model_Locale for consistent UTC-based formatting app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php40-60sys:encryptionkey:regenerate ensures encryption key rotation with hooks to re-encrypt stored data lib/MahoCLI/Commands/SysEncryptionKeyRegenerate.php120-140This detailed breakdown outlines how Maho's pricing system unites various price types, rules, and indexes into a consistent, performant product price system built on the EAV framework and integrated with Magento heritage components.
Sources:
app/code/core/Mage/CatalogRule/Model/Resource/Rule.php
app/code/core/Mage/CatalogRule/Model/Observer.php
app/code/core/Mage/SalesRule/Model/Resource/Coupon.php
app/code/core/Mage/SalesRule/Model/Resource/Rule.php
app/code/core/Mage/Core/Helper/Data.php
app/code/core/Mage/Reports/Model/Resource/Report/Abstract.php
lib/MahoCLI/Commands/SysEncryptionKeyRegenerate.php
Refresh this wiki