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

Marketing Laravel Package

oro/marketing

Oro marketing package bundles marketing-related features for Oro applications, providing integrations intended for OroCommerce, OroCRM, and OroPlatform projects. Install via Composer and extend your app with Oro’s marketing-specific bundles.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to First Use

  1. Install the Package Add to composer.json:

    "require": {
        "oro/marketing": "^6.0"
    }
    

    Run composer update oro/marketing.

  2. Set Up Database Import the Doctrine schema via:

    php bin/console doctrine:schema:update --force
    

    (Note: Requires Doctrine ORM; use a bridge like php-di or laravel-bundle for Laravel compatibility.)

  3. Register Bundles In config/app.php, add:

    Oro\Bundle\CampaignBundle\CampaignBundle::class,
    Oro\Bundle\MarketingListBundle\MarketingListBundle::class,
    // Other Oro bundles as needed
    
  4. First Use Case: Create a Marketing List Use the MarketingList entity via Eloquent (if mapped) or Doctrine:

    use Oro\Bundle\MarketingListBundle\Entity\MarketingList;
    
    $marketingList = new MarketingList();
    $marketingList->setName('High-Value Customers');
    $entityManager->persist($marketingList);
    $entityManager->flush();
    
  5. Verify API Endpoints Check if REST endpoints are accessible (e.g., /api/marketingactivitytypes). If using Laravel routing, proxy or rewrite paths in routes/api.php.


Implementation Patterns

Core Workflows

1. Segmentation with Marketing Lists

  • Dynamic Lists: Use MarketingListProvider to filter contacts dynamically:
    $provider = $this->container->get('oro_marketing_list.provider.marketing_list');
    $iterator = $provider->getMarketingListEntitiesIterator($marketingListId);
    foreach ($iterator as $contact) {
        // Send targeted emails or trigger campaigns
    }
    
  • Custom Criteria: Extend MarketingListCriteria to add domain-specific filters (e.g., Customer::where('lifetime_value', '>', 1000)).

2. Campaign Management

  • Create/Update Campaigns:
    use Oro\Bundle\CampaignBundle\Entity\Campaign;
    
    $campaign = new Campaign();
    $campaign->setName('Summer Sale 2024');
    $campaign->setDescription('Promote summer collection');
    $entityManager->persist($campaign);
    
  • Track Metrics: Use CampaignStatistic to log events (e.g., clicks, conversions):
    $statistic = new \Oro\Bundle\CampaignBundle\Entity\CampaignStatistic();
    $statistic->setCampaign($campaign);
    $statistic->setType('click');
    $statistic->setValue(1);
    $entityManager->persist($statistic);
    

3. API-Driven Integrations

  • REST Endpoints: Leverage pre-built APIs (e.g., /api/marketinglists/{id}/items):
    // Example: Fetch marketing list items via HTTP client
    $response = Http::get("/api/marketinglists/{id}/items");
    $items = $response->json();
    
  • Webhooks: Extend CampaignEventListener to trigger external actions (e.g., Slack notifications on campaign completion).

4. Event-Driven Extensions

  • Listen to Marketing Events: Subscribe to Oro’s events (e.g., campaign.send):
    // In a service provider
    $this->app->booting(function () {
        $dispatcher = $this->app->make('event_dispatcher');
        $dispatcher->addListener('campaign.send', function ($event) {
            // Custom logic (e.g., log to analytics)
        });
    });
    
  • Custom Events: Dispatch your own events (e.g., marketing.list.updated) for decoupled workflows.

Integration Tips

  • Laravel-Symfony Bridge: Use php-di to adapt Symfony services:
    $container->set(\Oro\Bundle\MarketingListBundle\Provider\MarketingListProvider::class, function () {
        return new \Oro\Bundle\MarketingListBundle\Provider\MarketingListProvider(
            $this->get('doctrine.orm.entity_manager')
        );
    });
    
  • Eloquent Compatibility: Create a trait to map Doctrine entities to Eloquent:
    trait DoctrineToEloquentAdapter {
        public static function resolveEntityManager() {
            return app('doctrine')->getManager();
        }
    }
    
  • Twig Extensions: Register Oro’s Twig extensions in Laravel’s AppServiceProvider:
    public function register() {
        $this->app->tag(
            \Oro\Bundle\MarketingListBundle\Twig\Extension\MarketingListExtension::class,
            'twig.extension'
        );
    }
    

