Jump to content

Edit History

Ehsanai

Ehsanai

I create a module ( just with controller file ) for edit one field ( ean13 ) on database directly fro BO.

<?php

class AdminProductListController extends ModuleAdminController {
  public function __construct(){
    parent::__construct();
    $this->bootstrap = true; // use Bootstrap CSS
    $this->table = 'product'; // SQL table name, will be prefixed with _DB_PREFIX_
    $this->identifier = 'id_product'; // SQL column to be used as primary key
    $this->className = 'Product'; // PHP class name
    $this->allow_export = false; // allow export in CSV, XLS..
    $this->_orderBy = 'id_product'; // default SQL ORDER BY
        $this->_orderWay = 'DESC';
    $this->page_header_toolbar_title = 'Product'; // toolbar title
    $this->_select = 'a.id_product as productID,pl.name as productName,CONCAT_WS(" - " , pl.name, al.name) AS name,';
    $this->_join = '
      left join '._DB_PREFIX_.'product_lang pl on a.id_product = pl.id_product
left join '._DB_PREFIX_.'product_attribute  pa on a.id_product = pa.id_product
left join '._DB_PREFIX_.'product_attribute_combination pac  on pa.id_product_attribute = pac.id_product_attribute
left join '._DB_PREFIX_.'attribute at on pac.id_attribute = at.id_attribute 
left join '._DB_PREFIX_.'attribute_lang al on at.id_attribute = al.id_attribute
  
    ';

    $this->fields_list = [
        
  'productID' => ['title' => $this->trans('id', [], 'Admin.Global'),'class' => 'fixed-width-xs'],
       'name' => ['title' => $this->trans('name', [], 'Admin.Global')],
       'ean13' => ['title' => $this->trans('ean13', [], 'Admin.Global')],
    'price' => ['title' => $this->trans('price', [], 'Admin.Global')],



    ];

  $this->addRowAction('edit');

        $this->fields_form = [
      'legend' => ['title' => $this->l('Custom Order Detail'),'icon' => 'icon-list-ul'],

      'input' => [
        ['ean13'=>'ean13','type'=>'text','required' => true,'label' => 'ean13',],
    
    
    
      ],
      'submit' => ['title' => $this->trans('Save', [], 'Admin.Actions'),]
      
    ];
    
  }

  


}

and use the classes/Product.php class but I create the new class ( ProductList.php )class and copy to override/classes folder. But if I click on edit on my product listing, I redirected to default product edit page. What should I do?

Ehsanai

Ehsanai

I create a module ( just with controller file ) for edit one field ( ean13 ) on database directly fro BO.

public function __construct(){
parent::__construct();
$this->bootstrap = true; // use Bootstrap CSS
$this->table = 'product'; // SQL table name, will be prefixed with _DB_PREFIX_
$this->identifier = 'id_product'; // SQL column to be used as primary key
$this->className = 'ProductList'; // PHP class name
$this->allow_export = false; // allow export in CSV, XLS..
$this->_orderBy = 'id_product'; // default SQL ORDER BY
    $this->_orderWay = 'DESC';
$this->page_header_toolbar_title = 'Product'; // toolbar title
$this->_select = 'a.id_product as productID,pl.name as productName';
$this->_join = '
  JOIN '._DB_PREFIX_.'product_lang pl ON (a.id_product = pl.id_product)

';

$this->fields_list = [
    
  'productID' => ['title' => $this->trans('id', [], 'Admin.Global'),'class' => 'fixed-width-xs'],
   'productName' => ['title' => $this->trans('name', [], 'Admin.Global')],
          'ean13' => ['title' => $this->trans('ean13', [], 'Admin.Global')],
                        'price' => ['title' => $this->trans('price', [], 'Admin.Global')],



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

    $this->fields_form = [
  'legend' => ['title' => $this->l('Custom Product  Detail'),'icon' => 'icon-list-ul'],

  'input' => [
    ['ean13'=>'ean13','type'=>'text','required' => true,'label' => 'ean13',],



  ],
  'submit' => ['title' => $this->trans('Save', [], 'Admin.Actions'),]
  
];
}

and use the classes/Product.php class but I create the new class ( ProductList.php )class and copy to override/classes folder. But if I click on edit on my product listing, I redirected to default product edit page. What should I do?

×
×
  • Create New...