Aurélia222 Posted July 27 Share Posted July 27 (edited) Bonjour, je souhaite modifier la valeur PHP actuellement en 7.4 qui fonctionne très bien avec la 8.2.1. Mais lorsque j'augmente la version PHP , le site en Front off plante en erreur 500. Pourtant la version recommandée pour la 8.2.1 est PHP 8.2 !! Est ce que vous avez une idée pour trouver l'origine du bug et pouvoir le solutionner ? Merci d'avance Aurélia shopnature.fr Edited July 27 by Aurélia222 (see edit history) Link to comment Share on other sites More sharing options...
kerlin Posted July 27 Share Posted July 27 Bonjour, il faudrait activer le mode debug. Dans votre signature, vous dites que le site est en 1.7 ? Link to comment Share on other sites More sharing options...
Aurélia222 Posted July 27 Author Share Posted July 27 Bonjour Kerlin, si je test en PHP 8.0, j'obtiens avec le mode debug : ( ! ) Fatal error: Declaration of Product::getQuantity($idProduct, $idProductAttribute = null, $cacheIsPack = null, ?Cart $cart = null, $idCustomization = null) must be compatible with ProductCore::getQuantity($idProduct, $idProductAttribute = null, $cacheIsPack = null, ?CartCore $cart = null, $idCustomization = null) in /home/u245567316/domains/shopnature.fr/public_html/override/classes/Product.php on line 6 Call Stack #TimeMemoryFunctionLocation 10.0001381488{main}( ).../index.php:0 20.047710137792DispatcherCore->dispatch( ).../index.php:28 30.051410429648Controller->run( ).../Dispatcher.php:510 40.051410429648FrontController->init( ).../Controller.php:41 50.051410430072FrontControllerCore->init( ).../FrontController.php:13 60.062411137632PrestaShop\Autoload\Autoloader->load( $className = 'Product' ).../FrontController.php:502 70.062411138336require_once( '/home/u245567316/domains/shopnature.fr/public_html/override/classes/Product.php ).../Autoloader.php:103 ps: J'ai mis à jour ma signature 😉 Link to comment Share on other sites More sharing options...
kerlin Posted July 27 Share Posted July 27 L'erreur vient d'un override de la class Product.php, à la ligne 6, il utilise ?Cart $cart = null alors que la version de base utilise ?CartCore $cart = null. PHP 8 est plus strict c'est pourquoi ça ne marche pas. Si cet override est nécessaire, il faut le corriger dans ce sens partout où il y a ?Cart. Sinon, le désactiver. Après correction, ne pas oublier de vider le cache de Prestashop Link to comment Share on other sites More sharing options...
Aurélia222 Posted July 27 Author Share Posted July 27 merci d'avoir identifié le problème. comment le corriger ? Link to comment Share on other sites More sharing options...
kerlin Posted July 27 Share Posted July 27 Via le FTP, il faut ouvrir le fichier override/class/Product.php dans un éditeur de texte. Si vous voulez, je peux le faire si vous m'envoyez un accès ftp en MP. Cela me permettra de voir s'il y a d'autres Cart à corriger. Link to comment Share on other sites More sharing options...
Aurélia222 Posted July 27 Author Share Posted July 27 <?php class Product extends ProductCore { public static function getQuantity( $idProduct, $idProductAttribute = null, $cacheIsPack = null, Cart $cart = null, $idCustomization = null ) { if (Pack::isPack((int)$idProduct)) { return Pack::getQuantity($idProduct, $idProductAttribute, $cacheIsPack, $cart, $idCustomization); } $availableQuantity = StockAvailable::getQuantityAvailableByProduct($idProduct, $idProductAttribute); $nbProductInCart = 0; if (!empty($cart)) { $cartProduct = $cart->getProductQuantity($idProduct, $idProductAttribute, $idCustomization); if (!empty($cartProduct['deep_quantity'])) { $nbProductInCart = $cartProduct['deep_quantity']; } } // 28.04.21 - Webbax | TUTO 123 - ne pas tenir compte des quantités du panier */ $Context = Context::getContext(); if($Context->controller->php_self=='product'){ $nbProductInCart = 0; } // @since 1.5.0 return $availableQuantity - $nbProductInCart; } } Voici mon fichier, donc je rajoute Core juste apres tous les "cart" ? Link to comment Share on other sites More sharing options...
kerlin Posted July 27 Share Posted July 27 non 🙂 juste la ligne Cart $cart = null remplacer par CartCore $cart = null ensuite vider le cache de Presta et tester 1 Link to comment Share on other sites More sharing options...
Aurélia222 Posted July 27 Author Share Posted July 27 C'est parfait , ça fonctionne merci beaucoup Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now