Skip to content

Commit

Permalink
Prestashop 8.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
magentix committed Feb 2, 2024
1 parent 15a2558 commit c3ffcc5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.0

- Prestashop 8.1 compatibility

## 1.1.0

- Allow translating title and description when lang is global
Expand Down
52 changes: 30 additions & 22 deletions pixel_product_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Pixel_product_files extends Module implements WidgetInterface
public function __construct()
{
$this->name = 'pixel_product_files';
$this->version = '1.1.0';
$this->version = '1.2.0';
$this->author = 'Pixel Open';
$this->tab = 'content_management';
$this->need_instance = 0;
Expand Down Expand Up @@ -125,26 +125,34 @@ public function install(): bool
*/
protected function createTable(): bool
{
$result = (bool)Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'product_file` (
`id` INT(10) AUTO_INCREMENT NOT NULL,
`id_product` INT(10) unsigned NOT NULL,
`id_shop` INT(10) unsigned NULL DEFAULT NULL,
`id_lang` INT(10) unsigned NULL DEFAULT NULL,
`file` VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY(`id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'product_file_lang` (
`id` INT(10) AUTO_INCREMENT NOT NULL,
`id_file` INT(10) NOT NULL,
`id_lang` INT(10) unsigned NOT NULL,
`title` VARCHAR(255) NULL DEFAULT NULL,
`description` TEXT NULL DEFAULT NULL,
`position` INT(10) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`),
FOREIGN KEY (id_file) REFERENCES `' . _DB_PREFIX_ . 'product_file` (id) ON DELETE CASCADE
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
try {
Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'product_file` (
`id` INT(10) AUTO_INCREMENT NOT NULL,
`id_product` INT(10) unsigned NOT NULL,
`id_shop` INT(10) unsigned NULL DEFAULT NULL,
`id_lang` INT(10) unsigned NULL DEFAULT NULL,
`file` VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY(`id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');

Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'product_file_lang` (
`id` INT(10) AUTO_INCREMENT NOT NULL,
`id_file` INT(10) NOT NULL,
`id_lang` INT(10) unsigned NOT NULL,
`title` VARCHAR(255) NULL DEFAULT NULL,
`description` TEXT NULL DEFAULT NULL,
`position` INT(10) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`),
FOREIGN KEY (id_file) REFERENCES `' . _DB_PREFIX_ . 'product_file` (id) ON DELETE CASCADE
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
} catch (Exception $exception) {
$this->_errors[] = $exception->getMessage();
return false;
}

try {
Db::getInstance()->execute('
Expand All @@ -154,7 +162,7 @@ protected function createTable(): bool
');
} catch (Exception $exception) {}

return $result;
return true;
}

/************/
Expand Down
2 changes: 1 addition & 1 deletion views/templates/admin/files.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="row">
<div class="col-md-12">
<div class="translations tabbable">
<div class="col-md-12 translationsFields tab-content">
<div class="col-md-12 mt-4 translationsFields tab-content">
<div data-locale="{{ lang }}" class="translationsFields-form_additional_title_add_file_{{ lang }} tab-pane translation-field show active translation-label-{{ lang }}">
<button type="button" class="btn btn-primary product_files_add_file_button" data-shop-id="{{ id_shop }}" data-lang-id="{{ id }}" data-product-id="{{ id_product }}">
{{ 'Add a file'|trans({}, 'Modules.Pixelproductfiles.Admin') }}
Expand Down

0 comments on commit c3ffcc5

Please sign in to comment.