fixed product lits bad variations language
This commit is contained in:
parent
14169ab24a
commit
3105ce1e81
|
@ -1354,11 +1354,36 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|||
->map('path', $builder->fromValue('field_price_description.value'))
|
||||
);
|
||||
|
||||
// TODO: match the right language
|
||||
$registry->addFieldResolver('Product', 'variations',
|
||||
$builder->produce('entity_reference')
|
||||
->map('entity', $builder->fromParent())
|
||||
->map('field', $builder->fromValue('variations'))
|
||||
// $builder->produce('entity_reference')
|
||||
// ->map('entity', $builder->fromParent())
|
||||
// ->map('field', $builder->fromValue('variations'))
|
||||
$builder->compose(
|
||||
$builder->callback(function($parent, $args){
|
||||
$variations = $parent->get('variations')->getValue();
|
||||
$ids = [];
|
||||
foreach ($variations as $key => $value) {
|
||||
$ids[] = $value['target_id'];
|
||||
}
|
||||
$lang = $parent->language()->getId();
|
||||
return [
|
||||
"ids" => $ids,
|
||||
"language" => $lang
|
||||
];
|
||||
}),
|
||||
$builder->produce('entity_load_multiple')
|
||||
->map('type', $builder->fromValue('commerce_product_variation'))
|
||||
// ->map('bundles', $builder->fromValue(['materiau']))
|
||||
->map('ids', $builder->callback(function($parent, $args){
|
||||
return $parent['ids'];
|
||||
}))
|
||||
->map('language', $builder->callback(function($parent, $args){
|
||||
return $parent['language'];
|
||||
}))
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
protected function addVariation(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
||||
|
|
Loading…
Reference in New Issue