You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you implement the [`BrandResolverInterface`](src/Resolver/Brand/BrandResolverInterface.php) and register your class as a service it will automatically
107
+
be tagged with `setono_sylius_analytics.brand_resolver` and used when tracking.
108
+
109
+
### Category resolver
110
+
An item has category properties (`item_category`, `item_category2`, etc.) and by default the plugin will resolve these
111
+
properties based on either a product's main taxon or (if no main taxon is set) the first taxon in the collection of taxons.
and the [`Setono\SyliusAnalyticsPlugin\Resolver\Variant\OptionBasedVariantResolver`](src/Resolver/Variant/OptionBasedVariantResolver.php).
130
+
131
+
The option based version has the highest priority of the two and will therefore be tried first. It tries to create a
132
+
variant string based on the options on the variant (if any).
133
+
134
+
The name based version returns the `\Sylius\Component\Product\Model\ProductVariantInterface::getName()`.
135
+
136
+
To implement your own resolver just implement the `Setono\SyliusAnalyticsPlugin\Resolver\Variant\VariantResolverInterface`.
137
+
Here is an example:
138
+
139
+
```php
140
+
<?php
141
+
use Setono\SyliusAnalyticsPlugin\Resolver\Variant\VariantResolverInterface;
142
+
use Sylius\Component\Core\Model\ProductVariantInterface;
143
+
144
+
final class ProductNameBasedVariantResolver implements VariantResolverInterface
145
+
{
146
+
public function resolve(ProductVariantInterface $productVariant): ?string
147
+
{
148
+
return $productVariant->getProduct()->getName();
149
+
}
150
+
}
151
+
```
152
+
68
153
## Contribute
69
154
Ways you can contribute:
70
155
* Translate [messages](src/Resources/translations/messages.en.yaml) and [validators](src/Resources/translations/validators.en.yaml) into your mother tongue
71
-
* Create Behat tests that verifies the scripts are outputted on the respective pages
72
156
* Create new event subscribers that handle Analytics events which are not implemented
0 commit comments