diff --git a/config.xml b/config.xml index ba407583..4380d5fc 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ productcomments - + diff --git a/productcomments.php b/productcomments.php index 875f40d7..f28dc6ed 100644 --- a/productcomments.php +++ b/productcomments.php @@ -67,10 +67,11 @@ public function __construct() { $this->name = 'productcomments'; $this->tab = 'front_office_features'; - $this->version = '9.0.0'; + $this->version = '9.0.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; + $this->module_key = 'e699ddd0ac2d61593ec594e82b719da6'; parent::__construct(); diff --git a/src/Repository/ProductCommentRepository.php b/src/Repository/ProductCommentRepository.php index 0292723a..75ae8738 100644 --- a/src/Repository/ProductCommentRepository.php +++ b/src/Repository/ProductCommentRepository.php @@ -107,11 +107,14 @@ public function delete(ProductComment $entity): void { $entityId = $entity->getId(); - $this->remove($entity, true); - + // The rows below reference the comment, so they have to go first. Without the foreign keys the + // order does not matter, but a shop that applied the schema this module declares does have them, + // and removing the comment first fails with "Cannot delete or update a parent row". $this->deleteGrades($entityId); $this->deleteReports($entityId); $this->deleteUsefulness($entityId); + + $this->remove($entity, true); } /** @@ -302,6 +305,7 @@ public function getAverageGrades(array $productIds, $validatedOnly) $sql = 'SELECT'; $count = count($productIds); + $productIds = array_values($productIds); foreach ($productIds as $index => $id) { $esqID = (int) $id; @@ -367,6 +371,7 @@ public function getCommentsNumberForProducts(array $productIds, $validatedOnly) $sql = 'SELECT'; $count = count($productIds); + $productIds = array_values($productIds); foreach ($productIds as $index => $id) { $esqID = (int) $id; diff --git a/views/js/list-comments.js b/views/js/list-comments.js index 297f1164..f0e9e13f 100644 --- a/views/js/list-comments.js +++ b/views/js/list-comments.js @@ -39,6 +39,7 @@ jQuery(document).ready(function () { const nextCount = totalPages + 1; const gapText = '…'; + $('#product-comments-list-header .grade-stars').rating(); $('#product-comments-list .grade-stars').rating(); $('.product-comments-additional-info .grade-stars').rating(); @@ -47,6 +48,7 @@ jQuery(document).ready(function () { }) document.addEventListener('updateRating', function() { + $('#product-comments-list-header .grade-stars').rating(); $('#product-comments-list .grade-stars').rating(); $('.product-comments-additional-info .grade-stars').rating(); });