Search code examples
shopwareshopware6

How to var_dump?


I've been searching the internet for hours but I just can't seem to var_dump within the invoice template. I need to put things like EAN etc. in the invoice template but only for certain customer groups, that's why I need to know the variable names.

In Shopware 5 it was var_dump plain and easy but in Shopware 6 nothing I try seems to work.

I've already tried {{ dump() }} within twig code blocks but nothing happens.

Help would be greatly appreciated!


Solution

  • In general {{ dump() }} should work inside document templates, but the dump command is optimized for html output and not pdf output.

    Please ensure that you set APP_ENV = "dev" or APP_DEBUG = 1 inside your .env file, because otherwise the twig dump() command is not available.

    Also ensure that you call the dump from a block that is rendered in the output of the document (so everything inside the <body> tag).

    Additionally simply calling {{ dump() }} inside a document template probably leads to an infinite loading or out of memory errors, because twig tries to dump to much data.

    For document templates, the main variable you have access to is the order, which is an OrderEntity. The order entity has a orderCustomer property, so you could use a {{ dump(order.orderCustomer) }} to get the available data of the customer of an order.