Adding New Product_types

Sticky

Views: 161,400

Results 21 to 40 of 154
8 Aug 2005, 6:22 PM
#21
bondee avatar

bondee

New Zenner

Join Date:
May 2005
Posts:
62
Plugin Contributions:
0

Adding New Product_types

Hi, Jazzyjus. I'm now creating product types and find your mod very helpful. I think you have a lot of experience and knowledge to this. There is one thing I'm wondering. Is there anyway u can show me how to create a sidebox with filter?

My zencart is a big shoppingMall. In the ShoppingMall there are a lot of stores. I have a product types called stores. I've followed the Product Types doc and managed to create all the files in admin and catalog. It works succesfully in admin.

I've create this files in catalog:

/includes/languages/MY_LANGUAGE/product_stores_info.php
/includes/languages/english/product_stores_info.php
/includes/modules/pages/product_stores_info/header_php.php
/includes/modules/pages/product_stores_info/jscript_main.php
/includes/modules/pages/product_stores_info/main_template_vars.php
/includes/modules/pages/product_stores_info/main_template_vars_attributes.php
/includes/modules/pages/product_stores_info/main_template_vars_images.php
/includes/modules/pages/product_stores_info/main_template_vars_images_additional.php
/includes/templates/MY_TEMPLATE/templates/tpl_product_stores_info_display.php
/includes/templates/MY_TEMPLATE/sideboxes/stores.php
/includes/templates/MY_TEMPLATE/sideboxes/tpl_stores_select.php
/includes/index_filters/stores_filter.php

I've managed to create the 'STORES' sidebox as the 'MANUFACTURER' box, and list all stores_name in that box. But when I choose one of the store_name, it comes up that there are no products on that catagory. But if I have any products in music, it shows them! That's so wrong!::frust

The codes in stores_filter are exactly from default_filter.php. The only things I've modified there was change out manufacturers with stores:

<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                    |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004 The zen-cart developers              |
// |                                   |
// | http://www.zen-cart.com/index.php                  |
// |                                   |
// | Portions Copyright (c) 2003 osCommerce                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,    |
// | that is bundled with this package in the file LICENSE, and is    |
// | available through the world-wide-web at the following url:      |
// | http://www.zen-cart.com/license/2_0.txt.               |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to    |
// | [email][email protected][/email] so we can mail you a copy immediately.     |
// +----------------------------------------------------------------------+
// $Id: default_filter.php 1223 2005-04-22 03:46:20Z ajeh $
//
// show the products of a specified STORE
  if (isset($_GET['stores_id']) && $_GET['stores_id'] != '' )
  {
   if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
   {
// We are asked to show only a specific category
    $listing_sql = "select " . $select_column_list . " p.products_id, stores_id, p.products_price, p.products_tax_class_id, pd.products_description, if(sp.status = '1', sp.specials_new_products_price, NULL) AS specials_new_products_price, IF(sp.status = '1', sp.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_STORES . " s left join " . TABLE_SPECIALS . " sp on p.products_id = sp.products_id where p.products_status = '1' and p.stores_id = s.stores_id and s.stores_id = '" . (int)$_GET['stores_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
   } else {
// We show them all
    $listing_sql = "select " . $select_column_list . " p.products_id, p.stores_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(sp.status = '1', sp.specials_new_products_price, NULL) as specials_new_products_price, IF(sp.status = '1', sp.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_STORES . " s left join " . TABLE_SPECIALS . " sp on p.products_id = sp.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.stores_id = s.stores_id and s.stores_id = '" . (int)$_GET['stores_id'] . "'";
   }
  } else {
// show the products in a given categorie
   if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
   {
// We are asked to show only specific catgeory
    $listing_sql = "select " . $select_column_list . " p.products_id, p.stores_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(sp.status = '1', sp.specials_new_products_price, NULL) as specials_new_products_price, IF(sp.status = '1', sp.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_STORES . " s, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " sp on p.products_id = sp.products_id where p.products_status = '1' and p.stores_id = s.stores_id and s.stores_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
   } else {
// We show them all
    $listing_sql = "select " . $select_column_list . " p.products_id, p.stores_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(sp.status = '1', sp.specials_new_products_price, NULL) as specials_new_products_price, IF(sp.status ='1', sp.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_STORES . " s on p.stores_id = s.stores_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " sp on p.products_id = sp.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
   }
  }

// set the default sort order setting from the Admin when not defined by customer
  if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
   $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
  }

  if ( (!isset($_GET['sort'])) || (!ereg('[1-8][ad]', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) )
  {
   for ($i=0, $n=sizeof($column_list); $i<$n; $i++)
   {
    if ($column_list[$i] == 'PRODUCT_LIST_NAME')
    {
     $_GET['sort'] = $i+1 . 'a';
     $listing_sql .= " order by p.products_sort_order, pd.products_name";
     break;
    } else {
// sort by products_sort_order when PRODUCT_LISTING_DEFAULT_SORT_ORDER ia left blank
// for reverse, descending order use:
//    $listing_sql .= " order by p.products_sort_order desc, pd.products_name";
     $listing_sql .= " order by p.products_sort_order, pd.products_name";
     break;
    }
   }
// if set to nothing use products_sort_order and PRODUCTS_LIST_NAME is off
   if (PRODUCT_LISTING_DEFAULT_SORT_ORDER == '') {
    $_GET['sort'] = '20a';
   }
  } else {
   $sort_col = substr($_GET['sort'], 0 , 1);
   $sort_order = substr($_GET['sort'], 1);
   $listing_sql .= ' order by ';
   switch ($column_list[$sort_col-1])
   {
    case 'PRODUCT_LIST_MODEL':
     $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
    case 'PRODUCT_LIST_NAME':
     $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
     break;
    case 'PRODUCT_LIST_STORE':
     $listing_sql .= "s.stores_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
    case 'PRODUCT_LIST_QUANTITY':
     $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
    case 'PRODUCT_LIST_IMAGE':
     $listing_sql .= "pd.products_name";
     break;
    case 'PRODUCT_LIST_WEIGHT':
     $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
    case 'PRODUCT_LIST_PRICE':
//     $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     $listing_sql .= "p.products_price_sorter " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
     break;
   }
  }
// optional Product List Filter
  if (PRODUCT_LIST_FILTER > 0)
  {
   if (isset($_GET['stores_id']) && $_GET['stores_id'] != '')
   {
    $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.stores_id = '" . (int)$_GET['stores_id'] . "' order by cd.categories_name";
   } else {
    $filterlist_sql= "select distinct s.stores_id as id, s.stores_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_STORES . " s where p.products_status = '1' and p.stores_id = s.stores_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by s.stores_name";
   }
   $filterlist = $db->Execute($filterlist_sql);
   if ($filterlist->RecordCount() > 1)
   {
     $do_filter_list = true;
    if (isset($_GET['stores_id']))
    {
     $getoption_set = true;
     $get_option_variable = 'stores_id';
     $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
    } else {
     $options = array(array('id' => '', 'text' => TEXT_ALL_STORES));
    }
    while (!$filterlist->EOF) {
     $options[] = array('id' => $filterlist->fields['id'], 'text' => $filterlist->fields['name']);
     $filterlist->MoveNext();
    }
   }
  }

// Get the right image for the top-right
  $image = DIR_WS_TEMPLATE_IMAGES . 'table_background_list.gif';
  if (isset($_GET['stores_id']))
  {
   $sql = "select stores_image
        from  " . TABLE_STORES . "
        where   stores_id = '" . (int)$_GET['stores_id'] . "'";

   $image_name = $db->Execute($sql);
   $image = $image_name->fields['stores_image'];

  } elseif ($current_category_id) {

   $sql = "select categories_image from " . TABLE_CATEGORIES . "
       where categories_id = '" . (int)$current_category_id . "'";

   $image_name = $db->Execute($sql);
   $image = $image_name->fields['categories_image'];
  }
?>

This is how it looks like in tpl_stores_select.php:

<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                    |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers              |
// |                                   |
// | http://www.zen-cart.com/index.php                  |
// |                                   |
// | Portions Copyright (c) 2003 osCommerce                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,    |
// | that is bundled with this package in the file LICENSE, and is    |
// | available through the world-wide-web at the following url:      |
// | http://www.zen-cart.com/license/2_0.txt.               |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to    |
// | [email][email protected][/email] so we can mail you a copy immediately.     |
// +----------------------------------------------------------------------+
// $Id: tpl_stores_select.php 1266 2005-07-27 02:51:24Z xxxx$
//
 $content = '<center>';
 $content.= zen_draw_form('stores', zen_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get');
 $content .= zen_draw_pull_down_menu('stores_id', $store_sidebox_array, (isset($_GET['stores_id']) ? $_GET['stores_id'] : ''), 'onchange="this.form.submit();" class="DropdownMeny" size="' . MAX_STORES_LIST . '"') . zen_hide_session_id() . zen_draw_hidden_field('typefilter', 'stores');
 $content .= zen_draw_hidden_field('main_page', FILENAME_DEFAULT) . '</center></form>';
?>

I've put a value 'stores_id' in table 'get_terms_to_filter'...

I want my zencart to list all the products relative to the store that I choose from the 'STORES' sidebox... I've been working with this for days, but still not figuring out what is wrong!!

Please, any comments/help from anyone will be appreciate... Thanxx

11 Aug 2005, 7:30 AM
#22
drbyte avatar

drbyte

Sensei

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

Re: Adding New Product_types

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

11 Aug 2005, 10:42 AM
#23
bondee avatar

bondee

New Zenner

Join Date:
May 2005
Posts:
62
Plugin Contributions:
0

Re: Adding New Product_types

Thanx dr.byte,
I'll take a look at that, and try it out. I'll come back if I've managed to do it or not..

11 Aug 2005, 8:28 PM
#24
bondee avatar

bondee

New Zenner

Join Date:
May 2005
Posts:
62
Plugin Contributions:
0

Re: Adding New Product_types

Hi, again. It seems that Kim has answered my question here. I found out that I didn't need any Product Types filter sidebox. But jumping into it makes me learning a lot on how to make a Product Type. I'm sure it will be useful for me one day.

Thanx for a good support team and anyone who shares all their knowledge to people like me here.

Zencart just ROCKS!

16 Aug 2005, 6:50 PM
#25
bpc avatar

bpc

New Zenner

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

Re: Adding New Product_types

i would like to add fields to the book demo. for an example lets say i would like to create a field called 'year'. How many instances or files would i have to change to view it correctly in admin and catalog?

16 Aug 2005, 7:04 PM
#26
jazzyjus avatar

jazzyjus

New Zenner

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

Re: Adding New Product_types

Well first you would have to create a new field in the pubs_products_book_extra table for year.

Then you would edit

admin/includes/modules/collect_info.php
and update_product.php

then:
/includes/modules/pages/pubs_products_book_info/main_template_vars.php

/includes/modules/templates/template_default/templates/tpl_pubs_product_book_infp_display.php

16 Aug 2005, 7:10 PM
#27
hareslade avatar

hareslade

Totally Zenned

Join Date:
Nov 2004
Location:
U.K. South Wales
Posts:
442
Plugin Contributions:
0

Re: Adding New Product_types

Hi BPC and jazzyjus

This link goes to my downloads page,

download page

You'll see two downloads of a book type, both work on 1.2.5
with metatags i hope...
one has the 'short description' field (existing contribution)added, that's for braver people

The ordinary book product has lots of fields, including
publish year and first edition year. ......try it out on a
test cart, it shouldn't interfere with the jazzyjus offering if
thats already installed

pm me if any probs so not to confuse this thread,

the main website itself is under construction. Find my version of book product working on the hareslade.com site itself

Thanks jazzyjus, it happened because of your initial contrib

17 Aug 2005, 1:45 AM
#28
jazzyjus avatar

jazzyjus

New Zenner

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

Re: Adding New Product_types

Hi hareslade,

Good to see that someone has made great enhancements to the original code (it was meant to be more of a tutorial than anything else!).

I guess the next step of the tutorial would be to explain exactly how one goes about adding the new fields. Any input would be great.

17 Aug 2005, 12:14 PM
#29
hareslade avatar

hareslade

Totally Zenned

Join Date:
Nov 2004
Location:
U.K. South Wales
Posts:
442
Plugin Contributions:
0

Re: Adding New Product_types

Hi Jazzyjus
I wouldn't go for a tutorial exactly, its all too complicated

I think Dreamweaver's essential for coding changes 'cos of the search facility.

When I added fields I 'just' searched for an existing field name as per in the database, altered / added to the sql codes, located the $ variable for the field, added a new variable and so on. A lot of hassle.

Not for beginner coders as there are so many admin pages
for the product type ( new, update, etc, plus the 'copy' functions)
and then the damn cart template has to get the new
field as well.

I think best solution is to always add extra
fields, user can then modify those codings in a simpler way.

I put 4 or so 'secret' fields in, they can be used as display fields if required. I used them as 'back office' fields for admin, but they are displayable by altering the template, - the code is on there but is set only to display under special circumstances.

So I think adding 'redundant' fields is a helpful thing
and ultimately a set of 'switches' in admin would switch them on or off, if it was a super dooper contrib :)

18 Aug 2005, 9:41 PM
#30
bpc avatar

bpc

New Zenner

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

Re: Adding New Product_types

i installed the book demo and everything worked great. then i attempted to creat my own following the book demo. admin works great, saving everything in the db.

only problem now is the links in product listings is wrong.

book demo returns main_page=_info
my new producttype returns main_page=closures_product_info

both just refresh the product listing page and updates the bread trail and titles.

i did upload the book demo again to see if it would overwrite something i changed but still no luck. :blink: any ideas?

28 Sep 2005, 2:26 PM
#31
darkwander avatar

darkwander

Zen Follower

Join Date:
May 2005
Location:
Australia
Posts:
321
Plugin Contributions:
0

Re: Adding New Product_types

okey , downloaded the book , went to the SQL part , pasted the sql files contence into the Executor and pressed send , then i get a funky error

1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ') TYPE=MyISAM' at line 1

Any ideas anyone ?

28 Sep 2005, 3:13 PM
#32
hareslade avatar

hareslade

Totally Zenned

Join Date:
Nov 2004
Location:
U.K. South Wales
Posts:
442
Plugin Contributions:
0

Re: Adding New Product_types

Sorry not getting advice of the earlier post

Darkwander which sql file name are you using which gave the sql error? I can then check it specifically

Also sometimes bits get left off the copy/paste, such as an ending

Or one has to have notepad set not to wordwrap, as it cuts lines in two, then admin patch doesn't like it


bpc... sorry that post's a long time back, did you give up?

28 Sep 2005, 5:24 PM
#33
darkwander avatar

darkwander

Zen Follower

Join Date:
May 2005
Location:
Australia
Posts:
321
Plugin Contributions:
0

Re: Adding New Product_types

hareslade:

Sorry not getting advice of the earlier post

Darkwander which sql file name are you using which gave the sql error? I can then check it specifically

Also sometimes bits get left off the copy/paste, such as an ending

Or one has to have notepad set not to wordwrap, as it cuts lines in two, then admin patch doesn't like it


bpc... sorry that post's a long time back, did you give up?
Thanks , stupid copy and paste..

I tryed to add a new field called "rated" , made the table and everything , however in the admin and catalog i get it showing "TEXT_DVD_RATED instead of "Rated".

Example: http://www.delightsoftheflesh.com/store/in...roducts_id=3992

28 Sep 2005, 5:41 PM
#34
darkwander avatar

darkwander

Zen Follower

Join Date:
May 2005
Location:
Australia
Posts:
321
Plugin Contributions:
0

Re: Adding New Product_types

Okey , fixed the problem,

you also have to edit the files Language / English

in both the admin and Includes folder.

28 Sep 2005, 5:56 PM
#35
darkwander avatar

darkwander

Zen Follower

Join Date:
May 2005
Location:
Australia
Posts:
321
Plugin Contributions:
0

Re: Adding New Product_types

I want to make a new input called "Running time" , however i dont want it to be set like Format, i need it to be like Product ID and or Weight.

How would you go about doing this ?

28 Sep 2005, 6:30 PM
#36
hareslade avatar

hareslade

Totally Zenned

Join Date:
Nov 2004
Location:
U.K. South Wales
Posts:
442
Plugin Contributions:
0

Re: Adding New Product_types

Hi Darkwander
You mean a number field not text?

Adding fields is a long job if you want to cover all the admin icon functions on right of an admin product list such as 'product copy'.

Personally I'd find an existing unwanted field of similar field type and rename it on the admin pages templates, and in product display.

Or you just sit there and find ALL the pages of that product type which process a particular field, and add in your own one. But there are places where an array pre-sets the possible field names used further down the code, so they have to have added entries as well.

Mind you it is how I added fields to the book product and its worth adding extra ones because you WILL suddenly decide later after doing it all, to add some more, by which time you forget what to do.. ::frust and then want to shoot yourself

28 Sep 2005, 8:01 PM
#37
darkwander avatar

darkwander

Zen Follower

Join Date:
May 2005
Location:
Australia
Posts:
321
Plugin Contributions:
0

Re: Adding New Product_types

What i did was change Publisher to Studio. The only problem is that there isnt a place where you can set "publisher" or "Studio" and it is a drop down box. So what i want to do is make it like "Subject" and have a option under Extra where you can add the options..

29 Sep 2005, 2:28 PM
#38
darkwander avatar

darkwander

Zen Follower

Join Date:
May 2005
Location:
Australia
Posts:
321
Plugin Contributions:
0

Re: Adding New Product_types

Help please....

I have done everything except for some reason it is not showing up when i click on "add product" the new field dosnt show up in the list..

Everything else as far as i know works. however it is just that.

Download: zen_demo_dvd.2.10

29 Sep 2005, 5:22 PM
#39
darkwander avatar

darkwander

Zen Follower

Join Date:
May 2005
Location:
Australia
Posts:
321
Plugin Contributions:
0

Re: Adding New Product_types

Hey guys , i am getting this error in the Admin panel when i goto edit a Product that belongs to the group Product DVD..

**1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'from products p, products_description pd, **

I also updated the download file that is linked on the last post incase you want to look at the coding.

29 Sep 2005, 7:19 PM
#40
darkwander avatar

darkwander

Zen Follower

Join Date:
May 2005
Location:
Australia
Posts:
321
Plugin Contributions:
0

Re: Adding New Product_types

Help please.... "???