Prestashop: CartControllerCore tpl_var 'cart' is overrided by parent 'cart'

Created on 4 Jun 2019  路  4Comments  路  Source: PrestaShop/PrestaShop

Describe the bug
As you can see, parent is called on the end.

```
//CartController.php
/**
* @see FrontController::initContent()
*/
public function initContent()
{
//..
$presenter = new CartPresenter();
$presented_cart = $presenter->present($this->context->cart, $shouldSeparateGifts = true);

    $this->context->smarty->assign([
        'cart' => $presented_cart,
        'static_token' => Tools::getToken(false),
    ]);

//..
parent::initContent();
}

On the end  FrontendController::initContent is called, and it call 
assignGeneralPurposeVariables, overriding 'cart'.

  ```
// FrontController.php
  protected function assignGeneralPurposeVariables()
    {
        $templateVars = array(
            'cart' => $this->cart_presenter->present($this->context->cart),
            'currency' => $this->getTemplateVarCurrency(),
            'customer' => $this->getTemplateVarCustomer(),
            'language' => $this->objectPresenter->present($this->context->language),
            'page' => $this->getTemplateVarPage(),
            'shop' => $this->getTemplateVarShop(),
            'urls' => $this->getTemplateVarUrls(),
            'configuration' => $this->getTemplateVarConfiguration(),
            'field_required' => $this->context->customer->validateFieldsRequiredDatabase(),
            'breadcrumb' => $this->getBreadcrumb(),
            'link' => $this->context->link,
            'time' => time(),
            'static_token' => Tools::getToken(false),
            'token' => Tools::getToken(),
        );

//..
        $this->context->smarty->assign($templateVars);
//..
    }

that mean that this smarty->assign from CartController do nothing.

Possible chained bug?
none known

How to fix?
just move that parent::initContent() on the top o the CartControllerCore::initContent() function

1.7.5.2 1.7.6.0 Bug CO No change required

Most helpful comment

Up :)

All 4 comments

Hi @Bonobomagno,

Thanks for your report.
Ping @PrestaShop/prestashop-core-developers what do you think?

Thanks!

Up :)

Feel free to create a pull request, we will be happy to review and merge it :)

Hello @Bonobomagno ,
Since we had no news from you for more than 30 days, I'll close this ticket to avoid cluttering up the backlog. Please note that you can always create a new one if further information pops up.
Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vincent-dp picture vincent-dp  路  3Comments

centoasa picture centoasa  路  3Comments

matks picture matks  路  3Comments

Prestaworks picture Prestaworks  路  3Comments

sandra2n picture sandra2n  路  3Comments