2.0.30 Version History - Shopify Integration Module for Dolibarr

Version History

🚨 Version 2.0.30 (2025-09-09) - CRITICAL ORDER SYNCHRONIZATION FIXES

🚨 Critical Production Fixes
  • Issue #86 - CRITICAL: Fixed "Failed to fetch company" crash in production environments
  • ROOT CAUSE: createOrUpdateCustomer() method returned mixed types (-1 or Societe object)
  • FIX: Added strict type validation before accessing customer properties
  • Issue #87: Comprehensive logging system for production debugging
  • Issue #88: Automatic CRON user permissions verification
  • Issue #90: Enhanced error handling in customer management
🔧 Code Improvements
  • Type Safety: Strict object and ID validation for all customer operations
  • Error Context: Enhanced error messages with email, entity, and operation details
  • Transaction Safety: Improved database transaction handling with proper rollback
  • Logging Standards: Standardized log levels (DEBUG, INFO, WARNING, ERR) across operations
🎯 Client Impact
  • IMMEDIATE: Resolves "Failed to fetch company" crashes in production
  • RELIABILITY: Enhanced error handling prevents synchronization interruptions
  • SUPPORT: Detailed logs facilitate faster problem resolution
  • MONITORING: CRON permissions verification prevents silent authorization failures
📊 Modified Files
  • class/shopifyordermanager.class.php: Enhanced customer management with strict validation
  • core/modules/modShopifyIntegration.class.php: Version bump to 2.0.30

🐛 Version 2.0.29 (2025-09-05) - CRITICAL MULTI-ENTITY FIXES

🚨 Critical Fixes
  • Issue #83 - CRITICAL: Fixed "Failed to fetch company" error in multi-entity Dolibarr environments
  • Issue #84: Dynamic version retrieval in diagnostic JSON export
✨ Improvements
  • Multi-Entity: Customer search now properly filtered by entity
  • Diagnostics: Version automatically retrieved from module
  • Logging: Enhanced error handling for company fetch() operations
🎯 Client Impact
  • ✅ Order synchronization restored for multi-entity users
  • ✅ Diagnostic export now displays correct version
  • ✅ Enhanced client support with accurate diagnostics

🐛 Version 2.0.28 (2025-09-04) - CRITICAL SYNCHRONIZATION FIXES

🚨 Critical Fixes
  • CRITICAL BUG #80: Orders becoming "paid" after creation not synchronized
  • SOLUTION: Use of updated_at_min instead of created_at_min
  • SECURITY WINDOW: Automatic addition of 24h window to catch missed orders
  • CRITICAL BUG #81: getDolGlobalBool() error on Dolibarr v19-20
  • POLYFILL: Automatic compatibility function for versions prior to v21
✨ Diagnostic Improvements
  • JSON EXPORT: Complete exportable diagnostic for technical support (47 checks + 39 parameters)
  • IMPROVED INTERFACE: CSS classes for Shopify connection status with visual colors
  • SECURE CONFIGURATION: Export with automatic masking of sensitive keys (API keys, tokens)
  • TIMING CORRECTION: JSON export after complete report construction
📝 Support Documentation
  • TECHNICAL EMAILS: Templates for client support with detailed explanations
  • SOLUTIONS: Bug and solution documentation for similar cases
🔄 Universal Compatibility
  • DOLIBARR v19: Full compatibility with polyfill
  • DOLIBARR v20: Full compatibility with polyfill
  • DOLIBARR v21+: Native function used

🎯 Critical version: Installation strongly recommended for all users, especially if you use Dolibarr v19-20 or encounter order synchronization issues.

🚀 Version 2.0.27 (2025-08-28) - CONFIGURATION MIGRATION TO DOLIBARR CONSTANTS

🏗️ Major Architectural Changes
  • ISSUE #73 CRITICAL: Complete migration from custom table to Dolibarr standard constants
  • MAJOR CHANGE: Configuration now stored in llx_const instead of llx_shopify_dolibarr_storedetails
  • NEW CLASS: ConfigurationMigrator for automatic migration and backward compatibility
  • AUTO MIGRATION: Automatic migration on first access with fallback to old table if needed
  • 42 PARAMETERS: All configuration parameters migrated to Dolibarr constants with proper naming
  • MULTI-ENTITY: Improved multi-entity support using Dolibarr standard mechanisms
🔧 Enhanced Diagnostics and Monitoring
  • MIGRATION COUNTER: Migration status display in rights checker (X/42 parameters)
  • VISUAL INDICATORS: Badges for complete/partial/non-migrated configuration
  • DETECTION: Old configuration table presence reporting for cleanup guidance
  • STATISTICS: getConfigurationStats() method for detailed monitoring
  • LOGGING: Comprehensive migration process and error logging
