Get Free Audit

Prestashop 1.6 vs 1.7 Comparison

May 30, 2018

8828 Alexey Homiakov

Prestashop 1.6 vs 1.7 Comparison

When it comes to Prestashop 1.7, it should be mentioned that the developers have implemented the additional features to deal with Smarty.

{url}

{url} function is meant for working with URL addresses. It works via the standard class PrestaShop «Link». For example,


The result,
example.com/en/address
example.com/en/address
example.com/en/address?delete=1

In Prestashop 1.6, there’s no such function for Smarty, that’s why you have to collect URL into an array and do it for your needs. For example,


– template code.


–  php file code.

*Be careful while dealing with “Link”. If you have to make a friendly URL, there can be some problems, if something is done incorrectly.

{widget}

{widget} allows considering the module connection in a different way. Instead of using standard hook, you can use {widget}. For example,


If your standard module template is replaced, you can put the link to the necessary hook into {widget}. For example,


Pay attention to the fact that all {widget} work only with modules for Prestashop 1.7 the names of which start from «ps_».

In Prestashop 1.6 you need to go to the folder that contains the module \modules\blockcontactinfos and add your custom hook in the file blockcontactinfos.phpFor example,


Then you can call it anywhere. For example,


Actually, in Prestashop 1.6 there’s one more method. You can go to the module directly. But this method is better to use if you are master of complex structures (e. x. hook in hook and one more hook is implied). For example,


The result is that the store data is displayed in the created block.

Prestashop 1.6 vs. 1.7. Comparison_1

{widget_block}

Using {widget_block}, you can rewrite the template.  The module will use your written code as well as the template file code.

As an example, let’s consider the module ps_imageslider \modules\ps_imageslider\views\templates\hook\list.tpl.


In Prestashop 1.6 in your theme template (pic 1) of the modules folder you need to create a folder (pic 2) with the name of module structure you want to change (pic 3) and there create *.tpl (pic 4) and make its own structure.

Prestashop 1.6 vs. 1.7. Comparison_2

Picture 1

Prestashop 1.6 vs. 1.7. Comparison_3

Picture 2

Prestashop 1.6 vs. 1.7. Comparison_4

Picture 3

Prestashop 1.6 vs. 1.7. Comparison_5

Picture 4

{render}

The function allows selecting a variable from the template. For example,


In the template  login-form.tpl, the variable «UI» is described and can be used with the help of {render}.  {render} is the PrestaShop function which has been added in Smarty.

In Prestashop 1.6 “include” is used. So you can put the part of the code, function or variable somewhere according to the user’s needs. But you need to specify the pathname of the code file being used.

NOTE! It can lead to negative consequences. Your website may be hacked, as the hacker is provided with significant files data.

For example,
— mymodule.php
— views
—- templates
—— hook
—— displayFooBarTemplate.tpl
——– inc
———- foo.tpl
———- bar.tpl

The absolute pathname:


Then in your file tpl (displayFooBarTemplate.tpl):


The relative pathname:

{form_field}

The function allows form elements to have the common design. Before there was misunderstanding between frontend and backend developers when they had to use form fields differently. Now the developer can apply almost the same parameters for form fields. For example,


$field – array where parameters are specified.

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


In Prestashop 1.6 you have to do it manually. For example,


NOTE: if it’s necessary to add a custom attribute to the form, it can’t be performed via {form_field} and you’ll have to do it manually also.

Classname

It’s a modifier that helps to avoid making mistakes when creating class or line. It allows the following:

