1. Go to this page and download the library: Download mannu24/gmc-integration library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Sync a single product manually
$product->syncwithgmc();
// Or use the alternative method
$product->syncToGMC();
// Enable sync for a product
$product->enableGMCSync();
// Disable sync for a product
$product->disableGMCSync();
// Check if sync is enabled
if ($product->shouldSyncToGMC()) {
echo "Sync is enabled for this product";
}
public function shouldSyncToGMC(): bool
{
// Only sync premium products
return $this->is_premium && $this->status === 'active';
}
// Single product
$product->syncwithgmc();
// Bulk sync with progress tracking
$gmcService = app(GMCService::class);
$result = $gmcService->syncMultipleProducts($products, 25); // 25 per batch
// This will automatically sync to GMC when status changes to inactive
$product->update(['status' => 'inactive']);
// This will NOT automatically sync (status is not 'inactive')
$product->update(['status' => 'active']);
// This will NOT automatically sync (no status change)
$product->update(['price' => 29.99]);
// Get sync status
$status = $product->getGMCSyncStatus();
// Returns: ['is_synced' => true, 'gmc_id' => '123', 'last_sync' => '2024-01-01T00:00:00Z', 'sync_enabled' => true, 'sync_status' => 'synced', 'last_error' => null]
// Check if synced
if ($product->isSyncedWithGMC()) {
echo "Product is synced with GMC";
}
// Get sync logs
$logs = $product->getGMCSyncLogs();
// Get last successful sync
$lastSync = $product->getLastSuccessfulGMCSync();
// Get last error
$lastError = $product->getLastGMCError();
$gmcService = app(GMCService::class);
$gmcService->setBatchSize(25); // Process 25 products at a time
$result = $gmcService->syncMultipleProducts($products);