Gotchas and Tips

Pitfalls

  1. Symfony Dependency Hell:

    • Issue: The package relies on Symfony components (e.g., EventDispatcher, PropertyAccess). Laravel’s equivalents may not map 1:1.
    • Fix: Use symfony/event-dispatcher and symfony/property-access as Composer dependencies, then bridge them in a service provider.
  2. Doctrine ORM Lock-In:

    • Issue: Laravel’s Eloquent and Doctrine have divergent query builders. Complex queries (e.g., DQL) may break.
    • Fix: Abstract queries with a repository pattern:
      class MarketingListRepository {
          public function findByCriteria($criteria) {
              return $this->entityManager->createQueryBuilder()
                  ->from('OroMarketingListBundle:MarketingList', 'ml')
                  ->where('ml.name = :name')
                  ->setParameter('name', $criteria['name'])
                  ->getQuery()
                  ->getResult();
          }
      }
      
  3. Breaking API Path Changes:

    • Issue: Major versions rename endpoints (e.g., /api/matypes/api/marketingactivitytypes). Old paths return 404.
    • Fix: Pin to a specific version (e.g., oro/marketing:6.0.0) and handle deprecations proactively.
  4. Twig Template Conflicts:

    • Issue: Oro’s Twig templates assume Symfony’s asset pipeline. Laravel’s @vite or @asset directives may break.
    • Fix: Override templates in resources/views/oro/ and replace Symfony-specific tags.
  5. Event Dispatcher Mismatch:

    • Issue: Symfony’s EventDispatcher and Laravel’s Illuminate\Events\Dispatcher are incompatible.
    • Fix: Use a facade or wrapper:
      class OroEventDispatcher {
          public function dispatch($event, $listener = null) {
              return app('events')->dispatch($event);
          }
      }
      

Debugging Tips

  • Enable Doctrine Logging: Add to config/services.yaml (Symfony) or Laravel’s config/doctrine.php:

    doctrine:
        dbal:
            logging: true
            profiler: true
    

    View logs in storage/logs/doctrine.log.

  • Check Event Listeners: Dump registered listeners to debug event flow:

    $dispatcher = $this->app->make('event_dispatcher');
    foreach ($dispatcher->getListeners() as $event => $listeners) {
        dump($event, $listeners);
    }
    
  • Validate Entity States: Use Oro’s StateMachine to debug workflow transitions:

    $stateMachine = $this->container->get('oro_marketing_list.state_machine.marketing_list');
    $stateMachine->apply($marketingList, 'publish');
    

Extension Points

  1. Custom Marketing List Criteria: Extend MarketingListCriteria to add domain logic:

    class CustomMarketingListCriteria extends MarketingListCriteria {
        public function addCustomFilter($field, $value) {
            $this->getParameters()->add('custom.' . $field, $value);
        }
    }
    
  2. Campaign Workflow Extensions: Add custom transitions to Oro’s state machines:

    # config/oro/marketing_list.yml
    oro_marketing_list:
        state_machine:
            marketing_list:
                transitions:
                    archive:
                        from: [published]
                        to: archived
                        guard: [is_archivable]
    
  3. API Resource Customization: Override REST controllers to add fields or filters:

    class CustomMarketingListController extends \Oro\Bundle\MarketingListBundle\Controller\Api\Rest\MarketingListController {
        public function cgetAction($id) {
            $this->get('oro_api.get_data')->setFields(['name', 'custom_field']);
            return parent::cgetAction($id);
        }
    }
    
  4. Data Importers/Exporters:

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky