vendor/shopware/core/Content/Product/ProductHydrator.php line 183

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Product;
  3. use Shopware\Core\Framework\Context;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntityHydrator;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Entity;
  6. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  7. use Shopware\Core\Framework\Uuid\Uuid;
  8. class ProductHydrator extends EntityHydrator
  9. {
  10.     /**
  11.      * @param array<string, string> $row
  12.      *
  13.      * @throws \Exception
  14.      */
  15.     protected function assign(EntityDefinition $definitionEntity $entitystring $root, array $rowContext $context): Entity
  16.     {
  17.         if (isset($row[$root '.id'])) {
  18.             $entity->id Uuid::fromBytesToHex($row[$root '.id']);
  19.         }
  20.         if (isset($row[$root '.versionId'])) {
  21.             $entity->versionId Uuid::fromBytesToHex($row[$root '.versionId']);
  22.         }
  23.         if (isset($row[$root '.parentId'])) {
  24.             $entity->parentId Uuid::fromBytesToHex($row[$root '.parentId']);
  25.         }
  26.         if (isset($row[$root '.manufacturerId'])) {
  27.             $entity->manufacturerId Uuid::fromBytesToHex($row[$root '.manufacturerId']);
  28.         }
  29.         if (isset($row[$root '.unitId'])) {
  30.             $entity->unitId Uuid::fromBytesToHex($row[$root '.unitId']);
  31.         }
  32.         if (isset($row[$root '.taxId'])) {
  33.             $entity->taxId Uuid::fromBytesToHex($row[$root '.taxId']);
  34.         }
  35.         if (isset($row[$root '.coverId'])) {
  36.             $entity->coverId Uuid::fromBytesToHex($row[$root '.coverId']);
  37.         }
  38.         if (isset($row[$root '.deliveryTimeId'])) {
  39.             $entity->deliveryTimeId Uuid::fromBytesToHex($row[$root '.deliveryTimeId']);
  40.         }
  41.         if (isset($row[$root '.featureSetId'])) {
  42.             $entity->featureSetId Uuid::fromBytesToHex($row[$root '.featureSetId']);
  43.         }
  44.         if (isset($row[$root '.canonicalProductId'])) {
  45.             $entity->canonicalProductId Uuid::fromBytesToHex($row[$root '.canonicalProductId']);
  46.         }
  47.         if (isset($row[$root '.cmsPageId'])) {
  48.             $entity->cmsPageId Uuid::fromBytesToHex($row[$root '.cmsPageId']);
  49.         }
  50.         if (\array_key_exists($root '.price'$row)) {
  51.             $entity->price $definition->decode('price'self::value($row$root'price'));
  52.         }
  53.         if (isset($row[$root '.productNumber'])) {
  54.             $entity->productNumber $row[$root '.productNumber'];
  55.         }
  56.         if (isset($row[$root '.stock'])) {
  57.             $entity->stock = (int) $row[$root '.stock'];
  58.         }
  59.         if (isset($row[$root '.restockTime'])) {
  60.             $entity->restockTime = (int) $row[$root '.restockTime'];
  61.         }
  62.         if (isset($row[$root '.autoIncrement'])) {
  63.             $entity->autoIncrement = (int) $row[$root '.autoIncrement'];
  64.         }
  65.         if (isset($row[$root '.active'])) {
  66.             $entity->active = (bool) $row[$root '.active'];
  67.         }
  68.         if (isset($row[$root '.availableStock'])) {
  69.             $entity->availableStock = (int) $row[$root '.availableStock'];
  70.         }
  71.         if (isset($row[$root '.available'])) {
  72.             $entity->available = (bool) $row[$root '.available'];
  73.         }
  74.         if (isset($row[$root '.isCloseout'])) {
  75.             $entity->isCloseout = (bool) $row[$root '.isCloseout'];
  76.         }
  77.         if (isset($row[$root '.displayGroup'])) {
  78.             $entity->displayGroup $row[$root '.displayGroup'];
  79.         }
  80.         if (\array_key_exists($root '.configuratorGroupConfig'$row)) {
  81.             $entity->configuratorGroupConfig $definition->decode('configuratorGroupConfig'self::value($row$root'configuratorGroupConfig'));
  82.         }
  83.         if (isset($row[$root '.mainVariantId'])) {
  84.             $entity->mainVariantId Uuid::fromBytesToHex($row[$root '.mainVariantId']);
  85.         }
  86.         if (isset($row[$root '.displayParent'])) {
  87.             $entity->displayParent = (bool) $row[$root '.displayParent'];
  88.         }
  89.         if (isset($row[$root '.variantListingConfig'])) {
  90.             $entity->variantListingConfig $definition->decode('variantListingConfig'self::value($row$root'variantListingConfig'));
  91.         }
  92.         if (\array_key_exists($root '.variantRestrictions'$row)) {
  93.             $entity->variantRestrictions $definition->decode('variantRestrictions'self::value($row$root'variantRestrictions'));
  94.         }
  95.         if (isset($row[$root '.manufacturerNumber'])) {
  96.             $entity->manufacturerNumber $row[$root '.manufacturerNumber'];
  97.         }
  98.         if (isset($row[$root '.ean'])) {
  99.             $entity->ean $row[$root '.ean'];
  100.         }
  101.         if (isset($row[$root '.purchaseSteps'])) {
  102.             $entity->purchaseSteps = (int) $row[$root '.purchaseSteps'];
  103.         }
  104.         if (isset($row[$root '.maxPurchase'])) {
  105.             $entity->maxPurchase = (int) $row[$root '.maxPurchase'];
  106.         }
  107.         if (isset($row[$root '.minPurchase'])) {
  108.             $entity->minPurchase = (int) $row[$root '.minPurchase'];
  109.         }
  110.         if (isset($row[$root '.purchaseUnit'])) {
  111.             $entity->purchaseUnit = (float) $row[$root '.purchaseUnit'];
  112.         }
  113.         if (isset($row[$root '.referenceUnit'])) {
  114.             $entity->referenceUnit = (float) $row[$root '.referenceUnit'];
  115.         }
  116.         if (isset($row[$root '.shippingFree'])) {
  117.             $entity->shippingFree = (bool) $row[$root '.shippingFree'];
  118.         }
  119.         if (\array_key_exists($root '.purchasePrices'$row)) {
  120.             $entity->purchasePrices $definition->decode('purchasePrices'self::value($row$root'purchasePrices'));
  121.         }
  122.         if (isset($row[$root '.markAsTopseller'])) {
  123.             $entity->markAsTopseller = (bool) $row[$root '.markAsTopseller'];
  124.         }
  125.         if (isset($row[$root '.weight'])) {
  126.             $entity->weight = (float) $row[$root '.weight'];
  127.         }
  128.         if (isset($row[$root '.width'])) {
  129.             $entity->width = (float) $row[$root '.width'];
  130.         }
  131.         if (isset($row[$root '.height'])) {
  132.             $entity->height = (float) $row[$root '.height'];
  133.         }
  134.         if (isset($row[$root '.length'])) {
  135.             $entity->length = (float) $row[$root '.length'];
  136.         }
  137.         if (isset($row[$root '.releaseDate'])) {
  138.             $entity->releaseDate = new \DateTimeImmutable($row[$root '.releaseDate']);
  139.         }
  140.         if (isset($row[$root '.ratingAverage'])) {
  141.             $entity->ratingAverage = (float) $row[$root '.ratingAverage'];
  142.         }
  143.         if (\array_key_exists($root '.categoryTree'$row)) {
  144.             $entity->categoryTree $definition->decode('categoryTree'self::value($row$root'categoryTree'));
  145.         }
  146.         if (\array_key_exists($root '.propertyIds'$row)) {
  147.             $entity->propertyIds $definition->decode('propertyIds'self::value($row$root'propertyIds'));
  148.         }
  149.         if (\array_key_exists($root '.optionIds'$row)) {
  150.             $entity->optionIds $definition->decode('optionIds'self::value($row$root'optionIds'));
  151.         }
  152.         if (\array_key_exists($root '.streamIds'$row)) {
  153.             $entity->streamIds $definition->decode('streamIds'self::value($row$root'streamIds'));
  154.         }
  155.         if (\array_key_exists($root '.tagIds'$row)) {
  156.             $entity->tagIds $definition->decode('tagIds'self::value($row$root'tagIds'));
  157.         }
  158.         if (\array_key_exists($root '.categoryIds'$row)) {
  159.             $entity->categoryIds $definition->decode('categoryIds'self::value($row$root'categoryIds'));
  160.         }
  161.         if (isset($row[$root '.childCount'])) {
  162.             $entity->childCount = (int) $row[$root '.childCount'];
  163.         }
  164.         if (isset($row[$root '.customFieldSetSelectionActive'])) {
  165.             $entity->customFieldSetSelectionActive = (bool) $row[$root '.customFieldSetSelectionActive'];
  166.         }
  167.         if (isset($row[$root '.sales'])) {
  168.             $entity->sales = (int) $row[$root '.sales'];
  169.         }
  170.         if (\array_key_exists($root '.cheapestPrice'$row)) {
  171.             $entity->cheapestPrice $definition->decode('cheapestPrice'self::value($row$root'cheapestPrice'));
  172.         }
  173.         if (isset($row[$root '.createdAt'])) {
  174.             $entity->createdAt = new \DateTimeImmutable($row[$root '.createdAt']);
  175.         }
  176.         if (isset($row[$root '.updatedAt'])) {
  177.             $entity->updatedAt = new \DateTimeImmutable($row[$root '.updatedAt']);
  178.         }
  179.         $entity->deliveryTime $this->manyToOne($row$root$definition->getField('deliveryTime'), $context);
  180.         $entity->tax $this->manyToOne($row$root$definition->getField('tax'), $context);
  181.         $entity->manufacturer $this->manyToOne($row$root$definition->getField('manufacturer'), $context);
  182.         $entity->unit $this->manyToOne($row$root$definition->getField('unit'), $context);
  183.         $entity->cover $this->manyToOne($row$root$definition->getField('cover'), $context);
  184.         $entity->featureSet $this->manyToOne($row$root$definition->getField('featureSet'), $context);
  185.         $entity->cmsPage $this->manyToOne($row$root$definition->getField('cmsPage'), $context);
  186.         $entity->canonicalProduct $this->manyToOne($row$root$definition->getField('canonicalProduct'), $context);
  187.         $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
  188.         $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
  189.         $this->customFields($definition$row$root$entity$definition->getField('customFields'), $context);
  190.         $this->manyToMany($row$root$entity$definition->getField('options'));
  191.         $this->manyToMany($row$root$entity$definition->getField('properties'));
  192.         $this->manyToMany($row$root$entity$definition->getField('categories'));
  193.         $this->manyToMany($row$root$entity$definition->getField('streams'));
  194.         $this->manyToMany($row$root$entity$definition->getField('categoriesRo'));
  195.         $this->manyToMany($row$root$entity$definition->getField('tags'));
  196.         $this->manyToMany($row$root$entity$definition->getField('customFieldSets'));
  197.         return $entity;
  198.     }
  199. }