Jump to content

Errore 500, prodotto


Robin_CH

Recommended Posts

Buongiorno,

da poco il mio sito www.tofeelgood.ch non mi apre più i prodotti nonostante siano online, mi esce sempre un errore 500.

Posso sempre navigare tranquillamente in tutto il sito.. é unicamente quando clicco su un prodotto, mi esce questo errore

Link to comment
Share on other sites

Mi esce questo

 

(1/1) ContextErrorException

Warning: Declaration of Cart::removeCartRule($id_cart_rule) should be compatible with CartCore::removeCartRule($id_cart_rule, bool $useOrderPrices = false)

in Cart.php line 11

at ErrorHandler->handleError(2, 'Declaration of Cart::removeCartRule($id_cart_rule) should be compatible with CartCore::removeCartRule($id_cart_rule, bool $useOrderPrices = false)', '/home/clients/1e809c418709bff9945f55dcaa311a43/sites/tofeelgood.ch/override/classes/Cart.php', 11, array('className' => 'Cart', 'classDir' => '/home/clients/1e809c418709bff9945f55dcaa311a43/sites/tofeelgood.ch/'))in PrestaShopAutoload.php line 152

at require_once()in PrestaShopAutoload.php line 152

at PrestaShopAutoload->load('Cart')in DebugClassLoader.php line 159

at DebugClassLoader->loadClass('Cart')

at spl_autoload_call('Cart')in FrontController.php line 359

at FrontControllerCore->init()in Controller.php line 287

at ControllerCore->run()in Dispatcher.php line 525

at DispatcherCore->dispatch()in index.php line 28

 

Fino a stamattina funzionava tutto

Link to comment
Share on other sites

ho trovato questa possibile soluzione

 

Devi modificare la firma del metodo removeCartRule nella tua classe Cart per includere il secondo parametro opzionale in modo che corrisponda alla definizione nella classe CartCore. Ecco cosa fare:

Apri il file override/classes/Cart.php.

Trova il metodo removeCartRule.

Modifica la sua dichiarazione aggiungendo il parametro $useOrderPrices come segue:

php

