File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Resources/config/services Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ /*
6
+ * This file has been created by developers from BitBag.
7
+ * Feel free to contact us once you face any issues or want to start
8
+ * another great project.
9
+ * You can find more information about us on https://bitbag.shop and write us
10
+
11
+ */
12
+
13
+ namespace BitBag \SyliusElasticsearchPlugin \EventListener ;
14
+
15
+ use BitBag \SyliusElasticsearchPlugin \Refresher \ResourceRefresherInterface ;
16
+ use Sylius \Component \Core \Model \ProductTaxonInterface ;
17
+ use Sylius \Component \Resource \Model \ResourceInterface ;
18
+ use Symfony \Component \EventDispatcher \GenericEvent ;
19
+ use Webmozart \Assert \Assert ;
20
+
21
+ final class ProductTaxonIndexListener
22
+ {
23
+ /** @var ResourceRefresherInterface */
24
+ private $ resourceRefresher ;
25
+
26
+ /** @var string */
27
+ private $ objectPersisterId ;
28
+
29
+ public function __construct (ResourceRefresherInterface $ resourceRefresher , string $ objectPersisterId )
30
+ {
31
+ $ this ->resourceRefresher = $ resourceRefresher ;
32
+ $ this ->objectPersisterId = $ objectPersisterId ;
33
+ }
34
+
35
+ public function updateIndex (ProductTaxonInterface $ productTaxon ): void
36
+ {
37
+ $ this ->resourceRefresher ->refresh ($ productTaxon ->getProduct (), $ this ->objectPersisterId );
38
+ }
39
+ }
Original file line number Diff line number Diff line change 28
28
<tag name =" kernel.event_listener" event =" sylius.product_variant.post_create" method =" updateIndex" />
29
29
<tag name =" kernel.event_listener" event =" sylius.product_variant.post_update" method =" updateIndex" />
30
30
</service >
31
+ <service id =" bitbag_sylius_elasticsearch_plugin.event_listener.product_taxon_index" class =" BitBag\SyliusElasticsearchPlugin\EventListener\ProductTaxonIndexListener" >
32
+ <argument type =" service" id =" bitbag.sylius_elasticsearch_plugin.refresher.resource" />
33
+ <argument >fos_elastica.object_persister.bitbag_shop_product.default</argument >
34
+ <tag name =" doctrine.orm.entity_listener" event =" postUpdate" method =" updateIndex" entity =" %sylius.model.product_taxon.class%" />
35
+ </service >
31
36
<service id =" bitbag_sylius_elasticsearch_plugin.event_listener.order_products" class =" BitBag\SyliusElasticsearchPlugin\EventListener\OrderProductsListener" public =" true" >
32
37
<argument type =" service" id =" bitbag.sylius_elasticsearch_plugin.refresher.resource" />
33
38
<argument type =" string" >fos_elastica.object_persister.bitbag_shop_product.default</argument >
You can’t perform that action at this time.
0 commit comments