agencednd/google-shopping-connector-bundle
Installation
composer require agence-dnd/google-shopping-connector-bundle:1.3.*
Enable the bundle in app/AppKernel.php:
$bundles[] = new Dnd\Bundle\GoogleShoppingConnectorBundle\DndGoogleShoppingConnectorBundle();
Add routing in app/config/routing.yml:
dnd_google_shopping_connector:
prefix: /google-shopping-connector
resource: "@DndGoogleShoppingConnectorBundle/Resources/config/routing.yml"
Symlink for Images
Create a symlink from app/file_storage to web/file_storage:
ln -s /path/to/pim/app/file_storage /path/to/pim/web/file_storage
First Use Case: Export Products
GoogleShoppingConnectorBundle.title, description, price, image_link, availability, gtin, mpn).Attribute Mapping
title → Akeneo’s name or meta_title.description → Akeneo’s description or long_description.link → Product URL (e.g., reference + domain).image_link → Image path (symlinked to web/file_storage).availability → Stock status (e.g., in_stock, out_of_stock).condition → Product condition (e.g., new, used).gtin/mpn → Akeneo’s ean or custom attributes.Taxonomy Import
Scheduled Exports
php bin/console akeneo:job-instance:execute --job-code=export_google_shopping
Validation & Debugging
var/logs) for mapping errors or missing attributes.new/used) dynamically.use GuzzleHttp\Client;
$client = new Client();
$response = $client->post('https://merchantcenter.googleapis.com/content/v2/{merchantId}/products:upload', [
'headers' => ['Authorization' => 'Bearer YOUR_ACCESS_TOKEN'],
'body' => fopen('path/to/export.xml', 'r'),
]);
Missing Symlink
http://example.com/file_storage/...).web/file_storage → app/file_storage).Unmapped Mandatory Fields
"Missing required field: 'gtin'".Incorrect Taxonomy IDs
Character Encoding Issues
&, <, >) or UTF-8 encoding errors.htmlspecialchars) or configure Akeneo’s export to use UTF-8.Large File Sizes
Log Export Details: Enable debug mode in app/config/config.yml:
framework:
profiler: { only_exceptions: false }
Check var/logs/dev.log for mapping errors.
Test with a Subset: Export a single product or category first to validate mappings:
php bin/console akeneo:export:execute --export-code=google_shopping_test --limit=1
Google Merchant Center Diagnostics: Use the Diagnostics Tool to identify feed issues.
Custom Field Mappings
Override the bundle’s mapping logic by extending the DndGoogleShoppingConnectorBundle\Manager\ExportManager:
namespace AppBundle\Manager;
use Dnd\Bundle\GoogleShoppingConnectorBundle\Manager\ExportManager as BaseExportManager;
class CustomExportManager extends BaseExportManager {
public function getMappedValue($attributeCode, $value) {
// Custom logic for specific attributes
if ($attributeCode === 'gtin') {
return strtoupper($value); // Ensure GTIN is uppercase
}
return parent::getMappedValue($attributeCode, $value);
}
}
Register the service in services.yml:
services:
app.google_shopping.export_manager:
class: AppBundle\Manager\CustomExportManager
tags: ['akeneo_export_manager']
Post-Export Processing Trigger a Laravel event after export to process the XML (e.g., upload to S3):
// In a custom event listener
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Dnd\Bundle\GoogleShoppingConnectorBundle\Event\ExportEvent;
class GoogleShoppingExportSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return ['google_shopping.export.post' => 'onExport'];
}
public function onExport(ExportEvent $event) {
$xmlPath = $event->getXmlPath();
// Upload to S3 or trigger API sync
}
}
Dynamic Attribute Values
Use Akeneo’s Attribute Calculators to generate Google-specific values (e.g., availability based on stock):
// Example: Calculate availability from stock
$stock = $product->getStock();
$availability = $stock->getQuantity() > 0 ? 'in_stock' : 'out_of_stock';
How can I help you explore Laravel packages today?