Multi-Attribute Matching

Advanced customer attribute matching with configurable AND/OR logic for precise targeting.

Overview

Multi-Attribute Matching enables sophisticated customer targeting by combining multiple customer attributes with flexible logic operators. Unlike simple pricelists where attributes use fixed AND logic, Product-Customer Matrix allows you to configure AND or OR relationships between attributes for each matrix.

Key Advantages

  • Flexible Logic: Choose AND (all must match) or OR (any can match) per matrix
  • Multiple Values: Assign multiple values per attribute (e.g., multiple groups)
  • Complex Scenarios: (Group A OR Group B) AND (Region X) patterns
  • Attribute Table: Dedicated table for scalable attribute storage
  • Real-Time Evaluation: Attributes evaluated on login and profile updates

How It Works

Attributes Relation Field

Each matrix has an attributes_relation field that controls how multiple attributes combine.

Options:

  • AND (Default): ALL filled attributes must match
  • OR: ANY filled attribute can match

Attribute Storage

Attributes stored in dedicated table: pricesystem_product_customer_matrix_attribute

Structure:

CREATE TABLE pricesystem_product_customer_matrix_attribute (
  id INT PRIMARY KEY AUTO_INCREMENT,
  matrix_id INT NOT NULL,
  attribute_code VARCHAR(50) NOT NULL,  -- 'group', 'company', 'tax', etc.
  attribute_value VARCHAR(255) NOT NULL,

  FOREIGN KEY (matrix_id) REFERENCES pricesystem_product_customer_matrix(id) ON DELETE CASCADE
);

Example Data:

matrix_id | attribute_code | attribute_value
----------|----------------|----------------
1         | group          | 2               (Wholesale)
1         | group          | 4               (VIP)
1         | country        | US

This means: (Group = 2 OR Group = 4) AND (Country = US)


Evaluation Process

Step-by-Step

Input:

  • Customer ID: 123
  • Customer attributes: Group=2 (Wholesale), Country=US, Region=California, Company="ACME Corp"

Process:

Step 1: Get Active Matrices

SELECT * FROM pricesystem_product_customer_matrix
WHERE is_active = 1
  AND website_id = 1
  AND (from_date IS NULL OR from_date <= CURDATE())
  AND (to_date IS NULL OR to_date >= CURDATE());

Result: 3 active matrices

Step 2: Load Attributes for Each Matrix

SELECT matrix_id, attribute_code, attribute_value
FROM pricesystem_product_customer_matrix_attribute
WHERE matrix_id IN (1, 2, 3);

Result:

Matrix 1 (attributes_relation='AND'):
- group: 2
- country: US

Matrix 2 (attributes_relation='OR'):
- group: 2
- group: 4
- region: California

Matrix 3 (attributes_relation='AND'):
- company: ACME
- country: US
- region: California

Step 3: Evaluate Each Matrix

Matrix 1 (AND logic):

Check: group=2? YES (customer group = 2) ✓
Check: country=US? YES (customer country = US) ✓
Result: MATCH (all attributes matched)

Matrix 2 (OR logic):

Check: group=2? YES (customer group = 2) ✓
(OR logic: stop here, already matched)
Result: MATCH (at least one attribute matched)

Matrix 3 (AND logic):

Check: company=ACME? YES (customer company contains "ACME") ✓
Check: country=US? YES ✓
Check: region=California? YES ✓
Result: MATCH (all three attributes matched)

Step 4: Assign Matching Matrices

Customer assigned to: Matrix 1, Matrix 2, Matrix 3


Supported Attributes

Customer Group

Attribute Code: group

Source: Customer entity → group_id field

Example:

Attribute: group = 2 (Wholesale)
Customer: group_id = 2
Match: YES

Multiple Values:

Attributes:
- group = 2 (Wholesale)
- group = 4 (VIP)

Logic: Customer matches if group=2 OR group=4

Use Case:

  • Target multiple customer segments
  • VIP + Partner programs
  • Wholesale + Retail (different tiers)

Company Name

Attribute Code: company

Source: Customer entity → company attribute

Example:

Attribute: company = ACME
Customer: company = "ACME Corporation"
Match: YES (loose mode contains "ACME")

