I'm getting this error: Class "Zend_Filter_LocalizedToNormalized" not found

1.2k Views Asked by At

Not sure if it has to do with php 8.2 specifically or just php 8. My exception log is saying that it's not found here in this file but below is the code from line(s) 190 - 197. Checkout/Controller/Cart/Add.php:191

    if (isset($params['qty'])) {
        $filter = new \Zend_Filter_LocalizedToNormalized(
            ['locale' => $this->_objectManager->get(
                \Magento\Framework\Locale\ResolverInterface::class
            )->getLocale()]
        );
        $params['qty'] = $filter->filter($params['qty']);
    }

It was working in php 7.3 and so i honestly am not sure what it wants me to do here. Any help would be greatly appreciated. Thank you.

2

There are 2 best solutions below

0
Singleton On BEST ANSWER

This was what ended up working for me:

use Magento\Framework\Filter\LocalizedToNormalized;
use Magento\Framework\Locale\ResolverInterface;


            if (isset($params['qty'])) {
            $filter = new LocalizedToNormalized(
                ['locale' => $this->_objectManager->get(
                    ResolverInterface::class
                )->getLocale()]
            );
            $params['qty'] = $filter->filter($params['qty']);
        }
4
The LB On

In version 2.4.6, Zend_Filter_LocalizedToNormalized has been replacement with Magento\Framework\Filter\LocalizedToNormalized (try this class and everything will working).

I think the reason you get this error because you upgrade to version 2.4.6 but your module not compatible with magento 2.4.6 yet.

You can read about class change in vendor/magento/magento-coding-standard/Magento2/Sniffs/Legacy/_files/restricted_classes.php in line 282-285.