13
13
14
14
namespace Sulu \Bundle \SyliusConsumerBundle \Adapter ;
15
15
16
+ use Doctrine \ORM \EntityManagerInterface ;
16
17
use Sulu \Bundle \CategoryBundle \Entity \CategoryInterface ;
17
18
use Sulu \Bundle \CategoryBundle \Entity \CategoryRepositoryInterface ;
18
19
use Sulu \Bundle \CategoryBundle \Entity \CategoryTranslationInterface ;
@@ -38,19 +39,30 @@ class TaxonCategoryAdapter implements TaxonAdapterInterface
38
39
*/
39
40
private $ categoryTranslationRepository ;
40
41
42
+ /**
43
+ * @var EntityManagerInterface
44
+ */
45
+ private $ entityManager ;
46
+
41
47
public function __construct (
42
48
TaxonCategoryBridgeRepositoryInterface $ taxonCategoryBridgeRepository ,
43
49
CategoryRepositoryInterface $ categoryRepository ,
44
- CategoryTranslationRepositoryInterface $ categoryTranslationRepository
50
+ CategoryTranslationRepositoryInterface $ categoryTranslationRepository ,
51
+ EntityManagerInterface $ entityManager
45
52
) {
46
53
$ this ->taxonCategoryBridgeRepository = $ taxonCategoryBridgeRepository ;
47
54
$ this ->categoryRepository = $ categoryRepository ;
48
55
$ this ->categoryTranslationRepository = $ categoryTranslationRepository ;
56
+ $ this ->entityManager = $ entityManager ;
49
57
}
50
58
51
59
public function synchronize (TaxonPayload $ payload ): void
52
60
{
53
61
$ this ->handlePayload ($ payload );
62
+
63
+ // Needed to use categories in other adapters
64
+ // (e.g. category pages with a smart-content filtered by the sylius category)
65
+ $ this ->entityManager ->flush ();
54
66
}
55
67
56
68
private function handlePayload (TaxonPayload $ payload , ?CategoryInterface $ parent = null ): void
0 commit comments