Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Google Shopping Connector Bundle Laravel Package

agencednd/google-shopping-connector-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup Steps

  1. 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"
    
  2. 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
    
  3. First Use Case: Export Products

    • Navigate to Spread > Export Profiles in Akeneo.
    • Create a new export profile of type GoogleShoppingConnectorBundle.
    • Map Akeneo attributes to Google Shopping’s required fields (e.g., title, description, price, image_link, availability, gtin, mpn).
    • Test the export by generating an XML file.

Implementation Patterns

Workflow for Daily Use

  1. Attribute Mapping

    • Use the Export Profile to map Akeneo attributes to Google Shopping’s mandatory fields:
      • 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.
    • Leave unmapped fields empty if unused (Google Shopping ignores them).
  2. Taxonomy Import

    • Download Google’s product taxonomy (XLSX format).
    • Create an Import Profile in Collect > Import Profiles to load Google’s category IDs into Akeneo.
    • Assign Google category IDs to Akeneo categories for proper product classification.
  3. Scheduled Exports

    • Use Akeneo’s Job Queue to schedule exports (e.g., nightly updates).
    • Example cron job (via Akeneo’s CLI):
      php bin/console akeneo:job-instance:execute --job-code=export_google_shopping
      
  4. Validation & Debugging

Integration Tips

  • Channel-Specific Exports: Create a dedicated Google Shopping channel in Akeneo to isolate product data.
  • Dynamic Attributes: Use Akeneo’s family variants to handle product conditions (e.g., new/used) dynamically.
  • Image Optimization: Ensure images are resized to Google’s recommendations (e.g., 800x800px) before export.
  • API Sync: Automate XML uploads to Google Merchant Center via a Laravel task:
    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'),
    ]);
    

Gotchas and Tips

Common Pitfalls

  1. Missing Symlink

    • Error: Image links in XML are broken (e.g., http://example.com/file_storage/...).
    • Fix: Verify the symlink exists (web/file_storage → app/file_storage).
  2. Unmapped Mandatory Fields

    • Error: Google Shopping rejects the feed with errors like "Missing required field: 'gtin'".
    • Fix: Ensure all required fields are mapped in the export profile.
  3. Incorrect Taxonomy IDs

    • Error: Products are categorized under the wrong Google Shopping category.
    • Fix: Double-check imported taxonomy IDs and Akeneo category assignments.
  4. Character Encoding Issues

    • Error: XML contains invalid characters (e.g., &, <, >) or UTF-8 encoding errors.
    • Fix: Sanitize product data in Akeneo (e.g., use htmlspecialchars) or configure Akeneo’s export to use UTF-8.
  5. Large File Sizes

    • Error: XML files exceed Google’s size limits (e.g., >50MB).
    • Fix: Split exports by category or use Akeneo’s chunked exports.

Debugging Tips

  • 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.

Extension Points

  1. 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']
    
  2. 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
        }
    }
    
  3. 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';
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui