Forums / Setting Up Categories, Products, Attributes / How-To: Add new Properties to your Products

How-To: Add new Properties to your Products

Views: 144,144

Results 221 to 240 of 272
31 Jul 2011, 1:29 PM
#221
weljkodj avatar

weljkodj

New Zenner

Join Date:
Oct 2010
Posts:
34
Plugin Contributions:
0

How-To: Add new Properties to your Products

I've followed solution to add another product field, but in a separate table. Everything was fine unless I try to add new products via Easy Populate. However EP populates products to db but my additional table that holds custom field is not updated with new product_id. So if I go to a new product (inserted via EP) the page doesnt show any data because main query in main_template_vars.php breaks when trying to read product_id that doesnt exist in additional table.

I have ended creating trigger after insert which adds new product_id to the custom table, which is not elegant solution.

11 Aug 2011, 4:43 PM
#222
cummank avatar

cummank

New Zenner

Join Date:
Aug 2011
Posts:
2
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Hi everyone, i really interesting with this tips and I've finally finish that 8 steps. I success made 2 field and it appear on admin.

1.But when I finish add a new product, the new page appear and it says:

1054 Unknown column 'products_stock_lama' in 'field list'
in:
[insert into zen_products (products_quantity, products_type, products_model, products_price, products_date_available, products_weight, products_status, products_virtual, products_tax_class_id, manufacturers_id, products_quantity_order_min, products_quantity_order_units, products_priced_by_attribute, product_is_free, product_is_call, products_quantity_mixed, product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max, products_sort_order, products_discount_type, products_discount_type_from, products_price_sorter, products_stock_lama, products_stock_baru, products_image, products_date_added, master_categories_id) values ('0', '1', '', '0', '2011-08-12', '0', '1', '0', '0', '0', '1', '1', '0', '0', '0', '1', '0', '1', '0', '0', '0', '0', '0', '15116129', '15116129', 'aaaaddd3.jpg', now(), '6')]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

2.when i click the edit button for my product, the new page appear and :

1054 Unknown column 'p.products_stock_lama' in 'field list'
in:
[select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_virtual, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, p.products_sort_order, p.products_discount_type, p.products_discount_type_from, p.products_price_sorter, p.master_categories_id, p.products_stock_lama, p.products_stock_baru from zen_products p, zen_products_description pd where p.products_id = '6' and p.products_id = pd.products_id and pd.language_id = '1']
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

anyone, please help me . . . :cry:

16 Aug 2011, 4:34 AM
#223
spifflifkin avatar

spifflifkin

New Zenner

Join Date:
Aug 2011
Location:
Pacific NW
Posts:
28
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

I followed the instructions in the first post and was able to add several fields to my collect_info page and am able to display them on my site. No problems there.

Instead of the text entry fields on the collect_info page, I would like to use fckeditor. I got as far as getting the editor to display the correct info from the database but I can't get it to write to the database.

Does any one have any experience with this?

Thanks!

16 Aug 2011, 6:23 PM
#224
spifflifkin avatar

spifflifkin

New Zenner

Join Date:
Aug 2011
Location:
Pacific NW
Posts:
28
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Here's the code related the the previous post:

************** this is the text field that reads and writes to the database. this works *******************

		<td class="main"><?php echo Specifications; ?></td>
        
		<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '10') . ' ' . 
		
		zen_draw_input_field('products_specifications', $pInfo->products_specifications, 'size="100"', zen_set_field_length(TABLE_PRODUCTS, 'products_specifications')); ?></td>
        
	   </tr>

************** this is the fckeditor code that reads from the database, but won't update the database with any changes typed into it *******************

