Jump to content

How do I find the Smarty variables assigned in a template?


rkk

Recommended Posts

Is there a way to get a comprehensive look at all the variables assigned in loaded template?

I've tried {debug} in different places but it doesn't go deep enough to show me the variables I need.

For example, I want to see all variables assigned under the $product array. I can see $product.description referenced in the template, so I know there are more attributes of $product to work with.

In themes/x/templates/catalog/product.tpl I put {debug} in the product_table block. The smarty debug console comes up, but only shows me: 

$product

Array (2)
value => PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingLazyArray Object (0)
scope => "module:ps_featuredproducts/views/temp..."

It doesn't even show that $product.description exists, even though it's defined in the template.

How can I make {debug} more robust so I can see more? Something like a print_r($product); but for Smarty?

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

Hi,

You can try this :  {$product|@var_dump}

working on Smarty / Prestashop 1.7

For example, on a foreach loop :

{foreach from=$listing.products item=product}

          {$product|@var_dump}

{/foreach}

You will get all informations about $product Object, instead of a single value "PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingLazyArray Object"

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...