Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

shopware - Cant see element at frontpage in shopware6?

I am creating an element to show products in 4 column, I am able to see it at admin but its not appearing at frontend.

any help will be appreciated. Thank you in advance.

enter image description here

enter image description here

enter image description here

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...