📊 Files Migrated to Constants System
  • admin/setup.php: All saves now use dolibarr_set_const()
  • admin/diagnostic.php: Configuration reading via ConfigurationMigrator
  • admin/sync_products.php: Configuration checks via constants
  • class/importcollections.class.php: loadConfiguration() modernized
  • class/collectionsconflictresolver.class.php: loadConfiguration() modernized
  • class/shopifyordermanager.class.php: Historical import dates via constants
  • lib/shopifyintegration.lib.php: Admin tabs via constants
🛡️ Backward Compatibility & Security
  • ZERO BREAKING CHANGES: Automatic fallback to old table if constants missing
  • SEAMLESS MIGRATION: No user intervention required
  • FAIL-SAFE: If migration fails, system continues using old table
  • AUTOMATIC: Migration runs on first access after update
  • REVERSIBLE: Old table preserved until manual cleanup
🐛 Critical Fixes (2025-08-29)
  • CRITICAL FIX: ConfigurationMigrator was falsely showing "30/42 parameters migrated"
  • CRITICAL FIX: Migration now properly handles `0` values (excluded by previous `!empty()` condition)
  • CRITICAL FIX: Added missing translations for UserRightsCheck interface (5 languages)
  • FIX: Product synchronization checkboxes now display correctly based on migrated constants
  • FIX: Migration statistics now accurately count only the 42 mapped parameters
  • FIX: Product synchronization options (prices, descriptions, images, stocks, attributes) properly migrated
🚀 Interface Improvements (2025-08-29)
  • NEW: Force migration button in diagnostic interface for incomplete migrations (< 42 parameters)
  • NEW: Automatic Shopify API connection test with rights verification on page load
  • NEW: Unified diagnostic interface combining all verification functionalities
  • NEW: Complete translations added for all new diagnostic features (14 keys × 5 languages = 70 translations)
  • ENHANCED: Diagnostic page now includes migration status, rights check, and API connectivity in single view
  • IMPROVED: forceMigration() method to re-migrate all parameters even if already present
  • IMPROVED: testShopifyConnection() method with GraphQL shop query and scope detection
  • REMOVED: Separate rights_check.php tab - functionality integrated into main diagnostic
🩺 User Rights Diagnostic System (2025-08-31)
  • ISSUE #74 NEW: Complete user rights verification system for support acceleration
  • NEW CLASS: ShopifyRightsChecker for comprehensive permissions analysis
  • REAL-TIME VERIFICATION: Checks 15+ required Dolibarr rights (products, orders, invoices, stocks, admin)
  • CRITICAL/OPTIONAL DISTINCTION: Missing critical rights = red, missing optional = orange
  • VISUAL INDICATORS: Automatic color coding (green/orange/red)
  • IMPACT ANALYSIS: Detailed impact for each missing right with corrective guidance
  • MULTILINGUAL SUPPORT: Compatibility via data-* attributes (FR/EN/DE/ES/IT)
  • UNIFIED INTEGRATION: All checks in single admin/diagnostic.php page
🔧 Major Diagnostic Interface Improvements (2025-08-31)
  • CRITICAL FIX: HTML structure corrected - "Configuration Status" section properly closed
  • CRITICAL FIX: JavaScript detection via data-* attributes instead of language-dependent text
  • CRITICAL FIX: User rights calculation using correct data structure (status['current'] vs status['status'])
  • NEW: Collapsible sections with automatic expand/collapse based on status
  • NEW: Visual color coding with CSS classes (has-success, has-warning, has-error)
  • NEW: Complete consistency between displayed values and JavaScript calculations
  • ENHANCED: Auto-collapse success sections, auto-expand warnings/errors
  • IMPROVED: Shopify connection test with detailed scopes analysis (required vs optional)
🎯 Benefits: Performance (native Dolibarr caching), Standards (convention compliance), Multi-entity (improved support), Maintenance (no more custom table), Debugging (Dolibarr tools integration), Future-proof (prepared for future versions)

🔧 Version 2.0.26 (2025-08-26) - COMPLETE COLLECTIONS PATCH

🚨 Critical Session Fixes
  • DIAGNOSTIC CONSTRUCTOR: Fixed missing $langs parameter causing PHP Fatal error
  • HTML DISPLAY: Fixed HTML buttons showing as raw text in diagnostic interface
  • JSON EXPORT: Fixed JSON export displaying in browser instead of downloading
  • CRON ACTIVATION: Fixed CRON activation using proper Dolibarr API instead of SQL
  • CONFIGURATION DISPLAY: Fixed "non défini" values by reading complete configuration
  • PARENT CATEGORY EXCLUSION: Organizational anchor category no longer syncs to Shopify
  • PACKAGE GENERATION: Fixed dist folder cleanup forcing complete regeneration
