Forums / Code Collaboration / Add a new product type in 1.5, or not...

Add a new product type in 1.5, or not...

Started by jeffiec on 18 Feb 2013, 10:18 PM · Views: 3,949

Results 1 to 10 of 10
18 Feb 2013, 10:18 PM
#1
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Add a new product type in 1.5, or not...

I have a need to add products that have many fields, attributes are not the answer because the customer will not be able to choose, just a ton of new fields.
I have searched and searched for a way to add a new product type, however everything I have found in posts are pre 1.5. and not working as intended.

So my question is what is the best way to add a new product type in 1.5, is it worth it, is there a better alternative.
Thanks in advance
Jeff

18 Feb 2013, 11:26 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Add a new product type in 1.5, or not...

The product-type concepts are the same in v1.5

What EXACTLY do you mean by "not working as intended"? That's a rather vague explanation of your problem ;)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Feb 2013, 12:33 AM
#3
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Re: Add a new product type in 1.5, or not...

Sorry, I meant to tell you lol,
here goes, I used the product_music as the template and copied every file i could find and renamed product_forklift following this post.
http://www.zen-cart.com/showthread.php?76252-Creating-a-new-General-Product-Type

./admin/product_music.php
./admin/includes/languages/english/product_music.php
./admin/includes/languages/english/extra_definitions/product_music.php
./admin/includes/boxes/extra_boxes/product_music_extras_dhtml.php
./admin/includes/modules/product_music
./admin/includes/functions/extra_functions/product_music_functions.php
./includes/languages/english/product_music_info.php
./includes/languages/english/extra_definitions/product_music.php
./includes/modules/pages/product_music_info
./includes/templates/template_default/templates/tpl_product_music_info_display.php
./includes/templates/custom_template/templates/tpl_product_music_info_display.php

frontend loads ok, however backend gives me a blank page.

I have traced it to forklift_type_database_names.php, which I edited after the initial 500 error crashes to this:
define('TABLE_FORKLIFT', DB_PREFIX . 'forklift')

if i rename the file, the backend comes up ok.
I am in the process of revamping the collect_info.php the match field names for the new product, not sure if this may solve the blank page issue, 49 fields is a lot lol.

even though the a post talks a lot about it, i'm still a little confused on how it will work, i found an old article that explained product types in detail, while it was written for an older version, it wasn't too helpful, i think you posted it with the article above.

My vision is to have a product named forklift, with many many (49) fields, i need to be able to save ALL of the fields at one time and associated with a particular forklift.

19 Feb 2013, 12:40 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Add a new product type in 1.5, or not...

Is your define() statement missing a closing semicolon?
What's the actual PHP error message?

jeffiec:

backend gives me a blank page.
http://www.zen-cart.com/content.php?124-blank-page

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Feb 2013, 1:12 AM
#5
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Re: Add a new product type in 1.5, or not...

if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
define('TABLE_FORKLIFT', DB_PREFIX . 'forklift');

no errors, just the white page, renaming the file seems to at least get the page back.

And wouldn't you know, I cleaned the white spaces after the end php tag and it comes up lol. Prolly shoulda done that before I posted. :oops:

I will let you know how the rest goes, I have the tedious job of going through all the files in the product_forklift folder to make the logic work. :wacko:

Your aide is invaluable, no amount of money could ever repay the knowledge that you share with us, I am glad to be of acquaintance :D

PS. You were kind of giving me direction on another post http://www.zen-cart.com/showthread.php?205988-custom-search-page-using-defined-page-with-ajax&p=1186536#post1186536, where should i put the business logic? is there a tutorial or post i can reference?

19 Feb 2013, 1:17 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Add a new product type in 1.5, or not...

jeffiec:

And wouldn't you know, I cleaned the white spaces after the end php tag and it comes up lol. Prolly shoulda done that before I posted. :oops:
Lol ... I know how that goes.
In fact, why not just remove the ending PHP tag. Explained here: http://www.zen-cart.com/content.php?271-some-of-my-php-files-are-missing-the-at-the-end-of-the-file

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Feb 2013, 9:24 PM
#7
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Re: Add a new product type in 1.5, or not...

Ok, first problem:
File:admin/includes/modules/product_forklift/update_product.php

//// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////

      $tmp_value = zen_db_prepare_input($_POST['forklift_id']);

      $forklift_id = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;

      $sql_data_array = array('forklift_id' => (int)$products_id,
                              'forklift_make' => zen_db_prepare_input($_POST['forklift_make'][$language_id]), 
							  'forklift_model' => zen_db_prepare_input($_POST['forklift_model'][$language_id]), 
							  'forklift_cpac' => zen_db_prepare_input($_POST['forklift_cpac'][$language_id]),
							  'forklift_mast' => zen_db_prepare_input($_POST['forklift_mast'][$language_id]),
							  'forklift_mast_type' => zen_db_prepare_input($_POST['products_name'][$language_id]),
							  'forklift_attach' => zen_db_prepare_input($_POST['forklift_attach'][$language_id]),
							  'forklift_trans' => zen_db_prepare_input($_POST['forklift_trans'][$language_id]),
							  'forklift_fuel' => zen_db_prepare_input($_POST['forklift_fuel'][$language_id]),
							  'forklift_tires' => zen_db_prepare_input($_POST['forklift_tires'][$language_id]),
							  'forklift_stock' => zen_db_prepare_input($_POST['forklift_stock'][$language_id]),
							  'forklift_year' => zen_db_prepare_input($_POST['forklift_year'][$language_id]),
							  'forklift_po' => zen_db_prepare_input($_POST['forklift_po'][$language_id]), 
							  'forklift_tnailfile' => zen_db_prepare_input($_POST['forklift_tnailfile'][$language_id]),
							  'forklift_tnailpic2' => zen_db_prepare_input($_POST['forklift_tnailpic2'][$language_id]),
							  'forklift_tnailpic3' => zen_db_prepare_input($_POST['forklift_tnailpic3'][$language_id]),
							  'forklift_tnailpic4' => zen_db_prepare_input($_POST['forklift_tnailpic4'][$language_id]),
							  'forklift_tnailpic5' => zen_db_prepare_input($_POST['forklift_tnailpic5'][$language_id]),
							  'forklift_tnailpic6' => zen_db_prepare_input($_POST['forklift_tnailpic6'][$language_id]),
							  'forklift_tnailpic7' => zen_db_prepare_input($_POST['forklift_tnailpic7'][$language_id]),
							  'forklift_tnailpic8' => zen_db_prepare_input($_POST['forklift_tnailpic8'][$language_id]),
							  'forklift_offer' => zen_db_prepare_input($_POST['forklift_offer'][$language_id]),
							  'forklift_leng_fork_face' => zen_db_prepare_input($_POST['forklift_leng_fork_face'][$language_id]),
							  'forklift_overall_width' => zen_db_prepare_input($_POST['forklift_overall_width'][$language_id]),
							  'forklift_height' => zen_db_prepare_input($_POST['forklift_height'][$language_id]),
							  'forklift_wheelbase' => zen_db_prepare_input($_POST['forklift_wheelbase'][$language_id]),
							  'forklift_ground_clear' => zen_db_prepare_input($_POST['forklift_ground_clear'][$language_id]),
							  'forklift_height_top_gaurd' => zen_db_prepare_input($_POST['forklift_height_top_gaurd'][$language_id]),
							  'forklift_max_fork_height' => zen_db_prepare_input($_POST['forklift_max_fork_height'][$language_id]),
							  'forklift_mast_tip_forward' => zen_db_prepare_input($_POST['forklift_mast_tip_forward'][$language_id]),
							  'forklift_mast_tip_year' => zen_db_prepare_input($_POST['forklift_mast_tip_year'][$language_id]),
							  'forklift_emake' => zen_db_prepare_input($_POST['forklift_emake'][$language_id]),
							  'forklift_emodel' => zen_db_prepare_input($_POST['forklift_emodel'][$language_id]),
							  'forklift_power' => zen_db_prepare_input($_POST['forklift_power'][$language_id]),
							  'forklift_torque' => zen_db_prepare_input($_POST['forklift_torque'][$language_id]),
							  'forklift_power_measured' => zen_db_prepare_input($_POST['forklift_power_measured'][$language_id]),
							  'forklift_op_weight' => zen_db_prepare_input($_POST['forklift_op_weight'][$language_id]),
							  'forklift_num_f_tires' => zen_db_prepare_input($_POST['forklift_num_f_tires'][$language_id]),
							  'forklift_num_r_tires' => zen_db_prepare_input($_POST['forklift_num_r_tires'][$language_id]),
							  'forklift_max_speed' => zen_db_prepare_input($_POST['forklift_max_speed'][$language_id]),
							  'forklift_turn_rad' => zen_db_prepare_input($_POST['forklift_turn_rad'][$language_id]),
							  'forklift_load_center' => zen_db_prepare_input($_POST['forklift_load_center'][$language_id]),
							  'forklift_m_fork_speed' => zen_db_prepare_input($_POST['forklift_m_fork_speed'][$language_id]),
							  'forklift_lift_speed' => zen_db_prepare_input($_POST['forklift_lift_speed'][$language_id]),
							  'forklift_lower_speed' => zen_db_prepare_input($_POST['forklift_lower_speed'][$language_id]),
							  'forklift_r_angle_stack' => zen_db_prepare_input($_POST['forklift_r_angle_stack'][$language_id])) ;



      zen_db_perform(TABLE_FORKLIFT, $sql_data_array);



      ////    *END OF PRODUCT-TYPE-SPECIFIC INSERTS* ////////

After clicking Preview, then Insert, I get this error,
WARNING: An Error occurred, please refresh the page and try again.
Thinking either I cant use the product_id in this:
'forklift_id' => (int)$products_id,
or this tag is malformed by the [$language_id] tag:
'forklift_make' => zen_db_prepare_input($_POST['forklift_make'][$language_id]),

Just not too sure what ties the extra data to a particular product.

Jeff

19 Feb 2013, 11:00 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Add a new product type in 1.5, or not...

jeffiec:

After clicking Preview, then Insert, I get this error,
WARNING: An Error occurred, please refresh the page and try again.
You'll need to find the exact error. See: http://www.zen-cart.com/content.php?311-warning-an-error-occurred-please-refresh-the-page-and-try-again

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

20 Feb 2013, 12:16 AM
#9
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Re: Add a new product type in 1.5, or not...

Bah!!!:frusty:
After several misspelling errors, both in the arrays and in the table, it is working! :clap:
I knew the logs were somewhere, i just couldnt find them lol.

Just to clarify though, the preview file is going to have to be adjusted too huh?

Thanks again

20 Feb 2013, 3:14 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Add a new product type in 1.5, or not...

jeffiec:

Just to clarify though, the preview file is going to have to be adjusted too huh?A definite maybe, depending on what all you've added to your custom product type.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.