Listener Priority

The Event Collector \Spryker\Service\Event\Dependency\EventCollectionInterface uses a priority queue store events so each that event can have different priority and will be executed in correct order when triggered.

For example:

<?php
$eventCollection
    ->addListener(ProductEvents::PRODUCT_ABSTRACT_BEFORE_CREATE, new ProductRelationAbstractProductChangeListener(), 1);

$eventCollection
    ->addListener(ProductEvents::PRODUCT_ABSTRACT_BEFORE_CREATE, new ProductOptionAbstractProductChangeListener(), 10);

In the example above, the second event will be triggered first because the third argument’s value of 10 indicates higher priority.