Jump to content

Bouton details sur la liste des produits back office


Recommended Posts

Bonjour,

 

J'aimerai dans Catalogue -> Produits, c'est-à-dire sur la liste des produits afficher lorsque je clique sur le bouton details (que j'ai rajouter mais qui ne fait rien pour le moment), afficher la liste des fournisseurs tout en pouvant gérer leur position (à l'image de AdminAttributesGroups).

 

Ca doit être dans ajaxProcessDetails mais je ne vois pas comment démarrer ..

Link to comment
Share on other sites

Bon, j'ai un "peu" avancé sur mon problème. Au lieu de vouloir des infos sur les fournisseurs (comme indiqué précédemment) j'aimerai avoir des infos sur les activités.

 

Voici mon code de AdminProductsController :

public function renderList() {
        $this->addRowAction('edit');
        $this->addRowAction('duplicate');
        $this->addRowAction('delete');
        $this->addRowAction('details');

        return parent::renderList();
    }

    /**
     * method call when ajax request is made with the details row action
     * @see AdminController::postProcess()
     */
    public function ajaxProcessDetails() {
        if (($id = Tools::getValue('id'))) {
        $this->table = 'product';
        $this->className = 'Product';
        $this->identifier = 'id_product';
        $this->lang = true;

        if (!Validate::isLoadedObject($obj = new Product((int) $id)))
          $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
        
        $this->fields_list = array(
            'id_product' => array(
                'title' => $this->l('ID'),
                'width' => 40,
                'align' => 'center'
            ),
            'name' => array(
                'title' => $this->l('Value'),
                'width' => 'auto',
                'filter_key' => 'b!name'
            )
        );

        /*if ($obj->group_type == 'color')
          $this->fields_list['color'] = array(
          'title' => $this->l('Color'),
          'width' => 40,
          'filter_key' => 'b!color'
          );

          $this->fields_list['position'] = array(
          'title' => $this->l('Position'),
          'width' => 40,
          'filter_key' => 'a!position',
          'position' => 'position'
          ); */

        $this->addRowAction('edit');
        $this->addRowAction('delete');

        // override attributes
        $this->display = 'list';
        $this->tpl_folder = 'attributes/';

        //$this->_where = 'AND a.`id_attribute_group` = ' . (int) $id;
        // $this->_orderBy = 'position';
        // get list and force no limit clause in the request
        $this->getList($this->context->language->id, null, null, 0, false);

        // Render list
        $helper = new HelperList();
        $helper->actions = $this->actions;
        $helper->override_folder = $this->tpl_folder;
        $helper->no_link = true;
        $helper->shopLinkType = '';
        $helper->identifier = $this->identifier;
        $helper->toolbar_scroll = false;
        //$helper->orderBy = 'position';
        //$helper->orderWay = 'ASC';
        $helper->currentIndex = self::$currentIndex;
        $helper->token = $this->token;
        $helper->table = $this->table;
        $helper->simple_header = true;
        $helper->show_toolbar = false;
        $helper->bulk_actions = $this->bulk_actions;
        //$helper->position_identifier = 'id_attribute';
        $content = $helper->generateList($this->_list, $this->fields_list);

        die(Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content)));
        }
    }

Avec ce code, au bout de chaque ligne correspondant à un produit j'ai le bouton détails. Quand je cliquait dessus rien ne se passait mais maintenant quand je clique une liste de tous les produits s'affiche en dessous. Bon, c'est pas du tout ce que je veux, moi je voudrais afficher les infos d'une autre table. Dans mon cas la table activite, où j'ai bien créé la classe Activite et le controller AdminActiviteController.

 

J'ai essayé en remplaçant dans mon code ce qui concerne product par activite mais rien n'y fait, lors du clique sur le bouton details rien ne se passe :

$this->table = 'activite';
        $this->className = 'Activite';
        $this->identifier = 'id_activite';
        $this->lang = true;

        if (!Validate::isLoadedObject($obj = new Product((int) $id)))
          $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
        
        $this->fields_list = array(
            'id_activite' => array(
                'title' => $this->l('ID'),
                'width' => 40,
                'align' => 'center'
            ),
            'name' => array(
                'title' => $this->l('Value'),
                'width' => 'auto',
                'filter_key' => 'b!name'
            )
        );

Merci d'avance pour votre aide.

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