Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Attributes.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
17 class Attributes implements ResolverInterface
18 {
24  public function resolve(
25  Field $field,
26  $context,
28  array $value = null,
29  array $args = null
30  ) {
31  if (!isset($value['options']) || !isset($value['product'])) {
32  return null;
33  }
34 
35  $data = [];
36  foreach ($value['options'] as $option) {
37  $code = $option['attribute_code'];
38  if (!isset($value['product'][$code])) {
39  continue;
40  }
41 
42  foreach ($option['values'] as $optionValue) {
43  if ($optionValue['value_index'] != $value['product'][$code]) {
44  continue;
45  }
46  $data[] = [
47  'label' => $optionValue['label'],
48  'code' => $code,
49  'use_default_value' => $optionValue['use_default_value'],
50  'value_index' => $optionValue['value_index']
51  ];
52  }
53  }
54  return $data;
55  }
56 }
resolve(Field $field, $context, ResolveInfo $info, array $value=null, array $args=null)
Definition: Attributes.php:24
$value
Definition: gender.phtml:16
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52
$code
Definition: info.phtml:12