Notable changes in PrestaShop 1.7.6

CLDR

The CLDR is a component responsible of displaying data such as the date & time, prices depending on a given language. It was reworked during several versions of PrestaShop 1.7, and will be enabled with 1.7.6. The previous one has been removed, and trying to use it will end to an exception.

A new variable is now available in the Context when going through a controller:

class ContextCore
{
    /**
     * Current locale instance.
     *
     * @var PrestaShop\PrestaShop\Core\Localization\Locale
     */
    public $currentLocale;

    [...]
}

This property is the link to format properly a number:

Context::getContext()->currentLocale->formatNumber($number);

or a price:

Context::getContext()->currentLocale->formatPrice($number);

Note that Tools::displayNumber(...) andTools::displayPrice(...) works as before, although deprecated.

For more details, please see the related pull-request on GitHub. The summary of removed elements is the following:

Removed classes:

  • PrestaShop\PrestaShop\Core\Cldr\Composer\Hook
  • PrestaShop\PrestaShop\Core\Cldr\Localize
  • PrestaShop\PrestaShop\Core\Cldr\Repository
  • PrestaShop\PrestaShop\Core\Cldr\Update

Deprecated methods:

  • Tools::getCldr(...)