One of the features of PrestaShop is the ability to use the SQL manager function to make custom queries to find specific data within the database of the shop.  You can create queries, view the results, and export them to a CSV file.  The following tutorial reviews how to add SQL queries in PrestaShop 1.5.

Using the SQL Manager in Advanced Parameters to add a SQL Query

  1. To get to the Performance section of the Advanced Parameters for Prestashop, first login to the Administrator as an Administrator
  2. Hover over menu bar where it says ADVANCED PARAMETERS - click on SQL MANAGER when it appears in the drop-down menu.
  3. You will see something similar to this screenshot:

    prestashop151-SQLmanager-1

    Note the blue field and the instructions.  This is an information field provided by Prestashop.  It gives direct instructions on how to add a new query,  view the results and export the results.  We will focus on simply adding query in this article.

  4. In the top right hand corner click on the green ADD NEW button.  You will the following screen:

    prestashop151-SQLmanager-add


    The two required fields are the name of the query you want to create as well the query itself.  Click on the NAME field and name the query.  For example, the sample screenshots below will show a simple MySQL Query (for information on using MySQL queries, go to MYSQL documentation on Entering Queries) called "newquery" and then it will show a very simple MySQL query pulling data from the PS_ADDRESS table:

    prestashpo151-sqlquery-add-simple1

    In order to add the query, simply click in the REQUEST field and type in the code.  The request above is a simple select request which will show all the addresses in the PS_ADDRESS table.

  5. You can type in the name of the table directly in the request or you can actually select the table from the LIST of MYSQL TABLES and it will appear in the request field.  Conveniently, Prestashop has also listed all of the tables in the database that can be addressed.  Clicking on the table in the list will look like this:

    prestashop151-sqlmanager-addtable

    The table attributes are listed and are added to the query by simply clicking on the ADD TRIBUTE button beside each table attribute.  The attribute is added into the query field for you saving some typing time (especially if the attribute name is pretty long).  You can click on multiple tables for the query.  Care should be taken with the queries you are running on the database.  Remember that you are taking resources from the server to run these queries.

  6. Click on the SAVE button and it will return to list view and look like this:

    prestashop151-SQLmanager-1a


    Here you will see the following options:

    Icon Action description of icon
    csvicon
    CSV export option
    viewqueryresultsicon

    View query results

    editqueryicon
    Edit query results
    trashicon
    Delete query


  7. To find more information on using the CSV Export option, go to How to Export SQL Query results to CSV in PrestaShop 1.5.  The other options are relatively self-explantory. Click on on the VIEW QUERY RESULTS ICON and you will see the following:

    prestashpo151-sqlquery-results

    This screen also lets you back up and EDIT the query.  Editing the query is exactly the same as adding the request expect that code for the query already exists. 

    The EDIT option is available in the ACTION icons list as well as the DELETE option represented by the trashcan icon.  If you wish to delete a specific query, you can delete by selecting the checkbox and the clicking on DELETE SELECTED, or you can click on the trashcan icon for the specific query you wish to remove.

Querying the database is made into an simple task with the PrestaShop SQL Manager feature.  However, it requires some knowledge of querying SQL databases in order to properly obtain the proper data and show the resutls in a meaningful manner.  Make sure to show care when crafting queries as SQL queries can be very large obtaining unnecessary data and possibly resulting in a resource hit on your server.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Did you find this article helpful?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 757-416-6627 Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}