Jump to content

[SOLVED] Add backoffice columns products list


m3w

Recommended Posts

Hi,

i need help to add custom columns in product list in backoffice, what i'd like is get Features value and Manufacturer beside Category column.

 

I'm editing AdminProductsController.php and found:

$this->fields_list['id_manufacturer'] = array(
			'title' => $this->l('Manufacturer'),
			'align' => 'left',
			'width' => 40
						
		);

With this code i get the id of manufacturer, how can i get the name?

 

Hope someone can help to figured it out

  • Like 1
Link to comment
Share on other sites

open file: controllers/admin/AdminProductsController.php

 

you've got there $this->field_list definition:

	$this->fields_list = array();
		$this->fields_list['id_product'] = array(
			'title' => $this->l('ID'),
			'align' => 'center',
			'type' => 'int',
			'width' => 40
		);
		$this->fields_list['image'] = array(
			'title' => $this->l('Photo'),
			'align' => 'center',
			'image' => 'p',
			'width' => 70,
			'orderby' => false,
			'filter' => false,
			'search' => false
		);
		$this->fields_list['name'] = array(
			'title' => $this->l('Name'),
			'filter_key' => 'b!name'
		);
		$this->fields_list['reference'] = array(
			'title' => $this->l('Reference'),
			'align' => 'left',
			'width' => 80
		);

		if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP)
			$this->fields_list['shopname'] = array(
				'title' => $this->l('Default shop:'),
				'width' => 230,
				'filter_key' => 'shop!name',
			);
		else
			$this->fields_list['name_category'] = array(
				'title' => $this->l('Category'),
				'width' => 'auto',
				'filter_key' => 'cl!name',
			);
		$this->fields_list['price'] = array(
			'title' => $this->l('Base price'),
			'width' => 90,
			'type' => 'price',
			'align' => 'right',
			'filter_key' => 'a!price'
		);
		$this->fields_list['price_final'] = array(
			'title' => $this->l('Final price'),
			'width' => 90,
			'type' => 'price',
			'align' => 'right',
			'havingFilter' => true,
			'orderby' => false
		);
		if (Configuration::get('PS_STOCK_MANAGEMENT'))
			$this->fields_list['sav_quantity'] = array(
				'title' => $this->l('Quantity'),
				'width' => 90,
				'type' => 'int',
				'align' => 'right',
				'filter_key' => 'sav!quantity',
				'orderby' => true,
				'hint' => $this->l('This is the quantity available in the current shop/group.'),
			);
		$this->fields_list['active'] = array(
			'title' => $this->l('Status'),
			'width' => 70,
			'active' => 'status',
			'filter_key' => $alias.'!active',
			'align' => 'center',
			'type' => 'bool',
			'orderby' => false
		);

		if ($join_category && (int)$this->id_current_category)
			$this->fields_list['position'] = array(
				'title' => $this->l('Position'),
				'width' => 70,
				'filter_key' => 'cp!position',
				'align' => 'center',
				'position' => 'position'
			);

you can edit it, just remove / add new fields. everything depends on you :)

 

best regarads

  • Like 2
  • Thanks 2
Link to comment
Share on other sites

open file: controllers/admin/AdminProductsController.php

 

you've got there $this->field_list definition:

	$this->fields_list = array();
		$this->fields_list['id_product'] = array(
			'title' => $this->l('ID'),
			'align' => 'center',
			'type' => 'int',
			'width' => 40
		);
		$this->fields_list['image'] = array(
			'title' => $this->l('Photo'),
			'align' => 'center',
			'image' => 'p',
			'width' => 70,
			'orderby' => false,
			'filter' => false,
			'search' => false
		);
		$this->fields_list['name'] = array(
			'title' => $this->l('Name'),
			'filter_key' => 'b!name'
		);
		$this->fields_list['reference'] = array(
			'title' => $this->l('Reference'),
			'align' => 'left',
			'width' => 80
		);

		if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP)
			$this->fields_list['shopname'] = array(
				'title' => $this->l('Default shop:'),
				'width' => 230,
				'filter_key' => 'shop!name',
			);
		else
			$this->fields_list['name_category'] = array(
				'title' => $this->l('Category'),
				'width' => 'auto',
				'filter_key' => 'cl!name',
			);
		$this->fields_list['price'] = array(
			'title' => $this->l('Base price'),
			'width' => 90,
			'type' => 'price',
			'align' => 'right',
			'filter_key' => 'a!price'
		);
		$this->fields_list['price_final'] = array(
			'title' => $this->l('Final price'),
			'width' => 90,
			'type' => 'price',
			'align' => 'right',
			'havingFilter' => true,
			'orderby' => false
		);
		if (Configuration::get('PS_STOCK_MANAGEMENT'))
			$this->fields_list['sav_quantity'] = array(
				'title' => $this->l('Quantity'),
				'width' => 90,
				'type' => 'int',
				'align' => 'right',
				'filter_key' => 'sav!quantity',
				'orderby' => true,
				'hint' => $this->l('This is the quantity available in the current shop/group.'),
			);
		$this->fields_list['active'] = array(
			'title' => $this->l('Status'),
			'width' => 70,
			'active' => 'status',
			'filter_key' => $alias.'!active',
			'align' => 'center',
			'type' => 'bool',
			'orderby' => false
		);

		if ($join_category && (int)$this->id_current_category)
			$this->fields_list['position'] = array(
				'title' => $this->l('Position'),
				'width' => 70,
				'filter_key' => 'cp!position',
				'align' => 'center',
				'position' => 'position'
			);

you can edit it, just remove / add new fields. everything depends on you :)

 

best regarads

 

 

Thanks for the reply.

I know that is that part of code i have to work, infact i added this part of code inside it:

$this->fields_list['id_manufacturer'] = array(
			'title' => $this->l('Manufacturer'),
			'align' => 'left',
			'width' => 40
						
		);

This works, but print only the ID number, how can i show the manufacturer's name?

Link to comment
Share on other sites

so in this case you have to add new join to this:

	$this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.') 
				LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')';

LEFT JOIN manufacturers table (join based on id_manufacturer)

then in field definition use 'filter_key' => 'ALIAS!name', where ALIAS is manufacturers table alias

  • Like 1
Link to comment
Share on other sites

so in this case you have to add new join to this:

	$this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.') 
				LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')';

LEFT JOIN manufacturers table (join based on id_manufacturer)

then in field definition use 'filter_key' => 'ALIAS!name', where ALIAS is manufacturers table alias

 

i tried but with no luck.... can you please write me the correct LEFT JOIN?

Link to comment
Share on other sites

$this->_join .= ' INNER JOIN `'._DB_PREFIX_.'manufacturer` AS manu ON (manu.`id_manufacturer` = a.`id_manufacturer`) ';

+

 

$this->fields_list['manufacturer'] = array(
'title' => $this->l('Manufacturer name:'),
'width' => 230,
'filter_key' => 'manu!name',
);

=

 

 

TchKhKO.png

 

 

:)

  • Like 7
Link to comment
Share on other sites

  • 1 month later...

Hi,

I have a similar problem, but I am using the 1.4.8.2 version, and I can't find the AdminProductsController.php file anywhere.

 

My problem is that I have to add a column in which you can check or uncheck  (like the one for "displayed"), in order to make a product available or unavailable. (view image to see what settings I am talking about). Is that possible?

 

exemplu.jpg

Link to comment
Share on other sites

Hi,

I have a similar problem, but I am using the 1.4.8.2 version, and I can't find the AdminProductsController.php file anywhere.

 

My problem is that I have to add a column in which you can check or uncheck  (like the one for "displayed"), in order to make a product available or unavailable. (view image to see what settings I am talking about). Is that possible?

 

exemplu.jpg

I know this is not my topic, but please don't ignore my question. :)

Link to comment
Share on other sites

  • 2 weeks later...

Hi vekia!

I tried to add Producers column to my BO as you describe, but nothing change:-/ I have Prestashop 1.5.4.1. What could be wrong? I would like to column producers, and column with regular price or something which show me is this price is regular or pricedrop. Can you help me please?

Regards

Link to comment
Share on other sites

Hi vekia!

I tried to add Producers column to my BO as you describe, but nothing change:-/ I have Prestashop 1.5.4.1. What could be wrong? I would like to column producers, and column with regular price or something which show me is this price is regular or pricedrop. Can you help me please?

Regards

sorry it is a bit old thread, may i know what you exactly did?

Link to comment
Share on other sites

Hi vekia, thanks for your answer.

I would like to add producers tab in my BO as you describe in this topic.

I've put this code:

$this->fields_list['manufacturer'] = array(
'title' => $this->l('Manufacturer name:'),
'width' => 230,
'filter_key' => 'manu!name',
);

to controllers/admin/AdminProductsController.php but nothing was changed:-/ Can you tell me what should I do? I would like to add also tab which will show regular price (without price drop) or something like that. Is there a chance to do that?

Regards

Link to comment
Share on other sites

$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = a.id_shop_default)

LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = a.id_shop_default)

LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = a.id_shop_default) 

LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop=a.id_shop_default)';

}

$this->_select .= 'shop.name as shopname, ';

}

else

{

$alias = 'a';

$alias_image = 'i';

$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = 1)';

}

 

$this->_select .= 'MAX('.$alias_image.'.id_image) id_image,';

 

 

Somewhere there?:-)

Link to comment
Share on other sites

It works:-) Thank you:-). But there is one issue, if a product is not related to a producer is does not display in BO. Can it be fixed somehow? And can you help me with one more tab? I would like to add tab that will show if the product is in pricedrop or regular price. Or maybe table with regular price. I need to see which products are in pricedrop.

Best regards!

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

  • 1 month later...
  • 2 weeks later...
  • 4 weeks later...
  • 3 weeks later...

Any help?

to fields list add

        $this->fields_list['product_supplier_reference'] = array(
			'title' => $this->l('Suuplier Reference'),
			'filter_key' => 'supp!product_supplier_reference'
		);

k01UCAk.png

 

 

and extend query with this left join:

LEFT JOIN `'._DB_PREFIX_.'product_supplier` supp ON sa.id_product = supp.id_product

effect:

 

Link to comment
Share on other sites

to fields list add

        $this->fields_list['product_supplier_reference'] = array(
			'title' => $this->l('Suuplier Reference'),
			'filter_key' => 'supp!product_supplier_reference'
		);

k01UCAk.png

 

 

and extend query with this left join:

LEFT JOIN `'._DB_PREFIX_.'product_supplier` supp ON sa.id_product = supp.id_product

effect:

 

 Thank you so much! That worked!

Link to comment
Share on other sites

I realize this table don't always store all supplier reference because some attributes are 0. There is another table which contains more accurate data.

 

How do I get supplier_reference field of ps_product_attribute table instead? I tried replacing the table and fields using your solution but keep getting 

 

  • Bad SQL query
    Column 'reference' in field list is ambiguous

 

 

Any help would be great!

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

The exact same code you recommended, just that I swap the table and fields accordingly. That apparently didn't work.

$this->fields_list['supplier_reference'] = array(
            'title' => $this->l('Suplier Reference'),
            'filter_key' => 'supp!supplier_reference'
        );
LEFT JOIN `'._DB_PREFIX_.'product_attribute` supp ON sa.id_product = supp.id_product
Link to comment
Share on other sites

Ehi Vekia!Sorry for the question,

 

but if i want to show an icon if in the order there is a NOTE, how can i do?!

$this->fields_list['herewhatdoIput?!'] = array(
            'title' => $this->l('herewhatdoIput?!'),
            'width' => 40
                        
        
);

Link to comment
Share on other sites

I have a area "bigimage" in my database (ps_image)

 

"bigimage" is tinyint(1), inside have just "0" or "1".  And basicly i use that value to make photo bigger size (1) or normal size (0).

 

I just want to change the "bigimage" value in database from that product-list on backoffice. Just like green "status" button. I know how to add a column to show a data but i dont know how to do that. Do you know?

 

 

CIClGVD.jpg

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

  • 3 weeks later...

Hello,

 

I would like to ask you for extending your solution.

 

I am using Prestashop 1.5.6 with products combinations.

So for one product with ID 18 for example i have 3 supplier_references and i would like to see all of them in product list and best way to show them also in search list.

 

Thank you very much

 

to fields list add

        $this->fields_list['product_supplier_reference'] = array(
			'title' => $this->l('Suuplier Reference'),
			'filter_key' => 'supp!product_supplier_reference'
		);

k01UCAk.png

 

 

and extend query with this left join:

LEFT JOIN `'._DB_PREFIX_.'product_supplier` supp ON sa.id_product = supp.id_product

effect:
 

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys,

 

i am successful to integrate the column CATEGORY, with this code in AdminOrderController:

 

$this->_select = '
		a.id_currency,
		a.id_order AS id_pdf,
		CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
		osl.`name` AS `osname`,
		os.`color`,
        od.`product_reference`,
        cl.`name` AS `cat_name`,
		IF((SELECT COUNT(so.id_order) FROM `' . _DB_PREFIX_ . 'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
		GROUP_CONCAT(od.product_name separator \', \') as products';

        $this->_join = '
		LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON (c.`id_customer` = a.`id_customer`)
		LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON (os.`id_order_state` = a.`current_state`)
		LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = ' . (int)$this->context->language->id . ')
		LEFT JOIN `'._DB_PREFIX_. 'order_detail` od ON (od.id_order = a.id_order )
        LEFT JOIN `'._DB_PREFIX_. 'product` p ON (p.id_product = od.product_id )
        LEFT JOIN `'._DB_PREFIX_. 'category_lang` cl ON (cl.id_category = p.id_category_default )';
        $this->_orderBy = 'id_order';
        $this->_orderWay = 'DESC';
        $this->_group = 'GROUP BY a.id_order';

        $statuses_array = array();
        $statuses = OrderState::getOrderStates((int)$this->context->language->id);

        foreach ($statuses as $status)
            $statuses_array[$status['id_order_state']] = $status['name'];

        $this->fields_list = array(
            'id_order' => array(
                'title' => $this->l('ID'),
                'align' => 'center',
                'width' => 25
            ),
            'reference' => array(
                'title' => $this->l('Reference'),
                'align' => 'center',
                'width' => 65
            ),
            'product_reference' => array(
                'title' => $this->l('Reference'),
                'align' => 'center',
                'width' => 65
            ),
            'new' => array(
                'title' => $this->l('New'),
                'width' => 25,
                'align' => 'center',
                'type' => 'bool',
                'tmpTableFilter' => true,
                'icon' => array(
                    0 => 'blank.gif',
                    1 => array(
                        'src' => 'note.png',
                        'alt' => $this->l('First customer order'),
                    )
                ),
                'orderby' => false
            ),
            'customer' => array(
                'title' => $this->l('Customer'),
                'havingFilter' => true,
            ),
            //viewproductsoforder
            'products' => array(
                'title' => $this->l('Products'),
                'align' => 'center',
                'width' => 150,
                'filter_key' => 'od!product_name'
            ),
             'cat_name' => array(
                'title' => $this->l('Categoria'),
                'align' => 'center',
                'width' => 100
            ),
            'gift' => array(
                'title' => $this->l('Fattura'),
                'havingFilter' => true,
                'align' => 'center',
                'icon' => array(
                    0 => 'blank.gif',
                    1 => array(
                        'src' => 'note.png',
                        'alt' => $this->l('Richiede Fattura'),
                    )
                ),
                
                'width' => 35
            ),
          

            'total_paid_tax_incl' => array(
                'title' => $this->l('Total'),
                'width' => 70,
                'align' => 'right',
                'prefix' => '<b>',
                'suffix' => '</b>',
                'type' => 'price',
                'currency' => true
            ),
            'payment' => array(
                'title' => $this->l('Payment: '),
                'width' => 100
            ),
            'osname' => array(
                'title' => $this->l('Status'),
                'color' => 'color',
                'width' => 280,
                'type' => 'select',
                'list' => $statuses_array,
                'filter_key' => 'os!id_order_state',
                'filter_type' => 'int'
            ),
            'date_add' => array(
                'title' => $this->l('Date'),
                'width' => 130,
                'align' => 'right',
                'type' => 'datetime',
                'filter_key' => 'a!date_add'
            ),
            'id_pdf' => array(
                'title' => $this->l('PDF'),
                'width' => 35,
                'align' => 'center',
                'callback' => 'printPDFIcons',
                'orderby' => false,
                'search' => false,
                'remove_onclick' => true),
        );

But in the order list, the product is repeated 6 times!Where is my error?


 

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

  • 1 month later...

Sorry for digging up this topic but i'm trying to do the same on PS 1.6 but the width parameter is not working. Whatever i put as width is not taken into account.

You can find below my code as i can't seem to find anything related to this for PS 1.6.

class AdminFormulaireController extends ModuleAdminController
{    

    public function __construct()
    {

        $this->table = 'formulaire';
        $this->className = 'Formulaire';

        $this->fields_list = array();
        $this->fields_list['id_formulaire']= array(
            'title' => 'id_formulaire',
            'width' => 25);
        $this->fields_list['id_customer']= array(
                'title' => 'ID Client',
                'width' => 'auto');
        $this->fields_list['Prix']= array(
                'title' => 'Prix HT',
                'width' => 40);
        $this->fields_list['desc']= array(
                'title' => 'Description',
                'width' => 50);
        
        $this->identifier='id_formulaire';
        $this->simple_header=false;
        $this->actions = array('delete','view','edit');
    
        parent::__construct();
    }
    
 
}

And when i look into AdminProductsController.php, i cannot find any width parameter for the fields_list. Here's part of the code

		$this->fields_list = array();
		$this->fields_list['id_product'] = array(
			'title' => $this->l('ID'),
			'align' => 'center',
			'class' => 'fixed-width-xs',
			'type' => 'int'
		);
		$this->fields_list['image'] = array(
			'title' => $this->l('Photo'),
			'align' => 'center',
			'image' => 'p',
			'orderby' => false,
			'filter' => false,
			'search' => false
		);

Found the solution here in french. Now we have to use bootstrap classes to do it.

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

  • 1 month later...

Hi vekia,

 

How to sort the product listing page using reference ? in the reference field i am giving the number only, but it is not sorting properly. i have attached the screen shot. in the screen shot you can see after the number 1 it shows the product with the number 10 not 2 . whether i need to change the reference field type to int ?

post-453398-0-21769200-1405409300_thumb.png

Link to comment
Share on other sites

i have not modified any code in adminproductscontroller,  the sorting through reference no is already part of prestashop. i have found out the reference datatype is varchar so that it is not sorting while giving numbers, and i changed the datatype of reference field to int and it  sorts correctly, if i am not filling the reference field i am getting 0 filled automatically, how to avoid that ? is this method correct or through coding i need to change ?

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

 

Hello, 

 

I need to bring in the list "Condition" but if i add this code:

 

$this->fields_list['condition'] = array(
'title' => $this->l('Condition'),
'align' => 'left',
'width' => 40
 
);
 
its not workin! Any idea? 

 

 

can you show a whole part of fields_list ?

how it looks like with code that you applied?

Link to comment
Share on other sites

  • 2 weeks later...

Please vekia help. If we add product with no selected manufacturers. and go to product list, we cant see the new added product. Can modification something to get it work, because some product with no selected manufacturers cant viewed in product list.

 

can you please show what exactly you modified?

and also in what ps verison

Link to comment
Share on other sites

can you please show what exactly you modified?

and also in what ps verison

 

Thanks Vekia. im use prestashop 1.6.0.8 and in backoffice we adding manufacturer on product list and last update product with display time,  

Did you try for adding new product with no manufacturers selected and you can see product list in admin product?

Link to comment
Share on other sites

  • 1 month later...
  • 4 months later...

Sorry to bring up and old topic, but this was the closest match to what I want to accomplish, but can't quite get it to work.

 

I would like to add a column in the back office products section to search and filter by EAN13 code. I've successfully tried and added the Supplier column, but not sure what code I need to enter to show the EAN13 column. 

 

Can you help?

 

Version 1.5.6.1

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

hello,

 

I hope I'm in the right topic. I'm looking at my BO catalog > products, and I would like to see the Suppliers name in there, for every product. When I've imported the products, I have named the supplier in Supplier reference as: ABCDATA, NOD, ROYAL and so on.

 

Can I display this field in the desired area, and if so, how ?, attached an image in order for a better understanding.

supplier.jpg

P.S. - the shop is in Romanian Language.

 

 

Thank you

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

  • 1 month later...

Hi,

I having a problem after adding a new column to my product list. I'm using prestashop 1.5.4.0.

For the new column, I edited the AdminProductsController.php file and I manage to get the column that I want, but then I realise that after save new product details, my screen goes blank, reload page will give same blank page and I need to go back one page for the product list page. I figured that my AdminProductsController.php file cannot be edited, even a space added to the file will cause the same blank space after save new product detail. Only when I inserted the original file that i didn't encountered the blank page. Hope you can help with my problem.

Thank You.

Link to comment
Share on other sites

Hi all

 

I'm trying to add a column with Supplier reference to the products table in AdminSearchController, to be displayed when you search for a product in the BO (using the search box at the top of the panel).

I have successfully added the column, but the column only shows '--' where i want the values to be displayed.

I have modified AdminSearchController.php to add the column, but I don't know what to modify for displaying the values. I'm guessing AdminProductsController.php?

 

Vekia provided some code for adding the supplier reference to product_list, but I need it in the search results page.

 

Please can someone help?

Link to comment
Share on other sites

  • 2 months later...

Hi, i need to add to my backoffice the column with the field date_add of the table ps_product. but when i try to do this i receive the message: " prestashop Column 'date_add' in field list is ambiguous "

what can i do? thank you

Link to comment
Share on other sites

No work on my version, 1.5.4.1

to fields list add

        $this->fields_list['product_supplier_reference'] = array(
			'title' => $this->l('Suuplier Reference'),
			'filter_key' => 'supp!product_supplier_reference'
		);

k01UCAk.png

 

 

and extend query with this left join:

LEFT JOIN `'._DB_PREFIX_.'product_supplier` supp ON sa.id_product = supp.id_product

effect:
 

Link to comment
Share on other sites

I have similar problem like m2net, but with column advanced_stock_management. I know cause of this problem. But I dont know how can I add alias like a.advanced_stock_management into sql query.

 

Code:

$this->fields_list['advanced_stock_management'] = array(
'title' => $this->l('Advanced stock'),
'align' => 'text-center',
'filter_key' => $alias.'!advanced_stock_management',
'class' => 'fixed-width-sm'
);

 

Error: Column 'advanced_stock_management' in where clause is ambiguous

 

Sql query:

SELECT SQL_CALC_FOUND_ROWS			a.`id_product`,b.name as name,`reference`,a.price as price,sa.active as active			, shop.name as shopname, a.id_shop_default, MAX(image_shop.id_image) id_image, cl.name `name_category`, sa.`price`, 0 AS price_final, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` as sav_quantity, sa.`active`, sa.`advanced_stock_management`, IF(sav.`quantity`<=0, 1, 0) badge_danger			FROM `ps_product` a			LEFT JOIN `ps_product_lang` b ON (b.`id_product` = a.`id_product` AND b.`id_lang` = 2 AND b.`id_shop` = 1)					LEFT JOIN `ps_image` i ON (i.`id_product` = a.`id_product`)		LEFT JOIN `ps_stock_available` sav ON (sav.`id_product` = a.`id_product` AND sav.`id_product_attribute` = 0		 AND sav.id_shop = 1  AND sav.id_shop_group = 0 )  JOIN `ps_product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = a.id_shop_default)				LEFT JOIN `ps_category_lang` cl ON (sa.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = a.id_shop_default)				LEFT JOIN `ps_shop` shop ON (shop.id_shop = a.id_shop_default)				LEFT JOIN `ps_image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop = a.id_shop_default)				LEFT JOIN `ps_product_download` pd ON (pd.`id_product` = a.`id_product`) 						WHERE 1  AND `advanced_stock_management` = 1			GROUP BY sa.id_product
Link to comment
Share on other sites

I solved my problem. The correct code (for me) is:

        $this->fields_list['product_supplier_reference'] = array(
            'title' => $this->l('Supplier Reference'),
            'filter_key' => 'supp!product_supplier_reference'
        );

And the querry
 

$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_supplier` supp ON a.`id_product` = supp.id_product ';
Edited by Krauser (see edit history)
Link to comment
Share on other sites

  • 1 month later...

has anyone ever managed to show multiple columns of product features?

 

In AdminProductsController.php I have:

		$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON (fp.`id_product` = a.`id_product` AND fp.`id_feature` = '.ID_FEATURE.') ';
		$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` fl ON (fp.`id_feature_value` = fl.`id_feature_value` AND b.`id_lang` = fl.`id_lang`) ';
		
		$this->fields_list['feature'] = array(
		'title' => $this->l('Artist'),
		'width' => 100,
		'filter_key' => 'fl!value',
		);

But when you have more than 1 feature, it lists each product twice or 3 times (depending how many features there are). Ideally we'd like to have 1 column per feature and only show the same product on 1 single line.

 

How do I add more columns for each feature?

 

Thank you PS community!

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

Hi guys, I wanted to display features and features values in backoffice, but stuck with it... maybe somebody?

 

$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON (fp.`id_product` = a.`id_product` AND fp.`id_feature` = '.ID_FEATURE.') ';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` fl ON (fp.`id_feature_value` = fl.`id_feature_value` AND b.`id_lang` = fl.`id_lang`) ';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'feature_lang` fgf ON (fp.`id_feature` = fgf.`name` AND b.`id_lang` = fgf.`id_lang`) ';




$this->fields_list['fgfname'] = array(
'title' => $this->l('WarCecha'),
'width' => 100,
'filter_key' => 'fgf!name',
);
$this->fields_list['feature'] = array(
'title' => $this->l('Cecha'),
'width' => 100,
'filter_key' => 'fl!value',
);
Link to comment
Share on other sites

  • 3 weeks later...

I was able to enter all the required columns to the list of orders in the back office. But I can not figure out how to add the date of the last order status if it has as ID = 7.

 
I want to show the order list the date of the state "refunded", because it would be a comfortable viewing while watching the orders list.
 
You can do? Can you help?
 
 
Thanks again in advance.
Link to comment
Share on other sites

ok, i am solved, but it shows only the first date of status:

 

_______

LEFT JOIN `'._DB_PREFIX_. 'order_history` max2 ON (max2.id_order = a.id_order)


//viewproductsoforder
            'datastato' => array(
                'title' => $this->l('Datastato'),
                'align' => 'center',
                'width' => 50,
                'filter_key' => 'max2.date_add', 
'orderby' => 'true'
            ),
 
 
Instead i want only the last date of status. How can I correct?
Link to comment
Share on other sites

no, I'm wrong, because I need the redemption request date which is has a specific id in my prestashop, ID = 31.
 
So if the order status is ID = 31, then write the date.
 
 
Or...
 
 
also it goes very well with the date of the last state that has associated the order.
 

 

So write only the date of the last was associated with the order.
 
 
Please help me
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
  • 3 weeks later...

Hello! 

 

I would like to add supplier reference on the product list in back office. My version of PS is 1.6.1.5 and I would like to make these change so they don't disappear next time I upgrade. 

 

I have tried the code that was in this post but I did not manage to get it to work. Perhaps there is a module for this? Appreciate any help!

Link to comment
Share on other sites

AdminProductsController.php

add

LEFT JOIN `'._DB_PREFIX_.'product_supplier` ps ON (ps.`id_product` = a.`id_product`) 
to the end of:

 

        $this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_product` = a.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_image` = image_shop.`id_image`)
				LEFT JOIN `'._DB_PREFIX_.'product_download` pd ON (pd.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_supplier` ps ON (ps.`id_product` = a.`id_product`)
                 ';
and add new field to display

        $this->fields_list['product_supplier_reference'] = array(
            'title' => $this->l('Supplier Reference'),
            'align' => 'left',
        );

+

 

if you use combinations - add group by clause:

$this->_group = 'group by a.id_product';
Link to comment
Share on other sites

AdminProductsController.php

add

LEFT JOIN `'._DB_PREFIX_.'product_supplier` ps ON (ps.`id_product` = a.`id_product`) 
to the end of:

 

        $this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_product` = a.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')
				LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_image` = image_shop.`id_image`)
				LEFT JOIN `'._DB_PREFIX_.'product_download` pd ON (pd.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_supplier` ps ON (ps.`id_product` = a.`id_product`)
                 ';
and add new field to display

        $this->fields_list['product_supplier_reference'] = array(
            'title' => $this->l('Supplier Reference'),
            'align' => 'left',
        );
+

 

if you use combinations - add group by clause:

$this->_group = 'group by a.id_product';

 

When I made these changes I get an "HTTP ERROR 500" when I try to access the product list in the Catalog tab in back office. The rest of the back office works fine. What could I have done wrong?

Link to comment
Share on other sites

  • 4 weeks later...

Hello to everybody,

 

 

I would like to add a column in the back office related to the Price of Sale to Public. Now what I have is two columns:

 

The first one shows me our purchase price, and the second one the Price of Sale to Public. I am using the 1.6.1.5 version and this is what I have added:

 

 $this->fields_list['wholesale_price'] = array(
            'title' => $this->l('Precio tienda'),
            'type' => 'price',
            'align' => 'text-left',
            'filter_key' => 'a!wholesale_price'
        );
        $this->fields_list['price'] = array(
            'title' => $this->l('PVP'),
            'type' => 'priceTI',
            'align' => 'text-left',
            'havingFilter' => true,
            'orderby' => true,
            'search' => true,
        );

 

The problem is that the second one shows the Price but without taxes and i need the Price of Sale to Public (taxes included)

 

Thank you so much,

Link to comment
Share on other sites

  • 1 month later...

I'm trying to add one column and i can't see it on list. Sql is changing but adding next position on key to fields_list array nothing is changing.  I want add auto_update_price column PS 1.6.1.2

$this->fields_list['auto_update_price'] = array(
            'title' => $this->l('ID'),
            'align' => 'center',
            'class' => 'fixed-width-xs',
            'type' => 'bool',
	    'orderby' => false,
            'filter' => false,
            'search' => false
        );
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hi everyone. I could to add a field in the table and it displays correctly :) but i have an issue that it sicks me :(.. In the case that i display the field, the table displays correctly, but in the case it doesn't, the line for "Filters" doesn't show up.

 

I was researching in the view (list_header.tpl) and when it constructs the table with the fields received from the controller, i see a variable called "$show_filters" that in this case, its value is "false" and i don't know why..

 

Any help?

 

Capture.png

 

Thanks! :)

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