-
How-To: Add new Properties to your Products
hi folks,
this is a little howto add new properties to general products
(like guarantee time, color, oem-number, compatible models, whatsoever)- think
decide which new properties you want to add to your products
(in this example we take guarantee-time (in months) and color)
. - db manipulation
open the table "products" in your zencart-database and insert new rows at the end of the table called "products_guarantee" and "products_color"
ALTER TABLE `zencart_products` ADD `products_guarantee` INT NOT NULL , ADD `products_color` VARCHAR( 32 ) NOT NULL;
.
- edit 'collect_info.php' (in /admin/includes/modules/product/)
- at the very beginning there is the variable $parameters set. add your row-names to the end:
'products_guarantee' => '0', 'products_color' => '' );
. - just below there is the db-query set [$product = $db->Execute("...]
add your rows with a 'p.' in front (before the "from ..." part)
select ......., p.products_guarantee, p.products_color from ....
. - now you can add the input fields in the product-mask (lets say somewhere around line 450 or so):
<tr>
<td class="main">Guarantee Time (in months)</td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_guarantee', $pInfo->products_guarantee, zen_set_field_length(TABLE_PRODUCTS, 'products_guarantee')); ?></td>
</tr><tr>
<td class="main">Color</td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_color', $pInfo->products_color, zen_set_field_length(TABLE_PRODUCTS, 'products_color')); ?></td>
</tr>
.
- edit 'preview_info.php' (in /admin/includes/modules/product/)
somewhere around line 10 is the variable $product set. like in step 3.2 add the new rows with a 'p.' in front just before the 'from'
select ......., p.products_guarantee, p.products_color from ....
. - finally, edit 'update_product.php' (in /admin/includes/modules/)
around line 20 is the $sql_data_array set. add to the last lines before ');' the new rownames.
$sql_data_array = .......... 'products_guarantee' => zen_db_prepare_input($_POST['products_guarantee']), 'products_color' => zen_db_prepare_input($_POST['products_color']) );
. - Setup All Done!
.
.:D
.
.Of course, now we want to display our cool new properties .
.
- edit 'main_template_vars.php' (in /includes/modules/pages/product_info/)
around line 46 you find the variable $sql set. like in step 3.2 add the new rows with a 'p.' in front just before the 'from'
select ......., p.products_guarantee, p.products_color from ....
. - last step: display the new infos
edit 'tpl_product_info_display.php' (in /includes/templates/template_default/templates/)
now, wherever you want, you can add to the html:
<?php echo $product_info->fields['products_guarantee']; ?> and <?php echo $product_info->fields['products_color']; ?>
enjoy!
ps: now i'm feeling really ############ up : P
:blink::blink::blink:
written by chris at linuxuser.at
-
Re: How-To: Add new Properties to your Products
Personally, I prefer to put new product properties into a separate table rather than the products table - you never know when the core code is going to change and perhaps encounter problems if you've added extra fields to a table (ever have a mysql error telling you the column count doesn't match?). It's a little more work to achieve the same result, but could save lots of time bug-hunting in the future.
-
Re: How-To: Add new Properties to your Products
That's a really good point. I added a new field as described above but may go back at some point (in my copious free time - ha!) and change it to a separate table.
-
Re: How-To: Add new Properties to your Products
I would like to make the output conditional upon a value being present in the DB. Could you expand on your PHP a little bit. I am having a little trouble with the logic.
Guarantee: <?php echo $product_info->fields['products_guarantee']; ?>
Color: <?php echo $product_info->fields['products_color']; ?>
I would only like this to display if a value is present. I can't seem to come up with a conditional statement that works properly.
Any help is greatly appreciated.
Thanks.
-
Re: How-To: Add new Properties to your Products
Guarantee:
<?php if (!empty($product_info->fields['products_guarantee'])) echo $product_info->fields['products_guarantee']; ?>
-
Re: How-To: Add new Properties to your Products
Crazy Chris,
Thanks for the help.
roblaw
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
crazy_chris
Guarantee:
<?php if (!empty($product_info->fields['products_guarantee'])) echo $product_info->fields['products_guarantee']; ?>
Very useful! Thanks guys
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
bunyip
Personally, I prefer to put new product properties into a separate table rather than the products table - you never know when the core code is going to change and perhaps encounter problems if you've added extra fields to a table (ever have a mysql error telling you the column count doesn't match?). It's a little more work to achieve the same result, but could save lots of time bug-hunting in the future.
It makes sense to do the separate table so what needs to be done to integrate it? I understand how to make a new table in MySQL without any problems but I'm fairly new in working with PHP code. So do you have the changes available to share so some of us can set it up this way?
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
bunyip
Personally, I prefer to put new product properties into a separate table rather than the products table - you never know when the core code is going to change and perhaps encounter problems if you've added extra fields to a table (ever have a mysql error telling you the column count doesn't match?). It's a little more work to achieve the same result, but could save lots of time bug-hunting in the future.
Have you (or has anyone else) done this? If so, would they be willing to share the code?
-
Re: How-To: Add new Properties to your Products
Wow, I wish I'd seen this sooner. I've spent so much time reading 23 pages of piece-meal instructions on the Additional Products Fields contribution, only to find out that TheOracle is no longer around to help me make it work. His contribution still involves editing so many files that this seems just as good.
I would love to see step-by-step instructions like those from crazy_chris but using the new table, like the others have suggested.
Alternatively, is there a way to manually asign product id numbers? My main problem is that I want to show both the manufacturer's model number & my sku number. The dev team seems to suggest using the 'model' field for your sku, but I need both. Using my sku as the id would be ideal.
Thanks in advance for any suggestions!
-
Re: How-To: Add new Properties to your Products
Why not set your SKU number as the products model number (standard Zen Cart functionality) and then add an extra field (as post 1 in this thread explains) for your Manufacturers model number?
-
Re: How-To: Add new Properties to your Products
Thanks for the suggestion. That's what I was planning to do (or vice versa), now that I found this. (Unless someone has a better idea...) Does it matter which one is the new field and which uses the 'model' field? Would both fields be visible to the search function? Would I be able to limit one of the fields to not allow duplication (for my skus)?
I was originally trying to use TheOracle's contribution to create the extra field, but it's more trouble than it's worth.
I guess the only thing I'm waiting on now is the code for a new table instead of adding to the existing one. When it comes time to upgrade, I wouldn't want to lose the new field.
One more question - would Easy Populate be able to enter data into the new field? Would it matter for Easy Populate if it's added to the existing table or a new one?
Thanks!
-
Re: How-To: Add new Properties to your Products
I'm also interested in this but would love to put the extra fields in a separated table... anyone?
Thanks in advance !
Shirley :)
-
Re: How-To: Add new Properties to your Products
I am using Easy Populate and when I import I get this error:
No model field in record. This line was not imported
-
Re: How-To: Add new Properties to your Products
I would also love an answer to the extra tables. and I am using Easy Populate as well.
maybe 1.4 could even have an 'add custom fields' button built in!??! :D
that would be cool.
Thanks in advance...
-
Re: How-To: Add new Properties to your Products
hey, trying this out. but how do I create dropdowns and text areas? you only give examples of a text field.
I tried changing zen_set_field_length to zen_draw_textarea_field but it gave me errors.
-
Re: How-To: Add new Properties to your Products
Thanks Chris! it worked perfect for me.
If you have a chance to respond,
Do you have any thoughts on:
separate tables instead,
easy populate,
and having these new fields included in the search fields!!
just a wishlist.
thanks again for your time in that step-by-step
-
Re: How-To: Add new Properties to your Products
Oh man, this is a pain in my arse. Ok, so i think i got the text area going. I am able to use my new product property in the admin. it is there in the databse. The problem now is the output. I check my file over and over, I did just as instructed, but it's nto working right.
Nothing shows up unless ANOTHER property is also displayed (model, quantity,etc).
What in the hell can this mean? I am pulling my hair out over this. Been spending the last 2 days trying different things with the code.
PLEASE someone help me!
thanks.
-
Re: How-To: Add new Properties to your Products
Argh. Ok, the problem seems to be with this part of the code:
Code:
<ul id="productDetailsList" class="floatingBox back">
<?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?>
<?php echo (($flag_show_product_info_weight == 1 and $products_weight !=0) ? '<li>' . TEXT_PRODUCT_WEIGHT . $products_weight . TEXT_PRODUCT_WEIGHT_UNIT . '</li>' : '') . "\n"; ?>
<?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; ?>
<?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n"; ?>
</ul>
If I try to put the new property inside here it doesnt work, if i put it above this it does. This sucks because I am trying to control the way this information is presented. I want it in the same List, and in the order I want.
So, any ideas how to make it display correctly within the above code?
thanks again!
-
Re: How-To: Add new Properties to your Products
Well, after 2 days of madness and no replies....I got it to work somewhat.
Ok, so who knows how to do this but with something that has options for the admin to choose from? This purpose of this site is to sell used clothes, and when someone adds a new product, we want to be able to choose the size from a drop down list. this is NOT an attribute for the customer, this is for admin to set for one item.
Also, wondering how we could display this in a pull down for the customer side, so they can shop by size.
Any help is much appreciated!
-
Re: How-To: Add new Properties to your Products
Can someone please help me? I don't understand the first step. Where do I change what you are talking about? I don't see anywhere where it just says Product. Please help me.
Step 1 is what I don't understand.
-
Re: How-To: Add new Properties to your Products
Please someone can help? I don't understand step 1. What exactly and where exactly you want me to change this? I don't see a table anywhere.. Can you please give me specific steps. And what exactly do I want to write if I want to add physical condition and warranty as the options?
-
Re: How-To: Add new Properties to your Products
You need to open up your database and add your new properties to the "products" table.
You can probably do this using MyPHPAdmin through your webhosts control panel.
-
Re: How-To: Add new Properties to your Products
Okay,
Here is what I got now.
Add 1 field(s) At End of Table, then clicked next.
Field TypeDocumentation Length/Values1 Collation Attributes Null Default2 Extra Primary Index Unique --- Fulltext Comments
I got that in a line and under it they tell me to choose what I want. Also they ask where I want to store this in.
I didn't know what to put in there. Any help?
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
ElBasha
Okay,
Here is what I got now.
Add 1 field(s) At End of Table, then clicked next.
Field TypeDocumentation Length/Values1 Collation Attributes Null Default2 Extra Primary Index Unique --- Fulltext Comments
I got that in a line and under it they tell me to choose what I want. Also they ask where I want to store this in.
I didn't know what to put in there. Any help?
I'm not sure if I can help, but it worked for me. I got the exact same line of fields that you show here (starting with 'Field'...). I filled in the ones that crazy_chris mentioned & left the rest blank (unless I knew I wanted something else, such as 'unique').
I didn't have a question after this about where to store info, but did have a question on the 'Add 1 field' line. It gave me the option to add at the beginning, end, or after a specified field. Nothing else regarding 'where'. Were you already in your 'products' table when you clicked on 'Add 1 field..."?
-
Re: How-To: Add new Properties to your Products
Yeah! Only one day, and it works!!! (I had to focus on my live site for awhile, and just got back to working on this...)
It took me longer to uninstall the Additional Products Fields mod than it did to create fields using this method!
I made one mistake that I caught and thought I'd share, just in case somebody else has the same problem. When I finished all the instructions, I had the fields in the product pages in Admin & could enter data, but they didn't show up on my site in my product info display.
It turns out I'd tried to use the override system in a place where it doesn't work. I knew you couldn't use overrides in the admin section, but usually should in the storefront section. I tried to use zen overrides for includes/modules/pages/product_info/main_template_vars.php
When I was trying to figure out what went wrong, I remembered that there was one section of the storefront that doesn't accept overrides either, and I thought it might be 'modules'. Sure enough, when I modified the file in its original location (no overrides), my new fields showed up on my site!
Now, one question for the zencart team. I noticed when I was in phpMyAdmin that if I removed the 'auto_increment' condition from products_id, it looked like I could then enter my own values for product id (I'd like this to be my sku's). Would this mess up other functions in zen if I did this? Would the answer depend on if the skus are integers vs. alphnumeric? That's all I wanted in the first place, was to use my skus as the id's.
Thanks, if any of you guys (zen team) are reading this!
-
Re: How-To: Add new Properties to your Products
Yes I was in the table already, but I mean what is written by crazy is kind of confusing me, I don't know how to fill it, he has both the products he wants to add on one line, but we have to add each of them seperatly.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
magneteye
hey, trying this out. but how do I create dropdowns and text areas? you only give examples of a text field.
I tried changing zen_set_field_length to zen_draw_textarea_field but it gave me errors.
I need mine as a text area too. Any help?
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
ElBasha
Yes I was in the table already, but I mean what is written by crazy is kind of confusing me, I don't know how to fill it, he has both the products he wants to add on one line, but we have to add each of them seperatly.
The line that crazy_chris wrote, "ALTER..." is the SQL query itself. The menu that you found is an alternative to writing your own SQL queries for us SQL-illiterate folks. When you fill out the form and save your new field, phpMyAdmin creates the query for you, and it'll look like what crazy_chris wrote. You have to do it separately for each field. If you want to write in SQL query form instead, click on 'SQL' from the menu along the top. I think that if you're writing an SQL query you can include as many fields as you want at the same time.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
lismith
I need mine as a text area too. Any help?
I looked at what they did for the 'description' field (its in TABLE products_description) and they just put 'text' in the 'Type' field. Have you tried that?
As for the drop-downs, I'd suggest trying to duplicate what they did for manufacturers_id. It looks like there's a column there for 'distinct values'. I haven't done it, but I'd try that...
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
k4satin
The line that crazy_chris wrote, "ALTER..." is the SQL query itself. The menu that you found is an alternative to writing your own SQL queries for us SQL-illiterate folks. When you fill out the form and save your new field, phpMyAdmin creates the query for you, and it'll look like what crazy_chris wrote. You have to do it separately for each field. If you want to write in SQL query form instead, click on 'SQL' from the menu along the top. I think that if you're writing an SQL query you can include as many fields as you want at the same time.
Okay,
I went to SQL and I see this:
Run SQL query/queries on database phones:
In the blank where I can put what I want it says: SELECT * FROM `products` WHERE 1
Do I just erase that an paste: ALTER TABLE `zencart_products` ADD `product_condition` INT NOT NULL , ADD `products_warranty` VARCHAR( 32 ) NOT NULL;
And press on GO?
-
Re: How-To: Add new Properties to your Products
Are you using prefixes on your database tables?
The default line you show reads products but what you say you want to add is reading zencart_products ... :unsure:
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
Ajeh
Are you using prefixes on your database tables?
The default line you show reads products but what you say you want to add is reading zencart_products ... :unsure:
Well I just copied and pasted what crazy had and changed the two things to what I want them to be. He had zencart_products in there. So what did I do wrong?
-
Re: How-To: Add new Properties to your Products
If the products table in your database is NOT called:
zencart_products
then you need to look and see what it is called ...
-
Re: How-To: Add new Properties to your Products
Ajeh,
Glad to see you've joined us in this thread! We could use someone a little more knowledgeable.
Would I mess everything up if I asigned my sku numbers as my product id's instead of using the auto-increment feature for 'products_id'? My sku numbers are alph-numeric.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
Ajeh
If the products table in your database is NOT called:
zencart_products
then you need to look and see what it is called ...
Okay, I don't see zencart_products anywhere. I see just products and after that it has like products_image, _weight, etc. What should I do?
P.S. Could you please also reply to my other post: http://www.zen-cart.com/forum/showth...027#post414027
Thanks.
-
Re: How-To: Add new Properties to your Products
I think what you'd want would go more like this:
ALTER TABLE `products` ADD `products_condition` INT NOT NULL , ADD `products_warranty` VARCHAR( 32 ) NOT NULL;
You might also want to edit INT and VARCHAR. INT means integer - you'd probably want VARCHAR for your product_condition, and you can set the length of the input field in the perentheses. For products_warranty, you might use INT, if it's just going to be a number...
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
k4satin
I think what you'd want would go more like this:
ALTER TABLE `products` ADD `products_condition` INT NOT NULL , ADD `products_warranty` VARCHAR( 32 ) NOT NULL;
You might also want to edit INT and VARCHAR. INT means integer - you'd probably want VARCHAR for your product_condition, and you can set the length of the input field in the perentheses. For products_warranty, you might use INT, if it's just going to be a number...
Okay, do I need to put it where I thought I woud?
I went to SQL and I see this:
Run SQL query/queries on database phones:
In the blank where I can put what I want it says: SELECT * FROM `products` WHERE 1
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
ElBasha
Okay, do I need to put it where I thought I woud?
I went to SQL and I see this:
Run SQL query/queries on database phones:
In the blank where I can put what I want it says: SELECT * FROM `products` WHERE 1
Just delete whatever's there and add your statement ('ALTER TABLE...) I think the other stuff is there to help you create an SQL statement, but not for what you're trying to do.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
k4satin
Would I mess everything up if I asigned my sku numbers as my product id's instead of using the auto-increment feature for 'products_id'? My sku numbers are alph-numeric.
The products_id is a control feature of Zen Cart and all of the code addresses this ...
You do not want to alter this field nor manipulate it in any way ...
-
Re: How-To: Add new Properties to your Products
I was able to get text area to work by copying the Description code. You need to duplicate it all over the files and do a similar table in your db.
I tried to copy the manufacturers_id for a pull down, but it didn't work. I am thinking cause that code works differently. It pulls the manufacturers names form a table that is populated by the admin. I just want to do it myself one time with 6 values. I haven't been able to get a working pull down yet. and no one has yet to have answers for me on this forum. :unsure:
-
Re: How-To: Add new Properties to your Products
Still hoping for someone to cue in on how to get 6 options in a pull down menu as a new product property...
What I really don't understand about all this is why is it so hard to do? I used a different cart like 5 years ago, and it let you set these up really easily in the admin. I really think this should be a feature of the cart as it makes customizing product types and properties so easy. This is a pain for anyone needing specialized fields.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
magneteye
I tried to copy the manufacturers_id for a pull down, but it didn't work. I am thinking cause that code works differently. It pulls the manufacturers names form a table that is populated by the admin.
yes, that works differently, although there are similarities.
Quote:
Originally Posted by
magneteye
I just want to do it myself one time with 6 values. I haven't been able to get a working pull down yet. and no one has yet to have answers for me on this forum. :unsure:
Somewhere in the top of your product type's collect_info.php script, put something like this:
Code:
$my_list_of_options = array();
$my_list_of_options[] = array('id' => 'Name of option 1', 'text' => 'Name of option 1');
$my_list_of_options[] = array('id' => 'Name of option 2', 'text' => 'Name of option 2');
$my_list_of_options[] = array('id' => 'Name of option 3', 'text' => 'Name of option 3');
$my_list_of_options[] = array('id' => 'Name of option 4', 'text' => 'Name of option 4');
$my_list_of_options[] = array('id' => 'Name of option 5', 'text' => 'Name of option 5');
$my_list_of_options[] = array('id' => 'Name of option 6', 'text' => 'Name of option 6');
Note the duplication of description in both the id and text sides.
Then, later where you want the pulldown to display, echo something like this:
Code:
zen_draw_pull_down_menu('my_selected_option_from_database', $my_list_of_options, $pInfo->my_selected_option_from_database)
where my_selected_option_from_database refers to the name of the database field which is storing the value selected, and which you've already retrieved earlier in the script.
-
Re: How-To: Add new Properties to your Products
Dr Byte. I really appreciate your response. I can kind of get what you have there. Any tips on setting up the tables in the database? I think I did that wrong when i first tried.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
magneteye
Dr Byte. I really appreciate your response. I can kind of get what you have there. Any tips on setting up the tables in the database? I think I did that wrong when i first tried.
Sorry, I have no idea what you've done to get where you're at. The process of adding new fields is not something that is described in one page. It requires significant understanding of databases, database structures, coding methodologies, etc. It's not for the faint of heart.
I've not read all your posts in this thread, and I suspect that some steps are right, and others are not understanding.
The first post in this thread covers the "big picture" of the concepts, and probably worked great for the original poster's initial needs. That doesn't mean it necessarily meets "your" needs fully.
How many fields are you trying to add?
What is their purpose? What is the business need you're trying to solve?
How is each being used?
What fields have you created in the database?
-
Re: How-To: Add new Properties to your Products
Dr. Byte... to answer your questions:
Quote:
How many fields are you trying to add?
Six fields.
Quote:
What is their purpose?
Sizes of clothing.
Quote:
What is the business need you're trying to solve?
Consignment (used) clothing. Items sold only once, then removed from product database. See the link in my sig to see the site.
Quote:
What fields have you created in the database?
I created a table called products_sizes and added 6 fields, one for each size (small, medium, large, xlarge, petite, plus sizes). I think I may need to have a primary key setup?
I basically just want to be able to select the size in admin when adding a product. Then the size is displayed on the product page. Lastly, I want to add the sizes to the end of my categories menu so a user can shop by size.
-
Re: How-To: Add new Properties to your Products
Dr. Byte,
a quick question about the drop down menu, if i wanted to have a drop down of lets say 6 images to be placed in a product how would i link the image to what you have displayed:
$my_list_of_options = array();
$my_list_of_options[] = array('id' => 'Name of option 1', 'text' => 'Name of option 1');
$my_list_of_options[] = array('id' => 'Name of option 2', 'text' => 'Name of option 2');
$my_list_of_options[] = array('id' => 'Name of option 3', 'text' => 'Name of option 3');
$my_list_of_options[] = array('id' => 'Name of option 4', 'text' => 'Name of option 4');
$my_list_of_options[] = array('id' => 'Name of option 5', 'text' => 'Name of option 5');
$my_list_of_options[] = array('id' => 'Name of option 6', 'text' => 'Name of option 6');
the drop down would have text for the admin to chose from but the result would be an image displayed in the product display for the customer
any help i would be gratfull
thanks in advance
rich
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
hostmonster
Dr. Byte,
a quick question about the drop down menu, if i wanted to have a drop down of lets say 6 images to be placed in a product how would i link the image to what you have displayed:
$my_list_of_options = array();
$my_list_of_options[] = array('id' => 'Name of option 1', 'text' => 'Name of option 1');
$my_list_of_options[] = array('id' => 'Name of option 2', 'text' => 'Name of option 2');
$my_list_of_options[] = array('id' => 'Name of option 3', 'text' => 'Name of option 3');
$my_list_of_options[] = array('id' => 'Name of option 4', 'text' => 'Name of option 4');
$my_list_of_options[] = array('id' => 'Name of option 5', 'text' => 'Name of option 5');
$my_list_of_options[] = array('id' => 'Name of option 6', 'text' => 'Name of option 6');
the drop down would have text for the admin to chose from but the result would be an image displayed in the product display for the customer
any help i would be gratfull
thanks in advance
rich
The whole issue is a complex topic. The first post in this thread covers the overall concepts.
You'll need to create a database field to store the choice. Then create the forms for selecting the desired option when entering/editing the products, make sure the info gets saved, and then in the display template make sure the page displays the proper image based on the entry.
-
Re: How-To: Add new Properties to your Products
Dr Byte, did you see my reply up a couple from what you asked me last about what I was trying to do... my pulldown question got kinda hijacked here. I am still trying to figure it out.
Thanks!
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
magneteye
Six fields.
Sizes of clothing.
This would be a classic reason for using attributes.
Quote:
Originally Posted by
magneteye
I created a table called products_sizes and added 6 fields, one for each size (small, medium, large, xlarge, petite, plus sizes).
If I correctly read your proposed structure for the products_sizes table as being a reference table, your needs are more directly reflective of pulling data from the Manufacturers table and simply storing the selected choice into your new "product_size" field in your products table:
- query the table
- build an array of its entries
- display a pulldown
- store the selected entry
- then in the storefront, display information appropriately based on the selected setting
- and build your shop-by-size choices in the category menu
Quote:
Originally Posted by
magneteye
Lastly, I want to add the sizes to the end of my categories menu so a user can shop by size.
That's yet another kettle of fish ... and doing it by using normal attributes would be admittedly more difficult. Using a dedicated size table as you're considering may be a touch easier. Nevertheless, I recall a contribution floating around some time back that had code for shop-by-size in it. It should be in the downloads section if you want to use it as a reference. I think it was attribute-based.
-
Re: How-To: Add new Properties to your Products
ok, but doesn't using attributes on the user side? Meaning, when a user is say looking a tshirt, and they wantr to order it and they select their size. Isn't tht how the attributes work? That NOT what I need. Since the clothes being sold are always just one set size by the admin.
Shopping by size doesn't have to be part of the category menu I guess, I could just make it a pull down menu or other type just below the category menu in a sidebox.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
magneteye
ok, but doesn't using attributes on the user side? Meaning, when a user is say looking a tshirt, and they wantr to order it and they select their size. Isn't tht how the attributes work? That NOT what I need. Since the clothes being sold are always just one set size by the admin.
Fair enough. Then attributes won't be your solution. My other comments still apply.
-
Re: How-To: Add new Properties to your Products
Just for the record, re: post 19 (product details list and not getting your new field to display by itself), before the output <ul> section there is an if() test which only displays the list if one of its elements has a value or is set to display.
Add your field to that test and it will trigger the list to show.
-
Re: How-To: Add new Properties to your Products
Has anyone been able to add additional product fields using a separate table? Can you provide an easy 'how-to' for us with little knowledge such as the one shown here?
Not sure if this has been posted on the wish-list, but this, along with the ability to add additional customer info fields, is essential to any growing business and probalby should be a standard feature of ZenCart.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
crazy_chris
Guarantee:
<?php if (!empty($product_info->fields['products_guarantee'])) echo $product_info->fields['products_guarantee']; ?>
This is supposedly only going to output if something exists, but it am placing my items in a list and can't seem to figure out how to make it NOT show the list bullets (and list title) when it is empty. Can anyone help?
EDIT:
I figured it out on my own:
<?php if (!empty($product_info->fields['products_guarantee'])) echo '<li>' . $product_info->fields['products_guarantee'] . '</li>'; ?>
BUT, I can't figure out how to hide the list title if nothing exists in any of my 4 new fields that create the list.
Here's the code as is, and obviously the "Product Features" is always there at this point:
Quote:
<p><strong>Product Features:</strong></p>
<ul>
<?php if (!empty($product_info->fields['products_feature1'])) echo '<li>' . $product_info->fields['products_feature1'] . '</li>'; ?>
<?php if (!empty($product_info->fields['products_feature2'])) echo '<li>' . $product_info->fields['products_feature2'] . '</li>'; ?>
<?php if (!empty($product_info->fields['products_feature3'])) echo '<li>' . $product_info->fields['products_feature3'] . '</li>'; ?>
<?php if (!empty($product_info->fields['products_feature4'])) echo '<li>' . $product_info->fields['products_feature4'] . '</li>'; ?>
</ul>
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
gjh42
Just for the record, re: post 19 (product details list and not getting your new field to display by itself), before the output <ul> section there is an if() test which only displays the list if one of its elements has a value or is set to display.
Add your field to that test and it will trigger the list to show.
I'm working on a product type;however it really only is adding one field to the products table for that product type. I'm having the same issue - getting the field to display on the products detail page. I've done this before, in an older version with no problems - but for some reason its giving me fits this time (I'm upgrading).
The admin side works perfectly - all data is collected and displayed properly.
I did as you stated above and listed the field in the test - Here is the code from that section (product_candle is the product type - burn_time is the field - )
Code:
<!--bof Product details list -->
<?php if ( (($flag_show_product_candle_info_model == 1 and $products_model != '') or <?php if ( (($flag_show_product_candle_info_burn_time == 1 and $products_burn_time != '') or ($flag_show_product_candle_info_weight == 1 and $products_weight !=0) or ($flag_show_product_candle_info_quantity == 1) or ($flag_show_product_candle_info_manufacturer == 1 and !empty($manufacturers_name))) ) { ?>
<ul id="productDetailsList" class="floatingBox back">
<?php echo (($flag_show_product_candle_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?>
<?php echo (($flag_show_product_candle_info_burn_time == 1 and $products_burn_time !='') ? '<li>' . TEXT_PRODUCT_BURNTIME . $products_burn_time . '</li>' : '') . "\n"; ?>
<?php echo (($flag_show_product_candle_info_weight == 1 and $products_weight !=0) ? '<li>' . TEXT_PRODUCT_WEIGHT . $products_weight . TEXT_PRODUCT_WEIGHT_UNIT . '</li>' : '') . "\n"; ?>
<?php echo (($flag_show_product_candle_info_quantity == 1) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; ?>
<?php echo (($flag_show_product_candle_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n"; ?>
</ul>
Any suggestions?:blink:
-
Re: How-To: Add new Properties to your Products
Hey this is a great tutorial thanks,
I have a question, I want to use textarea instead of the input field, I looked to see how the description field was coded so I copied and replaced “zen_draw_input_field” with “zen_draw_textarea_field” and Zen Cart did not like that at all, how can I change the input field to a textarea?
Code:
Warning: Missing argument 4 for zen_draw_textarea_field()
-
Re: How-To: Add new Properties to your Products
Ok I got it to work using the following code, I hope others find this useful
Code:
<?php echo zen_draw_textarea_field('products_YOUR-FIELD-NAME[' . $languages[$i]['id'] . ']', 'soft', '100%', '10', $pInfo->products_YOUR-FIELD-NAME, zen_set_field_length(TABLE_PRODUCTS, 'products_YOUR-FIELD-NAME')); ?>
-
Re: How-To: Add new Properties to your Products
Hi,
this issue is really bothering me as well. I will soon go insane on this!
I also needs extra fields to choose from in admin. Some of them should be textfields, some would be dropdown with values and some would need checkboxes.
In other carts I worked with this was not usually a problem and with Zencart that is bright and good on everything else I cant understand why this have to be such an issue.
For my needs It would be enough to be able to create attributes in normal way but then only use them for adminpart. No customers should be able to choose anything (like magneticeyes needs)
I really need to get this issue fixed somehow. If someone feels like they could fix this i´m willing to pay him/her to do it.
Best regards,
Ola
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
jagge
I really need to get this issue fixed somehow. If someone feels like they could fix this i´m willing to pay him/her to do it.
There is a message board in this forum for hiring custom coding work. I've done that very successfully, worked with a developer in another country, in fact, who was familiar enough with ZC and he was able to deliver what I needed very nicely, at a fair price. What you describe is trivial for an experienced developer who knows ZC, but if you're not handy with PHP and SQL, adding extra product attribute fields is not a simple thing. It would be lovely to automate custom fields in some future edition of ZC, it would make creating custom product types a breeze, wouldn't it! The custom code will need to be nested inside several files according to the current code structure. This creates future maintenance chores for you, as you must manually merge and update files for each future ZC release. Just some things to think about.
---Diana
-
Re: How-To: Add new Properties to your Products
Hi all. I have a quick question on this procedure if someone would be kind enough to help me out.
I've followed this procedure exactly as outlined in the first post, and have successfully added six custom properties to my general products. THANKS SO MUCH crazy_chris!!!
I decided it would be nice to add similar custom properties for the Document - General "product" type as well. I set up the custom fields in the products table exactly as before, and made the same modifications to collect_info and preview_info, EXCEPT...
...in admin/modules/document_general
instead of admin/modules/product
The input fields are there, just as expected, when I go to create or update a Document - General product.
However, looking at the newly-created product in the database (via PHPAdmin) the values entered into the custom fields aren't being inserted into the database.
There's only one update_product file for all product types, and I did add the new custom properties to the SQL array right below where I added the previous ones.
I do notice that a little farther down in the update_product code, there are two sections:
///////////////////////////////////////////////////////
//// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////
//// *END OF PRODUCT-TYPE-SPECIFIC INSERTS* ////////
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
//// INSERT PRODUCT-TYPE-SPECIFIC *UPDATES* HERE //////
//// *END OF PRODUCT-TYPE-SPECIFIC UPDATES* ////////
///////////////////////////////////////////////////////
...but if I need to put something there, what needs to be put there unfortunately is a bit over my head.
Anybody care to share some thoughts on what I'm missing to insert these values?
-
Re: How-To: Add new Properties to your Products
Update: I have manually populated the new fields through PHPAdmin, and:
1. tpl_document_general_info_display shows the custom properties just fine
2. document_general/collect_info pre-populates the fields with the new, manually-entered info when I view the product in ZC admin.
I haven't yet tried to "update" the product through ZC admin, because I'm afraid it'll reset the fields in the database to NULL :)
Seems everything works great except the insert. I really think it has something to do with product-type being 3 (Document - General) in update_product. But for the life of me, I can't seem to figure out why.
-
Re: How-To: Add new Properties to your Products
Hello,
I have two question:
firstly, I went through all the steps, but I cannot see the textboxes to put my information in from the New Product admin control.
Secondly, is it possible to have a checklist of things: I have a car dealership. I would like to check off all of the features that the car has. Is that possible?
Thanks!
-
Re: How-To: Add new Properties to your Products
Wish I could help someone out here cuz I am stumped with my problem.
This install how-to worked great for me! But for some reason the 20+ new fields are not getting searched. Anybody else having this problem? Did I miss something?
I've inserted hoobajonesfieldname in each new field of a test product (where fieldname is substituted by the, uh, field name), so I know the data is there, but when I search for each variation, no luck.
Ahhh, troubleshooting on a Friday night.
-
Re: How-To: Add new Properties to your Products
Three and a half hours later less dinner and a dog walk, here is an answer to enhanced custom search.
-
Re: How-To: Add new Properties to your Products
Hi
I follow this post and managed to add 2 extra fields (Size A and size B). But on the product overview they can't be sortable (like quantity or weight). Is anybody know wher the problem can be?. The example is on :
http://www.zancart137.may.com.pl/ind...dex&cPath=3_10
Thanks in advance.
-
Re: How-To: Add new Properties to your Products
Open includes\index_filters\default_filter.php and includes\modules\pages\advanced_search_result\header_php.php.
Look at the areas surrounding the following fields and see how it is coded.
PRODUCT_LIST_MODEL
PRODUCT_LIST_MANUFACTURER
PRODUCT_LIST_QUANTITY
PRODUCT_LIST_IMAGE
PRODUCT_LIST_WEIGHT
I imagine if you follow the established code and do some cut-n-paste to add your fields in the same format that it ought to work or at least get you on the right track. That'd be my guess since I just edited those two files to handle the search for 20+ custom fields. And in the code notes, it mentions setting "the default sort order" before the fields I listed above.
-
Re: How-To: Add new Properties to your Products
Many Many Thanks didn't expect it will be so easy
-
Re: How-To: Add new Properties to your Products
I got another question regarding product extra fields. Let say we got extra sizes A, B, C, D ...
Products in category 1 got sizes A, B, C
Products in category 2 got only sizes A, C
How to make if you leave blank size B for category 2 that is automaticly no visible
in product overview for category 2 so only sizes A and C are visible and there is no
empty space between them.
thanks in advance
-
Re: How-To: Add new Properties to your Products
<?php if (!empty($product_info->fields['custom1_planets'])) echo '<tr><td class="custom-head">Planetary Body:</td><td class="custom-body">' . $product_info->fields['products_custom1'] . '</td></tr>'; ?>
When the custom1_planets field has an entry, e.g. Saturn, then the above snippet of code will display (depending upon CSS, of course):
Planetary Body: Saturn
If the custom1_planets field is empty, then nothing is displayed, including the "Planetary Body:" portion. Mind your spaces, periods and single quotes.
-
Re: How-To: Add new Properties to your Products
Many thanks for help.
But not sure where to place that code and which line. I that gonne be default_filter.php or maybe other?
-
Re: How-To: Add new Properties to your Products
tpl_product_info_display.php would be where I'd start. or try the product_listings file (forget its proper name). of course it depends upon on how you're setting up you're store. regardless, this piece of code goes in an html section.
-
How-To: Add input_field to upload a product pdf
-
Re: How-To: Add new Properties to your Products
I got this great mod going without a hitch, took about an hour to get right. I do have one question tho:
How can I display my custom fields in the product listing pages such as featured products, and categories? I also need to be able to sort by these custom settings.
Any help would be appreciated, and my hat's off to crazy for such a well described mod!:bigups:
-
Re: How-To: Add new Properties to your Products
Zep, look at the last post of page 7 of this thread and mimic that code snippet (or wherever in this thread the echo statement is discussed. The feature product listing page is:
\includes\templates\template_default\templates\tpl_featured_products_default.php .
Not sure about categories but I think works off of product_listing file in the same directory or tpl_modules_product_listing.php. I forget.
If you need search capability, there's a link in another post of mine on page 7. Let me know if that's incomplete because I've got pretty comprehensive instructions for the admin side of things, too. I just haven't made the time to "anonymize" them.
I am assuming that by sort you mean, "Filter By:" which is what I want to eventually add to all my product listing pages. The default_filter.php file in includes\index_filters\ may affect sort, too. But it'll be awhile before I get to it myself.
-
Re: How-To: Add new Properties to your Products
Hi Zep
Have you managed to display extra fields in product detail view?
If yes I will tell you how to display them in product list, but displaing fields in detail view is a first step to display them in list.
-
Re: How-To: Add new Properties to your Products
Thanks for the tips, but this issue is confusing me...
I change tpl_modules_featured_products.php, and my text displays fine. But the new fields do not display. do I need to include one of the other php files? I tried putting the info into variables, then placing them after the price, that does not work either :frusty:
the code I am using is something like this:
$case =$product_info->fields['products_case'];
$indiv = $product_info->fields['products_indiv'];
then echoing like this:
<div class="p_left"><br style="line-height:9px;"/>Case Price: <a href="'.$href.'">'.$price.$case.$indiv.' </a>
Please help!
-
Re: How-To: Add new Properties to your Products
Thank you janekbar5 and cartguin, I really appreciate all the help.
I have successfully displayed the information in the single item view (product_info), but want to be able to display the info if someone goes to browse featured products, or a category as well.
I will also be making a drop down box to sort (my custom fields are numbers) from low to high, and vise versa - but I have not done my due diligence on that yet, I'm focusing on getting them displayed first:smile:baby steps...
Thanks in advance for pointing me in the right direction!
-
Re: How-To: Add new Properties to your Products
Hi
in my case I wanted to add about 20 extra fields to each product. I follow this post and with help of the guys I managed to do it. Fields are visible in product details. Then I wanted to to make them visible in category overview (products listing) and make them also sortable like other fields(weight, price, manufacturer...) I managed to achive that. so if you managed to display those
extra fields in product details you are in half way. Now if you want do show those fields in product listing you must modify those files:
-includes/languages/english/index.php
standard fields:
define('TABLE_HEADING_QUANTITY', 'Quantity');
define('TABLE_HEADING_PRICE', 'Price');
define('TABLE_HEADING_WEIGHT', 'Weight');
define('TABLE_HEADING_BUY_NOW', 'Buy Now');
my new fields
define('TABLE_HEADING_NORMDIN', 'Norm DIN');
define('TABLE_HEADING_THREADSIZE', 'Thread size');
define('TABLE_HEADING_SIZEA', 'A mm');
define('TABLE_HEADING_SIZEB', 'B mm');
define('TABLE_HEADING_SIZEC', 'C mm');
define('TABLE_HEADING_SIZED', 'D mm');
-includes/modules/product_listing.php
you have to include your extra fields
similar to those standard
line about 20
case 'PRODUCT_LIST_MODEL':
$lc_text = TABLE_HEADING_MODEL;
$lc_align = '';
$zc_col_count_description++;
break;
case 'PRODUCT_LIST_NAME':
$lc_text = TABLE_HEADING_PRODUCTS;
$lc_align = '';
$zc_col_count_description++;
break;
and the same in line about 580
case 'PRODUCT_LIST_QUANTITY':
$lc_align = 'right';
$lc_text = $listing->fields['products_quantity'];
break;
case 'PRODUCT_LIST_WEIGHT':
$lc_align = 'right';
$lc_text = $listing->fields['products_weight'];
break;
case 'PRODUCT_LIST_NORMDIN':
if ($listing->fields['products_normdin']==0) {
//hide image column
$lc_text = '';
$lc_align = '';
} else {
//show image column
$lc_align = 'right';
$lc_text = $listing->fields['products_normdin'];
}
break;
case 'PRODUCT_LIST_THREADSIZE':
if ($listing->fields['products_threadsize']==0) {
//hide image column
$lc_text = '';
$lc_align = '';
} else {
//show image column
$lc_align = 'right';
$lc_text = $listing->fields['products_threadsize'];
}
break;
I got here extra condition if field is =0 field is not visible
includes/index_filters/default_filter.php
to add extra fields to sql querry like I did:
$listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = 1,
s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping,
p.products_qty_box_status, p.products_normdin, p.products_threadsize, p.products_sizeA, p.products_sizeB, p.products_sizeC, p.products_sizeD,
p.products_sizeD1, p.products_sizeD2, p.products_sizeE, p.products_sizeE1, p.products_sizeF, p.products_sizeG, p.products_sizeH, p.products_sizeW, p.products_sizeX, p.products_sizeQG, p.products_sizeQX, p.products_peld, p.products_pelld, p.products_pehd, p.products_pa66, p.products_tpe,
p.products_peeva, p.products_pvc, p.products_pelldwasher, p.products_pa66oring, p.products_pelduvtreatment, p.products_injectedhole,
p.products_pa66washer, p.products_pehdwasher, p.products_pipethread, p.products_oldrefrence
there are 4 blocks with that querry in this file line from 28 to 105
and line 136
you can see standard fields and my new:
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_NORMDIN':
$listing_sql .= "p.products_normdin " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_THREADSIZE':
$listing_sql .= "p.products_threadsize " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
last file is:
includes/modules/pages/index/main_template_vars.php
line 138
$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
'PRODUCT_LIST_NORMDIN' => PRODUCT_LIST_NORMDIN,
'PRODUCT_LIST_THREADSIZE' => PRODUCT_LIST_THREADSIZE,
'PRODUCT_LIST_SIZEA' => PRODUCT_LIST_SIZEA,
'PRODUCT_LIST_SIZEB' => PRODUCT_LIST_SIZEB,
'PRODUCT_LIST_SIZEC' => PRODUCT_LIST_SIZEC,
'PRODUCT_LIST_SIZED' => PRODUCT_LIST_SIZED,
'PRODUCT_LIST_SIZED1' => PRODUCT_LIST_SIZED1,
'PRODUCT_LIST_SIZED2' => PRODUCT_LIST_SIZED2,
'PRODUCT_LIST_SIZEE' => PRODUCT_LIST_SIZEE,
'PRODUCT_LIST_SIZEE1' => PRODUCT_LIST_SIZEE1,
'PRODUCT_LIST_SIZEF' => PRODUCT_LIST_SIZEF,
'PRODUCT_LIST_SIZEG' => PRODUCT_LIST_SIZEG,
'PRODUCT_LIST_SIZEH' => PRODUCT_LIST_SIZEH,
'PRODUCT_LIST_UVTREAT' => PRODUCT_LIST_UVTREAT,
'PRODUCT_LIST_INJECT' => PRODUCT_LIST_INJECT,
'PRODUCT_LIST_PA66WASH' => PRODUCT_LIST_PA66WASH,
'PRODUCT_LIST_PEHDWASH' => PRODUCT_LIST_PEHDWASH,
'PRODUCT_LIST_PIPETHREAD' => PRODUCT_LIST_PIPETHREAD,
'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE);
and line 190
case 'PRODUCT_LIST_MODEL':
$select_column_list .= 'p.products_model, ';
break;
case 'PRODUCT_LIST_NAME':
$select_column_list .= 'pd.products_name, ';
break;
case 'PRODUCT_LIST_MANUFACTURER':
$select_column_list .= 'm.manufacturers_name, ';
break;
case 'PRODUCT_LIST_QUANTITY':
$select_column_list .= 'p.products_quantity, ';
break;
case 'PRODUCT_LIST_IMAGE':
$select_column_list .= 'p.products_image, ';
break;
case 'PRODUCT_LIST_NORMDIN':
$select_column_list .= 'p.products_normdin, ';
break;
case 'PRODUCT_LIST_THREADSIZE':
$select_column_list .= 'p.products_threadsize, ';
break;
case 'PRODUCT_LIST_SIZEA':
$select_column_list .= 'p.products_sizeA, ';
break;
case 'PRODUCT_LIST_SIZEB':
$select_column_list .= 'p.products_sizeB, ';
break;
case 'PRODUCT_LIST_SIZEC':
$select_column_list .= 'p.products_sizeC, ';
break;
case 'PRODUCT_LIST_SIZED':
$select_column_list .= 'p.products_sizeD, ';
break;
once you take a closer look you gonne now how to do it
-
Re: How-To: Add new Properties to your Products
I will try it out tomorrow, janekbar5 - I am eternally in your debt, thank you:wink:
-
Re: How-To: Add new Properties to your Products
Thanks jane! I am going to add that tomorrow afternoon.
This is somewhat related and since I'm not sure how to go about it, maybe someone has already combined new fields to auto-generate a global field.
More specifically, how do I combine several of my new product detail fields (along with the mfr ID field) so that [FONT="Courier New"]zen_products_description . products_name[/FONT] is created automatically? Essentially what is happening is that the products_name field is made up of several other fields. There is no need for it to be typed. IOW, the product name is controlled and consistent across the site.
Excusing the code, let's say the combined field protocol for products_name is:
[FONT="Courier New"]$manufacturers_id . ' » ' . $details_model_name . $details_style . ' » ' $details_size . $details_orientation . ' » ' . $details_color[/FONT]
For example, when displayed, the products names would look like:
- ACME » Medallion Trampoline » 18' round » blue and black
- SILLY » Trampoline » 9'x12'
- AVD » Slide » 12' high curlicue » clear painted aluminum
So, all the data is pulled from fields in the zen_products table (plus using the text conversion of manufacturer_id) based upon a conditional (the right angle brackets are only included if the following field contains something) and needs to be written into the products_name field in the zen_products_description table.
I've tried searching but my keywords are too general to get anywhere. Anybody have an idea of what PHP code is needed to do this?
-
Re: How-To: Add new Properties to your Products
Jane,
I have modified the files, and Im sorry for such a questions, but....
I am having issues displaying the info in tpl_moduals_featured_products.php
I'm calling calling $case = $product_info->fields['products_case'];
and also tried $case = $featured_products>fields['products_case'];
Im then putting the var into this statement :
<div class="p_left"><br style="line-height:9px;"/>Case Price: <a href="'.$href.'">'.$price.'<br/>'.$case.'<br/>'.$case2.'<br/>'.$case3.' </a>
When I echo, I'm getting no output, so the variable I put it into is empty. Im sorry to seem so needy, but could you lend a tip?
Thanks
-
Re: How-To: Add new Properties to your Products
Hi
Your case may be bit diffrent than mine but if you send my your email I can send you all files which i modified so you can have look. mail me if you intredted.
Regards
Janek
-
Re: How-To: Add new Properties to your Products
swne (at) sbcglobal.net....THANKS!!
-
Re: How-To: Add new Properties to your Products
I've got everything working on the search results/ product listing including the sort for my custom field. Problem is that it always displays on the right, after the built in fields. Where is this order set in the code? (I know it's sent in admin-> product listing for the existing fields)
Thanks,
Gregg Short
GShort.com Web Marketing & Design
-
Re: How-To: Add new Properties to your Products
Thanks for this tutorial!
But...
I don't know why, but my new Properties is not working correctly.
First of all, the value that I put on the admin page for a product is not put in the DB
Other problem: the new field not appear in the description in the store (client)
Can you help me?
I am a newbie and I don't "speak" PHP for the moment.
my email is ipuce [at] videotron.ca
Thank you!
-
Re: How-To: Add new Properties to your Products
hey...I just implemented a product 'volume' property in my shopping cart by following the directions on the front page of this string. I wanted to say THANKYOU!!!! Your instructions have guided me exactly where I needed to go and it has taken a lot of stress off of my shoulders. Thankyou so Much! I even feel a slight bit confident now in mucking around with deep zencart. Sweet dreams! You've given me mine =)
-
Re: How-To: Add new Properties to your Products
I have my new property showing up but it does not show the name of it. I am wanting to add an Item Number field to my products. I have everything showing up just fine in the admin area but its just showing the number on my actual store. here is an example http://silentshadow.oxyhost.com/inde...roducts_id=123
As you can see it just shows "111" and thats it. It does not have the Item Number: in front of it. Any suggestions?
-
Re: How-To: Add new Properties to your Products
Try...
Code:
<?php if (!empty($product_info->fields['custom_item_number'])) echo '<li>Item Number: ' . $product_info->fields['custom_item_number'] . '</li>'; ?>
...where custom_item_number is the data field you added to the products table in the database.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
cartguin
Try...
Code:
<?php if (!empty($product_info->fields['custom_item_number'])) echo '<li>Item Number: ' . $product_info->fields['custom_item_number'] . '</li>'; ?>
...where custom_item_number is the data field you added to the products table in the database.
THANK YOU!!! I had to edit it just a little to get it to work but it works. thanks so much!
-
Re: How-To: Add new Properties to your Products
Hi
Can you please help. I want to add a new property to the 'extras' fields for product type music. I think its table product_music and I want to add the field 'format'
These additional music fields are maintained via the admin screen 'extra's menu choice.
Thanks for any guidance.
John
-
Re: How-To: Add new Properties to your Products
I am having a problem with this setup. I added the extra fields, and I can update them & have them show up just fine. I am having trouble getting them to show up on the listings page, where there are multiple products.
I found where the descriptions go (in product_listing.php) but whenever I try to execute a line like this, right before the description, it is always turning up null, even when data is there:
PHP Code:
$c_height = $product_info->fields['products_height']
maybe $product_info can't be accessed from this page, is that the problem? it seems all the other data is getting from an array called $listings. do I need to edit another file to make sure that array can get to the new fields. if so, what file is it, and where do I find it?
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
zep
Jane,
I have modified the files, and Im sorry for such a questions, but....
I am having issues displaying the info in tpl_moduals_featured_products.php
I'm calling calling $case = $product_info->fields['products_case'];
and also tried $case = $featured_products>fields['products_case'];
Im then putting the var into this statement :
<div class="p_left"><br style="line-height:9px;"/>Case Price: <a href="'.$href.'">'.$price.'<br/>'.$case.'<br/>'.$case2.'<br/>'.$case3.' </a>
When I echo, I'm getting no output, so the variable I put it into is empty. Im sorry to seem so needy, but could you lend a tip?
Thanks
Hey Zep, did you get this working, I'm trying to get my custom field to show up in the products_all page and I'm getting the same outcome it's like the field is empty...
This is the code I'm trying to use in the tpl_modules_products_all_listing.php, but it's only showing 0
PHP Code:
if ($product_info->fields['products_on_order']){$products_on_order = $product_info->fields['products_on_order'];}else{$products_on_order = "0";}
echo '<td align="left" width="18%">'.$product_info->fields['products_on_order'].' Units On Order: '.$products_on_order.'</td>';
Any help would be great thanks guys :smile:
-
Re: How-To: Add new Properties to your Products
Yes I did get this working, I actually combined a different post to use the same template for all the listings (Note: search requires a different template)
http://www.zen-cart.com/forum/showth...single+listing
Its pretty strait forward, then and by adding the new fields to your MySQL queries for the particular display you are calling (new, featured,product), you can include them in your product info array, thus when they are called the information will actually be there:wink:
good luck, if you need another hint, shoot an email
also I used $case = $featured_products>fields['products_case'] the $featured_products query is where you need to add your new fields (use the developers toolkit)
-
Re: How-To: Add new Properties to your Products
GSto: yes you are correct $product_info is the array that the SQL statement creates for the product info page, see above for the changes you must make for each view you wish to alter.
-
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
zep
GSto: yes you are correct $product_info is the array that the SQL statement creates for the product info page, see above for the changes you must make for each view you wish to alter.
Awesome, thanks. yeah, I finally got it working. About to try editing the search engine so that it can search by the new attributes.
And thanks to everyone else in this thread that posted lots of helpful information. The boss loved the new look!
-
Re: How-To: Add new Properties to your Products
I'm having an issue with this mod. I followed all of the beginning steps. I was able to successfully add the custom fields to the database and admin section and have them display for each product.
But I'm wanting to do something like janekbar5 posted in post #66.
http://www.zancart137.may.com.pl/ind...&cPath=3_67_74
I would like my custom fields to show up on the categories page. I also followed this post http://www.zen-cart.com/forum/showth...single+listing like was suggested by zep on post 94. But that didn't accomplish what i wanted.
Are there any other resources that can point me in the direction to get the categories page to display the products in a list with the custom fields like this?
http://www.zancart137.may.com.pl/ind...&cPath=3_67_74
-
Re: How-To: Add new Properties to your Products
This may be the most helpful post ever.
-
Re: How-To: Add new Properties to your Products
Okay - I'm trying to add a new DB property to the new products box on the index page...
I have created the DB field and followed all the instructions, and I know it works because I can call my new info from my new table 'products_itemprice' in the main product info.
BUT...
I cannot seem to find out how to replace the standard PRICE displayed in the new products listing on the front page!
I have edited the file /modules/new_products.php to include the relevent DB query here:
<code>
if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
$new_products_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_itemprice, p.products_price, p.products_date_added, p.products_qty_box_status, product_is_call, products_quantity
from " . TABLE_PRODUCTS . " p
where p.products_status = 1 " . $display_limit;
} else {
$new_products_query = "select distinct p.products_id, p.products_image, p.products_itemprice, p.products_tax_class_id, p.products_date_added, p.products_qty_box_status, product_is_call, products_quantity,
p.products_price
from " . TABLE_PRODUCTS . " p
left join " . TABLE_SPECIALS . " s
on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
TABLE_CATEGORIES . " c
where p.products_id = p2c.products_id
and p2c.categories_id = c.categories_id
and c.parent_id = '" . (int)$new_products_category_id . "'
and p.products_status = 1 " . $display_limit;
</code>
I now need to replace the price lookup with my new DB field info - so I tried changing:
<code>
$products_price = zen_get_products_display_price($new_products->fields['products_id']);
</code>
with this
<code>
$products_price = $products->fields['products_itemprice'];
</code>
But obviously my SQL query is pants :(
Any help please?
-
Re: How-To: Add new Properties to your Products
First many thanks to crazy_chris. After following the instructions, I have my new fields in the products table and am able to add data to them via the admin products panel.
My problem comes when I try to display the new fields in the product_info display.
I have followed the instructions re: adding the field in main_template_vars and tpl_product_info_display.php. I have verified that my additions are correct (no errors being thrown). Yet none of the data from new fields is showing.
I have the main_template_vars in an override directory but have also tried without the override.
The tpl_product_info_display.php is in an override for my custom template.
I have gone through this thread, and some others, but am not finding any answers that explain why my sql queries are not returning data for the new fields (at least this would certainly seem to be the problem). Maybe I am overlooking something obvious.
I am using 1.3.8a
Any advice would be deeply appreciated.