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.)
Code:
$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;
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!'
Code:
$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;
3. 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.
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
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:
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.
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?
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.
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).
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
IllusionGuy
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')); ?>
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
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.
Re: How-To: Add new Properties to your Products
Quote:
Originally Posted by
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.