Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EntityIdToId.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
17 
24 {
28  private $metadataPool;
29 
33  public function __construct(MetadataPool $metadataPool)
34  {
35  $this->metadataPool = $metadataPool;
36  }
37 
41  public function resolve(
42  Field $field,
43  $context,
45  array $value = null,
46  array $args = null
47  ) {
48  if (!isset($value['model'])) {
49  throw new GraphQlInputException(__('"model" value should be specified'));
50  }
51 
53  $product = $value['model'];
54 
55  $productId = $product->getData(
56  $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField()
57  );
58 
59  return $productId;
60  }
61 }
__()
Definition: __.php:13
$value
Definition: gender.phtml:16
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52
resolve(Field $field, $context, ResolveInfo $info, array $value=null, array $args=null)