extractFields example

 else {
            $product->setCustomerPriceCount($data['__product_fallback_price_count']);
        }
    }

    /** * Iterates the attribute data and assigns the attribute struct to the product. */
    private function assignAttributeData(ListProduct $product, array $data): void
    {
        $translation = $this->getProductTranslation($data);
        $translation = $this->extractFields('__attribute_', $translation);
        $attributeData = $this->extractFields('__productAttribute_', $data);
        $attributeData = array_merge($attributeData$translation);
        $attribute = $this->attributeHydrator->hydrate($attributeData);
        $product->addAttribute('core', $attribute);
    }
}
use Shopware\Bundle\StoreFrontBundle\Struct\Extendable;

class AttributeHydrator extends Hydrator
{
    /** * @return Attribute */
    public function hydrate(array $data)
    {
        $attribute = new Attribute();
        $translation = $this->getTranslation($data, null);
        $translation = $this->extractFields('___attribute_', $translation);
        unset($data['translation']$data['translation_fallback']);

        foreach ($data as $key => $value) {
            if (isset($translation[$key])) {
                $attribute->set($key$translation[$key]);
            } else {
                $attribute->set($key$value);
            }
        }

        return $attribute;
    }
$blog->setShortDescription($data['__blog_short_description']);
        $blog->setDescription($data['__blog_description']);
        $blog->setViews((int) $data['__blog_views']);
        $blog->setDisplayDate($data['__blog_display_date'] ? date_create($data['__blog_display_date']) : null);
        $blog->setCategoryId((int) $data['__blog_category_id']);
        $blog->setTemplate($data['__blog_template']);
        $blog->setMetaKeywords($data['__blog_meta_keywords']);
        $blog->setMetaDescription($data['__blog_meta_description']);
        $blog->setMetaTitle($data['__blog_meta_title']);

        if (isset($data['__blogAttribute_id'])) {
            $attributeData = $this->extractFields('__blogAttribute_', $data);
            $attribute = $this->attributeHydrator->hydrate($attributeData);
            $blog->addAttribute('core', $attribute);
        }

        if (isset($data['__blog_tags'])) {
            $blog->setTags(explode(',', $data['__blog_tags']));
        }

        return $blog;
    }

    
$id = (int) $data['__customFacet_id'];
        $translation = $this->getTranslation($data, '__customFacet', []$id);
        $data = array_merge($data$translation);

        $customFacet = new CustomFacet();

        $customFacet->setId($id);
        $customFacet->setUniqueKey($data['__customFacet_unique_key']);
        $customFacet->setName($data['__customFacet_name']);
        $customFacet->setPosition((int) $data['__customFacet_position']);

        $translation = $this->extractFields('__customFacet_', $translation);
        $facets = json_decode($data['__customFacet_facet'], true);

        foreach ($facets as $class => &$facet) {
            $facet = array_merge($facet$translation);

            if (\array_key_exists('streamId', $facet)) {
                $facet['stream'] = $streams[$facet['streamId']];
            }
        }

        $facets = $this->reflector->unserialize(
            
Home | Imprint | This part of the site doesn't use cookies.