🆕 Enhanced Diagnostic System
  • SYSTEM INFORMATION: Complete environment analysis (Dolibarr, PHP, database versions)
  • ADVANCED STATISTICS: Products, orders, collections with parent exclusion tracking
  • ONE-CLICK FIXES: CRON activation, duplicate cleanup, configuration validation
  • SUPPORT EXPORT: JSON diagnostic export for technical support
  • COLLECTIONS RESTORED: Issue #70 - Full collections synchronization functionality
  • BIDIRECTIONAL SYNC: 3 configurable directions with intelligent conflict resolution
  • PARENT EXCLUSION: Organizational category serves only as anchor, not synced
  • MAPPING INTERFACE: Administrative interface for collection-category management
🏗️ Technical Architecture
  • CLASS: ShopifyDiagnostic enhanced with complete system analysis
  • CLASS: CollectionsUtils - Mapping management with CRUD operations
  • CLASS: ImportCollections - Shopify to Dolibarr import system
  • CLASS: CollectionsConflictResolver - Intelligent conflict resolution
  • ENHANCED: ImportProducts with parent category exclusion logic
  • ENHANCED: ShopifyApi with 4 GraphQL methods for collections
📊 Professional Tools
  • TABLE: llx_shopify_collections_mapping for complete traceability
  • DIAGNOSTIC: Professional system information display
  • STATISTICS: Real-time sync metrics with parent category exclusion
  • TROUBLESHOOTING: One-click solutions for common issues
  • MULTILINGUAL: Complete translations in 5 languages for all features
  • EXPORT: JSON diagnostic download for technical support
📈 Impact
  • FIXES: Critical diagnostic system errors preventing support
  • ENABLES: Professional diagnostic and troubleshooting capabilities
  • IMPROVES: Collection synchronization with parent exclusion logic
  • PROVIDES: Complete system information for better support

🚨 Version 2.0.25 (2025-08-04) - CRITICAL HOTFIX

🔧 Critical Fixes
  • CRITICAL BUG: Fixed first synchronization failing to retrieve recent orders when no previous sync exists
  • ROOT CAUSE: When MAX(tms) returns NULL (empty table), no date filter was applied to GraphQL query, causing Shopify to return oldest orders instead of recent ones
  • SOLUTION: Implemented intelligent fallback using module installation date when no previous sync exists
  • NEW METHOD: SqlUtils::getModuleInstallationDate() with hierarchical fallback logic:
    • Priority 1: Module activation date from llx_const table
    • Priority 2: Table creation date from information_schema
    • Priority 3: First configuration date from store details
    • Priority 4: Default fallback (6 months ago)
  • ENHANCED: ShopifyOrderManager::getLastSuccessfulSync() now guarantees valid reference date for all synchronizations
📈 Impact
  • FIXES: Clients on v2.0.23/2.0.24 experiencing "no orders synced" on fresh installations
  • ENSURES: First synchronization correctly retrieves recent orders since module installation
  • MAINTAINS: Full backward compatibility with existing synchronizations

🚀 Version 2.0.24 (2025-01-08) - HISTORICAL IMPORT AND AUTO-ACTIVATION

🆕 New Features
  • Issue #60: Historical order import functionality integrated into CRON system
  • Issue #60: Automatic CRON activation when product and order configurations are complete
  • NEW: Intelligent CRON management with configuration completeness checks
  • NEW: Historical order import via ShopifyOrderSyncCron with automatic customer creation
  • NEW: Auto-deactivation of CRONs when configuration is incomplete to prevent API errors
🔧 Critical Fixes
  • Issue #61: Fixed manual synchronization search displaying products but unable to sync them (S001 case)
  • Issue #62: Fixed services being synchronized as physical products instead of services
  • CRITICAL: Fixed parameter handling inconsistency between search and sync interfaces
  • CRITICAL: Fixed service type detection - services now correctly set requiresShipping: false in Shopify
⚡ Improvements
  • ENHANCED: Unified parameter handling using GETPOST('search_ref', 'aZ09') to preserve leading zeros in SKUs
  • ENHANCED: Proper service vs product differentiation in Shopify sync (fk_product_type detection)
  • ENHANCED: CRON tasks disabled by default on installation to prevent premature API calls
  • ENHANCED: Configuration validation before CRON execution in both ImportProductsCron and ShopifyOrderSyncCron
  • SIMPLIFIED: Removed separate import_orders interface - functionality integrated into CRON system
  • MULTILINGUAL: Added translations for new features in 5 languages (FR/EN/DE/ES/IT)
🏗️ Technical Improvements
  • ARCHITECTURE: Integrated historical order import into existing CRON workflow
  • RELIABILITY: Added configuration completeness checks before CRON execution
  • USABILITY: Automatic CRON activation feedback messages to users
  • MAINTENANCE: Removed redundant import_orders.php interface file

🚨 Version 2.0.23 - Session 16 (2025-05-31) - CRITICAL VARIANTS PENDING STATUS FIX

