Prestashop Ajax显示已分配的模板变量

How do I display the "assigned template variables" inside a displayajax() function (I am using prestashop 1.5.6.0).

If you go to:

sitedomain/index.php?id_product=1&controller=product you see the product

but if you go to:

sitedomain/index.php?id_product=1&controller=product&ajax=true you see a blank page

to have some output in that page I added this function in ProductController.php and it works:

public function displayAjax()
{
    echo "something";
}

How can I access all the "assigned template variables" that I see usually in the debug console of prestashop...like $combinations $groups...

Thank you!

The assigned template variables can be returned via the following code:

$this->context->smarty->getTemplateVars();

or if you need a specific variable:

$this->context->smarty->getTemplateVars('combinations');

the method getTemplateVars() returns those variables, so you may dump it with the standard function:

var_dump($this->context->smarty->getTemplateVars());

you can add this at the displayAjax() method.

You can also call the debug window if the debug param is set (by default SMARTY_DEBUG) so url like

index.php?id_product=1&controller=product&ajax=1&SMARTY_DEBUG

with the following displayAjax():

public function displayAjax()
{
    $this->context->smarty->display($this->context->smarty->getDebugTemplate());
}

will popup the window.

    public function displayAjax()
    {
        $array= $this->context->smarty->tpl_vars['combinations'];
        foreach($array as $k => $v)
        {
            //some code
        }
    }