diff --git a/README.md b/README.md index 476e71a..e3d7c20 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,76 @@ $ php bin/console doctrine:migrations:diff $ php bin/console doctrine:migrations:migrate ``` +### Step 6: Create a property +When you create a property in Google Analytics you receive a tracking id which looks something like UA-12345678-1. + +Now create a new property in your Sylius shop by navigating to `/admin/properties/new`. +Remember to enable the property and enable the channels you want to track. + +### Step 7: You're ready! +The events that are tracked are located in the [EventListener folder](src/EventListener). +To make your tracking even better you should create event listeners listening to the +builder events fired in i.e. the [PurchaseSubscriber](src/EventListener/PurchaseSubscriber.php). + +Let's say you use the [Brand plugin](https://github.com/loevgaard/SyliusBrandPlugin) and want to enrich the items +tracked with the brand of the product. That would look like this: + +```php + [ + 'addBrand', + ], + ]; + } + + public function addBrand(BuilderEvent $event): void + { + $builder = $event->getBuilder(); + if(!$builder instanceof ItemBuilder) { + return; + } + + $subject = $event->getSubject(); + + if(!$subject instanceof OrderItemInterface) { + return; + } + + $product = $subject->getProduct(); + if(!$product instanceof BrandAwareInterface) { + return; + } + + $builder->setBrand($product->getBrand()->getName()); + } +} + +``` + +## Contribute +Ways you can contribute: +* Translate [messages](src/Resources/translations/messages.en.yaml) and [validators](src/Resources/translations/validators.en.yaml) to your mother tongue +* Create Behat tests that verifies the scripts are outputted on the respective pages +* Create new event subscribers that handle Analytics events which are not implemented + +Thank you! [ico-version]: https://poser.pugx.org/setono/sylius-analytics-plugin/v/stable [ico-unstable-version]: https://poser.pugx.org/setono/sylius-analytics-plugin/v/unstable diff --git a/composer.json b/composer.json index 993d412..47d2de7 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "friends-of-behat/symfony-extension": "^2.0", "friends-of-behat/variadic-extension": "^1.1", "lakion/mink-debug-extension": "^1.2.3", + "loevgaard/sylius-brand-plugin": "^2.0@beta", "phpspec/phpspec": "^5.0", "phpstan/phpstan-doctrine": "^0.10", "phpstan/phpstan-shim": "^0.10", diff --git a/src/Doctrine/ORM/PropertyRepository.php b/src/Doctrine/ORM/PropertyRepository.php index 483c780..0dca4b6 100644 --- a/src/Doctrine/ORM/PropertyRepository.php +++ b/src/Doctrine/ORM/PropertyRepository.php @@ -10,9 +10,6 @@ class PropertyRepository extends EntityRepository implements PropertyRepositoryInterface { - /** - * {@inheritdoc} - */ public function findByChannel(ChannelInterface $channel): array { return $this->createQueryBuilder('o')