Matching Mode:

  • Loose: Partial string match, case-insensitive
  • Exact: Strict equality, case-sensitive

Configuration: pricesystem/productcustomermatrix/match_exact_type

Multiple Values:

Attributes:
- company = ACME
- company = XYZ
- company = Global

Logic: Customer matches if company contains any of these strings

Use Case:

  • Multi-company B2B contracts
  • Partner programs with multiple companies
  • Corporate group pricing

Tax/VAT Number

Attribute Code: tax

Source: Customer entity → taxvat attribute

Example:

Attribute: tax = DE123456789
Customer: taxvat = DE123456789
Match: YES

Use Case:

  • EU VAT-registered businesses
  • Tax-exempt organizations
  • B2B verified accounts

Notes:

  • Usually exact match (even in loose mode)
  • Format-sensitive (include dashes, spaces as stored)
  • Verify data quality

Postcode

Attribute Code: postcode

Source: Customer address → postcode

Example:

Attribute: postcode = 90210
Customer billing: postcode = 90210
Match: YES

Address Checking:

  • Checks BOTH billing AND shipping addresses
  • Match if EITHER address matches

Loose Matching:

Attribute: postcode = 9021
Customer: postcode = 90210
Match: YES (contains "9021")

Multiple Values:

Attributes:
- postcode = 90210
- postcode = 90211
- postcode = 90212

Logic: Customer matches if any address has any of these postcodes

Use Case:

  • ZIP code-based regional pricing
  • Local delivery zones
  • Metropolitan area targeting

Region

Attribute Code: region

Source: Customer address → region text field

Example:

Attribute: region = California
Customer billing: region = California
Match: YES

Data Quality:

  • Magento stores region as text (not ID)
  • "California" vs "CA" might not match
  • Standardize or use loose matching

Multiple Values:

Attributes:
- region = California
- region = Nevada
- region = Arizona

Logic: Customer matches if any address in any of these regions

Use Case:

  • State/province-specific pricing
  • Regional campaigns
  • Tax jurisdiction targeting

Country

Attribute Code: country

Source: Customer address → country_id (ISO 2-letter code)

Example:

Attribute: country = US
Customer billing: country_id = US
Match: YES

Format:

  • Always 2-letter ISO codes: US, DE, GB, FR, IT, ES, etc.
  • Exact match even in loose mode

Multiple Values:

Attributes:
- country = US
- country = CA
- country = MX

Logic: North American customers (USMCA)

Use Case:

  • Country-specific pricing
  • Currency localization
  • Regulatory compliance
  • Continental targeting (EU, APAC, etc.)

AND Logic Patterns

Pattern 1: Precise Targeting

Goal: California wholesale customers only.

Matrix Configuration:

attributes_relation: AND

Attributes:
- group = 2 (Wholesale)
- country = US
- region = California

Matching:

Customer A: Wholesale, US, California → MATCH ✓
Customer B: Wholesale, US, Texas → NO MATCH (wrong region)
Customer C: Retail, US, California → NO MATCH (wrong group)
Customer D: Wholesale, DE, California → NO MATCH (wrong country)

Use Case: Very specific regional + segment targeting.


Pattern 2: B2B Company + Location

Goal: ACME Corp employees in US only.

Matrix Configuration:

attributes_relation: AND

Attributes:
- company = ACME
- country = US

Matching:

Customer A: ACME Corp, US → MATCH ✓
Customer B: ACME Corp, DE → NO MATCH (wrong country)
Customer C: XYZ Inc, US → NO MATCH (wrong company)

Use Case: Multi-national B2B contracts with regional restrictions.


Pattern 3: Triple Attribute Precision

Goal: Wholesale California customers from ACME Corp.

Matrix Configuration:

attributes_relation: AND

Attributes:
- group = 2 (Wholesale)
- company = ACME
- region = California

Matching:

Customer A: Wholesale, ACME, California → MATCH ✓
Customer B: Wholesale, ACME, Texas → NO MATCH (wrong region)
Customer C: VIP, ACME, California → NO MATCH (wrong group)

Use Case: Highly specific targeting with multiple conditions.


OR Logic Patterns

Pattern 1: Multiple Customer Groups

Goal: Wholesale OR VIP customers.

Matrix Configuration:

attributes_relation: OR

