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.

Products do not save in PS 1.6

Save and Stay button in Prestashop 1.6.0

The “Save and stay” button does not work in product detail in various subversions of Prestashop 1.6.0.9. This problems first appeared with Chrome some time ago. But the button was more or less operational in Firefox – until the March 2019 Firefox update.

There is a nice and easy to install module attempting to resolve the issue. Unfortunately this solution is not 100% reliable. Some customers were greatly satisfied with the module, some reported the problem as still unsolved, even when advised to clear the browser cache.

Thus, the only reliable solution is to upgrade the prestashop version. You may decide for the “big” upgrade to PS 1.7 or for the much easier upgrade to PS 1.6.1. Yes, that is righ, any subversion of PS 1.6.1.X is sufficient, but you will certainly use the last one. let us assume prestashop 1.6.1.24.

Can you keep your customized PS 1.6.0.x default theme when upgrading to latest PS 1.6.1.24 subversion? The answer is yes, with due precautions. These are issues we are aware:

  • Contact form – the contact form in in PS 1.6.1.24 get some extra hidden fields and will not work after upgrade. Get the PS 1.6.1.24 zip file, unpack and replace \themes\default-bootstrap\contact-form.tpl with the same file from the unpacked zip
  • Product page. Check product with combination and special prices. It it does not work properly (the prices do not change as expected), you need to replace both \themes\default-bootstrap\product.tpl and \ themes\default-bootstrap\js\product.js . Do not forget to clear the browser cache

Warning – upgrading Prestashop without upgrading the theme is always risky. On the other hand, I am aware of many shops undergoing such kind of speed upgrade without any several errors.

Tweaking prestashop search – searching by products codes (reference)

Prestashop search engine is based on individual words stored in the database. It will return no results for incomplete (partial) words.

This problem was recently encountered on a website selling quad spare parts. Every spare part has a reference number in the form xxxxyyyzzzz where xxxx is specific for group , yyy for subgroup and zzzz for the product itself. Searching for “xxxx polaris” should return all spareparts belonging to the the group “xxxx” and matching the word polaris. But, as mentioned above, “xxxx” is only an incomplete word and will be normally ignored by the search engine. A simple solution is adding several lines of code into the indexation method of the Search class and rebuild the index:

if($key == ‘reference’) {
for($i = 5; $i < 10; $i++) {
if(strlen($value) > $i) {
$words[]=substr($value,0,$i);
}
}
}

Extending tinyMCE editor in prestashop 1.6 – the full story

Tiny MCE is the rich text editor used for editing the large multilangual text fields like product desription or content of CMS pages. The interface used in PS 1.6 is rather a moderate one and many features were ommited. Just take a look at the available buttons in the classic example .

Fortunatelly, adding extra buttons to the default PS 1.6 tiny MCE is not difficult. Specifically, you will need:

1) Modify the tinyMCE settings

Locate the /js/tinymce.inc.js file, open in in a clean text editor and add the required functionality. Simply inspect the source code in the classic example and add plugins and buttons you need. Alternatively, if this seems complicated, you may use the whole /js/tinymce.inc.js file as described in another tutorial , but be sure to complete the steps 2 and 3 as described below.

2) Disable the html validation

by modifiing the prestashop Validate.php class. For several reasons, it is considered a bad practice to modify Prestashop core classes, one of them beeing the fact that these modification will not persitst through the next upgrade. Therefore:

a) in a clean text editor (e.g. notepad), create a clean file named Validate.php and copy paste the following code inside it:

b) copy the file into the directory /override/classes/

c) delete the file /cache/class_index.php

3) In backoffice go to the Preferences :: General and set the option Allow HTML purifier to off . Without it, the HTML purifier will keep removing certain elements – for example, you will be unable to insert a new window link.

Adding YouTube video in Prestashop 1.6

Inability to embed youtube video in Prestashop 1.5 product and CMS pages raised a lot of confusion on prestashop forums and promoted development of various modules.

Fortunatelly, this issue no longer persists in Prestashop 1.6.

1) In backoffice go to the Preferences :: General and set the option Allow iframes on HTML fields to yes . This option is present at least in version PS 1.6.0.9 and higher. You may neet to set the option Allow HTML purifier off as well.

2) Find the video on youtube and click on the Share option. Copy the full code into the clippoard (e.g.

3) In the backoffice, go to the product detail and locate the Description field. Find the Tools button in the editor toolbar, click it to expand and select the Source code button. Paste the youtube code copied in the previous step into the source code pop up window.

4) Press OK to close the source code pop up, press than Save and Stay to actually save the changes. You will see a large questionmark in the place you have copied the video, but this is normal and the video is visible at the frontend.

5) You can use the same approach for CMS pages.