Skip to content

Conversation

@bokelley
Copy link
Contributor

@bokelley bokelley commented Nov 4, 2025

Summary

Fixed two critical issues with product inventory management:

  1. Inventory display not showing breakdown - The inventory column only showed "None" or a total count, not a breakdown by type
  2. Custom targeting keys not saving - Custom key/value pairs were stored in config but not tracked as inventory mappings

Changes

1. Enhanced Inventory Display

  • Changed from simple count to breakdown by type (ad_units, placements, custom_keys)
  • Updated products list template with colored badges for each inventory type:
    • Green badge for ad units
    • Blue badge for placements
    • Purple badge for custom keys
  • Now displays: "3 ad units", "1 placement", "2 custom keys"

2. Fixed Custom Key Saving in Add Product

  • Create ProductInventoryMapping records for custom targeting keys
  • Store with inventory_type="custom_key" and inventory_id="key=value"
  • Ensures custom keys are properly tracked in the database

3. Fixed Custom Key Saving in Edit Product

  • Added inventory mapping sync when product is edited
  • Deletes all existing mappings and recreates them from implementation_config
  • Ensures all three inventory types (ad units, placements, custom keys) stay in sync

Test Coverage

  • ✅ Unit tests: 861 passed
  • ✅ Integration tests: 32 passed
  • ✅ Integration V2 tests: 28 passed
  • ✅ All pre-commit hooks passed
  • ✅ Black formatting applied
  • ✅ Ruff linting passed
  • ✅ mypy type checking passed

Result

Users can now:

  • ✅ Save custom targeting key/value pairs when creating/editing products
  • ✅ See them displayed in the inventory column on the products list
  • ✅ View complete breakdown showing ad units, placements, and custom keys

�� Generated with Claude Code

**Problem:**
- Custom targeting key/value pairs weren't being saved to ProductInventoryMapping
- Inventory column only showed "None" even when placements/custom keys were assigned

**Changes:**
1. Enhanced inventory display:
   - Changed from total count to breakdown by type (ad_units, placements, custom_keys)
   - Updated template to show colored badges for each type
   - Now displays "3 ad units, 1 placement, 2 custom keys"

2. Fixed custom key saving in add_product:
   - Create ProductInventoryMapping records for custom targeting keys
   - Store as inventory_type="custom_key" with inventory_id="key=value"

3. Fixed custom key saving in edit_product:
   - Sync inventory mappings when product is edited
   - Delete and recreate all mappings from implementation_config
   - Ensures custom keys are properly tracked

**Result:**
- Custom targeting keys now persist when saved
- Inventory column shows complete breakdown by type
- All three inventory types (ad units, placements, custom keys) properly tracked

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley merged commit 991656b into main Nov 4, 2025
10 checks passed
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…ontextprotocol#692)

**Problem:**
- Custom targeting key/value pairs weren't being saved to ProductInventoryMapping
- Inventory column only showed "None" even when placements/custom keys were assigned

**Changes:**
1. Enhanced inventory display:
   - Changed from total count to breakdown by type (ad_units, placements, custom_keys)
   - Updated template to show colored badges for each type
   - Now displays "3 ad units, 1 placement, 2 custom keys"

2. Fixed custom key saving in add_product:
   - Create ProductInventoryMapping records for custom targeting keys
   - Store as inventory_type="custom_key" with inventory_id="key=value"

3. Fixed custom key saving in edit_product:
   - Sync inventory mappings when product is edited
   - Delete and recreate all mappings from implementation_config
   - Ensures custom keys are properly tracked

**Result:**
- Custom targeting keys now persist when saved
- Inventory column shows complete breakdown by type
- All three inventory types (ad units, placements, custom keys) properly tracked

🤖 Generated with Claude Code

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants