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

Tradedoubler Bundle Laravel Package

astina/tradedoubler-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install via Composer:

    composer require astina/tradedoubler-bundle:dev-master
    

    (Note: Use dev-master as the package is archived and no stable releases exist.)

  2. Enable the Bundle: Add to app/AppKernel.php:

    new Astina\Bundle\TradedoublerBundle\AstinaTradedoublerBundle(),
    
  3. Configure config.yml:

    astina_tradedoubler:
        api_token: "your_tradedoubler_api_token"
        feed_id: "your_feed_id"
        trackback:
            organization: "your_org_id"
            event_id: "your_event_id"
            redirect_default_url: "http://your-shop.com"
    
  4. First Use Case: Push a single product to Tradedoubler via CLI:

    php app/console astina:tradedoubler:populate
    

    (Requires implementing ProductSourceInterface—see Implementation Patterns.)


Implementation Patterns

Core Workflow: Product Sync

  1. Define a Product Source Service: Implement ProductSourceInterface to fetch products from your database:

    // src/Acme/ShopBundle/Service/ProductSource.php
    use Astina\Bundle\TradedoublerBundle\Client\ProductSourceInterface;
    
    class ProductSource implements ProductSourceInterface
    {
        public function getProducts()
        {
            return ProductCollection::fromArray($this->fetchFromDb());
        }
    }
    
  2. Register the Service:

    services:
        my_product_source:
            class: Acme\ShopBundle\Service\ProductSource
            tags:
                - { name: astina_tradedoubler.product_source }
    

    Update config.yml:

    astina_tradedoubler:
        product_source: my_product_source
    
  3. Trigger Sync:

    php app/console astina:tradedoubler:populate
    

    (Logs output to var/log/dev.log by default.)


Integration Tips

  • Event-Driven Updates: Hook into Symfony events (e.g., kernel.request) to push updates incrementally:

    $client->updateProduct($productId, $updatedProduct);
    
  • Bulk Operations: Use ProductCollection for batch processing:

    $collection = new ProductCollection([$product1, $product2]);
    $client->createProducts($collection);
    
  • Error Handling: Wrap API calls in try-catch:

    try {
        $client->createProducts($collection);
    } catch (\Astina\Bundle\TradedoublerBundle\Exception\TradedoublerException $e) {
        $this->logger->error($e->getMessage());
    }
    
  • XML Reports: Enable the mailer by configuring astina_tradedoubler.xml_report in config.yml:

    astina_tradedoubler:
        xml_report:
            enabled: true
            email: "reports@example.com"
    

Gotchas and Tips

Pitfalls

  1. Deprecated Dependencies:

    • Uses Guzzle v3 (unsupported; upgrade to Guzzle v6+ if possible).
    • Symfony 2.x only (not compatible with Symfony 3+).
  2. Timeout Issues:

    • Default timeout is 30 seconds (configurable via Client constructor).
    • Increase for large feeds:
      $client = new Client($config, ['timeout' => 60]);
      
  3. Product ID Mismatches:

    • Tradedoubler requires unique product_id in ProductCollection.
    • Validate IDs before submission:
      $collection->validateUniqueIds();
      
  4. Logging Quirks:

    • TradedoublerException messages are automatically logged (v1.2.5+).
    • Check var/log/dev.log for API errors.

Debugging Tips

  1. Enable API Debugging: Set debug: true in config:

    astina_tradedoubler:
        debug: true
    

    (Logs raw API requests/responses.)

  2. Validate XML Output: Use jms/serializer to inspect serialized payloads:

    $serializer = $this->container->get('jms_serializer');
    $xml = $serializer->serialize($product, 'xml');
    
  3. Test Locally: Mock the Client for unit tests:

    $client = $this->createMock(\Astina\Bundle\TradedoublerBundle\Client\Client::class);
    $client->method('createProducts')->willReturn(true);
    

Extension Points

  1. Custom Fields: Extend Product model to add Tradedoubler-specific attributes:

    class CustomProduct extends \Astina\Bundle\TradedoublerBundle\Model\Product
    {
        protected $customField;
    
        public function setCustomField($value) { $this->customField = $value; }
        public function getCustomField() { return $this->customField; }
    }
    
  2. Override Serialization: Replace the jms/serializer configuration for custom formats:

    jms_serializer:
        metadata:
            directories:
                AcmeShop:
                    namespace_prefix: "Acme\\ShopBundle\\Model"
                    path: "%kernel.root_dir%/config/serializer/AcmeShop"
    
  3. Add Webhooks: Implement a PostSyncEventListener to trigger actions after sync:

    use Astina\Bundle\TradedoublerBundle\Event\PostSyncEvent;
    
    class MyListener
    {
        public function onPostSync(PostSyncEvent $event)
        {
            if ($event->isSuccess()) {
                // Send Slack notification, etc.
            }
        }
    }
    

    Register as a service with the kernel.event_listener tag.

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.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle