Forums / General Questions / Create custom fields for Products for Admins only

Create custom fields for Products for Admins only

Views: 20,841

Results 1 to 5 of 5
11 Oct 2023, 3:26 PM
#1
swissarmyknife avatar

swissarmyknife

New Zenner

Join Date:
Apr 2019
Location:
Boulder City NV
Posts:
2
Plugin Contributions:
0

Create custom fields for Products for Admins only

Hi. I created a duplicate store in a private location. This is my playground.

In my playground, i created a child table for Products by copying the products_description child table to products_suppliers and modifying the structure. I dropped two (2) fields and inserted nine (9) new fields, designed to contain Supplier data. I want these fields to be available to the Admin when he adds or edits a product, but they will not appear to the shopper on the front end.

Which PHP scripts must I create or edit to make this happen?

Thank you.

17 Oct 2023, 10:03 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Create custom fields for Products for Admins only

SwissArmyKnife:

Hi. I created a duplicate store in a private location. This is my playground.

In my playground, i created a child table for Products by copying the products_description child table to products_suppliers and modifying the structure. I dropped two (2) fields and inserted nine (9) new fields, designed to contain Supplier data. I want these fields to be available to the Admin when he adds or edits a product, but they will not appear to the shopper on the front end.

Which PHP scripts must I create or edit to make this happen?

Thank you.
Its been nearly a week since this was posted and it appears that no support has been offered related to this request.

So, some basics to try to help you at least identify where changes are needed:
The existence of data in the database does not mean that the data will be readily accessible by customers visiting the site. Think about all of the tables and records that are present in a standard database, all information doesn't just get magically displayed to the product information page. It takes code to get there. Also, just because data is in the database, doesn't mean that admins have ready access to the data.

So, basically, whatever fields you add/create to whatever database table will not be visible to customers without some level of code to make them visible, and the that same thing is true for the admin side.

So, these new tables with associated fields you have created, that data will not be readily available to customers until you code to make that data available.

As for admins, well, your question is in direct relationship about how to make these fields accessible to that admins and then once accessible, how to be updateable.

You have multiple means by which to do this; however, the most "straightforward" is for the product related information to appear in relation to the product in question.

This is usually through the product information page. Now, if you only use one product type (product) which tends to be the default product type, then basically you will only need to worry about one "set" of files found in and below this directory:
YOUR_ADMIN/includes/modules/

In sequence, the files in question tend to be:
product/collect_info.php
product/preview_info.php
and
update_product.php

Now, that said, there are some other things to consider within that modules directory: how should the system respond when copying product, moving product, deleting product, etc...

I'm sure there is an entire help file on product and data collection, but the above three files (two in the modules/product sub-directory and one in the modules sub-directory) are at the base of input/output of the desired data.

Now, even with these three files, there are notifiers within the files that allow you to use an observer to interact instead of modifying those files... Moving away from file modification is an ideal situation for you and all. Basically, if you can get the operations you need without modifying a file, then ideally the next new version that comes along can be updated around your code instead of in addition to updating your code... That is at least if the modifications of the core code are made with that in mind.

Even if the core code updates cause a problem with your code then, update and development on other than your live site will prevent disruption of your income... Yes, that means somewhat having two websites (one development, one operational) but that also means you can make mistakes without affecting your income.

Anyways, a lot of words to say the above, but hopefully has either guided you to your goal or perhaps duplicated what you have already found.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

18 Oct 2023, 8:55 AM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: Create custom fields for Products for Admins only

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

18 Oct 2023, 9:00 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Create custom fields for Products for Admins only

Oh, and I just realized it's a good thing I didn't reference you to the generic 158 github.com code branch. Seems that between the code developers and maintainers they still haven't figured out the immediate direction they are headed.

Not too long ago the statement was that 1.5.8 was stopping at revision 'a' and the next release was going to be some other number, hinting at version 2. But, today as I was about to reference code and files from the "abandoned" working copy branch of 158, I found that back in July the above mentioned files have been removed/ relocated. Basically, placement in the admin/includes/modules/product directory would work like a template override. The version of the files in admin/includes/modules is the base version. There's a text file in the override directory offering instruction on the concept.

Anyways, sorry for any false direction previously provided based on making this discovery. It's certainly going to be fun to do an upgrade to whatever comes next. I do know that here and there meaningful ways of incorporating trigger points to modify site operation have been incorporated, suggested and in some cases accepted. Ideally all things essential for a site would be drop and (securely) run. As said, you should be able to do that with what you are seeking.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

9 Dec 2023, 5:03 PM
#5
swissarmyknife avatar

swissarmyknife

New Zenner

Join Date:
Apr 2019
Location:
Boulder City NV
Posts:
2
Plugin Contributions:
0

Re: Create custom fields for Products for Admins only

Thank you, Totally Zenned. I was able to insert fields into the _products table and edit the 3 "files in question". The store owner doesn't copy or move products around; he is happy with the results.