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 Manufacturer Bundle Laravel Package

agencednd/google-manufacturer-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation:

    composer require agencednd/google-manufacturer-bundle
    
    • For Akeneo 3.x, enable the bundle in AppKernel.php.
    • For Akeneo 4.x, register it in config/bundles.php:
      Dnd\GoogleManufacturerBundle\DndGoogleManufacturerBundle::class => ['all' => true],
      
    • Add routes in config/routes/routes.yml:
      dnd_google_manufacturer:
          resource: "@DndGoogleManufacturerBundle/Resources/config/routing.yml"
      
  2. Configure Media Handling: Update liip_imagine.yml to ensure images are processed correctly:

    liip_imagine:
        filter_sets:
            thumbnail_full:
                quality: 100
                format: jpeg
                filters:
                    relative_resize: { scale: 1.0 }
    
  3. Clear Cache & Rebuild Assets:

    php bin/console cache:clear --env=prod
    php bin/console pim:installer:assets --env=prod
    yarn run webpack
    
  4. First Export Profile:

    • Navigate to ExportCreate Export Profile.
    • Select "Google Manufacturer - XML Products Export" as the export type.
    • Map mandatory attributes (e.g., gtin, title, brand, description, image_link) to your Akeneo PIM attributes.
    • Save and run the export to generate the XML file.

Implementation Patterns

Workflows

  1. Attribute Mapping:

    • Use the UI to map mandatory (e.g., gtin, brand) and optional (e.g., color, size) Google Manufacturer attributes to Akeneo PIM attributes.
    • Example: Map brand (Google Manufacturer) → manufacturer (Akeneo PIM attribute).
  2. Product Details & Feature Descriptions:

    • Configure grouped attributes for structured data like:
      <g:product_detail>
          <g:section_name>Specifications</g:section_name>
          <g:attribute_name>Weight</g:attribute_name>
          <g:attribute_value>500g</g:attribute_value>
      </g:product_detail>
      
    • Use Feature Description nodes for rich content (e.g., headlines, text, images):
      <g:feature_description>
          <g:headline>Wireless Connectivity</g:headline>
          <g:text>Supports Bluetooth 5.0</g:text>
      </g:feature_description>
      
  3. Validation Levels:

    • Set acceptance level (low, medium, high) in the export profile to control validation strictness.
    • Example: Use high for production to enforce Google’s requirements (e.g., GTIN format, description length).
  4. Automated Exports:

    • Trigger exports via CLI for scheduled jobs:
      bin/console akeneo:batch:job google_manufacturer_profile_code
      
    • Integrate with cron jobs for daily/weekly exports.
  5. Image Handling:

    • Images are copied to web/media during export. Ensure your Akeneo PIM media storage is configured to allow writes to this directory.

Integration Tips

  1. Akeneo PIM Events:

    • Listen to pim_enrich.product_variant_update or pim_catalog.product_save to auto-trigger exports when products are updated:
      // In a custom bundle's EventSubscriber
      public function onProductUpdate(ProductUpdateEvent $event)
      {
          $this->exportManager->runExport('google_manufacturer_profile_code');
      }
      
  2. Custom Validation:

    • Extend the bundle’s validation logic by overriding the Dnd\GoogleManufacturerBundle\Validator\GoogleManufacturerValidator service:
      # config/services.yaml
      Dnd\GoogleManufacturerBundle\Validator\GoogleManufacturerValidator:
          arguments:
              - '@validator'
              - '@your_custom_validator'
      
  3. Dynamic Attribute Mapping:

    • Use Akeneo PIM’s attribute options to dynamically map attributes based on product type (e.g., map size to shoe_size for footwear).
  4. Testing:

    • Validate XML output against Google’s schema using:
      xmllint --schema google-manufacturer.xsd output.xml --noout
      

Gotchas and Tips

Pitfalls

  1. Image Paths:

    • Hardcoded paths in the bundle assume images are in web/media. If using a CDN or custom storage, override the Dnd\GoogleManufacturerBundle\Renderer\ImageRenderer service to adjust paths:
      // config/services.yaml
      Dnd\GoogleManufacturerBundle\Renderer\ImageRenderer:
          arguments:
              - '@your_custom_image_service'
      
  2. GTIN Validation:

    • Google requires valid GTINs (12/13/14 digits). The high acceptance level enforces this, but custom GTINs (e.g., 8 digits) may fail. Use a custom validator to handle exceptions:
      use Dnd\GoogleManufacturerBundle\Validator\Constraints as GoogleAssert;
      
      /**
       * @GoogleAssert\ValidGtin(groups={"google_manufacturer"})
       */
      
  3. Locale-Specific Attributes:

    • Google Manufacturer expects locale-specific values (e.g., title in the target language). Ensure your Akeneo PIM locale settings match the export profile’s locale.
  4. Media Permissions:

    • If images fail to copy, check web/media directory permissions (chmod -R 775 web/media).
  5. Circular Dependencies:

    • Avoid circular references in Product Detail or Feature Description nodes (e.g., referencing a product in its own description).

Debugging

  1. XML Validation Errors:

    • Enable debug mode (APP_DEBUG=true) and check the export log:
      bin/console debug:config dnd_google_manufacturer
      
    • Use bin/console akeneo:batch:job --log to see detailed job execution.
  2. Missing Attributes:

    • If mandatory attributes are missing, the export fails silently. Enable high acceptance level to surface errors:
      # config/packages/dnd_google_manufacturer.yaml
      dnd_google_manufacturer:
          acceptance_level: high
      
  3. Performance Issues:

    • Large catalogs may time out. Optimize by:
      • Limiting export scope (e.g., filter by category).
      • Increasing PHP memory (php.ini):
        memory_limit = 2G
        

Extension Points

  1. Custom Renderers:

    • Extend Dnd\GoogleManufacturerBundle\Renderer\AbstractRenderer to add custom XML nodes (e.g., for warranty info):
      namespace App\GoogleManufacturer\Renderer;
      
      use Dnd\GoogleManufacturerBundle\Renderer\AbstractRenderer;
      
      class WarrantyRenderer extends AbstractRenderer
      {
          public function render(): string
          {
              return sprintf('<g:warranty>%s</g:warranty>', $this->getProduct()->getWarranty());
          }
      }
      
    • Register the renderer in config/services.yaml:
      Dnd\GoogleManufacturerBundle\Renderer\RendererCollection:
          arguments:
              - ['@app.google_manufacturer.warranty_renderer']
      
  2. Pre/Post-Export Hooks:

    • Use Akeneo’s job instance listeners to modify data before export:
      namespace App\EventListener;
      
      use Dnd\GoogleManufacturerBundle\Event\PreExportEvent;
      
      class GoogleManufacturerListener
      {
          public function onPreExport(PreExportEvent $event)
          {
              $event->getProducts()->each(function ($product) {
                  $product->setDescription($this->formatDescription($product->getDescription()));
              });
          }
      }
      
    • Bind the listener in config/services.yaml:
      App\EventListener\GoogleManufacturerListener:
          tags:
              - { name: 'kernel.event_listener', event: 'dnd_google_manufacturer.pre_export' }
      
  3. Custom Validation Rules:

    • Add rules to Dnd\GoogleManufacturerBundle\Validator\Constraints\ValidGtin:
      namespace App\Validator\Constraints;
      
      use Symfony\Component\Validator\Constraint;
      
      class ValidCustomGtin extends Constraint
      {
          public $message = 'The GTIN {{ value }} is not valid for your region.';
      }
      
    • Use it in your entity:
      use App\Validator\Constraints as AppAssert;
      
      /**
       * @AppAssert\ValidCustomGtin
       */
      private $gtin;
      

4

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.
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
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver