Jump to content

Add backoffice "Total sold" to columns products list


Sergio Martins

Recommended Posts

  • 1 year later...
  • 5 years later...
  • 8 months later...
  • 2 years later...
34 minutes ago, janoroh said:

I'm looking for the same thing. Does anyone still have a currently working solution for this for PS 1.7.8? The user "4you.software" with their free module doesn't seem to exist anymore.

This thread is from 2015. Better open a new one and explain what you are looking to accomplish.

Name the Theme, versions, if over module and which one. Update history is a nice surplus.

Edited by Nickz (see edit history)
Link to comment
Share on other sites

6 hours ago, Nickz said:

This thread is from 2015. Better open a new one and explain what you are looking to accomplish.

Name the Theme, versions, if over module and which one. Update history is a nice surplus.

Sure, I'm aware of that. ;) But I don't need any module support, I would just like to achieve the exact same thing that this thread is about ("total sold" column in the product list). And the last post is from 2022 from a user who implemented it in 1.7, so everything still applies, I guess. Just looking for an easy solution for this, I don't mind if it's a module or just an override/edit to AdminProductsController.php.

Link to comment
Share on other sites

  • 5 months later...
Posted (edited)

It seems there is no easy way to achieve it in PS 1.7.8, it lacks useful hooks.

I came out to some simple and dirty solution, resulting in that column displayed, but without sorting or filtering.

Files to change:

\src\PrestaShopBundle\Controller\Admin\ProductController.php

Add:

foreach ($products as &$product) {
            $product['total_sales'] = (int) \Db::getInstance()->getValue('SELECT `quantity` FROM `'._DB_PREFIX_.'product_sale` WHERE `id_product` = '.$product['id_product']);
}

After line 165:

$lastSql = $productProvider->getLastCompiledSql();

 

\src\PrestaShopBundle\Resources\views\Admin\Product\CatalogPage\Lists\list.html.twig

Add:

        <td class="text-center">
           {{ product.total_sales }}
        </td>

After line 76, containing:

{% endif %}

\src\PrestaShopBundle\Resources\views\Admin\Product\CatalogPage\Lists\products_table.html.twig

Add:

          <th scope="col" class="text-center">
             {{ "Sales"|trans({}, 'Admin.Global') }}
          </th>

After line 69, containing:

{% endif %}

And add:

<th>&nbsp;</th>

After this block:

<th class="text-center"></th>
          {% if configuration('PS_STOCK_MANAGEMENT') %}
          <th class="text-center">
            {% include '@PrestaShop/Admin/Helpers/range_inputs.html.twig' with {
              'input_name': "filter_column_sav_quantity",
              'min': '-1000000',
              'max': '1000000',
              'minLabel': "Min"|trans({}, 'Admin.Global'),
              'maxLabel': "Max"|trans({}, 'Admin.Global'),
              'value': filter_column_sav_quantity,
              'disabled': filters_disabled,
            } %}
          </th>
          {% else %}
            <th></th>
          {% endif %}

And for more recent PrestaShop versions, check out the Gridder module:
https://codecanyon.net/item/gridder-add-and-remove-columns-from-prestashop-back-office-lists/33859071

Edited by Daresh (see edit history)
  • Like 1
Link to comment
Share on other sites

On 1/23/2025 at 7:08 PM, janoroh said:

I'm looking for the same thing. Does anyone still have a currently working solution for this for PS 1.7.8? The user "4you.software" with their free module doesn't seem to exist anymore.

Hi.

I changed my name and website 🙂

The module is still available for free.

However, it is currently disabled, like other modules, due to an upgrade for Prestashop 9.x versions.

It should be available by the end of the week.

Free modules page ;-)

Edited by ps8modules (see edit history)
Link to comment
Share on other sites

6 hours ago, ps8modules said:

I changed my name and website 🙂

The module is still available for free.

Ah, nice! Thanks a lot to you, too! I'll have a look next week then. :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...