Attributes:
- group = 2 (Wholesale)
- group = 4 (VIP)

Matching:

Customer A: Wholesale → MATCH ✓
Customer B: VIP → MATCH ✓
Customer C: Retail → NO MATCH

Use Case: Target multiple customer segments with same pricing.


Pattern 2: Multi-Region Campaign

Goal: Customers in California, Nevada, or Arizona.

Matrix Configuration:

attributes_relation: OR

Attributes:
- region = California
- region = Nevada
- region = Arizona

Matching:

Customer A: California → MATCH ✓
Customer B: Nevada → MATCH ✓
Customer C: Texas → NO MATCH

Use Case: Regional campaigns covering multiple states.


Pattern 3: Multi-Country Pricing

Goal: North American customers (US, Canada, Mexico).

Matrix Configuration:

attributes_relation: OR

Attributes:
- country = US
- country = CA
- country = MX

Matching:

Customer A: US → MATCH ✓
Customer B: CA → MATCH ✓
Customer C: DE → NO MATCH

Use Case: Continental/regional pricing zones.


Complex Scenarios

Scenario 1: (Group A OR Group B) AND (Region X)

Goal: Wholesale OR VIP customers in California.

Challenge: Need OR for groups, AND for region.

Solution: Create TWO matrices:

Matrix 1: Wholesale + California (Priority 20)

attributes_relation: AND
- group = 2 (Wholesale)
- region = California

Matrix 2: VIP + California (Priority 20)

attributes_relation: AND
- group = 4 (VIP)
- region = California

Result:

  • Wholesale California customers: Matrix 1
  • VIP California customers: Matrix 2
  • Same priority, same products/prices

Scenario 2: (Company A OR Company B) AND (Country US)

Goal: ACME Corp OR XYZ Inc, but only in US.

Solution: Create TWO matrices:

Matrix 1: ACME + US

attributes_relation: AND
- company = ACME
- country = US

Matrix 2: XYZ + US

attributes_relation: AND
- company = XYZ
- country = US

Alternative (if same pricing): Use single matrix with manual customer assignments instead of attributes.


Scenario 3: Exclusion Logic (NOT)

Goal: All customers EXCEPT wholesale.

Challenge: System doesn't support NOT operator.

Workaround 1: Use OR with all other groups:

attributes_relation: OR
- group = 1 (General)
- group = 4 (VIP)
- group = 5 (Partner)
(exclude group = 2 Wholesale by not listing it)

Workaround 2: Create separate matrices with higher priority for excluded segment.


Attribute Data Quality

Best Practices

1. Standardize Data Entry:

Good: Company = "ACME Corporation"
Bad: Company = "acme corp.", "ACME Corp", "Acme Corporation"

2. Validate on Registration:

  • Require company name for B2B customers
  • Validate tax IDs (format + checksum)
  • Use dropdown for regions (not free text)
  • Use ISO country codes

3. Data Cleanup:

-- Find company name variations
SELECT DISTINCT company FROM customer_entity WHERE company LIKE '%ACME%';

-- Standardize company names
UPDATE customer_entity SET company = 'ACME Corporation' WHERE company LIKE '%ACME%';

4. Use Loose Matching:

  • Forgives typos and variations
  • "ACME" matches "ACME Corp", "acme corporation"
  • Trade-off: Less precise

Testing Multi-Attribute Logic

Test Case 1: AND Logic

Setup:

Matrix: "Test AND Logic"
attributes_relation: AND
Attributes:
- group = 2 (Wholesale)
- country = US

Test Customers:

Customer A: Wholesale, US → Expected: MATCH ✓
Customer B: Wholesale, DE → Expected: NO MATCH
Customer C: Retail, US → Expected: NO MATCH
Customer D: Retail, DE → Expected: NO MATCH

Verify:

  1. Log in as each customer
  2. Check assigned matrices (admin or API)
  3. Verify expectations

Test Case 2: OR Logic

Setup:

Matrix: "Test OR Logic"
attributes_relation: OR
Attributes:
- group = 2 (Wholesale)
- group = 4 (VIP)

Test Customers:

Customer A: Wholesale → Expected: MATCH ✓
Customer B: VIP → Expected: MATCH ✓
Customer C: Retail → Expected: NO MATCH

