When you define custom element you should register your own data resolver like this:
<?php declare(strict_types=1);
namespace YournamespaceCoreContentProductCms;
use ShopwareCoreContentCmsAggregateCmsSlotCmsSlotEntity;
use ShopwareCoreContentCmsDataResolverCriteriaCollection;
.
.
.
class ProductSliderCmsElementResolver extends AbstractCmsElementResolver
{
private const PRODUCT_SLIDER_ENTITY_FALLBACK = 'product-slider-entity-fallback';
private const STATIC_SEARCH_KEY = 'product-four-column';
private const FALLBACK_LIMIT = 50;
/**
* @var ProductStreamBuilder
*/
private $productStreamBuilder;
public function __construct(ProductStreamBuilder $productStreamBuilder)
{
$this->productStreamBuilder = $productStreamBuilder;
}
public function getType(): string
{
return 'product-four-column';
}
Don't forget register the Resolver in your services.xml.
However your method works too.I have done it before with your method.
For the code base, you can use shopware.
You can see the image below. I defined a custom element.After that i registered data resolver.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…