/**
  * @param  object                                                                          $attribute
  * @param  null                                                                            $format
  * @param  array                                                                           $context
  * @return array|\Symfony\Component\Serializer\Normalizer\scalar
  * @throws NormalizeException
  * @throws \Actualys\Bundle\DrupalCommerceConnectorBundle\Guesser\Exception\GuessException
  */
 public function normalize($attribute, $format = null, array $context = [])
 {
     $type = $attribute->getAttributeType();
     if ($normalizer = $this->normalizerGuesser->guessNormalizer($type, 'attribute')) {
         $normalizedAttribute = $normalizer->normalize($attribute, null, $context);
     } else {
         throw new NormalizeException('Type field not supported: "' . $type . '".');
     }
     return $normalizedAttribute;
 }
 /**
  * @param ProductInterface $product
  * @param array            $drupalProduct
  * @param Channel          $channel
  * @param array            $configuration
  *
  * @throws \Exception
  */
 protected function computeProductValues(ProductInterface $product, array &$drupalProduct, Channel $channel, $configuration)
 {
     /** @var \Pim\Bundle\CatalogBundle\Model\ProductValue $value */
     foreach ($product->getValues() as $value) {
         /*
                     // Skip out of scope values or not global ones.
                     if ($value->getScope() != $channel->getCode() && $value->getScope(
                       ) !== null
                     ) {
                         continue;
                     }*/
         $field = $value->getAttribute()->getCode();
         $type = $value->getAttribute()->getAttributeType();
         $locale = $value->getLocale();
         if (is_null($locale)) {
             $locale = LANGUAGE_NONE;
         }
         $labelAttribute = $value->getEntity()->getFamily()->getAttributeAsLabel()->getCode();
         if ($type == 'pim_catalog_identifier') {
             continue;
         }
         // Setup default locale.
         $context = ['locale' => $locale, 'scope' => $value->getScope(), 'defaultLocale' => 'fr_FR', 'configuration' => $configuration];
         if ($normalizer = $this->normalizerGuesser->guessNormalizer($type, 'product_value')) {
             $normalizer->normalize($drupalProduct, $value, $field, $context);
         } else {
             throw new NormalizeException('Type field not supported: "' . $type . '".', 'Normalizing error');
         }
     }
 }