Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ nav:

# Add Data to CMS Element

## Overview

When creating custom CMS elements,
you sometimes want to use more complex data types than text or boolean values, e.g., other entities such as media or products.
In those cases you can implement a custom `CmsElementResolver` to resolve the configuration data.
Expand Down Expand Up @@ -90,7 +88,7 @@ In this case we read out `myCustomMedia` field which may contain a mediaId.
If a `mediaId` exists, we create a new `CriteriaCollection` for it.
Now we are able to use this media object later on.
If you want to add data from an [attribute entity](../../framework/data-handling/entities-via-attributes), you do not have an explicit definition class.
Instead, you pass `example_entity.defintion` as second parameter to the `CriteriaCollection::add()` method.
Instead, you pass `example_entity.definition` as second parameter to the `CriteriaCollection::add()` method.

::: code-group

Expand All @@ -99,7 +97,7 @@ Instead, you pass `example_entity.defintion` as second parameter to the `Criteri

// ...
use Shopware\Core\Content\Media\MediaDefinition;
use Shopware\Core\Content\Media\MediaEntity;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
// ...

public function collect(CmsSlotEntity $slot, ResolverContext $resolverContext): ?CriteriaCollection
Expand Down
Loading