Jump to content

Edit History

Daresh

Daresh

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

×
×
  • Create New...