Jump to content

Custom fields exist only in product.tpl


dmikhaylov

Recommended Posts

I added custom field to my Product class:

    class Product extends ProductCore {
    public $pills_per_blister;
    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) {
        self::$definition['fields']['pills_per_blister'] = array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId');
        parent::__construct($id_product, $id_lang, $id_shop, $context);
    }
}


But now I can see this field added to product only on product page, not on product list page.

Link to comment
Share on other sites

Well code you provided, would tie together database field and ensure certain validation on field.
You still have to manually display it where needed.
 
For example to display in admin product list (override/controllers/admin/AdminProductsController.php):

<?php

class AdminProductsController extends AdminProductsControllerCore
{

    public function __construct()
    {
        parent::__construct();

        // php >= 5.4
        //$this->fields_list['pills_per_blister'] = ['title' => $this->l('My Extra Field')];
        
        // php < 5.4
        $this->fields_list['pills_per_blister'] = array('title' => $this->l('My Extra Field'));
    }

}
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...