VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/8.4-pricing-system

⇱ Pricing System | MahoCommerce/maho | DeepWiki


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

Pricing System

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.

Overview and Scope

This pricing system covers:

  • Price indexing in flat tables for performance
  • Tier pricing based on quantity thresholds
  • Group pricing for customer group-specific prices
  • Special price support with date range validity
  • The final price calculation which incorporates all pricing inputs
  • Interaction with catalog price rules and sales coupons
  • Price rendering and currency formatting utilities

It is tightly integrated with the EAV model, catalog rules, and the checkout quote system to ensure accurate and efficient pricing.


Price Indexing

Price indexing is critical for performance in product collection loading and sorting.

Key Components

  • Index Table: catalog_product_index_price stores indexed final prices for combinations of product, website, and customer group.
  • Indexer: Rules and price data from EAV attributes and catalog rules are aggregated into the index.
  • CatalogRule Resource: Inserts rule price data into catalogrule/rule_product and contributes to index updates.

Data Flow


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

Tier pricing provides quantity-based discounts.

  • Stored in EAV attribute table catalog_product_entity_tier_price
  • Scoped per website
  • Applies discounts for customer purchasing specified quantity thresholds
  • Considered along with base price and special price during final price calculation

Tier prices are loaded and merged into the price index during reindexing, enabling fast retrieval without complex calculations at runtime.


Group Pricing

Group pricing enables customer group-specific prices.

  • Stored in EAV attribute table catalog_product_entity_group_price
  • Scoped per website
  • Overrides base price when customer's group price exists

The final price calculation considers group price before applying catalog rules or tier pricing.


Special Prices

Special prices are promotional prices valid within a date range.

  • Stored in catalog_product_entity_decimal attribute with attribute code special_price
  • Associated special_from_date and special_to_date date attributes define validity period
  • Special price is only active if current date is within this range

During price calculation, if the special price is valid and less than the base price, it is used as the price basis.


Price Calculation

The final price calculation integrates all price types to determine the customer-facing price.

Calculation Logic

  1. Start with the base price.
  2. If special price is active and lower, use it.
  3. Check tier price based on quantity if applicable.
  4. Check group price for customer group-specific override.
  5. Apply catalog price rules (discounts) which can lower price further.
  6. The minimum price based on above is chosen as the final price.

Relevant Code

Diagram: Price Calculation


Sources:
app/code/core/Mage/CatalogRule/Model/Observer.php131-170
app/code/core/Mage/Core/Helper/Data.php88-115


Catalog Price Rules

Catalog Price Rules are discounts applied dynamically based on conditions.

Rule-Customer Group-Website Association

Rules associate to various entities (website/customer group) through the _associatedEntitiesMap configuration. The resource model handles insertion, deletion, and retrieval of these associations.


Sales Price Rules (Coupons)

Sales rules with coupons are handled separately:


Price Rendering and Currency Formatting

Frontend price display relies on helper and store formatting.

Diagram: Price Rendering Components


Sources:
app/code/core/Mage/Core/Helper/Data.php88-139


Technical Details and Extensions

Date and Time Handling

Observers and Events

  • Pricing rules application is implemented as observers listening to product save and quote total collection events app/code/core/Mage/CatalogRule/Model/Observer.php30-130
  • Catalog price rules preload their matching prices during quote total collection to minimize runtime DB queries.
  • Sales rules (coupons) operate separately and require coupon validation during checkout.

Encryption and Security


Summary Diagram: Pricing System Components and Flow



This 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