1111use Psr \SimpleCache \CacheInterface ;
1212use Symfony \Component \Serializer \SerializerInterface ;
1313
14- final class FamilyLookup implements TransformerInterface
14+ final class Lookup implements TransformerInterface
1515{
1616 public function __construct (
1717 private \Psr \Log \LoggerInterface $ logger ,
1818 private \Kiboko \Magento \V2_1 \Client |\Kiboko \Magento \V2_2 \Client |\Kiboko \Magento \V2_3 \Client |\Kiboko \Magento \V2_4 \Client $ client ,
1919 private CacheInterface $ cache ,
20+ private string $ cacheKey ,
2021 private CompiledMapperInterface $ mapper ,
2122 private SerializerInterface $ serializer ,
2223 private string $ mappingField ,
@@ -28,11 +29,7 @@ public function transform(): \Generator
2829 $ line = yield ;
2930 while (true ) {
3031 try {
31- $ lookup = $ this ->serializer ->deserialize (
32- $ this ->cache ->get (sprintf ('family.%s ' , $ line [$ this ->mappingField ])),
33- \Kiboko \Magento \V2_3 \Model \EavDataAttributeOptionInterface::class,
34- 'json '
35- );
32+ $ lookup = $ this ->cache ->get (sprintf ($ this ->cacheKey , $ line [$ this ->mappingField ]));
3633
3734 if ($ lookup === null ) {
3835 $ lookup = $ this ->client ->catalogCategoryAttributeOptionManagementV1GetItemsGet (
@@ -48,8 +45,8 @@ public function transform(): \Generator
4845 }
4946
5047 $ this ->cache ->set (
51- sprintf (' family.%s ' , $ line [$ this ->mappingField ]),
52- $ this ->serializer ->serialize ($ lookup , 'json ' ),
48+ sprintf ($ this -> cacheKey , $ line [$ this ->mappingField ]),
49+ $ lookup = $ this ->serializer ->serialize ($ lookup , 'json ' ),
5350 );
5451 }
5552 } catch (\RuntimeException $ exception ) {
0 commit comments