Skip to content

Commit

Permalink
Merge branch '2.10.x' into 2.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
romainruaud committed Nov 22, 2024
2 parents 91174be + 4aa8aaf commit 7fb60e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,28 @@ class MapPageIdentifier implements EventProcessorInterface
'multishipping_checkout_shipping' => 'checkout_index_index',
];

/**
* @var array
*/
private $mapping = [];

/**
* @param array $mapping an additional mapping of pages identifiers (coming from the DI)
*/
public function __construct($mapping = [])
{
$this->mapping = array_merge_recursive(self::MAPPING_REPLACE_IDENTIFIER, $mapping);
}

/**
* {@inheritDoc}
*/
public function process($eventData)
{
if (isset($eventData['page']['type']['identifier'])) {
$pageIdentifier = $eventData['page']['type']['identifier'];
if (isset(self::MAPPING_REPLACE_IDENTIFIER[$pageIdentifier])) {
$eventData['page']['type']['identifier'] = self::MAPPING_REPLACE_IDENTIFIER[$pageIdentifier];
if (isset($this->mapping[$pageIdentifier])) {
$eventData['page']['type']['identifier'] = $this->mapping[$pageIdentifier];
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/module-elasticsuite-tracker/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,12 @@
<plugin name="elasticsuite_tracker_disable_session" type="Smile\ElasticsuiteTracker\Plugin\SessionStartCheckerPlugin"/>
</type>

<!-- Example of extending the page map identifier -->
<type name="Smile\ElasticsuiteTracker\Model\Event\Processor\MapPageIdentifier">
<arguments>
<argument name="mapping" xsi:type="array">
<item name="checkout_klarna_success" xsi:type="string">checkout_onepage_success</item>
</argument>
</arguments>
</type>
</config>

0 comments on commit 7fb60e0

Please sign in to comment.