Adding New Product_types

Sticky
Results 1 to 20 of 154
15 Sep 2004, 16:33
#1
pigdestroyer avatar

pigdestroyer

New Zenner

Join Date:
Aug 2004
Posts:
31
Plugin Contributions:
0

Adding New Product_types

Hi,

I am trying to customise my Zen Cart install to create a couple of new product_types in the same way that you have added the product_music type. I am having trouble with it to be honest.

I managed to copy the code for adding new Record Companies and rejig it to allow me to add Product Materials to a new table in my database, with a few hours of messing about, creating new language files and adding to existing files its all finished and working.

Now I copied the file product_music.php to /admin/product_body_jewellery.php and in an attempt to create a new product type entry page where I could customise it further to allow me to have a product type that has product material and product body part options. Unfortunately, at this stage I am unsure what to do...when I try to access my new file some of the page content including header, etc is displayed but after a little while I redirected in what appears to be a redirecting loop.

Can you tell me what the coding requirements are for setting up a new product type so that I can tinker and try and get a grasp of how this works. I think it is best that I try to implement the product_type that I require in the ZenCart and submit it to yourselves for possible inclusion of new releases rather than bombard you with requests to implement it.

Any help would be greatly appreciated :).
16 Sep 2004, 02:12
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: Adding New Product_types

Good strategy!

Did you duplicate these files as well?
- /admin/products_music.php
- /admin/includes/modules/product_music/*.php

and
- /includes/modules/pages/product_music/*.php
- /includes/templates/TEMPLATE/templates/product_music*.php
16 Sep 2004, 10:12
#3
pigdestroyer avatar

pigdestroyer

New Zenner

Join Date:
Aug 2004
Posts:
31
Plugin Contributions:
0

Re: Adding New Product_types

Thanks for getting back to me. From what I can see I have actually duplicated all of the files for product_music to my new product type product_body_jewellery.

[root@boar www.giftsforgoths.com]# find -name "*product_music*"
./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
[root@boar www.giftsforgoths.com]# find -name "*product_body_jewellery*"
./admin/includes/languages/english/extra_definitions/product_body_jewellery.php
./admin/includes/languages/english/product_body_jewellery.php
./admin/includes/boxes/extra_boxes/product_body_jewellery_extras_dhtml.php
./admin/includes/modules/product_body_jewellery
./admin/includes/functions/extra_functions/product_body_jewellery_functions.php
./admin/product_body_jewellery.php
./includes/languages/english/extra_definitions/product_body_jewellery.php
./includes/languages/english/product_body_jewellery_info.php
./includes/modules/pages/product_body_jewellery_info
./includes/templates/template_default/templates/tpl_product_body_jewellery_info_display.php
./includes/templates/custom_template/templates/tpl_product_body_jewellery_info_display.php

I go to the categories page in the /admin section and attempt to add a product (Product - Body Jewellery) from the list (which I can fathom is generated from the product_types table) the header displays. I can see that the code gets as far as testing what action is to be performed ie. new_product at which point it includes the collect_info.php file for the appropriate product_handler (being product_body_jewellery).

......

comes back after five minutes and realises that some code I added last week to the collect_info.php page was actually going round in a loop. doh. Sorry for any inconvenience....its now displaying.

As my colleague here always says you need a Cat to talk it through to make things clearer in your head. Thanks all the same mate.
16 Sep 2004, 15:03
#4
pigdestroyer avatar

pigdestroyer

New Zenner

Join Date:
Aug 2004
Posts:
31
Plugin Contributions:
0

Re: Adding New Product_types

One last thing, I don't suppose ZenCart has any built in functions to deal specifically with form select fields with multiple options to select? I have done a few tests and it looks like on the last value selected of say 'body_part_id' appears in the $HTTP_POST_VARS array and none of the others selected.

Doing a quick google some people are saying that if you need to use the select input for multiple selections that you need to use the GET method to sent the data....which kinda makes this a hell of a lot more complicated than I thought :S
17 Sep 2004, 00:18
#5
gaussboy avatar

gaussboy

New Zenner

Join Date:
Feb 2004
Posts:
17
Plugin Contributions:
1

Re: Adding New Product_types

Here is a little summary of what I had to do to add a new product type. This only covers the catalog section. Everything seems to be working OK. I've not tested it extensively by any means, so YMMV.


These are the files that I had to create in order to setup a new product_magnet type. 'TEMPLATE', of course, refers to your custom template directory.

includes/extra_datafiles/magnet_type_database_names.php
includes/languages/english/extra_definitions/product_magnet.php
includes/languages/english/product_magnet_info.php
includes/languages/english/TEMPLATE/product_magnet_info.php
includes/modules/pages/product_magnet_info/header_php.php
includes/modules/pages/product_magnet_info/jscript_main.php
includes/modules/pages/product_magnet_info/main_template_vars.php
includes/modules/pages/product_magnet_info/main_template_vars_attributes.php
includes/modules/pages/product_magnet_info/main_template_vars_images.php
includes/modules/pages/product_magnet_info/main_template_vars_images_additional.php
includes/templates/TEMPLATE/templates/tpl_product_magnet_info_display.php

1. includes/extra_datafiles/magnet_type_database_names.php

   define('TABLE_PRODUCT_MAGNET_EXTRA', DB_PREFIX . 'product_magnet_extra');
   define('TABLE_MAGNET_PLATE', DB_PREFIX . 'magnet_plate');
   define('TABLE_MAGNET_GRADE', DB_PREFIX . 'magnet_grade');


These three definitions are tables that I created in my database. Only the first definition is necessary. It, among other things, holds the id references for the other tables. The other two tables contain supporting data that you will have to design and input manually. You can probably use the other tables for the music genre as templates.


2. includes/languages/english/extra_definitions/product_magnet.php

define('BOX_HEADING_SPECS', 'Magnet Specifications');


This was the only definition that I needed. Pretty self explanitory. This is the extra english text that goes on your product_info page.

3. includes/languages/english/product_magnet_info.php
-OR-
includes/languages/english/YOUR_TEMPLATE/product_magnet_info.php

Copy the file product_music_info.php from the same directory and begin editing to your taste. Don't add any extra definitions... just change the ones that are there. If you need to add more definitions, then do it in step #2.

4. Copy the entire directory includes/modules/pages/product_music_info
to
includes/modules/pages/product_YOURTYPE_info/

5. includes/modules/pages/product_magnet_info/header_php.php
includes/modules/pages/product_magnet_info/jscript_main.php

NOTHING TO DO!!!


6. includes/modules/pages/product_magnet_info/main_template_vars.php

This file needs some serious consideration. This is where you will be grabbing all of your special information from the DB regarding this specific product. If you are database challenged, this is going to be difficult.. but not impossible!

Fortunately our friendly Zen Admin's have given us a good template in the product_music type. Read through it a few times.

7. includes/modules/pages/product_magnet_info/main_template_vars_attributes.php

Very few changes here. Only two lines changed to add the music product type.

This line (110):
if (((CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == '') or (STORE_STATUS == '1')) or (CUSTOMERS_APPROVAL_AUTHORIZATION == 2 and $_SESSION['customers_authorization'] != 0)) {


was changed to:
if ((CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == '') or (STORE_STATUS == '1')) {


And this line (170):
if ((SHOW_PRODUCT_INFO_WEIGHT_ATTRIBUTES=='1' and $products_options->fields['products_attributes_weight'] != '0')) {

was changed to:
 
     if ((SHOW_PRODUCT_MUSIC_INFO_WEIGHT_ATTRIBUTES=='1' and $products_options->fields['products_attributes_weight'] != '0')) {


I didn't have to change any of this since my product type doesn't use attributes.


8. includes/modules/pages/product_magnet_info/main_template_vars_images.php
includes/modules/pages/product_magnet_info/main_template_vars_images_additional.php

NOTHING TO DO!!!

9. includes/templates/TEMPLATE/templates/tpl_product_magnet_info_display.php

This is the file to customize how the product is displayed. You will want to make sure you are displaying all of the special information out of the database.


THE END

Hopefully this will do more good than harm. Let me know if anything is unclear, missing, or just plain wrong. I'll try to put the instructions for the admin section up later on.
29 Sep 2004, 20:56
#6
mfahlsing avatar

mfahlsing

New Zenner

Join Date:
Aug 2004
Posts:
5
Plugin Contributions:
0

Re: Adding New Product_types

The last post was pretty complete, so I'll just note here that I also was able to create a new product type by a combination of duplicating files, creating new tables and hacking a couple of existing tables. I also added two new category/pick lists (like the music genre) for my product type. Unfortunately I did not keep extensive notes of what I did :P

However, if you have specific questions about something that isn't working post it here or Personal Message me and I'll try and answer.

I was also able to create the display templates for my product type and add display controls to the store configuration to show/not show my new fields.

Then I had to hack the index page to display my fields in the listing and also hack the search code to include them in search. Once I have the whole thing the way I want it I might figure out how to abstract the addition of new search fields and submit it to the zen guys... but I have alot going on right now :)

Mike
30 Sep 2004, 19:20
#8
sunsetonline avatar

sunsetonline

Zen Follower

Join Date:
May 2004
Posts:
171
Plugin Contributions:
0

Re: Adding New Product_types

For anybody trying to implement the zen_book_demo product type... When I was doing this I got an SQL error when trying to run the SQL included. I found that there is a comma that needs to be removed following a zero at around line 20 of book.sql.

After this phpMyAdmin kept choking on:
# delete if exists
DELETE zen_product_type_layout FROM zen_product_type_layout zptl,zen_product_types zpt WHERE zpt.type_id = zptl.product_type_id AND zpt.type_handler = 'pubs_product_book';


I tweaked several things in there but could not get it to pass. Finally I deleted the fields by hand in phpMyAdmin and commented the above command out of the file. If anyone has any further insights on this issue, please share. I have not had time to test to see if all this is working yet (with the Book product type demo). I thought I'd post this here since this seems to be the most active thread about adding/creating product types right now.
30 Sep 2004, 19:22
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Adding New Product_types

More than likly it is the prefix reference on the table of zen_ that needs to be removed.
15 Oct 2004, 17:29
#10
jazzyjus avatar

jazzyjus

New Zenner

Join Date:
Aug 2004
Posts:
76
Plugin Contributions:
0

Re: Adding New Product_types

Just FYI.. the 0.2 version of the book product_type demo has a bug in the update_product.php file. v0.3 fixes it and should be downloadable in a few days.

If you want to fix it yourself.. just go to the last line and uncomment the commented out redirect.

http://www.zen-cart.com/modules/mydownload...wcat.php?cid=41
25 Jan 2005, 03:09
#11
jazzyjus avatar

jazzyjus

New Zenner

Join Date:
Aug 2004
Posts:
76
Plugin Contributions:
0

Re: Adding New Product_types

v0.4 is out.. fixed a bug that was not deleting the authors when a book was deleted.

Plus some additional comments in the docs,

http://www.zen-cart.com/modules/mydownload...wcat.php?cid=41
13 Feb 2005, 02:13
#12
tatlar avatar

tatlar

New Zenner

Join Date:
Oct 2004
Posts:
44
Plugin Contributions:
0

Re: Adding New Product_types

jazzyjus,

thanks for the updated module. how can I get the author's name onto the 'New Items for Month' section on the homepage, and also when viewing a whole category ('products-all)?

thanks.
14 Feb 2005, 07:11
#13
jazzyjus avatar

jazzyjus

New Zenner

Join Date:
Aug 2004
Posts:
76
Plugin Contributions:
0

Re: Adding New Product_types

tatlar:
This is not the best (most efficient) way to do this but it would take too much time for me to explain how to do it otherwise...

In file includes/modules/products_all_listing.php, paste this code under line 196 (after the php code).

 <tr>
  <td colspan="3" valign="top" class="main">
   <?php
     
 $products_id = $products_all->fields['products_id'];

 $sql = "select * from " . TABLE_PUBS_BOOK_AUTHOR . " 
     where products_id = '" . $products_id . "' order by list_order";
 $authors = $db->Execute($sql);
	$products_authors = array();
	while (!$authors->EOF) {
  $products_authors[] = $authors->fields['author_name'];
  $authors->MoveNext();
 }
 $products_authors_combined = implode(', ',$products_authors);
 
 echo $products_authors_combined;
   ?>
  </td>
 </tr>
     


I would assume you do the same for products_new_listing.php for new listing for the month!

Have fun! :)
25 Feb 2005, 13:10
#14
hareslade avatar

hareslade

Totally Zenned

Join Date:
Nov 2004
Posts:
442
Plugin Contributions:
0

Re: Adding New Product_types

# delete if exists
DELETE zen_product_type_layout FROM zen_product_type_layout zptl,zen_product_types zpt WHERE zpt.type_id = zptl.product_type_id AND zpt.type_handler = 'pubs_product_book';

Hi Jazzyjus & others

I tried this sql too (without prefixes) in the admin sql patch method, but it seems to me, without the prefixes (as required) the zen interpret code is faulty, it just gives up on interpreting this more complex sql.

It can't handle the multiple table references I think. I tried the alternative sql as advised in mysql, without the aliases, it still did not work.

Oh btw jazzyjus et al,

I've got a finished file set here for an extended book product with more fields and a new product layout, works on 1_2_4 file set only (modified the new 124 files with my existing coding where necessary)

[I'm setting up a cart to sell a few books I have, and already have an asp database with a few hundred books in, which I run on my personal asp-run site. I did all the coding for that some years back, but now think php is more fun and avoids .net with its expensive software. Php is like plasticine, it seems rarely to trip up.]

My book products code can also optionally insert data directly, to make new book products, from an existing Access database, if an ODBC set up for Access can be put in the server. and one does have to do some simple fields names interface coding for your particular existing access db fields setup.. Its designed to insert the data product by product, its not a 'bulk data' fix.

[ I tried that not-so-easy easypopulate offering, but found it lacking in explanation, and would not handle cases where existing database entries fields were just unsuitable.

For instance, my Access db had authors and editors fields separate, I conditionally combine them for zencart authors fields, in php code, for my example database offering]

I'm running my mods on a windows machine locally, but would appreciate a couple of friendly beta testers (with test carts 1_2_4) to check out if I got it right enough.

Because the book offering uses the 'short description' field, that download (modified) is included in my offering, and that meant changing the coding for the general product types as otherwise they can't enter the new short description field text in admin.

I didn't bother with music yet, it just shows a blank for short description.

so it did mushroom a bit.

Any offers of beta testing before I make it more public?
I wouldn't like to upset those running live carts by going public prematurely with it not fully debugged. The zencart download section is a bit all-or-nothing.

No way do I want to say I'm experienced enough zenwise to do all the coding just as zen does, but its working for me and all the files are marked where the mods are.
25 Feb 2005, 15:17
#15
jazzyjus avatar

jazzyjus

New Zenner

Join Date:
Aug 2004
Posts:
76
Plugin Contributions:
0

Re: Adding New Product_types

Originally posted by hareslade@Feb 25 2005, 01:10 PM
# delete if exists
DELETE zen_product_type_layout FROM zen_product_type_layout zptl,zen_product_types zpt WHERE zpt.type_id = zptl.product_type_id AND zpt.type_handler = 'pubs_product_book';



I tried this sql too (without prefixes) in the admin sql patch method, but it seems to me, without the prefixes (as required) the zen interpret code is faulty, it just gives up on interpreting this more complex sql.

Yup, for this mod to work you need to feed it into something like phpMyAdmin (and manually change the zen_ prefix to whatever prefix you're using) as some of the sql will not work using the sql_patch tool. (If you read the book product_type readme, I think it says that)

If using sql_patch is something that is really needed, I'll look into changing the sql's so it becomes compatible with sql_patch.
25 Feb 2005, 15:39
#16
hareslade avatar

hareslade

Totally Zenned

Join Date:
Nov 2004
Posts:
442
Plugin Contributions:
0

Re: Adding New Product_types

Hi Jazzyjus nice to see you are around

In the book readme you said the sql didn't work, but nothing more.

Its nice to know it's the admin sql inport faulty, not the sql :)

How do you stand now on the book product demo, are you doing any more on it?

I still hope someone will check out my mods if they have the time.
24 Mar 2005, 15:49
#17
miranda avatar

miranda

New Zenner

Join Date:
Jan 2005
Posts:
23
Plugin Contributions:
0

Re: Adding New Product_types

Originally posted by gaussboy@Sep 17 2004, 12:18 AM

Hopefully this will do more good than harm. Let me know if anything is unclear, missing, or just plain wrong. I'll try to put the instructions for the admin section up later on.


Gaussboy,

Thanks so much for posting that summary of creating a new product type. That saves me hours of sleuthing! Really great. A few questions though...

When you say "This only covers the catalog section" do you mean that you still need to adjust the basket or order review to handle your type? Also, what sort of things did you end up adding to your products? Is this just how you handled adding additional fields that you needed?

(I hope you're still around, I see your post is 6 months old.)

Thanks!
07 Aug 2005, 22:01
#18
jazzyjus avatar

jazzyjus

New Zenner

Join Date:
Aug 2004
Posts:
76
Plugin Contributions:
0

Re: Adding New Product_types

The v0.5 version of book_product_type is available.
Since I can't post it now (mod upload is disabled), here's the link:

http://www.talkloud.com/zen/zen_demo_book_v0.5.zip

v0.5:
Now you can use Zen's Install SQL Patches utility to create the new tables (Thanks DrByte!)
08 Aug 2005, 01:17
#19
jazzyjus avatar

jazzyjus

New Zenner

Join Date:
Aug 2004
Posts:
76
Plugin Contributions:
0

Re: Adding New Product_types

And just in case one is wondering... so what's the difference from 0.4b.. well the SQL in 0.4b wasn't right (there was a small bug) and the instructions wasn't updated to reflect the new method of creating tables.
08 Aug 2005, 02:58
#20
jazzyjus avatar

jazzyjus

New Zenner

Join Date:
Aug 2004
Posts:
76
Plugin Contributions:
0

Re: Adding New Product_types

And some notes on how to do slightly more advanced customizations with it.