public function removeCartRule($id_cart_rule, bool $useOrderPrices = false) { // Il tuo codice qui }

Link to comment
Share on other sites

/home/clients/1e809c418709bff9945f55dcaa311a43/sites/tofeelgood.ch/override/classes/Cart.php

dove /home/clients/1e809c418709bff9945f55dcaa311a43/ è il tuo account e quindi da Gestione File del tuo hosting potresti vedere a partire da sites

M

Link to comment
Share on other sites

Non capisco dove devo scrivere la modifica

 

<?php

class Cart extends CartCore
{
    
    /*
    * module: loyaltyrewardpoints
    * date: 2022-12-21 12:07:20
    * version: 2.2.0
    */
    public function removeCartRule($id_cart_rule)
    {
        include_once(_PS_MODULE_DIR_ . '/loyaltyrewardpoints/lib/bootstrap.php');
        LRPDiscountHelper::setPointsRedeem(0);
        return parent::removeCartRule($id_cart_rule);
    }
    /*
    * module: pricerounding
    * date: 2022-12-21 12:12:42
    * version: 1.3.7
    */
    public function getCartRules($filter = CartRule::FILTER_ACTION_ALL, $autoAdd = true, $useOrderPrices = false)
    {
        $result = parent::getCartRules($filter, $autoAdd, $useOrderPrices);
        if (!Module::isEnabled('pricerounding')) {
            return $result;
        }
        include_once(_PS_MODULE_DIR_.'pricerounding/classes/PriceroundingConfiguration.php');
        $pricerounding = new PriceroundingConfiguration();
        $context = Context::getContext();
        $prconfigs = $pricerounding->getConfigsGlobal(1);
        $compute_precision = 6;
        if (!empty($prconfigs) && !empty($result)) {
            $compute_precision = Configuration::get('_PS_PRICE_COMPUTE_PRECISION_');
            foreach ($result as &$row) {
                $row['value_real'] = $pricerounding->psRound($row['value_real'], $compute_precision, $prconfigs['type'], $prconfigs['mode'], $prconfigs['threshold']);
            }
        }
        return $result;
    }
    /*
    * module: pricerounding
    * date: 2022-12-21 12:12:42
    * version: 1.3.7
    */
    public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null, bool $keepOrderPrices = false)
    {
        if (!Module::isEnabled('pricerounding')) {
            return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
        }
        include_once(_PS_MODULE_DIR_.'pricerounding/classes/PriceroundingConfiguration.php');
        $pricerounding = new PriceroundingConfiguration();
        $context = Context::getContext();
        $prconfigs = $pricerounding->getConfigsGlobal(2);
        if (empty($prconfigs)) {
            return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
        }
        $shipping_cost = parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
        $compute_precision = 6;
        if ($shipping_cost == 0 || empty($prconfigs)) {
            return $shipping_cost;
        }
        if ($this->isVirtualCart()) {
            return 0;
        }
        if (!$default_country) {
            $default_country = Context::getContext()->country;
        }
        if (!is_null($product_list)) {
            foreach ($product_list as $key => $value) {
                if ($value['is_virtual'] == 1) {
                    unset($product_list[$key]);
                }
            }
        }
        if (is_null($product_list)) {
            $products = $this->getProducts();
        } else {
            $products = $product_list;
        }
        if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
            $address_id = (int)$this->id_address_invoice;
        } elseif (count($products)) {
            $prod = current($products);
            $address_id = (int)$prod['id_address_delivery'];
        } else {
            $address_id = null;
        }
        if (!Address::addressExists($address_id)) {
            $address_id = null;
        }
        if (is_null($id_carrier) && !empty($this->id_carrier)) {
            $id_carrier = (int)$this->id_carrier;
        }
        $cache_id = 'getPackageShippingCost_'.(int)$this->id.'_'.(int)$address_id.'_'.(int)$id_carrier.'_'.(int)$use_tax.'_'.(int)$default_country->id;
        if ($products) {
            foreach ($products as $product) {
                $cache_id .= '_'.(int)$product['id_product'].'_'.(int)$product['id_product_attribute'];
            }
        }
        if (!isset($id_zone)) {
            if (!$this->isMultiAddressDelivery()
                && isset($this->id_address_delivery) // Be carefull, id_address_delivery is not usefull one 1.5
                && $this->id_address_delivery
                && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery
            )) {
                $id_zone = Address::getZoneById((int)$this->id_address_delivery);
            } else {
                if (!Validate::isLoadedObject($default_country)) {
                    $default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
                }
                $id_zone = (int)$default_country->id_zone;
            }
        }
        if ($id_carrier && !$this->isCarrierInRange((int)$id_carrier, (int)$id_zone)) {
            $id_carrier = '';
        }
        if (empty($id_carrier) && $this->isCarrierInRange((int)Configuration::get('PS_CARRIER_DEFAULT'), (int)$id_zone)) {
            $id_carrier = (int)Configuration::get('PS_CARRIER_DEFAULT');
        }
        if (empty($id_carrier)) {
            $id_carrier = Configuration::get('PS_CARRIER_DEFAULT');
        }
        if (!isset(self::$_carriers[$id_carrier])) {
            self::$_carriers[$id_carrier] = new Carrier((int)$id_carrier, Configuration::get('PS_LANG_DEFAULT'));
        }
        $carrier = self::$_carriers[$id_carrier];
        if (!Validate::isLoadedObject($carrier)) {
            Cache::store($cache_id, 0);
            return 0;
        }
        $shipping_method = $carrier->getShippingMethod();
        if (!$carrier->active) {
            Cache::store($cache_id, $shipping_cost);
            return $shipping_cost;
        }
        if ($carrier->is_free == 1) {
            Cache::store($cache_id, 0);
            return 0;
        }
        if (!Tax::excludeTaxeOption()) {
            $address = Address::initialize((int)$address_id);
            if (Configuration::get('PS_ATCP_SHIPWRAP')) {
                $carrier_tax = 0;
            } else {
                $carrier_tax = $carrier->getTaxesRate($address);
            }
        }
        if (isset($context->customer->id)) {
            $priceDisplay = Product::getTaxCalculationMethod((int)$context->customer->id);
        } else {
            $priceDisplay = 0;
        }
        if ($use_tax && !$priceDisplay) { // visualización con impuestos
            $shipping_cost = $pricerounding->psRound($shipping_cost, $compute_precision, $prconfigs['type'], $prconfigs['mode'], $prconfigs['threshold']);
        }
        if (!$use_tax && !$priceDisplay) { // visualización con impuestos
            $shipping_cost_with_tax = parent::getPackageShippingCost($id_carrier, true, $default_country, $product_list, $id_zone);
            $shipping_cost = $pricerounding->psRound($shipping_cost_with_tax, $compute_precision, $prconfigs['type'], $prconfigs['mode'], $prconfigs['threshold']);
            $shipping_cost = Tools::ps_round($shipping_cost / (1 + ($carrier_tax / 100)), $compute_precision);
        }
        if (!$prconfigs['with_taxes']) {
            if ($use_tax && $priceDisplay) { // visualización sin impuestos
                $shipping_cost_with_tax = parent::getPackageShippingCost($id_carrier, true, $default_country, $product_list, $id_zone);
                $shipping_cost = $pricerounding->psRound($shipping_cost_with_tax, $compute_precision, $prconfigs['type'], $prconfigs['mode'], $prconfigs['threshold']);
                $shipping_cost = Tools::ps_round($shipping_cost * (1 + ($carrier_tax / 100)), $compute_precision);
            }
            if (!$use_tax && $priceDisplay) { // visualización sin impuestos
                $shipping_cost = $pricerounding->psRound($shipping_cost, $compute_precision, $prconfigs['type'], $prconfigs['mode'], $prconfigs['threshold']);
            }
        }
        Cache::store($cache_id, $shipping_cost);
        return $shipping_cost;
    }
    /*
    * module: pricerounding
    * date: 2022-12-21 12:12:42
    * version: 1.3.7
    */
    public function getOrderTotal($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, bool $keepOrderPrices = false)
    {
        if (!Module::isEnabled('pricerounding')) {
            return parent::getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache);
        }
        include_once(_PS_MODULE_DIR_.'pricerounding/classes/PriceroundingConfiguration.php');
        $pricerounding = new PriceroundingConfiguration();
        $context = Context::getContext();
        $prconfigs = $pricerounding->getConfigsGlobal(1);
        if (empty($prconfigs) || ($prconfigs['with_taxes'] && !$with_taxes)) {
            return parent::getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache);
        }
        $order_total = parent::getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache);
        if ($order_total == 0) {
            return $order_total;
        }
        $compute_precision = Configuration::get('_PS_PRICE_COMPUTE_PRECISION_');
        return $pricerounding->psRound((float)$order_total, $compute_precision, $prconfigs['type'], $prconfigs['mode'], $prconfigs['threshold']);
    }
}
 

