Filter Products By Manufacturer in the PrestaShop Back Office

In this PrestaShop Tutorial, we will add a column to filter by manufacturer, in the back office Products Catalog

Watch the Screencast

Text Version

This tutorial applies the same method used in the previous one to Filter by country in the PrestaShop Order list.

Open up AdminProductsController.php located in controllers/admin. You can either modify the original or create an override for it.

Locate the following join, at around line 179, inside the construct method

        $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`)';

Before the last line, join the manufacturer table:

        $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_.'manufacturer` m ON (m.`id_manufacturer` = a.`id_manufacturer`)
                LEFT JOIN `'._DB_PREFIX_.'product_download` pd ON (pd.`id_product` = a.`id_product`)';

Next, right after that join, let’s select the manufacturer name, giving it an alias so that it does not conflict with the product name:

$this->_select .= 'm.`name` AS `manufacturer_name`, ';

Lastly, we need to add the manufacturer name as column, in the products list. I added it right before $this->fields_list[‘name’]:

$this->fields_list['manufacturer_name'] = array(
            'title' => $this->l('Manufacturer'),
            'filter_key' => 'm!name',
            'orderby' => true,
        );

Save and refresh.
We are done!

You like the tuts and want to say "thank you"? Well, you can always feel free to donate:

  • Yes

    Is is available to override controllers in PS. So it would be marvelous if you add an explanation to your article how to make this with overrides and without changing core files. Thank you.

You like the tuts and want to say "thank you"? Well, you can always feel free to donate: