This manual is intended for people who have basic knowledge in HTML, Smarty, PHP. The plugin developer does not perform free optimization and profiling work.

With the help of profiling report you can detect all sources of Flexdiscount calls. This information will help you to find all weak performance places. By using recommendations for optimization, you will reduce load on server.

How to make profiling?

1) Open plugin settings and enable profiling mode.

2) If necessary, edit your settings and save them.

3) Create specified cookie in browser.

You need to create cookie with the name fl-profiling-1588100398736.

Open the page, where you would like to make a profiling.

Open developer tools in Chrome with the help of F12 on the keyboard. Select tab Application. In sidebar open Cookies and select your domain.

In order to create a cookie, you need to make double-click on the empty white field just under all the cookies. You will then be able to specify the name of the cookie.

Then press TAB and specify the value "1"

4) Reload the page, where you would like to make a profiling.

5) Open the application Logs and find the log-file flexdiscount.profile.log.

We recommend to delete it after each profiling every time, if you don't want to be confused among data.

Decode profile report

Plugin can be called from 3 sources:

  • Plugins
  • Methods
  • Templates

Profiling hooks:

  • frontend_products
  • order_calculate_discount

Plugin has 3 tracking points:

  • Before validating plugins
    Invoked before plugin validation. This determines whether the plugin is allowed to continue processing or not. You can estimate how many requests are received to the plugin.
  • After validating plugins
    Invoked after plugin validation. You can estimate how many plugins are passed the validation.
  • Calculating
    The most important point. Invoked after discount calculating.

Let's look at the report.

1) First rows have information about calling time and page that was profiled:

In our case this is a product page.

2) Then we can see the hook, which was called, number of calls, which passed through the points, and the time spent on processing.

Here you can estimate the main load on the plugin.

We can see, that there were 3 requests on discount calculating (Point "Calculating"). It took 0.04 sec.

6.3419342041016E-5. It is 6.34*10-5 sec.

This is a good result. There is nothing to optimize here. But let's continue.

Then follows the description of the sources.

The output is represented by a tree structure:

  • "−" one dash. The source of the request.
  • "−−" two dashes. Tracking point that the request passed through.
  • "−−−" three dashes. Service header (Calls statistics), after which the call history is listed (call).
  • "−−−−" four dashes. Service information. Number of the call and time spent on processing. Next is the call history.
  • "−−−−−" five dashes. The call that triggered the plugin to work at the tracking point. The number of such calls depend on the setting "Depth" in profile settings. There may be fewer results. This happens when the call history was small.

Consider part of the report.


We can determine, that call came from the method shopFrontendProductAction->prepareProduct(). This is a system method of Shop-Script. We cannot change it.

It passed through all points just one time. It was preceded by a chain of calls, starting from waEvent->runPlugins().


Badges plugin was the next source. It tried to call the plugin twice, but didn't get past the first point. Flexdiscount plugin filtered it out.

You can see that the main reason for the call was the method shopCartItemsModel->getByCode() through the method shopCart->items(), which was called by Badges plugin. If we refer to optimization article, we will find this method: (new shopCart())->items() - in the list of the requests, which activates discount calculating.


The next source is Flexdiscount plugin itself. We will omit this part of the report because the calls are system calls.


Promos plugin was also filtered.

7) Then we will consider only the point Calculating, because it is the most important.

Plugin was called twice from the template product.html:

  • when getting the list of recommended products: shopProduct->upSelling()
  • when getting the list of cross-selling products: shopProduct->crossSelling()

Find this calls in the template:


Hook order_calculate_discount (the main hook for calculating discounts) was called only once by Promos plugin. It took 4.79*10-5 sec. All subsequent calls to the hook were not recorded, because the Flexdiscount plugin cached the results and no longer performed any calculations.

This way we saw all the calls to the discount plugin. We can only disable the setting "Change product prices to discount prices" to optimize the plugin. This means that there will be no calls from 2 to 7 paragraph. Only order_calculate_discount call will remain. How much is it necessary is up to you.

Posted: April 29, 2020
Feedback form

Fill the form, and we will contact you.

Your name: