Problem: Clicking on live API products showed "Product Not Found" page
Root Cause:
- Live API products have IDs >= 1000
- ProductPageClient only searched
allProductsarray (static products with IDs 1-62) - API products don't exist in static array
Solution: Updated ProductCard.tsx to handle API products differently[cite:88]
// Check if API product (ID >= 1000)
const isApiProduct = product.id >= 1000;
// API products → Open eBay directly
// Static products → Open detail page
const productLink = isApiProduct ? product.affiliateLink : `/product/${product.id}`;Result:
- ✅ API products (ID >= 1000) open directly on eBay
- ✅ Static products (ID < 1000) open detail page
- ✅ No more "Product Not Found" errors
- ✅ Better UX - API products go straight to purchase
Problem: API products might not match category filters correctly
Root Cause:
- Category slugs vs category names mismatch
- Multi-word categories: "Smart Home" vs "smart-home"
- Inconsistent naming between API and static products
Solution: Created explicit category mapping in category endpoint[cite:89]
const categoryQueryMap: Record<string, { query: string; categoryName: string }> = {
'smart-home': {
query: 'smart home alexa echo nest devices',
categoryName: 'Smart Home' // Exact match with categories array
},
'pet-supplies': {
query: 'pet supplies dog cat food toys',
categoryName: 'Pet Supplies' // Exact match
},
// ... all categories mapped
};Result:
- ✅ All API products use exact category names
- ✅ Category filtering works correctly
- ✅ Multi-word categories handled properly
- ✅ Consistent across homepage and category pages
- Manually curated products
- Have detail pages at
/product/[id] - Include product descriptions, ratings, reviews
- Always available (no API required)
Behavior:
- Clicking image/title → Detail page
- "View Details" button → Detail page
- "Buy Now" button → eBay with affiliate link
- Fetched from eBay Browse API
- No detail pages (would be duplicate of eBay)
- Fresh, real-time data
- Require API credentials
Behavior:
- Clicking image/title → Opens eBay directly
- "View on eBay" button → Opens eBay
- No detail page (direct purchase flow)
- Shows "LIVE" badge
Static Products:
- No special badge
- Discount badge if
originalPriceexists - "View Details" + "Buy Now" buttons
API Products:
- 🟢 "LIVE" badge (green, top-left)
- Discount badge if applicable
- "View on eBay" button (single CTA)
┌─────────────────────┐
│ LIVE -25% OFF │ ← API product badges
│ │
│ [Product Image] │
│ │
├─────────────────────┤
│ Electronics │
│ Sony Headphones │
│ $299.99 $399.99 │
│ [View on eBay] │ ← Single button
└─────────────────────┘
┌─────────────────────┐
│ -22% OFF │ ← Static product badge
│ │
│ [Product Image] │
│ │
├─────────────────────┤
│ Sneakers │
│ Air Jordan 4 Retro │
│ $350.00 $450.00 │
│ [View Details] │ ← Two buttons
│ [Buy Now] │
└─────────────────────┘
| Slug | Category Name | Query |
|---|---|---|
electronics |
Electronics | electronics laptop smartphone tablet trending |
gaming |
Gaming | gaming console playstation xbox nintendo switch |
sneakers |
Sneakers | sneakers nike jordan adidas running shoes |
smart-home |
Smart Home | smart home alexa echo nest devices |
beauty |
Beauty | beauty cosmetics skincare makeup trending |
collectibles |
Collectibles | collectibles cards funko vintage rare |
home |
Home | home kitchen appliances cookware furniture |
fitness |
Fitness | fitness equipment yoga weights exercise |
pet-supplies |
Pet Supplies | pet supplies dog cat food toys |
baby |
Baby | baby stroller car seat monitor essentials |
auto |
Auto | auto car accessories dash cam tools |
office |
Office | office desk chair keyboard monitor supplies |
Important: Category names must match exactly between:
lib/products.ts- Categories arrayapp/api/products/discover/route.ts- Discover endpointapp/api/products/category/[slug]/route.ts- Category endpoint- Product filtering logic
For Static Products (ID < 1000):
# Click product ID 6 (Air Jordan 4 Retro)
# Expected: Opens /product/6 detail page
# Shows: Rating, description, related productsFor API Products (ID >= 1000):
# Click any product from homepage (live catalog)
# Expected: Opens eBay.com in new tab
# Shows: eBay product page with affiliate tracking# Visit category page
https://your-site.vercel.app/category/smart-home
# Check products returned
# Expected: All products have category="Smart Home"
# Not "smart-home" or "smart home" or other variants# Click any product (static or API)
# Check URL contains:
# ✅ campid=5338903178
# ✅ customid=api-[category] or static-[category]
# ✅ mkcid=1
# ✅ mkrid=711-53200-19255-0
# ✅ siteid=0components/ProductCard.tsx- Smart product link handlingapp/api/products/category/[slug]/route.ts- Category name mappingdocs/FIXES_APPLIED.md- This documentation
If you need to change the ID threshold:
// components/ProductCard.tsx
// Change from 1000 to your threshold
const isApiProduct = product.id >= 1000;
// app/api/products/discover/route.ts
// Adjust ID generation
idx * 1000 + itemIdx + 1 // Starting from 1, 1001, 2001, etc.✅ Fixed: Product not found errors
✅ Fixed: Category name consistency
✅ Improved: User experience (direct eBay links for API products)
✅ Added: Visual indicators (LIVE badges)
✅ Maintained: Affiliate tracking across all links
✅ Documented: ID ranges and behavior differences
All products now work correctly regardless of source (static or API)! 🎉