Jump to content

Modifier liste produit admin


Recommended Posts

Bonjour,

 

J'aimerai modifier l'affichage de la liste produit en admin. J'ai trouvé le controller qui se charge de l'affichage, je vois comment ça marche pour ajouter un champ, j'ai d'ailleurs pu ajouter la marque des produit sans souci.

Mon blocage est pour un affichage plus poussé, afficher le résultat d'un calcul par exemple (vente HT/achat HT*100) ou pour afficher le fil de catégorie du produit avec les 3 premières lettres ( CAU/JUF/BAT).

 

Comment je peux faire ça?

 

Romain.

Link to comment
Share on other sites

Dans la liste produit en admin (voir image jointe)

 

Pour le calcul et le fil de catégorie l'objectif est d'avoir un accès rapide à l'information, et pouvoir l'exporter facilement.

 

Pour le fil de catégorie si tu as un produit dans la catégorie suivante

(fil d’Ariane) Randonnée -> Chaussure -> Homme ->Mon produit

Je voudrai afficher RAN/CHA/HOM dans la colonne catégorie.

 

Romain.

post-386580-0-85039500-1370333751_thumb.png

Link to comment
Share on other sites

  • 3 months later...

Bonjour,

 

J'aimerai modifier l'affichage de la liste produit en admin. J'ai trouvé le controller qui se charge de l'affichage, je vois comment ça marche pour ajouter un champ, j'ai d'ailleurs pu ajouter la marque des produit sans souci.

Mon blocage est pour un affichage plus poussé, afficher le résultat d'un calcul par exemple (vente HT/achat HT*100) ou pour afficher le fil de catégorie du produit avec les 3 premières lettres ( CAU/JUF/BAT).

 

Comment je peux faire ça?

 

Romain.

Bonjour Romain

 

je suis preneur de tes pistes car je ne trouve pas ou je dois faire mes modifs pour simplement ajouter une colonne Coef dans la liste des produits de l'admin...

Cerise sur le gateau si en plus j'ai la possibilité de trier par cette nouvelle colonne.... ca serait top.

 

Mais impossible de trouver quel script ou quel tpl doit être modifié!!!

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

Pas de problème!

Il faut que tu surcharge la classe AdminProductsController, pour savoir comment surcharger lit ça http://doc.prestashop.com/display/PS15/Overriding+default+behaviors )

La propriété qui est utilisé pour l'affichage de la liste est "field_list"

 

Pour mon cas ça donne ça pour la surchage :

class AdminProductsController extends AdminProductsControllerCore {

    public function __construct() {
        parent::__construct();
        if (Shop::isFeatureActive()) {
            $alias = 'sa';
        } else {
            $alias = 'a';
        }
        $this->fields_list = array();
        $this->fields_list['id_product'] = array(
            'title' => $this->l('ID'),
            'align' => 'center',
            'width' => 20
        );
        $this->fields_list['image'] = array(
            'title' => $this->l('Photo'),
            'align' => 'center',
            'image' => 'p',
            'width' => 70,
            'orderby' => false,
            'filter' => false,
            'search' => false
        );
        $this->fields_list['reference'] = array(
            'title' => $this->l('Reference'),
            'align' => 'left',
            'width' => 80
        );

        $this->fields_list['name'] = array(
            'title' => $this->l('Name'),
            'filter_key' => 'b!name'
        );
        $this->fields_list['name_manufacturer'] = array(
            'title' => $this->l('Marque'),
            'filter_key' => 'man.name',
            'search' => true,
            'filter_key' => 'man!name',
        );

        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['id_category'] = array(
                'title' => $this->l('Category'),
                'width' => 'auto',
                'filter_key' => 'cl!name',
                'callback' => 'fil_category',
                'search' => false,
            );
        $this->fields_list['wholesale_price'] = array(
            'title' => 'Achat HT',
            'width' => 90,
            'type' => 'price',
            'align' => 'right',
            'filter_key' => 'a!wholesale_price'
        );
        $this->fields_list['price_final'] = array(
            'title' => 'Vente TTC',
            'width' => 90,
            'type' => 'price',
            'align' => 'right',
            'havingFilter' => true,
            'orderby' => true,
            'filter_key' => $alias . '!price',
        );
        $this->fields_list['product_marge'] = array(
            'title' => $this->l('Marge'),
            'callback' => 'marge',
            'search' => false,
        );
        $this->fields_list['sav_quantity'] = array(
            'title' => $this->l('Quantity'),
            'width' => 90,
            '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
        );
        $this->fields_list['corrige'] = array(
            'title' => $this->l('Corrigé'),
            'width' => 70,
            'active' => 'corrige',
            'filter_key' => $alias . '!corrige',
            'align' => 'center',
            'type' => 'bool',
            'orderby' => false
        );

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

    public function marge($price) {
        return number_format($price, 2) . '%';
    }

    public function fil_category($id_category) {
        $categFil = '';
        $category = new CategoryCore($id_category);
        $categFil = substr(mb_strtoupper($category->name[1], 'UTF-8'), 0, 3) . $categFil;
        $id_category = $category->id_parent;
        $category = new CategoryCore($id_category);
        $categFil = substr(mb_strtoupper($category->name[1], 'UTF-8'), 0, 3) . '/' . $categFil;
        $id_category = $category->id_parent;
        $category = new CategoryCore($id_category);
        $categFil = substr(mb_strtoupper($category->name[1], 'UTF-8'), 0, 3) . '/' . $categFil;
        $id_category = $category->id_parent;
        return $categFil;
    }
}

Attention, lorsque tu créé une nouvelle classe de surcharge, pense à supprimer le fichier /cache/class_index.php pour que presta détecte bien la présence de ta classe.

 

Là tu as tout ce dont tu as besoin.

 

Romain.

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