How to show product visibility in product list



  • Expand the product list with the product visibility column.
    Either:
    Controller / Admin / AdminProductsController.php
    or override
    override / controllers / admin / AdminProductsController.php.

    Find the following codes and replace them.

    Step 1
    original

    $this->_select .= $aliasImage.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`';
    

    change to

    $this->_select .= $aliasImage.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, '.$alias.'.`visibility` AS `my_visibility`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`';
    

    step 2
    before

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

    add this

    $this->fields_list['my_visibility'] = [
            'title' => $this->l('Visibility'),
            'align' => 'left',
                'class' => 'fixed-width-xs',
                'align' => center,
                'havingFilter' => true,
                'filter_key' => 'my_visibility',
            ];
    

    If the text should be translated
    use this code

    $this->fields_list['my_visibility'] = [
            'title' => $this->l('Visibility'),
            'align' => 'left',
                'class' => 'fixed-width-xs',
                'align' => center,
                'havingFilter' => true,
                'filter_key' => 'my_visibility',
                'callback' => 'my_visibility_function',
            ];
    

    step 3

    after

            if ($joinCategory && (int) $this->id_current_category) {
                $this->fields_list['position'] = [
                    'title'      => $this->l('Position'),
                    'filter_key' => 'cp!position',
                    'align'      => 'center',
                    'position'   => 'position',
                ];
            }
        }
    

    add with your languages between <span> … </span> or change the style

    public static function my_visibility_function($my_visibility_function)
        {
            if ($my_visibility_function == 'both')
                return '<span style="background-color : #0b9819; color : #ffffff; border-radius : 2px/2px"> Sichtbar </span>';
            elseif ($my_visibility_function  == 'catalog')
                return '<span style="background-color : #009adf; color : #ffffff; border-radius : 2px/2px"> Katalog </span>';
            elseif ($my_visibility_function  == 'search')
                return '<span style="background-color : #0020df; color : #ffffff; border-radius : 2px/2px"> Suche </span>';
            else
                return '<span style="background-color : #6c6c6c; color : #ffffff; border-radius : 2px/2px"> Nein </span>';
        }
    

    Note, if a different language is used, the filter only works with the English terms.
    both - catalog - search - none

    images only german - sorry
    0_1518458322937_a10.png

    0_1518458339454_a11.png


Log in to reply
 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.