Link to comment
Share on other sites

Modificato, ma da un altro errore

 

(1/1) FatalThrowableError

Call to private method ProductControllerCore::getIdProductAttributeByGroupOrRequestOrDefault() from context 'ProductController'

in ProductController.php line 181

at ProductController->getProductPageTitle()in ProductController.php line 152

at ProductController->getTemplateVarProduct()in ProductController.php line 374

at ProductControllerCore->initContent()in Controller.php line 306

at ControllerCore->run()in Dispatcher.php line 525

at DispatcherCore->dispatch()in index.php line 28


La soluzione potrebbe essere una di queste:

 

Se hai accesso al file ProductControllerCore.php (probabilmente situato nella directory controllers/front/), verifica se il metodo getIdProductAttributeByGroupOrRequestOrDefault è definito come private. Se è privato, puoi provare a cambiarne la visibilità in protected se desideri che il metodo sia accessibile dalle classi derivate.

php

Da questo (metodo privato): private function getIdProductAttributeByGroupOrRequestOrDefault() 

A questo (metodo protetto): protected function getIdProductAttributeByGroupOrRequestOrDefault() 

Il problema che non si trova il ProductControllerCore.php, quindi per modificare questo errore, come si potrebbe fare?

Edited by Robin_CH
Con possibile soluzione, ma con richiesta dove trovare la php (see edit history)
Link to comment
Share on other sites

On 9/20/2024 at 5:02 PM, Robin_CH said:

Modificato, ma da un altro errore

 

(1/1) FatalThrowableError

Call to private method ProductControllerCore::getIdProductAttributeByGroupOrRequestOrDefault() from context 'ProductController'

in ProductController.php line 181

at ProductController->getProductPageTitle()in ProductController.php line 152

at ProductController->getTemplateVarProduct()in ProductController.php line 374

at ProductControllerCore->initContent()in Controller.php line 306

at ControllerCore->run()in Dispatcher.php line 525

at DispatcherCore->dispatch()in index.php line 28


La soluzione potrebbe essere una di queste:

 

Se hai accesso al file ProductControllerCore.php (probabilmente situato nella directory controllers/front/), verifica se il metodo getIdProductAttributeByGroupOrRequestOrDefault è definito come private. Se è privato, puoi provare a cambiarne la visibilità in protected se desideri che il metodo sia accessibile dalle classi derivate.

php

Da questo (metodo privato): private function getIdProductAttributeByGroupOrRequestOrDefault() 

A questo (metodo protetto): protected function getIdProductAttributeByGroupOrRequestOrDefault() 

Il problema che non si trova il ProductControllerCore.php, quindi per modificare questo errore, come si potrebbe fare?

Sto ancora cercando come risolvere questo problema. Qualcuno che mi sappia aiutare? Perché non capisco dove sostituire la funzione

Link to comment
Share on other sites

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