🐛 Critical Fixes
  • CRITICAL: Fixed variants remaining in 'pending' status by implementing cascade status updates from parent products
  • CRITICAL: Added automatic variant status synchronization using fk_product_parent relationship
  • CRITICAL: When parent product status changes, all variants now automatically inherit the same status
  • CRITICAL: Resolved inconsistent variant behavior where variants stayed pending while parents succeeded
✨ Enhancements
  • IMPROVED: Variants now follow parent product status automatically (success, failed, skipped, pending)
  • IMPROVED: Added updateVariantsStatusFromParent() function for cascade status management
  • IMPROVED: TMS timestamp logic applied consistently to both parent and variant products
  • IMPROVED: Enhanced logging for variant cascade operations
🏗️ Technical Architecture
  • ARCHITECTURE: Leverages fk_product_parent relationship for automatic variant status management
  • ARCHITECTURE: Single parent status change triggers automatic update of all child variants
  • PERFORMANCE: Eliminates need to individually process each variant status
  • PERFORMANCE: Reduced database operations through cascade updates
🔄 Workflow
  • BEHAVIOR: Parent product sync success → All variants automatically marked as success
  • BEHAVIOR: Parent product sync failure → All variants automatically marked as failed
  • BEHAVIOR: Parent product skipped → All variants automatically marked as skipped
  • CONSISTENCY: Unified status management ensures parent and variants always have consistent states

🏗️ Version 2.0.23 - Session 15 (2025-05-31) - SYNCHRONIZATION TABLE MANAGEMENT UNIFICATION

🔧 Critical Refactoring
  • CRITICAL: Unified table management functions for llx_dolibarr_shopify_products_save table
  • CRITICAL: Created single manageProductMapping() function replacing three separate functions (releaseSyncLock, saveProductMapping, updateProductTimestamp)
  • CRITICAL: Fixed TMS timestamp logic - now only updates on 'success' status as requested
  • CRITICAL: Resolved inconsistent behavior between manual and automatic synchronization modes
✨ Enhancements
  • IMPROVED: Single consistent logic for all table operations eliminates behavioral differences
  • IMPROVED: Proper TMS initialization for new records - uses table default (CURRENT_TIMESTAMP) unless status is 'success'
  • IMPROVED: Enhanced error handling and logging in unified function
  • IMPROVED: Better code maintainability with reduced duplication and unified approach
🏗️ Technical Architecture
  • ARCHITECTURE: manageProductMapping() handles creation, updates, status management, and TMS logic
  • ARCHITECTURE: releaseSyncLock() now uses unified function with releaseLock=true parameter
  • ARCHITECTURE: saveProductMapping() now uses unified function with 'pending' status
  • ARCHITECTURE: updateProductTimestamp() now uses unified function with 'success' status
  • PERFORMANCE: Optimized database operations with smart UPDATE/INSERT logic
🐛 Fixes
  • CRITICAL: Fixed potential NULL TMS issues during record creation
  • CRITICAL: Eliminated inconsistent table management causing sync behavior differences
  • CRITICAL: Corrected TMS update logic to only trigger on successful synchronizations

🚨 Version 2.0.23 - Session 14 (2025-05-31) - SIMPLE PRODUCTS STATUS FIX

🐛 Critical fixes
  • CRITICAL: Fixed simple products remaining in 'pending' status after successful synchronization
  • CRITICAL: Corrected early exit logic in checkProductNeedsUpdate() to mark status as 'skipped' when products don't need updates but sync was successful
  • CRITICAL: Resolved issue where products like "PullColMontantTorsade202004" stayed in pending status indefinitely
🆕 New features
  • NEW: Added 'skipped' status to last_sync_status enum for products that don't need updates
  • NEW: Enhanced status distinction: 'success' (updated), 'skipped' (no update needed), 'failed' (error), 'pending' (in progress)
✨ Improvements
  • IMPROVED: Enhanced sync status management - products that don't need updates are now correctly marked as 'skipped' instead of preserving 'pending'
  • IMPROVED: Better distinction between products that failed sync vs products that were successfully processed but didn't need changes
  • IMPROVED: Database schema updated to support 'skipped' status in enum

🚨 Version 2.0.23 - Session 13 (2025-05-31) - CRITICAL FK_PRODUCT_PARENT FIX

🐛 Critical fixes
  • CRITICAL: Fixed fk_product_parent NULL issue during manual variant synchronization
  • CRITICAL: Corrected saveProductMapping() calls for variants to include parent product ID
  • CRITICAL: Resolved variants being created with fk_product_parent=NULL instead of correct parent ID
  • CRITICAL: Enhanced mapVariantsToShopify() method to properly handle parent-variant relationships
🔧 Technical improvements
  • NEW: Reorganized table columns for better readability and logical grouping
  • IMPROVED: Column organization in groups: Dolibarr, Shopify, Synchronization, Timestamps
  • IMPROVED: Unified migration script with automatic column reorganization