Verify: Same as Test Case 1.


Test Case 3: Multiple Values per Attribute

Setup:

Matrix: "Multi-Country"
attributes_relation: OR
Attributes:
- country = US
- country = CA
- country = MX

Test Customers:

Customer A: US → Expected: MATCH ✓
Customer B: CA → Expected: MATCH ✓
Customer C: MX → Expected: MATCH ✓
Customer D: DE → Expected: NO MATCH

Database Queries

View Matrix Attributes

SELECT
  m.id,
  m.name,
  m.attributes_relation,
  ma.attribute_code,
  ma.attribute_value
FROM pricesystem_product_customer_matrix m
LEFT JOIN pricesystem_product_customer_matrix_attribute ma ON ma.matrix_id = m.id
WHERE m.id = 1
ORDER BY ma.attribute_code, ma.id;

Example Output:

id | name               | attributes_relation | attribute_code | attribute_value
---|--------------------|--------------------|----------------|----------------
1  | Wholesale US 2025  | AND                | country        | US
1  | Wholesale US 2025  | AND                | group          | 2

Find Customers Matching Attributes

Complex Query (AND Logic Example):

SELECT DISTINCT ce.entity_id, ce.email, ce.group_id, ad.country_id
FROM customer_entity ce
JOIN customer_address_entity ad ON ad.parent_id = ce.entity_id AND ad.is_default_billing = 1
WHERE ce.group_id = 2  -- Wholesale
  AND ad.country_id = 'US'
  AND ce.website_id = 1;

Result: All wholesale customers in US (matches AND logic).


Count Potential Matches

-- How many customers would match this matrix?
SELECT COUNT(DISTINCT ce.entity_id) AS potential_matches
FROM customer_entity ce
JOIN customer_address_entity ad ON ad.parent_id = ce.entity_id
WHERE ce.group_id = 2  -- Wholesale
  AND ad.country_id = 'US';

Troubleshooting

Attributes Not Matching

Checklist:

  1. ✓ Correct attributes_relation (AND/OR)?
  2. ✓ Attribute codes correct? (group, company, tax, postcode, region, country)
  3. ✓ Attribute values exact? (check customer data)
  4. ✓ Matching mode? (loose vs exact)
  5. ✓ Data quality? (typos, case differences)
  6. ✓ Address vs customer? (some attributes check addresses)

Debug SQL:

-- Check customer attributes
SELECT ce.entity_id, ce.email, ce.group_id, ce.company, ce.taxvat
FROM customer_entity ce
WHERE ce.entity_id = 123;

-- Check customer addresses
SELECT ad.postcode, ad.region, ad.country_id
FROM customer_address_entity ad
WHERE ad.parent_id = 123;

-- Check matrix attributes
SELECT ma.attribute_code, ma.attribute_value
FROM pricesystem_product_customer_matrix_attribute ma
WHERE ma.matrix_id = 1;

OR Logic Not Working

Common Issue: Mixing AND and OR expectations.

Example:

Matrix (attributes_relation=OR):
- group = 2
- country = US

Customer: group=1 (Retail), country=US

Expected (incorrect): NO MATCH (thinking AND logic)
Actual: MATCH (OR logic: country matches)

Fix: Review attributes_relation field. If AND needed, create separate matrices or change to AND.


Too Many/Too Few Matches

Issue: Attribute logic too broad or too narrow.

Debug:

  1. Check how many customers have each attribute value
  2. Test with known customers
  3. Review attributes_relation logic
  4. Consider splitting into multiple matrices

Best Practices

Attribute Selection

  1. Start simple: Single attribute (group)
  2. Add complexity: Group + Country
  3. Test thoroughly: Edge cases
  4. Document logic: Why these attributes?

Logic Choice

  • AND: Use for precise targeting (3-4 attributes max)
  • OR: Use for broad targeting (multiple groups/regions)
  • Complex: Split into multiple matrices

Data Quality

  • Standardize company names
  • Validate tax IDs
  • Use consistent region naming
  • Encourage complete profiles

Performance

  • Fewer attributes = faster evaluation
  • Group + Country very fast (indexed)
  • Company matching slower (text search)
  • Regular data cleanup

Found an issue with this documentation? Let us know