1. to make your class or line lowercase.
2. to replace all characters different to ASCII.
3. to replace all characters (!@#$%^&*()) to dash (–).
4. to replace all spaces as well as low lines (_) and make class (line) the same.

For example,


Prestashop 1.6 vs. 1.7. Comparison_6


Prestashop 1.6 vs. 1.7. Comparison_7


Prestashop 1.6 vs. 1.7. Comparison_8


Prestashop 1.6 vs. 1.7. Comparison_9

If you want to use BEM methodology in your project, so there’s no need to use this modifier. In Prestashop 1.6 you have to put class names as well as correctness checking.

Classnames

The modifier takes array where the key is class name and parameters take on boolean value (true/false) in order to define the necessity to get it displayed. For example,

\controllers\front\listing\CategoryController.php


Go the template where we need to display the necessary class:

\themes\classic\templates\catalog\listing\product-list.tpl


The result,


Prestashop 1.6 vs. 1.7. Comparison_10

NOTE: Every classname is passed via classname modifier. In  Prestashop 1.6 there is no such function.

Now let us take a look at the differences of module development between the two versions of Prestashop.

Module development in Prestashop 1.6 vs 1.7

As you may know, the folder structure has been changed in PrestaShop 1.7. This means that the modules written on Prestashop 1.6 may not work on its 1.7 version.

Why this happens

This happens because Prestashop 1.7 can lack at least some hooks, which you could have used while writing your own module (addProduct, displayCartTotalPriceLabel, deleteProduct, etc. Check out the full list here).

Be careful, these are just a few examples of hooks that are no longer supported in 1.7 version, check your modules before migrating to Prestashop 1.7.

Of course, there are new hooks for creating new modules such as displayCheckoutSummaryTop, actionCartUpdateQuantityBefore, etc (full list of the new hooks). These hooks are only used in the 1.7 version.

How to update the modules from Prestashop 1.6 to 1.7

  1. Adapt product page modules (js and css files);
  2. Adapt modules of module pages (js and css files).

Prestashop developers have made the following changes.

  1. All the variables that are transferred to Smarty have been changed. We recommend that you check whether they are still used in your module.
  2. Massives are transmitted in Smarty instead of objects.
  3. The Smarty lines are automatically escaped:
    • Delete |escape:html‘:’UTF-8’  , but only in front office templates.
    • Use nofilter to output HTML.
  4. It is recommended to use the {URL} function instead of $link, since developers will remove $link in future updates.
  5. Use the new template call fetch(module:modulename/views/template.tpl).

Payment API update changes the parameters sent to the hooks: hookPaymentReturn and hookDisplayOrderConfirmation

Before:

Key Value
total_to_pay The result of $order->getOrdersTotalPaid().
currency The currency sign (string).
currencyObj The loaded currency (Currency class).
objOrder The current order object (Order class).

After:

 

Key Value
order The current order object (Order class).

Here is a codesample that will help you find all the orders.

Changes made to the product page modules in Prestashop 1.7

The product page has been completely rewritten for version 1.7 to simplify the creation of a product. If you compare version 1.6 with version 1.7, you will notice that in 1.7 there are 8 tabs instead of 12 in 1.6. Here is what the Prestashop 1.6 Admin page looks like:

image4

Now take a look at the new Prestashop 1.7 Admin page:

image3

Meanwhile, the amount of information has increased (combination of generator/manager; new shortcuts; an in-page catalog browser and other niceties). Below you can find the basic information that you will need to create a module for the product page.

modules prestashop belvg

PrestaShop 1.7 Modules

Take your online store to the next level with BelVG modules

Visit the store

Tabs processing

In Prestashop 1.6 you could make a separate tab for each module on the product page. In version 1.7, developers removed it but added a special tab where all modules are placed using the hookDisplayAdminProductsExtra hook.

Back office hook parameters

The parameters no longer come from the query, an array of methods is passed to hookDisplayAdminProductsExtra.

Assets

URLs for CSS, JS, images, etc. should start with http:// or https://. You can use the method Tools::getCurrentUrlProtocolPrefix () for this purpose.

Form fields

Field names must be created in the array of the hook in [MODULE_NAME][INPUT_NAME] format.

Folder structure in the module

Let’s take a look at the module and its structure. Here is the basic structure:
├── css
│   ├── external-lib.css
│   └── style.css
├── js
│   └── app.js
├── moduledemo.php
└── views
└── templates
└── front
├── included-template.tpl
└── moduledemo.tpl

Redefinition of the module with its assets files in version 1.7 looks like this:

└── modules
├── css
│ ├── external-lib.css
│ └── style.css
├── js
│ └── app.js
└── views
└── templates
└── front
├── included-template.tpl
└── moduledemo.tpl

Everything looks much simpler in version 1.7 compared with 1.6, where we had to create module folders in CSS and JS root folders. Here is the folder structure in Prestashop 1.6:

├── css
│   └── modules
│       └── css
│           ├── external-lib.css
│           └── style.css
├── js
│   └── modules
│       └── js
│           └── app.js
└── modules
└── views
└── templates
└── front
├── included-template.tpl
└── moduledemo.tpl

That is the end of the in-depth review of the differences between Prestashop 1.6 and 1.7. Leave your questions below if you have any, I’ll be glad to answer them.

Looking for a quality PrestaShop solution? Find a suitable one at BelVG store.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

3 Comments

  1. Hi David,

    Thanks for your questions. We will try to answer them, but before we need some more information on the issue:
    1. Could you please specify what do you mean by subscription here? Do you mean modules subscription or the services of our developers?
    2. Could provide ftp and admin access for us to take a closer look on the issue?

    Cheers!

  2. Hi Ivan,
    Very interesting set up you have. I have two questions for you:

    1. How much to subscribe and what do I get for my money?
    2. Just migrated from 1.6 to 1.7.4.2 and the following functions aren’t working. I get a message saying; “No input file specified.”
    • CATALOG -> Products.
    • CATALOG -> Stocks.
    • CATALOG-> Monitoring-> View.
    • MODULES -> Modules & Services.
    • MODULES -> Catalog.
    • SHOP PARAMETERS -> General
    • SHOP PARAMETERS -> Product Settings.
    • SHOP PARAMETERS -> Customer Settings.
    • ADVANCED PARAMETERS -> Information.
    • SHOP PARAMETERS -> Performance.
    • SHOP PARAMETERS -> Administration.
    • SHOP PARAMETERS -> Import.

    I host on Godaddy. Can you please help?
    Kind regards,

    Jason & David.

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *