Jump to content

Controller modułu nie działa


mscode

Recommended Posts

Przy wejściu na zakładkę którą tworzę w module.

Kod tworzenia zakładki

        $tab = new Tab();
        $tab->class_name = 'AdminWyprzedazeController';
        $tab->module = $this->name;
        $tab->id_parent = (int)Tab::getIdFromClassName('DEFAULT');
        $tab->icon = 'settings_applications';
        $languages = Language::getLanguages();
        foreach ($languages as $lang) {
            $tab->name[$lang['id_lang']] = $this->l('Wyprzedaże');
        }
        $tab->add();

Kontroler
 

<?php
require_once _PS_MODULE_DIR_.'emodo_wyprzedaze/override/classes/wyprzedaze_emodo/Wyprzedaze.php';

class AdminWyprzedazeController extends ModuleAdminController {
  public function __construct(){
      parent::__construct();
      // Base
      $this->bootstrap = true; // use Bootstrap CSS
      $this->table = 'emodo_wyprzedaze'; // SQL table name, will be prefixed with _DB_PREFIX_
      $this->identifier = 'id'; // SQL column to be used as primary key
      $this->className = 'Wyprzedaze'; // PHP class name
      $this->allow_export = true; // allow export in CSV, XLS..
      // List records
      $this->_defaultOrderBy = 'id'; // the table alias is always `a`
      $this->_defaultOrderWay = 'ASC';
      $this->fields_list = [
        'id' => ['title' => 'ID','class' => 'fixed-width-xs'],
        'facebook_post_url' => ['title' => 'Link FB'],
        'title' => ['title' => 'Tytuł'], // filter_key mandatory because "name" is ambiguous for SQL
        'date' => ['title' => 'Data', 'type'=>'date'], // filter_key mandatory because JOIN
        'status' => ['title' => 'Status'],
      ];
    // Read & update record
    $this->addRowAction('details');
    $this->addRowAction('edit');
    $this->fields_form = [
      'legend' => [
        'title' => 'Wyprzedaże',
        'icon' => 'icon-list-ul'
      ],
      'input' => [
        ['type'=>'html','html_content'=>'<div class="alert alert-info">Jeśli dane na stronie główne jsie nie odświeżą spróbuj wyczyścić pamięćpodręczną sklepu w Zaawansowane -> Wydajnośc</div>'],
        ['name'=>'facebook_post_url','type'=>'text','label'=>'Link FB','required'=>true],
        ['name'=>'title','type'=>'text','label'=>'Tytuł','required'=>true],
        ['name'=>'date','type'=>'datetime','label'=>'Data'],
        ['name'=>'status','type'=>'switch','choices' => [
          'Włączony' => "active",
          'Wyłączony' => "disabled",
      ],'label'=>'Status'],
      ],
      'submit' => [
        'title' => $this->trans('Zapisz', [], 'Admin.Actions'),
      ]
    ];
  }

}

Klasa

<?php
class Wyprzedaze extends ObjectModel {
  public $id; // fields are mandatory for create/update
  public $facebook_post_url;
  public $title;
  public $date;
  public $status;
  public static $definition = [
    'table' => 'emodo_wyprzedaze',
    'primary' => 'id',
    'fields' => [
      'facebook_post_url' =>  ['type' => self::TYPE_STRING, 'validate' => 'isAnything', 'required'=>true],
      'title' =>  ['type' => self::TYPE_STRING, 'validate' => 'isAnything', 'required'=>true],
      'date' =>  ['type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required'=>true],
      'status' =>  ['type' => self::TYPE_STRING, 'validate' => 'isAnything', 'required'=>true],
    ],
  ];
}

Wersja PHP: 7.4
Wersja sklepu: 1.7.8.7

BŁĄD:

image.png.fe73d8390a187eab8068e78611e929e6.png

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