Jump to content

Supplier ID smarty en ProductController


cyberespia

Recommended Posts

I need to get the SUPPLIER ID, for this I add the following to:

 

 

In /controllers/front/ProductController.php

'product_supplier' => new Supplier((int)$this->product->id_supplier, $this->context->language->id),

just after:

'product_manufacturer' => new Manufacturer((int)$this->product->id_manufacturer, $this->context->language->id),

With this I can already use {$product_supplier->id} in product.tpl

 

 

What I need is this change but in /override/ folder.

 

I've tried the following code in /override/controllers/front/ProductController.php  but it did not work 

<?php

class ProductControllerCore extends FrontController
{

    public function initContent()
    {


            $this->context->smarty->assign(array(
				'product_supplier' => new Supplier((int)$this->product->id_supplier, $this->context->language->id),
            ));

        
        $this->setTemplate(_PS_THEME_DIR_.'product.tpl');
    }



}

I would appreciate any help in this regard.

Edited by cyberespia (see edit history)
Link to comment
Share on other sites

Sorry I didn't understand well. Something like that should work

<?php
class ProductController extends ProductControllerCore
{

	public function initContent()
	{
		parent::initContent();
		if (!$this->errors)
		{
			$product_supplier = new Supplier((int)$this->product->id_supplier, $this->context->lang->id);
                        $this->context->smarty->assign('product_supplier', $product_supplier);
		}
	}
	

}

and delete the file

cache/class_index.php
Link to comment
Share on other sites

 

Sorry I didn't understand well. Something like that should work

<?php
class ProductController extends ProductControllerCore
{

	public function initContent()
	{
		parent::initContent();
		if (!$this->errors)
		{
			$product_supplier = new Supplier((int)$this->product->id_supplier, $this->context->language->id);
                        $this->context->smarty->assign('product_supplier', $product_supplier);
		}
	}
	

}

and delete the file

cache/class_index.php

 

Thank you very much, it has worked properly, only a small correction:

lang->id must be language->id
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...