From 36b31c4a442494bb1f26966d830848b576f7d8aa Mon Sep 17 00:00:00 2001 From: florine2623 <16019289+florine2623@users.noreply.github.com> Date: Thu, 6 Jul 2023 11:13:31 +0200 Subject: [PATCH 1/5] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 718c4c60..e961417a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Give more visibility to your content/static pages (CMS, external pages, or else), where you want and when you want, to make your visitors feel like shopping on your store. +## Compatibility + +PrestaShop: `8.1.0` or later + ## Multistore compatibility This module is compatible with the multistore :heavy_check_mark:
From a6eb142687e71dfa3d7331a6c833a4c4eb7025ad Mon Sep 17 00:00:00 2001 From: florine2623 <16019289+florine2623@users.noreply.github.com> Date: Thu, 3 Aug 2023 16:50:05 +0200 Subject: [PATCH 2/5] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index e961417a..838cae7b 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ It can be configured differently from one store to another.
It can be configured quickly in the same way on all stores thanks to the all shops context or the group of shops.
It can be activated on one store and deactivated on another +## How to test + +Edit the existing linklist block and add custom contents +CRUD a new linklist block + ## Building assets If you need to change the javascript code you have to compile the assets, this operation is done From 912098c9eea5d5b7c804060d2917f399c6c2798b Mon Sep 17 00:00:00 2001 From: Morgan Pichat Date: Thu, 3 Aug 2023 18:37:16 +0200 Subject: [PATCH 3/5] Update DBAL usage --- ps_linklist.php | 4 +-- src/Repository/LinkBlockRepository.php | 48 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ps_linklist.php b/ps_linklist.php index ba697a61..cf0ddf5b 100644 --- a/ps_linklist.php +++ b/ps_linklist.php @@ -155,7 +155,7 @@ public function install() /** * @return bool * - * @throws \Doctrine\DBAL\DBALException + * @throws \Doctrine\DBAL\Exception */ private function createTables() { @@ -174,7 +174,7 @@ private function createTables() /** * @return bool * - * @throws \Doctrine\DBAL\DBALException + * @throws \Doctrine\DBAL\Exception */ private function installFixtures() { diff --git a/src/Repository/LinkBlockRepository.php b/src/Repository/LinkBlockRepository.php index 4668c76c..8d85123b 100644 --- a/src/Repository/LinkBlockRepository.php +++ b/src/Repository/LinkBlockRepository.php @@ -21,9 +21,10 @@ namespace PrestaShop\Module\LinkList\Repository; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Query\QueryBuilder; +use Doctrine\DBAL\Result; use Hook; use PrestaShop\Module\LinkList\Adapter\ObjectModelHandler; use PrestaShop\PrestaShop\Adapter\Shop\Context; @@ -238,8 +239,6 @@ public function delete($idLinkBlock): void /** * @return array - * - * @throws \Doctrine\DBAL\DBALException */ public function createTables() { @@ -271,11 +270,11 @@ public function createTables() ]; foreach ($queries as $query) { - $statement = $this->connection->executeQuery($query); - - if ($statement instanceof Statement && 0 != (int) $statement->errorCode()) { + try { + $this->connection->executeQuery($query); + } catch (DBALException $e) { $errors[] = [ - 'key' => json_encode($statement->errorInfo()), + 'key' => json_encode($e->getMessage()), 'parameters' => [], 'domain' => 'Admin.Modules.Notification', ]; @@ -287,8 +286,6 @@ public function createTables() /** * @return array - * - * @throws \Doctrine\DBAL\DBALException */ public function installFixtures() { @@ -316,10 +313,12 @@ public function installFixtures() } foreach ($queries as $query) { - $statement = $this->connection->executeQuery($query); - if ($statement instanceof Statement && 0 != (int) $statement->errorCode()) { + $this->connection->executeQuery($query); + try { + $this->connection->executeQuery($query); + } catch (DBALException $e) { $errors[] = [ - 'key' => json_encode($statement->errorInfo()), + 'key' => json_encode($e->getMessage()), 'parameters' => [], 'domain' => 'Admin.Modules.Notification', ]; @@ -331,8 +330,6 @@ public function installFixtures() /** * @return array - * - * @throws \Doctrine\DBAL\DBALException */ public function dropTables() { @@ -344,10 +341,11 @@ public function dropTables() ]; foreach ($tableNames as $tableName) { $sql = 'DROP TABLE IF EXISTS ' . $this->dbPrefix . $tableName; - $statement = $this->connection->executeQuery($sql); - if ($statement instanceof Statement && 0 != (int) $statement->errorCode()) { + try { + $this->connection->executeQuery($sql); + } catch (DBALException $e) { $errors[] = [ - 'key' => json_encode($statement->errorInfo()), + 'key' => json_encode($e->getMessage()), 'parameters' => [], 'domain' => 'Admin.Modules.Notification', ]; @@ -415,15 +413,16 @@ private function updateLanguages($linkBlockId, array $blockName, array $custom) * @param QueryBuilder $qb * @param string $errorPrefix * - * @return Statement|int + * @return Result|int|string * * @throws DatabaseException */ private function executeQueryBuilder(QueryBuilder $qb, $errorPrefix = 'SQL error') { - $statement = $qb->execute(); - if ($statement instanceof Statement && !empty($statement->errorInfo())) { - throw new DatabaseException($errorPrefix . ': ' . var_export($statement->errorInfo(), true)); + try { + $statement = $qb->execute(); + } catch (DBALException $e) { + throw new DatabaseException($errorPrefix . ': ' . var_export($e->getMessage(), true)); } return $statement; @@ -447,7 +446,7 @@ private function getHookMaxPosition(int $idHook, int $idShop): int ->setParameter('idShop', $idShop) ; - $maxPosition = $qb->execute()->fetchColumn(0); + $maxPosition = $qb->execute()->fetch(\PDO::FETCH_COLUMN); return null !== $maxPosition ? $maxPosition + 1 : 0; } @@ -500,8 +499,9 @@ public function updatePositions(int $shopId, array $positionsData = []): void ++$i; - $statement = $qb->execute(); - if ($statement instanceof Statement && $statement->errorCode()) { + try { + $qb->execute(); + } catch (DBALException $e) { throw new DatabaseException('Could not update #%i'); } } From 7c27bd8544480fd1064244bfc2411a82f3a8fb0f Mon Sep 17 00:00:00 2001 From: javier1987 Date: Wed, 9 Aug 2023 07:31:50 +0200 Subject: [PATCH 4/5] Fix - Category with duplicate name does not appear in module configuration --- src/Form/ChoiceProvider/CategoryChoiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/ChoiceProvider/CategoryChoiceProvider.php b/src/Form/ChoiceProvider/CategoryChoiceProvider.php index d3a63dda..4ea61a92 100644 --- a/src/Form/ChoiceProvider/CategoryChoiceProvider.php +++ b/src/Form/ChoiceProvider/CategoryChoiceProvider.php @@ -47,7 +47,7 @@ public function getChoices() $categories = $qb->execute()->fetchAll(); $choices = []; foreach ($categories as $category) { - $choices[$category['name']] = $category['id_category']; + $choices[$category['id_category'] . ' ' . $category['name']] = $category['id_category']; } return $choices; From b094140124966dc8ceeb5bd7cf13c352a8fa556a Mon Sep 17 00:00:00 2001 From: Morgan Pichat Date: Mon, 4 Sep 2023 09:47:50 +0200 Subject: [PATCH 5/5] Prepare for 6.0.4 --- config.xml | 2 +- ps_linklist.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.xml b/config.xml index d0df9d31..08843a40 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_linklist - + diff --git a/ps_linklist.php b/ps_linklist.php index cf0ddf5b..6b72fcc4 100644 --- a/ps_linklist.php +++ b/ps_linklist.php @@ -73,7 +73,7 @@ public function __construct() { $this->name = 'ps_linklist'; $this->author = 'PrestaShop'; - $this->version = '6.0.3'; + $this->version = '6.0.4'; $this->need_instance = 0; $this->tab = 'front_office_features';