mannu24/gmc-integration
Composer 安装命令:
composer require mannu24/gmc-integration
包简介
A comprehensive Laravel package for Google Merchant Center integration with product synchronization, batch processing, and automatic sync management.
关键字:
README 文档
README
A Laravel package for seamless Google Merchant Center product synchronization with independent tables and optional per-product sync control.
Installation
composer require manu/gmc-integration
Setup
- Publish config:
php artisan vendor:publish --tag=gmc-config
- Publish migrations:
php artisan vendor:publish --tag=gmc-migrations
- Run migrations:
php artisan migrate
- Set environment variables:
GMC_MERCHANT_ID=your_merchant_id GMC_SERVICE_ACCOUNT_JSON=/path/to/service-account.json GMC_AUTO_SYNC=true GMC_THROW_EXCEPTIONS=false GMC_BATCH_SIZE=50 GMC_RETRY_ATTEMPTS=3
- Add trait to your product model:
use Manu\GMCIntegration\Traits\SyncsWithGMC; class Product extends Model { use SyncsWithGMC; protected $fillable = [ 'title', 'description', 'price', 'quantity', 'image_url', 'brand', 'sku', 'status' ]; public function prepareGMCData(): array { return [ 'offerId' => $this->sku ?: (string) $this->id, 'title' => $this->title, 'description' => $this->description, 'link' => url("/products/{$this->id}"), 'imageLink' => $this->image_url, 'price' => ['value' => (string) $this->price, 'currency' => 'USD'], 'availability' => $this->quantity > 0 ? 'in stock' : 'out of stock', 'brand' => $this->brand, 'condition' => 'new' ]; } }
Database Structure
gmc_products Table
product_id- Reference to your productproduct_type- Model class namesync_enabled- Control sync per productgmc_product_id- GMC's product IDgmc_last_sync- Last sync timestampsync_status- Current sync statuslast_error- Last error message
gmc_sync_logs Table
- Tracks all sync attempts
- Stores request/response data
- Performance metrics
- Error details
Features
- Independent tables - No modifications to existing tables
- Clean model - All GMC methods in trait
- Optional per-product sync control
- Manual and automatic syncing
- Bulk operations with batch processing
- Error handling with retry logic
- Data validation before syncing
- Rate limiting to avoid API limits
- Cache protection against duplicate syncs
- Async processing for better performance
- Sync history tracking
Usage Examples
Manual Syncing
$product->syncwithgmc(); $product->syncToGMC(); $product->forceSyncToGMC();
Bulk Operations
$gmcService = app(GMCService::class); $result = $gmcService->syncMultipleProducts($products, 25);
Sync Status
$status = $product->getGMCSyncStatus(); if ($product->isSyncedWithGMC()) { echo "Product is synced with GMC"; }
Artisan Commands
php artisan gmc:sync-all
php artisan gmc:sync-all --filter="status=active"
php artisan gmc:sync-all --dry-run
php artisan gmc:sync-all --force
php artisan gmc:sync-all --chunk=25
Configuration
GMC_MERCHANT_ID=your_merchant_id GMC_SERVICE_ACCOUNT_JSON=/path/to/service-account.json GMC_AUTO_SYNC=true GMC_BATCH_SIZE=50 GMC_RETRY_ATTEMPTS=3 GMC_RETRY_DELAY=1000 GMC_CACHE_DUPLICATE_SYNCS=true GMC_CACHE_DURATION=300 GMC_LOG_SYNC_EVENTS=true GMC_LOG_LEVEL=info
Advanced Features
Batch Processing
$gmcService = app(GMCService::class); $gmcService->setBatchSize(25); $result = $gmcService->syncMultipleProducts($products);
Error Handling
try { $product->syncwithgmc(); } catch (\Exception $e) { Log::error('GMC Sync failed: ' . $e->getMessage()); }
Sync History
use Manu\GMCIntegration\Models\GMCSyncLog; $logs = GMCSyncLog::with('gmcProduct')->latest()->get(); $failedLogs = GMCSyncLog::where('status', 'failed')->get(); $avgResponseTime = GMCSyncLog::where('status', 'success')->avg('response_time_ms');
Performance Optimizations
- Batch processing for large datasets
- Rate limiting to avoid API throttling
- Cache protection against duplicate syncs
- Async processing for better response times
- Retry logic for failed operations
- Memory efficient chunking
- Independent tables for better performance
mannu24/gmc-integration 适用场景与选型建议
mannu24/gmc-integration 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ecommerce」 「laravel」 「laravel-package」 「google-shopping」 「google-merchant-center」 「gmc」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mannu24/gmc-integration 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mannu24/gmc-integration 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mannu24/gmc-integration 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Nevogate Payment Gateway SDK
A Laravel package for converting English numbers into Bangla digits, Bangla words, Bangla month names, and Bangla money format with an easy-to-use API.
Laravel table comments loader (part of Diplodocker project)
Dealing with payments through the Egyptian payment gateway PayMob
jitone-ai is a powerful FilamentPHP plugin that integrates AI-powered features directly into your Filament forms.
Laravel JWT auth service package
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-19