Jump to content

Recommended Posts

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 by Aurélia222 (see edit history)
Link to comment
Share on other sites

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

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

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

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

  • Aurélia222 changed the title to changement de php , Résolu

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