<tr>
        <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_SPECIFICATIONS; ?></td>

        <td colspan="2"><table border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td class="main" width="25" valign="top"><?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

            <td class="main" width="100%">

    <?php if ($_SESSION['html_editor_preference_status']=="FCKEDITOR") {

            $oFCKeditor = new FCKeditor('products_specifications[' . $languages[$i]['id'] . ']') ;

            $oFCKeditor->Value = (isset($products_specifications[$languages[$i]['id']])) ? stripslashes($products_specifications[$languages[$i]['id']]) : zen_get_products_specifications($pInfo->products_id, $languages[$i]['id']);

            $oFCKeditor->Width  = '99%' ;

            $oFCKeditor->Height = '350' ;

// $oFCKeditor->Config['ToolbarLocation'] = 'Out:xToolbar' ;

// $oFCKeditor->Create() ;

            $output = $oFCKeditor->CreateHtml() ;  echo $output;

      } else { // using HTMLAREA or just raw "source"



      echo zen_draw_textarea_field('products_specifications[' . $languages[$i]['id'] . ']', 'soft', '100%', '30', (isset($products_specifications[$languages[$i]['id']])) ? htmlspecialchars(stripslashes($products_specifications[$languages[$i]['id']]), ENT_COMPAT, CHARSET, TRUE) : htmlspecialchars(zen_get_products_specifications($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE)); //,'id="'.'products_specifications' . $languages[$i]['id'] . '"');

      } ?>

   

   </td>
16 Aug 2011, 8:30 PM
#225
spifflifkin avatar

spifflifkin

New Zenner

Join Date:
Aug 2011
Location:
Pacific NW
Posts:
28
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

One other thing. I'd like to have 5 instances of fckeditor on the collect_info page.

Thanks!

24 Aug 2011, 10:54 PM
#226
jagall avatar

jagall

Zen Follower

Join Date:
Mar 2011
Location:
Ireland
Posts:
286
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

molywerks:

Gillian -

My custom data is now running through Tabbed Products Pro, but from an old tpl_product_info_display.php file I found this line of code which shows the title in bold and the data in plain via my CSS file:

<?php if (!empty($product_info->fields['init_upc'])) echo '<tr><td class="detail-head">UPC » </td><td class="detail-copy">' . $product_info->fields['init_upc'] . '</td></tr>'; ?>

where init_upc is my custom data field, and I am 99% positive this did not show UPC » when there was no data value.

FWIW, in TPP, I have the following bit of PHP, which definitely does not show the title when there is no data value:

$fmtDOT .= (($flag_show_product_info_init_upc == 1 and !empty($init_upc)) ? '<li style="list-style:none;margin-left:-2.25em"><strong>upc</strong>  ' . $init_upc . '</li>' : '') . "\n";

In the above example, like too many bits of hard-coded style values on my site, I have not yet converted it into CSS.

Hi All,

I am now on this thread as I picked up on the above link, I have tried to implement this but while my custom fields will show on product display page using the above code, they will not behave in the same manner when using TPP, has anybody else had this, I'm spending so much time on this and just seem to be going around in circles???:wacko:

26 Aug 2011, 9:38 AM
#227
jagall avatar

jagall

Zen Follower

Join Date:
Mar 2011
Location:
Ireland
Posts:
286
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Hi All just to let ye know in case anyone comes across the same problem that I have got this sorted by using the following code allowed me to call in my custom fields for TPP:

$fmtDOT .= '<li>' .TEXT_PRODUCT_COUNT . $products_count .($product_info->fields['products_count']). "\n";
$fmtDOT .= '<li>' .TEXT_PRODUCT_UNIT_COST . $products_unit_cost .($product_info->fields['products_unit_cost']). "\n";

Sooo Happy, might have been a walk in the park for some but a mountain climbed for me!!!!:clap::clap::clap::clap::clap:

24 Oct 2011, 2:02 PM
#228
timlo avatar

timlo

New Zenner

Join Date:
Jan 2008
Posts:
20
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

I have tried it and it works ~~~

But can anyone tell me how to add those new field and show in Product listing column and sort?

18 Feb 2012, 9:28 PM
#229
4jdesigns avatar

4jdesigns

Zen Follower

Join Date:
Jul 2011
Posts:
106
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

I have created quite a few fields which works perfectly, Thanks for this.

What I would like to do is put a couple of these entered fields into my product listings page.

Would I put the *$product_info->fields['products_guarantee'] * in my *common/columnar_display *file or my templates/product_listings page or some other page?

And if so where would I need to add SELECT p.products_guarantee... part in?

Any help would be appreciated.

Jay

19 Feb 2012, 12:33 PM
#230
4jdesigns avatar

4jdesigns

Zen Follower

Join Date:
Jul 2011
Posts:
106
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Ok, so far I am think I need to add what I want in modules/product_listing.php but from what I have learnt in the past is that the modules files can be a little sensitive...

...so before I start to play around (obviously with a backup done:)) if anyone could save me a bit of time and point me in the right direction, that would greatly be appreciated.

