Extra Product Description Fields

Open to all! Ask other shopowners for help.
User avatar
tessthepup
Certified Developer
Posts: 382
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Extra Product Description Fields

Post by tessthepup »

Good afternoon all,

I need to add extra fields to the admin product entry for additonal info to be shown in tabs on the product info page.

Now in the old days it was as simple as duplicating the products_description in admin/categories.php

What would be the correct process these days? I have had a look at the core code but do not want to drastically change anything if I dont need to.

I would appreciate a heads up from those who know the best practice for doing this

Many thanks

Mark


Join The Code Co-op to get access to your library in the Code Co-op Forum
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Extra Product Description Fields

Post by LeeFoster »

You create a module, copying one of the existing ones for product tabs will be the easiest way to do it.

Then you'll need a hook to allow you to amend the data and probably need to add the columns to the table too.
User avatar
tessthepup
Certified Developer
Posts: 382
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Extra Product Description Fields

Post by tessthepup »

LeeFoster wrote: Tue Dec 28, 2021 6:05 pm You create a module, copying one of the existing ones for product tabs will be the easiest way to do it.
Already got this part sorted
LeeFoster wrote: Tue Dec 28, 2021 6:05 pm Then you'll need a hook to allow you to amend the data and probably need to add the columns to the table too.
Its the admin side I have no idea where to start lol
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Extra Product Description Fields

Post by Kofod95 »

You could take a look at my specials at products edit addon. It would look a little different if you are on a version later than 1.0.8.4, but the general idea would be the same. Feel free to ask.
The beauty here is, that you can make this happen without editing core, and once you get the rythm of it, you'll find that it is quite easy to make these kind of additions, with the added bonus that updating is easy!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
tessthepup
Certified Developer
Posts: 382
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Extra Product Description Fields

Post by tessthepup »

Kofod95 wrote: Tue Dec 28, 2021 8:44 pm You could take a look at my specials at products edit addon. It would look a little different if you are on a version later than 1.0.8.4, but the general idea would be the same. Feel free to ask.
The beauty here is, that you can make this happen without editing core, and once you get the rythm of it, you'll find that it is quite easy to make these kind of additions, with the added bonus that updating is easy!

//Daniel
Hi Daniel,

Thank you for the advice. All I need to know now is where the heck is the code for product insertion lol

So different from the old day :shock:
14Steve14
Senior Contributor
Posts: 922
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Extra Product Description Fields

Post by 14Steve14 »

I looked into trying to make something similar as I wanted to add in a products specification area, using the product tabs and could not get it to work on an individual product basis. I could get a tab to show but it contained the same information on every products.

I am sure there must be a way of creating an admin hook for the categories page that would allow the text to show on a particular product but have yet to get any further with it. May have to have a bit of a look later to see what can be done.

I was thinking of a hook that would allow an extra products description box to be added to the products table and show the data entered on products. Probable not that hard for a coder to do.
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Extra Product Description Fields

Post by Kofod95 »

tessthepup wrote: Wed Dec 29, 2021 12:36 pm All I need to know now is where the heck is the code for product insertion lol
>= 1.0.8.5

=< 1.0.8.4


Note line 308 on the second link:

Code: Select all

        $OSCOM_Hooks->call('categories', 'productActionSave');
That allows you to inject code from a different file (which is what I do in the addon I linked in my previous post), meaning you can leave all core files as is.
You'll need a hook utilizing line 662 as well (as a function in the same file - as is done in the addon linked) :

Code: Select all

            echo $OSCOM_Hooks->call('categories', 'injectLanguageForm');
Which will inject the form for you to enter data into.

In versions >= 1.0.8.5 the structure is a bit different, but most files that work the old way will work here as well with just a few naming-changes
tessthepup wrote: Wed Dec 29, 2021 12:36 pm So different from the old day
Luckily, yes!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
tessthepup
Certified Developer
Posts: 382
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Extra Product Description Fields

Post by tessthepup »

Kofod95 wrote: Wed Dec 29, 2021 6:19 pm
tessthepup wrote: Wed Dec 29, 2021 12:36 pm All I need to know now is where the heck is the code for product insertion lol
>= 1.0.8.5

=< 1.0.8.4


Note line 308 on the second link:

Code: Select all

        $OSCOM_Hooks->call('categories', 'productActionSave');
That allows you to inject code from a different file (which is what I do in the addon I linked in my previous post), meaning you can leave all core files as is.
You'll need a hook utilizing line 662 as well (as a function in the same file - as is done in the addon linked) :

Code: Select all

            echo $OSCOM_Hooks->call('categories', 'injectLanguageForm');
Which will inject the form for you to enter data into.

In versions >= 1.0.8.5 the structure is a bit different, but most files that work the old way will work here as well with just a few naming-changes
tessthepup wrote: Wed Dec 29, 2021 12:36 pm So different from the old day
Luckily, yes!

//Daniel
Thanks Daniel although none the wiser but will have a go lol
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Extra Product Description Fields

Post by Kofod95 »

tessthepup wrote: Thu Dec 30, 2021 11:17 am Thanks Daniel although none the wiser but will have a go lol
That is why I adviced looking at my addon that does something similar to what you want (adding an input on the product-edit) - you could take my addon and just change the form and input to do what you want it to. Of course, you would probably want to inderst the form in the language-tab, but all the info you need to do that should be provided in my two previous posts.

Good that you will give it a try! Feel free to ask if you get stuck!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
tessthepup
Certified Developer
Posts: 382
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Extra Product Description Fields

Post by tessthepup »

Kofod95 wrote: Thu Dec 30, 2021 5:23 pm
tessthepup wrote: Thu Dec 30, 2021 11:17 am Thanks Daniel although none the wiser but will have a go lol
That is why I adviced looking at my addon that does something similar to what you want (adding an input on the product-edit) - you could take my addon and just change the form and input to do what you want it to. Of course, you would probably want to inderst the form in the language-tab, but all the info you need to do that should be provided in my two previous posts.

Good that you will give it a try! Feel free to ask if you get stuck!

//Daniel
Hi Daniel,

Having a go at tackling this but just wondering if you can let me know if I am right in thinking the code I should be looking to put inside the hook is from admin/includes/actions/catalog/views/new_product.php ???


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply