Jump to content

How to add a new column (e.g. supplier) in order backoffice


JulioQ

Recommended Posts

Hi there,

in PrestaShop 1.7.6 I have added a new column in oder details to see the supplier of each line of product. I did it this way:

-  adminXXXX/themes/default/template/controllers/orders/helpers/view/view.tpl -->adding line:
 <th><span class="title_box">{l s='Supplier'}</span></th>

- adminXXXX/themes/default/template/controllers/orders/_product_line.tpl --> adding lines:
    <td>
        {Supplier::getnamebyid($product.id_supplier)}
    </td>

But now with the new version I cannot find those files to modify them and to add the Supplier. 

Does anybody know how to do it?

 

Many thanks in advance

 

Link to comment
Share on other sites

  • 3 weeks later...
18 minutes ago, WebSoft said:

./admin-folder/themes/default/template/controllers/orders/_product_line.tpl

$product['product_supplier_reference']
$product['purchase_supplier_price']
$product['id_supplier']
$product['supplier_reference']

{Supplier::getNameById($product['id_supplier'])}

 

It does not exist that directory 'orders' in bersion 1.7.7.7

Link to comment
Share on other sites

In the new versions of Prestashop, it is quite complicated and without programming knowledge you will not achieve the goal and probably no one will give advice from A to Z here.

For a programmer, it is a matter of a few minutes of work to create a module.
The most sensible thing is to create a small module and create your own hook and create an override twig template product.html.twig.

Just use the parameters in your own hook, which you will add to the override twig template.

E.g.: (added renderhook)

{% if product.supplierReference is not empty %}
        <p class="mb-0 productSupplierReference">
          {{ 'Supplier reference:'|trans({}, 'Admin.Orderscustomers.Feature') }}
          {{ product.supplierReference }}
        </p>
        <p class="mb-0 productSupplierReference">
          {{ 'Supplier:'|trans({}, 'Admin.Orderscustomers.Feature') }}
          {{ renderhook('displaySupplierNameInOrderProductList', {'product_id':product.id, 'combination_id':product.combinationId, 'supplier_reference':product.supplierReference}) }}
        </p>
      {% endif %}

 

And put the correct SQL query into the module, eg:

public function hookDisplaySupplierNameInOrderProductList($params) 
    { 
        $id_product = $params['product_id'];
        $id_attribute = $params['combination_id'];
        $reference = $params['supplier_reference'];
        $getName = Db::getInstance()->getValue('SELECT a.name FROM '._DB_PREFIX_.'supplier a 
            LEFT JOIN '._DB_PREFIX_.'product_supplier b ON (b.id_supplier = a.id_supplier) 
            WHERE b.id_product = '.$id_product.' AND b.id_product_attribute = '.$id_attribute.' AND b.product_supplier_reference = '."'".$reference."'");
        
        return $getName;
    }

result:

obrazek.png.6d1f8d9835ec1bb2238f29651f41ff49.png

  • Like 2
Link to comment
Share on other sites

2 hours ago, WebSoft said:

In the new versions of Prestashop, it is quite complicated and without programming knowledge you will not achieve the goal and probably no one will give advice from A to Z here.

For a programmer, it is a matter of a few minutes of work to create a module.
The most sensible thing is to create a small module and create your own hook and create an override twig template product.html.twig.

Just use the parameters in your own hook, which you will add to the override twig template.

E.g.: (added renderhook)

{% if product.supplierReference is not empty %}
        <p class="mb-0 productSupplierReference">
          {{ 'Supplier reference:'|trans({}, 'Admin.Orderscustomers.Feature') }}
          {{ product.supplierReference }}
        </p>
        <p class="mb-0 productSupplierReference">
          {{ 'Supplier:'|trans({}, 'Admin.Orderscustomers.Feature') }}
          {{ renderhook('displaySupplierNameInOrderProductList', {'product_id':product.id, 'combination_id':product.combinationId, 'supplier_reference':product.supplierReference}) }}
        </p>
      {% endif %}

 

And put the correct SQL query into the module, eg:

public function hookDisplaySupplierNameInOrderProductList($params) 
    { 
        $id_product = $params['product_id'];
        $id_attribute = $params['combination_id'];
        $reference = $params['supplier_reference'];
        $getName = Db::getInstance()->getValue('SELECT a.name FROM '._DB_PREFIX_.'supplier a 
            LEFT JOIN '._DB_PREFIX_.'product_supplier b ON (b.id_supplier = a.id_supplier) 
            WHERE b.id_product = '.$id_product.' AND b.id_product_attribute = '.$id_attribute.' AND b.product_supplier_reference = '."'".$reference."'");
        
        return $getName;
    }

result:

obrazek.png.6d1f8d9835ec1bb2238f29651f41ff49.png

ok, many thanks, uf... so complicated. I tried but i cannot. I have put the first part of the code (added renderhook) in file product.html.twig and second part as a SQL query. 

I supposed it is wrong because it is not working... 

Link to comment
Share on other sites

Just now, WebSoft said:

You can add hook to Orders.php, but it must be registered.

ok. Really thank you for your help. But I don´t have enough knowledge to do that. It was very easy in previous version

many thanks anyway!

  • Sad 1
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...