Fulfillment – Daily Changelog – October 1, 2025

2025-10-01 – Multi-Store Architecture & OSA Integration

Multi-Store Product Synchronization

New Store Setup

  • Added Orchard Street Apparel Store: Configured second Shopify store (orchard-street-apparel.myshopify.com) with credentials stored in AWS Secrets Manager (OrchardStreetApparelShopifyAccess)
  • Store Record Created: Added store ID 34 linked to OSP customer (ID 34) in fulfillment_stores table
  • Shopify Scopes Migration: Ran migration 2025-08-22-add-shopify-scopes.sql to create shopify_required_scopes and shopify_scope_verifications tables in production
  • Scope Verification: Verified both Mama Tried and OSA stores have identical 30 Shopify Admin API scopes

Multi-Store Product Sync Infrastructure

  • Store-Specific Sync: Updated /api/products/sync-new endpoint to accept optional storeId parameter
  • When storeId provided: Uses that store’s Shopify credentials
  • When omitted: Falls back to default Mama Tried store for backward compatibility
  • Store Credential Lookup: Implemented automatic store credential resolution based on product customer_id
  • StoreService.getCustomerStores() retrieves stores for a customer
  • StoreService.getStoreShopifyCredentials() fetches AWS secrets for store-specific API access
  • Sync UI Page: Created /stores/sync-products page with store selector dropdown for importing products from any configured store
  • Product Type Assignment: Auto-assigns product type based on customer (Type 2 “Inventory Item” for OSA, Type 1 “Print-on-demand” for others)

Database Schema Fixes

  • Product Type Constraint: Added product_type_id to product inserts (was causing null constraint violations)
  • Decoration Process Requirement: Auto-creates “Screen Printing” (ID 3) decoration process for products without one during variant sync
  • Process ID Handling: Modified variant sync to handle products without pre-existing decoration processes

Multi-Store API Updates

Variant Sync Endpoints

  • Individual Variant Sync (/api/products/[id]/sync-variants):
  • Looks up product’s customer_id to determine correct Shopify store
  • Initializes ShopifyService with store-specific credentials
  • Auto-creates Screen Printing process for OSA inventory items
  • Falls back to default Mama Tried credentials if no customer assigned
  • Bulk Variant Sync (/api/products/bulk-sync-variants):
  • New endpoint for batch variant synchronization across all active products in a store
  • Processes products sequentially with 250ms delay to avoid Shopify rate limiting
  • Auto-creates decoration processes where missing
  • Returns detailed stats (processed, synced, skipped, errors)

Price & Description Endpoints

  • Pull Prices (/api/products/[id]/update-prices): Updated to use product’s customer store credentials
  • Pull Description (/api/products/[id]/pull-description): Updated to fetch from correct Shopify store based on product customer

Product Detail API

  • Added Customer Fields: Updated /api/products/[id] GET endpoint to include:
  • customer_id
  • customer_name
  • customer_sku_prefix
  • Customer Join: Added LEFT JOIN to customers table to populate customer details in product response

Orchard Street Apparel Import

Product Sync Results

  • Initial Sync: Successfully imported 250+ products from OSA Shopify store
  • Image Processing: Downloaded and uploaded all product images to S3 (orchardstreetmarket bucket)
  • Art File Records: Created mama_tried_art_files entries for product display images
  • Product Display Files: Linked art files to products via mama_tried_product_display_files

Product Status Distribution

  • Active: 115 products currently sold
  • Archived: 250 historical/discontinued products
  • Draft: 10 products in preparation

Variant Sync

  • Bulk Processing: Running bulk variant sync for 115 active OSA products
  • Size/Price Import: Syncing all product variants (XS-XXL, kids sizes, etc.) with Shopify prices
  • Inventory Quantities: Importing current stock levels from OSA store
  • Screen Printing Assignment: Auto-assigning appropriate decoration process to all products

Code Quality Improvements

  • Removed Email Spam: Eliminated email notifications from bulk product sync (would have sent 250+ emails)
  • Enhanced Logging: Added detailed console logging for store credential lookup and API initialization
  • Error Handling: Improved error messages and validation throughout multi-store flows
  • Case-Insensitive Status Checks: Fixed status filtering to handle uppercase “ACTIVE” vs lowercase “active”

Technical Notes

  • Architecture: System now supports unlimited Shopify stores, each with separate credentials in AWS Secrets Manager
  • Backward Compatibility: All existing Mama Tried functionality preserved; defaults to original behavior when no store specified
  • Product Association: Products automatically linked to customers/stores during import based on which store they’re synced from
  • Future Ready: Foundation laid for transitioning from Deco Network to OSP Fulfillment Platform for multi-client operations

Follow-Up Tasks

  • Systematically review remaining product sync tools to ensure multi-store compatibility
  • Consider adding store selector to other bulk operations
  • Monitor Shopify rate limits during large bulk operations
  • Test order sync with OSA products once variant sync completes