Custom Product-Box - No data in the storefront

Based on the element “Product-Box” I created my own element and the corresponding storefront-template. I only changed the names in the index.js.

In the backend, the data of the selected product is also correctly displayed and stored. But in the frontend I do not see any product. If I dump() the data in the storefront-template, the value data = null.

With the default product box element it works fine.

Does anybody have an idea what could be the reason for this?

I have the same problem at a custom text element. I copied the original text element to my extension. It’s working fine at the backend, but at the frontend element.data is null. But in translated -> config -> content -> value, there is my string. The original template uses {{ element.data.content|raw }} for the output which is null.

Have you tried { element.config.content.value|raw } for your text element? This is how i did it for my text element.

If i’ll do this for the product box i only get a hash value.

Yes, that’s working, but I don’t know if it’s the „right“ way. I will use that for the moment.

up,

this var is empty in the product box element, how can I receive data from the product?

I have the same problem!

Did anyone find a solution? Please share, as I am stuck on the same problem. Thanks

Hello,

I am having the same issue. Does anyone have an answer?

Thanks,

Tom

Hi, I am not sure if this will help, but it solved my issue. https://stackoverflow.com/questions/62699616/shopware-6-cloning-cmselement-and-get-null-as-data/63131238#63131238

Awesome. Where do I put that file? Thanks,  Tom

I searched the platform for instances of AbstractCmsElementResolver and then mirrored the location in my plugin. So I added it to Plugin/src/Core/Content/Media/Cms/Type and used the namespace Plugin\Core\Content\Media\Cms\Type. I then added the service to my Plugin/src/Resources/config/services.xml.

I am not 100% about why this works, nor why I need to create a DataResolver, or if this applies only to when I copy an element, as when I created a new custom element I did not have to create a resolver. If anyone has an answer to this, that would be great Halo

wow thanks! I’m new to this and had the same issue. This has actually helped me