20 Feb 2012, 8:16 PM
#231
4jdesigns avatar

4jdesigns

Zen Follower

Join Date:
Jul 2011
Posts:
106
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

So no-one knows?

Okay maybe this is going in the right direction but not to sure as its not working... so please if anyone knows what I am trying to do here and can see whats wrong, please feel free to jump in.

Here's what I have put in my includes/modules/MY_TEMPLATE/product_listing.php - (Only the bit in red, the rest is what's there.)

$lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);
        $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
	$product_info = $db->Execute("select p.products_guarantee, p.products_color,
		  			p.products_display, p.products_dimensions,
		  			p.products_energy, p.products_spin, p.products_load,
		  			p.products_frostfree, p.products_autodefrost,
		  			p.products_fastfreeze, p.products_fridgecapacity,
		  			p.products_fuel, p.products_lpgoption,
		  			p.products_hob, p.products_elements,
		  			p.products_cavities, p.products_oventype,
		  			p.products_capacityone, p.products_capacitytwo
				from " . TABLE_PRODUCTS . " p
				where p.products_status = '1'
				and   p.products_id = '" . (int)$_GET['products_id'] . "'");
	if (!empty($product_info->fields['products_guarantee'])) $lc_text .= '<b>Guarantee:<br /></b>' . ' ' . $product_info->fields['products_guarantee'];
        break;
        case 'PRODUCT_LIST_QUANTITY':
        $lc_align = 'right';
        $lc_text = $listing->fields['products_quantity'];
        break;
20 Feb 2012, 9:11 PM
#232
4jdesigns avatar

4jdesigns

Zen Follower

Join Date:
Jul 2011
Posts:
106
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Solution...

IF YOU WANT TO PLACE YOUR NEW FIELDS INTO YOUR PRODUCT LISTING.
-here's how...

  1. Open includes/modules/product_listing.php

  2. Add the code in 'Red', the 'Black' code just shows you where I placed mine 'Don't include it!'

$product_info = $db->Execute("select products_guarantee, products_color, products_dimensions
				from " . TABLE_PRODUCTS . "
				where products_status = '1'
				and   products_id = '" . (int)$listing->fields['products_id'] . "'");
	if (!empty($product_info->fields['products_guarantee'])) $lc_text .= '<div class="productListFields">' . $product_info->fields['products_guarantee'] . '</div>';
        if (!empty($product_info->fields['products_color'])) $lc_text .= '<div class="productListFields">' . $product_info->fields['products_color'] . '</div>';
        if (!empty($product_info->fields['products_dimensions'])) $lc_text .= '<div class="productListFields">' . $product_info->fields['products_dimensions'] . '</div>';
        break;
        case 'PRODUCT_LIST_QUANTITY':
        $lc_align = 'right';
        $lc_text = $listing->fields['products_quantity'];
        break;
  1. Change 'product_guarantee' 'product_color' and 'product_dimensions' to your own names / table columns you have created.

That's it!

For styling purposes I have wrapped a <div> around each output with a class (productListFields) which you can remove or rename as you please for your stylesheet.

Well I hope this is beneficial to someone...

Jay.

17 Apr 2012, 12:16 PM
#233
johnlewisdesign avatar

johnlewisdesign

New Zenner

Join Date:
Jan 2012
Location:
South West UK
Posts:
17
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

earmsby:

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.

There's a long thread here so apologies if its been said - but here's a thing - if its in a separate table then it is inaccessible using Apsona ShopAdmin as an import column. Therefore it should really be personal preference, as I now HAVE to add to the main db to get my clients old shop migrated (some fields are missing).

Great work - it saved my bacon! :flex:

3 Jun 2012, 2:06 PM
#234
gotlogos avatar

gotlogos

New Zenner

Join Date:
Nov 2010
Posts:
84
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

I have been able to do everything successfully here. When I added the input field, it does change the value in the database (I checked in myPHP). The problem I am having is when I go back into edit the product, the value that is in the database for that field is not showing what the present value is, just a blank input field. I created a varchar field...I did all of the steps modifyin the collect_info, preview_info and update_product.php files. I did not need to show this on the product listing page as it is strictly a field I want to use when I print my invoices (fyi, each product is to have its own bin number and this will print on the invoice for order pickers).

Anyone know what may be happening, any help is much appreciated and what a great thread.

20 Apr 2014, 7:04 PM
#235
vacuumwarlock avatar

vacuumwarlock

New Zenner

Join Date:
Mar 2014
Posts:
22
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Sorry if this has been asked already, but I'm not scanning thru this whole thread. What I am wondering due to the fact I don't know php or Zen Cart that well, YET, but in the examples everywhere no one ever says exactly where the sort for "colour" is even coming from. I can't just make something up if it isn't an attribute or something. So my question, is do these extra fields draw from something that was created in the products such as attributes?

21 Apr 2014, 11:20 AM
#236
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How-To: Add new Properties to your Products

Extra fields are just that, extra. You only create them when the data you want to handle does not exist anywhere else in the product. If you can handle the data properly with attributes, you don't need an extra field.

29 Jun 2014, 3:32 AM
#237
stiggybaby avatar

stiggybaby

New Zenner

Join Date:
Apr 2011
Posts:
91
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

Ok, I've read all 24 pages, and unless I overlooked a post, it seems that this modification is missing a change to the file that would be configuration>product listing

I did the mod as listed on the first post by crazy_chris. I have EP4 installed. I was able to import and export my csv text file with my extra fields.

The only thing left that I can see is to add the lines of code for the extra fields to the file/section that would add it to the configuration>product listing page in admin. Then I could assign sort order values to the extra fields and they should appear on the category and single product pages right?

If so, I need help finding that file, because I simply cannot find it (assuming I'm right).

Zen Cart 1.5.3, Database Patch Level: 1.5.3
Server OS: Linux 2.6.32, Database: MySQL 5.5.41
HTTP Server: Apache, PHP Version: 5.4.37

26 Jan 2015, 3:56 PM
#238
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

IllusionGuy:

Ok I got it to work using the following code, I hope others find this useful

<?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')); ?>

I know this was said some time ago, but I am adding a custom field to the products and it needs to be textarea.  I have tried the above but the data in the new cusotmfield is just been dropped.

Please could anyone advise what I am doing wrong?  I have set up the product field as 'text' at mySQL

Debbie Harrison
DVH Design | Web Design blog

26 Jan 2015, 11:12 PM
#239
drbyte avatar

drbyte

Sensei

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

Re: How-To: Add new Properties to your Products

Sounds like you only updated collect_info.php and not also preview_info.php and update_product.php to know to save that data or where to put it.

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

27 Jan 2015, 9:23 AM
#240
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: How-To: Add new Properties to your Products

DrByte:

Sounds like you only updated collect_info.php and not also preview_info.php and update_product.php to know to save that data or where to put it.

Dr, I followed the step by step guide religiously and updated all the pages mentioned. The setup works when its written as an input field, but when I try to set this up as a text area, it disregards the data and nothing is listed.

I have read that maybe I should set up the new field (called technical Spec) as a separate database table, similar to how product_description is set up, but I don't know freely how to achieve this.

Debbie Harrison
DVH Design | Web Design blog