Exemplo n.º 1
0
 /**
  * @param array $abstractProductVariants
  * @param \Orm\Zed\Product\Persistence\SpyProduct $concreteProductEntity
  *
  * @return array
  */
 protected function createConcreteProductLocalizedVariants(array $abstractProductVariants, SpyProduct $concreteProductEntity)
 {
     $productVariants = [];
     $concreteProductAttributes = Json::decode($concreteProductEntity->getAttributes(), true);
     $concreteLocalizedConcreteProductAttributes = $concreteProductEntity->getSpyProductLocalizedAttributess();
     foreach ($concreteLocalizedConcreteProductAttributes as $localizedAttributeEntity) {
         $productVariantTransfer = $this->getProductVariantTransfer($abstractProductVariants, $localizedAttributeEntity);
         $mergedAbstractAttributes = $productVariantTransfer->getAttributes();
         $abstractProduct = $concreteProductEntity->toArray();
         unset($abstractProduct['attributes']);
         $productVariantTransfer->fromArray($abstractProduct, true);
         $localizedAttributes = $localizedAttributeEntity->toArray();
         unset($localizedAttributes['attributes']);
         $productVariantTransfer->fromArray($localizedAttributes, true);
         $localizedConcreteProductAttributes = Json::decode($localizedAttributeEntity->getAttributes(), true);
         $concreteMergedAttributes = array_merge($mergedAbstractAttributes, $concreteProductAttributes, $localizedConcreteProductAttributes);
         $productVariantTransfer->setAttributes($concreteMergedAttributes);
         $productVariants[] = $productVariantTransfer;
     }
     return $productVariants;
 }