Make order reference equal to order id

Depending on the bank system of your country, it may be sometimes necessary to replace the Prestashop alphabet order reference by number, preferably by order id. There are several free modules suitable for this task. These modules add complexity to the ordering process and may eventually collide with third party payment modules. This may result in occassional difficult to track problems in the ordering process, for example in doubling the real paid amount etc.

In case you experience weird order problems when using an order reference change module, uninstall the module and replace its functionality by the simple code below.

  • open a new file in a clean text editor like notepad (use UTF-8 encoding)
  • copy paste the code into the file
  • save and copy to eshop as /override/classes/order/Order.php
  • clean prestashop cache
<?php
 class Order  extends OrderCore
{

   public function add($autodate = true, $null_values = true)
    {
        if (parent::add($autodate, $null_values)) {

            if($this->id != $this->reference) {
            $this->reference = $this->id;
            $this->update();
            }
            return SpecificPrice::deleteByIdCart($this->id_cart);
        }

        return false;
    }

 public static function generateReference()
    {
        $sql = 'SELECT MAX(id_order) FROM '._DB_PREFIX_.'orders WHERE 1';
        $id_order= Db::getInstance()->getValue($sql);
        return (int)$id_order + 1;
    }
}

Too many product features – slow back office

The product Features tab contains predefined list of features and values you can select. Sometimes there are dozens or even hundreds of predefined features. The whole list must be loaded, although just few features are used for a given product. This may considerably slow the loading of product page in back office.

A possible quick fix for this situation is to load the features list only if they are needed. For Prestashop 1.6:

  • upload this file
  • unzip and copy to /override /controllers/AdminProductsController.php
  • clear cache or manually delete /cache /class_index.php

The features tab in product page will now contain the button for switching the features in back office on / off . This setting apply for all products.

Important: do not override /override /controllers/AdminProductsController.php if it already exists

The procedure is safe and completely reversible, but cleaning the Prestashop cache is sometimes tricky. If you did not clean the cache for a long time, backup the /cache/class_index.php, clean the cache and wait several days to make sure no hidden problem become manifested after the cache was cleaned. Finally, perform the procedure described above.