Skip to content

Commit

Permalink
Merge pull request #3446 from romainruaud/fix_tracker-different-check…
Browse files Browse the repository at this point in the history
…out-handles

Extensible page identifier mapping + klarna support out-of-the-box
  • Loading branch information
romainruaud authored Nov 22, 2024
2 parents e222b03 + 631e806 commit 4aa8aaf
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 4aa8aaf

Please sign in to comment.