07/11/2023 Franck Bugnet How to

Bulk management of a second product description in PrestaShop

A classic use of custom fields is to display a second description on product pages. That is, additional information, in plain text or HTML, often multi-language and multi-shop, at a different location from the summary or long description.

After adding a new heading to the existing product_lang table, which already contains other translatable product texts (name, summary...), this article will show you step-by-step how to display it in Merlin Backoffice ® Flex, to then be able to edit its content more quickly product by product or en masse.


Adding a new field to a database table



Imagine that on your site, in the product pages, you wanted to add a second HTML text zone, to display a second description, containing HTML.
In this case, you would need to add a text type heading directly in the product_lang table, like this

Custom fields, tuto 1 - image 1 - Second description in product_lang table



Display the heading in a Merlin Backoffice ® Flex custom column



The management of personalized or custom fields, i.e. non-native data added to native tables or to tables that are themselves non-standard, can be achieved thanks to the concept of perso columns.

  1. In the column configurator, look in the left-hand table for the "Custom" block and drag one of the perso columns to the right-hand table.
  2. To open the custom column editor, right-click in either of the two tables.

champs_perso/Custom fields, tuto 1 - image 2 - drag and drop 1 custom column



With the custom column settings window open, simply follow the 5 steps. Step 1:

  1. We've added custom column N°3. Let's start by associating it with the table containing the second description. To do this, simply pull down the list of tables in the database...
  2. ...and select the row of the product_lang table (you can also find it quickly by typing the beginning of its name, starting with the prefix: "pscw_product_l...")

Custom fields, tuto 1 - image 3 - choix de la table contenant le champ



  1. Now scroll down the list of table headings.
  2. To select our custom heading "Description2".
  3. Step 2: in the next column, "Data type and processing", leave the default value "Unique values", as a product can only have one value associated with this field.

Custom fields, tuto 1 - image 4 - Choosing the field in the table



As this custom field has been added to a base table, already known to Merlin Backoffice Flex, the rest of the settings below can be completely ignored, as the tool has already checked and pre-filled for you what is required. Without touching anything else, this will work.
Let's take a look anyway, as this is a tutorial:

  1. Step 3, the filters. The "Filter by product" box checked itself, because the software went to read the table indexes and knows that id_product is one of the elements of the compound key. In 99% of cases you won't need to worry about this setting.
  2. Same for id_shop.
  3. And for id_lang. So basically this means that Merlin already knows that in this table, product-related information is stored that may be different for each language in each store (in the case of a multi-shop configuration). It will take this into account when reading and saving data.

Custom fields, tuto 1 - image 6 - Automatic filters



  1. Step 4: the joins. Quickly leave the "Automatic join" column. You'll see examples of its use later.
  2. And the "Filter or manual join" column. Let's ignore for the moment the other columns further to the right, useful only in far more complex cases.

Custom fields, tuto 1 - image 7 - Step 4: joins.



  1. Step 5: click "Validate" to save the settings and exit the window.
  2. If you haven't already done so, the program will ask you to check "the eye" to validate the display of the column and to give it a non-generic title.

Custom fields, tuto 1 - image 8 - On exit, check column to display



  1. Once back in the column configurator window, note that here too you can check or uncheck the eye for each row and change the title to be displayed.
  2. When this setup work is complete, click on "Validate and close".

Custom fields, tuto 1 - image 9 - Column Configurator, give column a title



Modifying values stored in custom field



Once out of the table configurator. We see that the product table now displays our new "Description 2" field.

Good to know: columns linked to custom fields are visually identifiable thanks to their title on a colored background (pale orange).

Entering its content, product by product, is perfectly possible, as with any other native field.
In the example below I've just entered simple text, but I could just as easily enter HTML text, like <h3 class="toto">This and a subtitle</h3>.

And as usual, the value is saved the moment you exit the line (we'll see later that automatic saving can be disabled in the "Calculation Options" panel and performed on demand):

Custom fields, tuto 1 - image 10 - La colone saffiche et permet la saisie



But where Merlin Backoffice ® Flex becomes truly magical is that all its mass processing tools are now available on this type of column too.
For example, to copy the second description of the first product identically to a selection of other products, simply:

  1. Select them.
  2. Right-click on the value to be copied.
  3. Then choose the Paste option from the context menu, like this:

Custom fields, tuto 1 - image 11 - Copy and paste text into the second description by right-clicking



  1. And finally to confirm that the contents of the personal columns (in this 1st example there are no others) are saved in the database.

Custom fields, tuto 1 - image 12 - Copy and paste confirmation, with immediate saving to base



Result after copy and paste:

Custom fields, tuto 1 - image 13 - After refreshing, the edits have been taken into account



Second possibility, using MagicEdit and MagicFormula.

  1. Selected products, right-click again in the column to be modified.
  2. Choose the "MagicEdit in all selected cells of this column" command.

Custom fields, tuto 1 - image 14 - Possible use of MagicEdit in a custom column



Imagine that we wanted to complete the current content of each second description with the text "product N°x", with x being the product ID number. We could do this with this setting:

  1. Click on "Add text at the end" and enter the beginning of the text "product N°".
  2. Click on "Insert content from other columns" to activate it and in the "Column 1" selector, choose "product ID".
  3. Click on "Phase 1...".

Custom fields, tuto 1 - image 15 - MagicEdit setup



  1. To save in the database, you then have two choices, either check the "Save custom columns" option below the "Phase 2..."
  2. button.
  3. Then click on the button:

Custom fields, tuto 1 - image 18 - Option denregistrement des colonnes perso



  1. Or don't check the "Save custom columns" box, but click directly on "Phase 2...", then in a second step call up the right-click context menu.
  2. And launch the save custom columns function:

Custom fields, tuto 1 - image 19 - Custom column registration function



Time-shifted registration allows you to fill several personal columns before registering the whole. We'll look at concrete use cases in future tutorials.

The result will be identical whatever the recording method. The modifications are now in base and the second descriptions can be displayed in the store.

On the front office side, there are of course a few additional steps: the product.php template needs to be enriched so that it too can read this new heading, and the theme's product files need to be adapted to add the display to the desired location. This can be achieved using override techniques or hooks. As this last step is outside the scope of this tutorial and varies according to the version of PrestaShop and theme used, it is not presented here and should be entrusted to your webmaster.

This first example shows just a tiny fraction of the possibilities offered by this hyper-powerful tool. We now invite you to take a look at the other examples below.

This first example shows just a tiny fraction of the possibilities offered by this hyper-powerful tool.


Category's other articles Mass management of custom fields

Settings
  • Login
    • £ GBP
    • $ USD
Menu