🏗️ Version 2.0.23 - Session 12 (2025-05-31) - ISSUE #56 PARENT-VARIANT ARCHITECTURE

🚀 New features
  • ISSUE #56: Added fk_product_parent column for better parent-variant relationships
  • NEW: Enhanced database schema with parent-variant relationship tracking
  • NEW: Foreign key constraints for data integrity between parent and variant products
  • NEW: Automatic data migration to populate existing parent-variant relationships
✨ Improvements
  • IMPROVED: saveProductMapping() method now supports fk_product_parent parameter for variants
  • IMPROVED: releaseSyncLock() method updated to work with new parent-variant architecture
  • IMPROVED: Database queries optimized to distinguish between parent products and variants
  • IMPROVED: SQL table creation script updated with new column and constraints
🔧 Technical
  • DATABASE: Added fk_product_parent column to llx_dolibarr_shopify_products_save table
  • DATABASE: Added idx_fk_product_parent index for performance optimization
  • DATABASE: Added fk_dolibarr_shopify_products_parent foreign key constraint
  • MIGRATION: Smart data population to identify and link existing variants to their parents
  • COMPATIBILITY: Full backward compatibility maintained with existing installations
🏛️ Architecture
  • DESIGN: Clear distinction between simple products (fk_product_parent IS NULL), parent products (fk_product_parent IS NULL), and variant products (fk_product_parent IS NOT NULL)
  • PERFORMANCE: Optimized WHERE clauses using fk_product_parent for targeted parent/variant operations
  • INTEGRITY: Cascade deletion ensures clean removal of variants when parent products are deleted

🚨 Version 2.0.23 - Session 11 (2025-05-30) - SYNC STATUS OVERWRITE FIX

🐛 Critical fixes
  • CRITICAL: Fixed sync status overwrite issue where 'success' was incorrectly replaced by 'skipped'
  • CRITICAL: Corrected releaseSyncLock() to preserve existing status when products don't need updates
  • Fixed database fields last_sync_status and last_sync_error not being maintained correctly
  • Enhanced releaseSyncLock() method to conditionally update status instead of systematic overwrite
✨ Enhancements
  • NEW: Intelligent status preservation in releaseSyncLock() - only updates when explicitly needed
  • NEW: Enhanced logging to trace status preservation vs updates
  • Better database field consistency for synchronization tracking
  • Improved cron execution status management

🚨 Version 2.0.23 - Session 10 (2025-05-30) - FINDPRODUCTBYSKU REGRESSION FIX

🐛 Critical regression fixes
  • CRITICAL REGRESSION: Fixed findProductBySku() not finding existing products due to GraphQL syntax changes
  • ROOT CAUSE: Added quotes in GraphQL queries broke Shopify search API (sku:"DEVIDOIR_6" vs sku:DEVIDOIR_6)
  • SOLUTION: Reverted to simple GraphQL syntax from v2.0.21 that was proven to work
  • ARCHITECTURAL FIX: Shopify parent products don't have SKU - only variants do, corrected search logic accordingly
  • Fixed parent product search strategy to prioritize variant-based lookup over unreliable title search
  • Enhanced parent/variant detection logic with isProductVariant() method
✨ Enhancements
  • NEW: Intelligent parent vs variant search strategies (P1-P4 for parents, V1-V3 for variants)
  • NEW: Enhanced variant-based parent product discovery with multiple SKU patterns
  • NEW: Comprehensive diagnostic search for troubleshooting missing products
  • NEW: Smart product type detection to avoid searching parents by SKU (which don't exist in Shopify)
  • Better error reporting and detailed logging for search strategy debugging
  • Restored reliable product discovery that worked in v2.0.21

🚨 Version 2.0.23 - Session 9 (2025-05-30) - VARIANT STATUS FIXES

🐛 Critical fixes
  • CRITICAL: Added missing releaseSyncLock() calls for variants to prevent permanent pending status
  • CRITICAL: Fixed variant sync status management with proper success/failed handling
  • Fixed statistics interface not counting variant sync results correctly
  • Enhanced error handling in variant mapping with detailed logging
✨ Enhancements
  • NEW: Complete sync status lifecycle for both parent products and variants
  • NEW: Robust variant mapping with success/failure status tracking
  • Better error reporting for variant synchronization issues
  • Improved logging for variant sync status workflow

🚨 Version 2.0.23 - Session 8 (2025-05-30) - TEMP_LOCK SKU SEARCH RESTORATION

🐛 Critical fixes
  • CRITICAL: Restored SKU search logic for products with TEMP_LOCK IDs to prevent duplicate creation
  • CRITICAL: Updated SQL creation schema with missing v2.0.23 columns and constraints
  • Fixed product detection logic to systematically search by SKU when no valid mapping exists
  • Enhanced findProductBySku() calls even with temporary lock records
✨ Enhancements
  • NEW: Comprehensive product existence detection combining mapping and SKU search
  • NEW: Updated table creation script with entity, sync_lock, last_sync_status columns
  • Better duplicate prevention through systematic SKU verification
  • Improved logging for product detection workflow

🔄 Version 2.0.23 - Session 7 (2025-05-30) - RETRY AND STATISTICS FIXES

🐛 Critical fixes
  • CRITICAL: Fixed TEMP_LOCK IDs incorrectly treated as Shopify updates causing retry failures
  • CRITICAL: Harmonized sync status between 'failed' and 'error' for consistent statistics display
  • Fixed statistics interface not counting sync failures due to status inconsistency
  • Improved product mapping logic to filter temporary lock IDs
✨ Enhancements
  • NEW: Intelligent filtering of temporary lock IDs to avoid invalid Shopify API calls
  • NEW: Harmonized sync status terminology throughout codebase and interface
  • Improved error reporting accuracy in admin dashboard
  • Better distinction between new products and actual updates

🚨 Version 2.0.23 - Session 6 (2025-05-30) - SYNC FIXES

🐛 Critical fixes
  • CRITICAL: Fixed sync lock mechanism to prevent database NOT NULL constraint violations
  • CRITICAL: Fixed concurrent synchronization protection with temporary lock IDs
  • CRITICAL: Fixed imprecise UPDATE query affecting multiple variant records
  • Fixed synchronization failure for new products due to empty Shopify IDs in lock creation
  • Enhanced updateProductTimestamp() precision by adding shopifyVariantId to WHERE clause
✨ Enhancements
  • NEW: Intelligent temporary lock system using unique TEMP_LOCK_[timestamp]_[productId] format
  • NEW: Improved concurrent sync protection for both manual and cron synchronization
  • NEW: Enhanced variant mapping precision to prevent cross-contamination between variants
  • Better error handling and logging for sync lock operations
  • Comprehensive analysis and fix of product-variant relationship handling

🚨 Version 2.0.23 - Session 5 (2025-05-30) - CRITICAL FIXES

🐛 Critical fixes
  • CRITICAL: Fixed manual synchronization not working - missing isManualSync=true parameter
  • CRITICAL: Fixed setSyncLock() creating empty string IDs instead of NULL values in database
  • Bug: Fixed "No products to synchronize" message blocking manual synchronization
  • Bug: Removed database pollution with invalid Shopify IDs
⚡ New features
  • NEW: Sync failure tracking with last_sync_status and last_sync_error fields
  • NEW: Failure statistics display in admin interface with visual alerts
  • NEW: Enhanced sync lock management with status tracking ('success', 'error', 'skipped', 'pending')
  • Enhancement: Database schema with automatic cleanup of invalid records
  • Enhancement: Comprehensive error messaging for failed synchronizations

🔧 Version 2.0.23 - Session 4 (2025-05-30) - CODE OPTIMIZATION

⚡ Major Improvements
  • Code factorization: Created getProductVariants() method to eliminate code duplication between importProducts() and importProductsManual()
  • Transaction handling: Added complete transactional management with begin...commit/rollback in importProductsManual()
  • Maintainability: Unified variant processing logic between automatic and manual synchronization
  • Improved logs: Added detailed logs for transaction tracking and error monitoring
🔧 Critical Fixes
  • Undefined variable: Fixed critical bug where $product was undefined in importProductsManual()
  • Synchronization counter: Fixed missing logic for incrementing $numSynced
  • Error handling: Improved error handling with automatic rollback
Technical Impact: This update significantly improves robustness and maintainability of synchronization code, with a reduction of more than 30 lines of duplicated code.

✅ Version 2.0.23 - Session 3 (2025-05-27) - FINALIZATION

🔧 Final Fixes
  • Numeric SKUs: Fixed search for purely numeric SKUs (e.g., 00667) in manual interface (Issue #51)
  • Unwanted synchronization: Fixed synchronization of products without tags/categories (Issue #52)
  • Fixed GETPOST('term', 'alphanohtml') corrupting numeric SKUs in ajax/search_products.php
  • Added specialized search logic for numeric SKUs with multiple approaches
  • Implemented mandatory category filtering in synchronization
🆕 Major New Feature
  • Category preview interface: Complete preview before manual synchronization (Issue #50)
  • Complete category analysis system and synchronization preview
  • Enhanced interface with category details, progress bars and summary statistics
  • Real-time analysis via AJAX endpoint ajax/preview_sync.php
  • Full support for French translations for preview functionality

Version 2.0.23 - May 2025

🔧 Refactoring
  • Code cleanup: Removed obsolete synchronization methods after unification
  • Removed deprecated synchronizeProductsToShopify() method (239 lines)
  • Removed unused syncProductWithVariants() and syncProductAsVariant() methods
  • Removed redundant getShopifyProductId() helper method
  • Streamlined codebase by eliminating duplicate synchronization logic
  • Unified all synchronization to use proven importProductsManual() method
🐛 Corrections critiques
  • CRITIQUE: Correction de la duplication infinie des produits et variants lors de la synchronisation (Issue #42)
  • Correction du double nettoyage des IDs dans la méthode updateProductTimestamp() causant l'échec de recherche dans la table de mapping
  • Suppression des transactions imbriquées dans updateProductTimestamp() empêchant la mise à jour correcte des enregistrements
  • Correction de la cohérence du format des IDs entre les IDs Shopify et le stockage en base de données
  • Amélioration des logs de débogage pour les opérations de mapping et mise à jour des timestamps
  • Résolution de la régression introduite dans la v2.0.22 lors du merge des commits v2.0.21
💡 Améliorations techniques
  • Refactorisation de updateProductTimestamp() pour utiliser la transaction parent au lieu de transactions imbriquées
  • Standardisation de la gestion du format des IDs Shopify dans toutes les méthodes de synchronisation
  • Ajout de logs détaillés pour déboguer les échecs de recherche dans la table de mapping
  • Amélioration de la gestion d'erreur pour la création de mapping quand les enregistrements sont manquants

Version 2.0.22 - Mai 2025

✨ Nouvelles fonctionnalités
  • Interface de synchronisation manuelle des produits dans l'administration (Issue #40)
  • Recherche en temps réel de produits Dolibarr avec autocomplétion
  • Synchronisation individuelle ou par lot directement depuis l'interface
  • Feedback visuel immédiat du statut de synchronisation
  • Support multilingue complet (FR, EN, DE, ES, IT)
🐛 Corrections de bugs
  • CRITIQUE: Correction des erreurs d'arrondi des prix (.95€ devenant .96€) affectant 13 références produits (Issue #38)
  • Les prix privilégient maintenant les prix TTC stockés au lieu de recalculer HT + TVA
  • CRITIQUE: Correction de la duplication des produits lors des synchronisations (Issue #37)
  • Mécanisme de verrou temporel (5 minutes) pour empêcher les synchronisations concurrentes
  • Protection par session pour éviter les doublons dans une même requête
  • Libération automatique des verrous même en cas d'erreur
💡 Améliorations techniques
  • Standardisation des en-têtes PHP et déclarations de licence dans tout le projet
  • Amélioration de la détection des modes d'exécution (CLI/web) pour les crons
  • Nouvelle option de configuration pour la priorité des prix TTC en mode multi-prix
  • Amélioration des logs de calcul de prix pour un meilleur débogage
  • Optimisation de l'organisation des requêtes SQL
  • Guide de configuration: Amélioration de la hiérarchie visuelle des options du chapitre 6
  • Sections hiérarchiques avec icônes : Configuration Prix, Contenu, Stocks
  • Indentation visuelle pour les options dépendantes avec indicateurs conditionnels
  • Interface plus claire avec en-têtes colorés et mise en page structurée
  • Filtrage des catégories: Correction pour utiliser uniquement la catégorie configurée et ses enfants
  • Récupération corrigée de la configuration des catégories depuis la base de données
  • Calcul amélioré des statistiques produits pour les catégories configurées uniquement
  • Interface de synchronisation manuelle avec structure hiérarchique des catégories basée sur la configuration
  • Mode debug: Ajout mode debug complet (?debug=1) pour diagnostiquer les problèmes de filtrage
  • Correction SQL critique: Correction des références de colonnes dans l'interface de synchronisation manuelle
  • - Changement de `p.fk_product_parent` vers `p.fk_parent` pour le filtrage des produits parents
  • - Changement de `dsp.dolibarr_product_id` vers `dsp.fk_product` pour les jointures de la table de synchronisation
  • Amélioration variants: Ajout support des produits parents de variants dans l'interface de synchronisation
  • - Inclusion des produits sans variants (fk_parent IS NULL OR fk_parent = 0)
  • - Inclusion des produits parents de variants (sous-requête EXISTS p2.fk_parent = p.rowid)
  • Simplification des requêtes SQL pour de meilleures performances et fiabilité
  • Validation du schéma de base de données et logs détaillés des requêtes SQL pour le dépannage
  • Correction des statistiques retournant 0 produit par correction des requêtes complexes

Version 2.0.21 - Mai 2025

🐛 Corrections de bugs
  • Correction de la logique de synchronisation des images qui se lançait même quand désactivée
  • Correction de la logique empty() vs isset() pour le paramètre sync_product_images
  • Suppression des vérifications redondantes de configuration dans syncProductAllImages()
  • La synchronisation d'images respecte maintenant correctement le paramètre "sync_product_images" (0=désactivé, 1=activé)
💡 Améliorations techniques
  • Simplification de la logique de synchronisation d'images en supprimant les vérifications de configuration dupliquées
  • Amélioration de la validation des paramètres pour la configuration de synchronisation d'images
  • Amélioration de la maintenabilité du code en centralisant les vérifications de synchronisation

Version 2.0.20 - Mai 2025

🐛 Corrections de bugs
  • Correction du problème de stocks négatifs lors de la synchronisation avec Shopify
  • Amélioration de la gestion des caractères spéciaux dans les noms de fichiers d'images
  • Correction de la recherche de produits dans la fonction de purge pour les produits dans les catégories et sous-catégories
  • Ajout du dossier ajax dans la configuration de construction du module
  • Correction des erreurs PHP fatales dans le script de recherche AJAX
  • Correction de la vérification du token CSRF dans search_products.php
  • Implémentation correcte du système de logs dans les endpoints AJAX
  • Amélioration de la gestion et des logs des stocks dans importproducts.class.php
  • Correction du problème de synchronisation des stocks quand la propriété stock est vide
💡 Améliorations techniques
  • Ajout d'un mécanisme de fallback pour les erreurs 404 avec encodage alternatif
  • Amélioration des logs pour faciliter le débogage des problèmes d'images
  • Restructuration de la recherche AJAX de produits en classe OOP avec LoggerTrait
  • Amélioration de l'interface utilisateur pour la recherche avec indicateur de chargement et messages d'erreur
  • Meilleure gestion des erreurs dans la recherche de produits
  • Ajout d'un mécanisme de fallback pour la récupération des sous-catégories (get_all_ways/get_all_childs)
  • Standardisation des logs dans l'ensemble du module avec LoggerTrait
  • Ajout du chargement préventif du stock avant calcul dans la mise à jour des inventaires de variantes
  • Amélioration des logs de stock avec une différenciation claire entre les types de stock

Version 2.0.19 - Mai 2025

🐛 Corrections de bugs
  • Correction complète pour sauvegarder le champ "dolibarr_hosturl" dans les paramètres du module
  • Résolution des erreurs SQL dans la gestion de la correspondance des méthodes d'expédition
💡 Améliorations techniques
  • Mise en place d'un système LoggerTrait centralisé pour tous les messages de log du module
  • Amélioration du format des logs avec ajout automatique du nom de la classe et de la méthode
  • Amélioration du debugging de configuration avec masquage sécurisé des tokens

Version 2.0.18 - Mai 2025

🐛 Corrections de bugs
  • Corrigé l'erreur "Unable to parse URI: https:///" dans le contexte des crons
  • Amélioration du chargement de configuration dans les contextes cron
  • Gestion robuste de l'entity avec fallback automatique à l'entity 1
💡 Améliorations techniques
  • Centralisation de la gestion de configuration dans ShopifyApi
  • Amélioration du logging pour le débogage des contextes cron
  • Refactorisation de toutes les classes pour utiliser la configuration centralisée
  • Les crons passent maintenant explicitement l'entity aux classes métier

Version 2.0.17 - Mai 2025

✨ Nouvelles fonctionnalités
  • Options de synchronisation des produits configurables dans l'interface d'administration
  • Support complet des niveaux de prix multiples de Dolibarr avec sélection configurable
  • Déplacement de l'option stock virtuel vers l'onglet produits pour une meilleure organisation
  • Activation/désactivation automatique des options dépendantes dans l'interface
  • Nouveau système de purge de la table de synchronisation avec réinitialisation auto_increment
🐛 Corrections de bugs
  • Correction de la synchronisation des variantes de produits (utilisation correcte de Product::id)
  • Résolution des problèmes de synchronisation lorsque le prix est zéro ou null
  • Amélioration de la gestion des erreurs pour le téléchargement d'images
  • Résolution des problèmes de validation des variantes avec métachamps Shopify
  • Support amélioré des métachamps spécifiques comme 'shopify.color-pattern'
💡 Améliorations
  • Interface utilisateur plus intuitive avec options contextuelles
  • Journalisation détaillée des niveaux de prix multiples
  • Système de validation extensible pour les options et métachamps
  • Guide de configuration mis à jour avec toutes les nouvelles fonctionnalités

Version 2.0.16 - Novembre 2024

✨ Nouvelles fonctionnalités
  • Support du stock virtuel pour la synchronisation des stocks
  • Intégration des pourboires Shopify dans les commandes
  • Amélioration de la gestion des remises sur les commandes
🐛 Corrections de bugs
  • Correction du calcul des prix TTC à partir des prix HT
  • Amélioration de la gestion des erreurs SQL
  • Résolution des problèmes de synchronisation multi-entités

Version 2.0.15 - Octobre 2024

✨ Nouvelles fonctionnalités
  • Gestion des variantes marquées "Hors ventes"
  • Import sélectif par référence de produit
  • Option pour garder les titres et descriptions existants
🐛 Corrections de bugs
  • Correction de la gestion des erreurs de connexion API
  • Amélioration de la stabilité du cron
Return to main page