Jump to content
thirty bees forum
  • 0

Add extra field to product selection in admin orders


b_otho

Question

Hi everyone,

I've been struggling to make an extra field visible in the dropdown box that shows up after searching for a product to add in the admin order view.

I'm pretty new to Thirty Bees but managed to add my own fields to products, product lists, imports etc. But I can't seem to figure this out.

Any help is much appreciated.

Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0

I have made a "title" field on my products. I sell vinyl records and CD's, and the product name is the artist, and my custom title field is the name of their record. Because of this I have severals product with the same name. When I then search for products to add when creating orders in the back office, I get multiple results with same name. That's why it would nice to add my title field to the results. Hope it makes sense.

Link to comment
Share on other sites

  • 0

@b_otho

Alternatively, I do not know if you need, for example, information in the manufacturer lists or supplier lists. If they are invisible / deactivated for the customer, then use them, for example. you can use artist as manufacturer or supplier. So you can separately customize the product list view and filter such as from this topic: https://forum.thirtybees.com/topic/1223/product-list-bo-with-manufacturers-and-suppliers-columns

Link to comment
Share on other sites

  • 0

@wakabayashi: I see your point. The only reason I'm not writing it as "artist - album name" is because I need to be able to export csv files with the two fields in their own columns. Otherwise it would make my life so much easier also with friendly urls, how it appears on invoices etc...

@zimmer-media: I'm going to use either manufacturer or supplier as the record label, haven't decided on which one yet, but I guess I could use the one left as my artist. I'll look into that. I've already added my own custom field, as mentioned in the post you link to, so it's not a problem for me to edit that list and add extra fields if needed.

It still doesn't really solve my problem though as either supplier or manufacturer won't come up in the results when I create orders. The ideal solution for me, no matter which kind of input field I use, is that both artist name and album name come up in these results.

Link to comment
Share on other sites

  • 0

@b_otho said in Add extra field to product selection in admin orders:

I see your point. The only reason I’m not writing it as “artist - album name” is because I need to be able to export csv files with the two fields in their own columns. Otherwise it would make my life so much easier also with friendly urls, how it appears on invoices etc…

If this is the only reason then I believe the best you could do is to either

  • modify csv export to output name as two columns
  • use a module that can do this split during export automatically (wink wink, shameless plug)
Link to comment
Share on other sites

  • 0

@b_otho yeah, sure, quite easily.

My module let you create list of (almost) any data in your system. Columns can contain expressions, similar to excel formulas. For examle you can replace string, perform mathematical operation, etc... So basically you can get the data out in any format you need.

Once you have a list, you can export it to csv manually, schedule it to generate csv file periodically, or even create endpoint (url) that, when accessed, will return up-to-date csv file.

I have prepared a short youtube video that shows how to create list and split product name to two columns.

youtube video

The module is paid, but there's a 14 day trial period, so feel free to test it out. And shoot me an email if you need any help

Link to comment
Share on other sites

  • 0

@b_otho

You can also follow the hints of Nemo and customize your code in your files / overrides. Continuing then only the invoice and the produkt.tpl would have to be adjusted. If necessary, additional files where the additional field should appear.

The other note from the forum, which I have previously used even with PS, I can not find right now.

https://mypresta.eu/en/art/developer/new-field-product-backoffice.html

Link to comment
Share on other sites

  • 0

its not perfect, but helpful as example to add extra field for product name

step 1 Add an entry to the database in the table prefix_product 0_1513990536778_dc836d8c-85fd-4bd4-b056-c03ec51d8d08-grafik.png

step 2.1 modify the file "Product.php" from "/classes/Product.php", preferably in the folder classes Override "/override/classes/Product.php" save see the lines /** @var int Supplier id */ public $id_supplier; /** @var int default Category id */ public $id_category_default; /** @var int default Shop id */ public $id_shop_default; /** @var string Manufacturer name */ public $manufacturer_name;

just add the following

/** @var string Artist name */ public $artist_name; step 2.2 for example find 'id_supplier' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'], 'reference' => ['type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32],

after this add 'artist_name' => ['type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 200], step 3 copy your informations.tpl under override / controllers / admin / templates / products / informations.tpl and find the code

<div class="form-group"> <div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="name" type="default" multilang="true"}</span></div> <label class="control-label col-lg-2 required" for="name_{$id_lang}"> <span class="label-tooltip" data-toggle="tooltip" title="{l s='The public name for this product.'} {l s='Invalid characters:'} &lt;&gt;;=#{}"> {l s='Name'} </span> </label> <div class="col-lg-5"> {include file="controllers/products/input_text_lang.tpl" languages=$languages input_class="{$class_input_ajax}{if !$product->id || Configuration::get('PS_FORCE_FRIENDLY_PRODUCT')}copy2friendlyUrl{/if} updateCurrentText" input_value=$product->name input_name="name" required=true } </div> </div> after this insert <div class="form-group"> <div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="name" type="default" multilang="true"}</span></div> <label class="control-label col-lg-2"> <span class="label-tooltip" data-toggle="tooltip" title="{l s='The second public name for this product.'} {l s='Invalid characters:'} &lt;&gt;;=#{}"> {l s='Artist Name'} </span> </label> <div class="col-lg-5"> <input type="text" id="artist_name" name="artist_name" value="{$product->artist_name|default:''}"/> </div> </div> step 4 product view - in your theme product.tpl ```

{$product->name|escape:'html':'UTF-8'}

change to

{$product->name|escape:'html':'UTF-8'} - {$product->artist_name|escape:'html':'UTF-8'}

```

my result: 0_1513991609169_9c7387b1-e087-4617-ad03-833cdd9963f2-grafik.png0_1513991628699_a97051d2-0791-404e-8836-6bb7c2ce8056-grafik.png0_1513991651931_c003730f-b868-4f43-98e1-5bfca89215fc-grafik.png

For the invoice etc, you should include {$product-> artist_name | escape: 'html': 'UTF-8'}

Link to comment
Share on other sites

  • 0

I expand my information

In the product list of the BO for filtering, adjust the following parameters in the code:

for example under "/override/controllers/admin/AdminProductsController.php"

after the code $this->fields_list['name'] = [ 'title' => $this->l('Name'), 'filter_key' => 'b!name', ]; add:

$this->fields_list['artist_name'] = [ 'title' => $this->l('Artist'), ];

0_1513997230548_f416c4df-2db9-4e93-adf1-8381684a167e-grafik.png

with filter 0_1513997252533_c4c295db-82a5-4196-b77f-2fcc1bb1c7e5-grafik.png

0_1513997890723_12773df1-7aef-4dcc-a11d-2af9f3a99a8a-grafik.png

0_1513997902225_489825ca-e342-4927-a6fb-9faa30009851-grafik.png

Link to comment
Share on other sites

  • 0

@zimmer-media: Thanks for all you work you're putting into this. I have already made a field as you describe by using Nemo's tutorials though, but got stuck when I wanted to add this field to dropdown that comes up after searching for products in bo order creation.

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...