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

How-To: Add new Properties to your Products

Views: 144,143

Results 241 to 260 of 272
27 Jan 2015, 5:21 PM
#241
drbyte avatar

drbyte

Sensei

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

How-To: Add new Properties to your Products

dharrison:

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.
Does it actually store the data fine, but just doesn't re-display it on the Edit screen again?

.
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, 5:25 PM
#242
drbyte avatar

drbyte

Sensei

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

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

The syntax for zen_draw_textarea_field() is different than for zen_draw_input_field()

zen_draw_input_field($fieldname, $defaultValue)

vs

zen_draw_textarea_field($fieldname, 'soft', '100%', '5', $defaultValue)

where 'soft' should be left as 'soft'
'100%' is the width setting
'5' is the number of rows the field should display

So, you can't just change "input" to "textarea" unless you also change the parameters list.

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

28 Jan 2015, 10:33 AM
#243
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

Hi Doctor

I made the following change:

<?php echo zen_draw_textarea_field('products_tinfo[' . $languages[$i]['id'] . ']', 'soft', '100%', '10', $pInfo->products_tinfo, zen_set_field_length(TABLE_PRODUCTS, 'products_tinfo')); ?>

and adjusted the products_tinfo to the products table as 'text' and 'null' which for input was 'varchar (32)'

Apologies for the confusion. I did post all this info on a new thread which quite rightly, got removed (I was unsure if anyone would respond to a thread that was several years old). :blush:

Debbie Harrison
DVH Design | Web Design blog

28 Jan 2015, 10:38 AM
#244
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:

Does it actually store the data fine, but just doesn't re-display it on the Edit screen again?

It doesn't re-display on the edit screen, the website or the MySQL record. It just completely disregards it.

Debbie Harrison
DVH Design | Web Design blog

28 Jan 2015, 2:04 PM
#245
drbyte avatar

drbyte

Sensei

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

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

dharrison:

<?php echo zen_draw_textarea_field('products_tinfo[' . $languages[$i]['id'] . ']', 'soft', '100%', '10', $pInfo->products_tinfo, zen_set_field_length(TABLE_PRODUCTS, 'products_tinfo')); ?>
Are you intending to treat this field as language-specific? 
If not, then remove the [ and ] and the stuff in between.

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

29 Jan 2015, 9:24 AM
#246
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

It works!!! That was the issue.

Thankyou so much. :smile:

Debbie Harrison
DVH Design | Web Design blog

28 Aug 2017, 3:21 PM
#247
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

I know this is over 2 years old but here is my situation.

I'm running the latest Zen Cart and using the Responsive Sheffield Blue template.

I have successfully imported 10,000 products into my database of my new site and have it laid out well thanks to this community. I have used EP4 to import the data and have set my options in EP4 to include a user defined product field and I have imported the data I want to that field, that it working fine.

What I would like is to include this data (if possible) in the details tab like this ...

Attachment 17254

Obviously not in red LOL. After the : I would like it to get the data from the new field in the products table, the extra field is ink_ml and as said before already has the data relevant to the product.

I have followed this thread that was done back in 2015 by crazy_chris but ended up with an error on the product page so I`m not sure if anything has changed since that was written. Has anyone done a step by step guide to achieve this ??

Many thanks in advance to any help ;)

28 Aug 2017, 3:42 PM
#248
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

MCS_Computers:

I know this is over 2 years old but here is my situation.

I'm running the latest Zen Cart and using the Responsive Sheffield Blue template.

I have successfully imported 10,000 products into my database of my new site and have it laid out well thanks to this community. I have used EP4 to import the data and have set my options in EP4 to include a user defined product field and I have imported the data I want to that field, that it working fine.

What I would like is to include this data (if possible) in the details tab like this ...

Attachment 17254

Obviously not in red LOL. After the : I would like it to get the data from the new field in the products table, the extra field is ink_ml and as said before already has the data relevant to the product.

I have followed this thread that was done back in 2015 by crazy_chris but ended up with an error on the product page so I`m not sure if anything has changed since that was written. Has anyone done a step by step guide to achieve this ??

Many thanks in advance to any help ;)
What is the error?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Aug 2017, 10:14 PM
#249
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

When the product was clicked all I got was a white screen with the word error at the top.

I went and checked I had put the code on correctly and made sure there was no spaces after the code, everything seemed to be in order, my first reaction was that maybe one of the files had been taken over by the theme.

28 Aug 2017, 10:41 PM
#250
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

MCS_Computers:

When the product was clicked all I got was a white screen with the word error at the top.

I went and checked I had put the code on correctly and made sure there was no spaces after the code, everything seemed to be in order, my first reaction was that maybe one of the files had been taken over by the theme.
Thought this had been provided previously in another thread related to a different issue, but follow the below instructions when presented with a blank screen or partial blank screen. Even if the issue is a little different than that, you can expect to find assistance in following it: http://www.zen-cart.com/content.php?124-blank-page

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Aug 2017, 10:44 PM
#251
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

Hey MC

I'm in the process of starting again. I have followed steps 1 to 6 and there are no errors. About to finish with 7 and 8 so we will see what happens before looking at the link :)

28 Aug 2017, 10:57 PM
#252
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

Ok, step 7 which reads ...

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

At this point when I click a product I get the outer page displaying but the centre of the page where the product and info site I ts just white with the words WARNING: An Error occurred, please refresh the page and try again.

Could you clarify, the field in my database is called** ink_ml** and the file I`m asked to edit looks like this ...

$sql = "select p.products_id, pd.products_name,
pd.products_description, p.products_model,
p.products_quantity, p.products_image,
pd.products_url, p.products_price,
p.products_tax_class_id, p.products_date_added,
p.products_date_available, p.manufacturers_id, p.products_quantity,
p.products_weight, p.products_priced_by_attribute, p.product_is_free,
p.products_qty_box_status,
p.products_quantity_order_max,
p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_status = '1'
and p.products_id = '" . (int)$_GET['products_id'] . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

I have tried variations of the instruction and get the error each time ??

28 Aug 2017, 11:02 PM
#253
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

And how does it look with your edit when you follow the provided instruction?

Again also, the link provided would guide you to error logs where the issue is likely described.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Aug 2017, 11:12 PM
#254
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

As soon as I edit the main_template_vars.php I refresh my store, click on a product and then get the error. I will follow the link you provided to see if it can shed some light, just wanted to check I had put the code in right as its a little confusing instruction 7 to a newbie :(

28 Aug 2017, 11:26 PM
#255
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

Okay, after the edit I look at the log file as advised by the link you sent and this was the log, way above my head if I`m being honest ...

[29-Aug-2017 00:21:29 Europe/London] Request URI: /index.php?main_page=product_info&cPath=1_7&products_id=77556, IP address: 86.164.234.122
#1 trigger_error() called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/classes/db/mysql/query_factory.php:167]
#2 queryFactory->show_error() called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/classes/db/mysql/query_factory.php:139]
#3 queryFactory->set_error() called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/classes/db/mysql/query_factory.php:266]
#4 queryFactory->Execute() called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/modules/pages/product_info/main_template_vars.php:58]
#5 require(/home/mcsbrid/public_html/ukinks.co.uk/includes/modules/pages/product_info/main_template_vars.php) called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php:251]
#6 require(/home/mcsbrid/public_html/ukinks.co.uk/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php) called at [/home/mcsbrid/public_html/ukinks.co.uk/index.php:97]

[29-Aug-2017 00:21:29 Europe/London] PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.ink_ml,
from products p, products_description pd
where ' at line 11 :: select p.products_id, pd.products_name,
pd.products_description, p.products_model,
p.products_quantity, p.products_image,
pd.products_url, p.products_price,
p.products_tax_class_id, p.products_date_added,
p.products_date_available, p.manufacturers_id, p.products_quantity,
p.products_weight, p.products_priced_by_attribute, p.product_is_free,
p.products_qty_box_status,
p.products_quantity_order_max,
p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter
p.ink_ml,
from products p, products_description pd
where p.products_status = '1'
and p.products_id = '77556'
and pd.products_id = p.products_id
and pd.language_id = '1' ==> (as called by) /home/mcsbrid/public_html/ukinks.co.uk/includes/modules/pages/product_info/main_template_vars.php on line 58 <== in /home/mcsbrid/public_html/ukinks.co.uk/includes/classes/db/mysql/query_factory.php on line 167

28 Aug 2017, 11:52 PM
#256
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

MCS_Computers:

Okay, after the edit I look at the log file as advised by the link you sent and this was the log, way above my head if I`m being honest ...

[29-Aug-2017 00:21:29 Europe/London] Request URI: /index.php?main_page=product_info&cPath=1_7&products_id=77556, IP address: 86.164.234.122
#1 trigger_error() called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/classes/db/mysql/query_factory.php:167]
#2 queryFactory->show_error() called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/classes/db/mysql/query_factory.php:139]
#3 queryFactory->set_error() called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/classes/db/mysql/query_factory.php:266]
#4 queryFactory->Execute() called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/modules/pages/product_info/main_template_vars.php:58]
#5 require(/home/mcsbrid/public_html/ukinks.co.uk/includes/modules/pages/product_info/main_template_vars.php) called at [/home/mcsbrid/public_html/ukinks.co.uk/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php:251]
#6 require(/home/mcsbrid/public_html/ukinks.co.uk/includes/templates/responsive_sheffield_blue/common/tpl_main_page.php) called at [/home/mcsbrid/public_html/ukinks.co.uk/index.php:97]

[29-Aug-2017 00:21:29 Europe/London] PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.ink_ml,
from products p, products_description pd
where ' at line 11 :: select p.products_id, pd.products_name,
pd.products_description, p.products_model,
p.products_quantity, p.products_image,
pd.products_url, p.products_price,
p.products_tax_class_id, p.products_date_added,
p.products_date_available, p.manufacturers_id, p.products_quantity,
p.products_weight, p.products_priced_by_attribute, p.product_is_free,
p.products_qty_box_status,
p.products_quantity_order_max,
p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter
p.ink_ml,
from products p, products_description pd
where p.products_status = '1'
and p.products_id = '77556'
and pd.products_id = p.products_id
and pd.language_id = '1' ==> (as called by) /home/mcsbrid/public_html/ukinks.co.uk/includes/modules/pages/product_info/main_template_vars.php on line 58 <== in /home/mcsbrid/public_html/ukinks.co.uk/includes/classes/db/mysql/query_factory.php on line 167
Remove the comma after p.ink_ml and put one before it.

The comma there represents that another field is to follow. There isn't one, so the database engine isn't sure what to do and errors...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

29 Aug 2017, 12:30 AM
#257
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

Without sounding thick are you saying to do this ..

,p.ink_ml

Or are you saying put a comma at the end of the previous line like so ..

p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter,

So the coding should be as follows ..

$sql = "select p.products_id, pd.products_name,
pd.products_description, p.products_model,
p.products_quantity, p.products_image,
pd.products_url, p.products_price,
p.products_tax_class_id, p.products_date_added,
p.products_date_available, p.manufacturers_id, p.products_quantity,
p.products_weight, p.products_priced_by_attribute, p.product_is_free,
p.products_qty_box_status,
p.products_quantity_order_max,
p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter
,p.ink_ml
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_status = '1'
and p.products_id = '" . (int)$_GET['products_id'] . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

Or

$sql = "select p.products_id, pd.products_name,
pd.products_description, p.products_model,
p.products_quantity, p.products_image,
pd.products_url, p.products_price,
p.products_tax_class_id, p.products_date_added,
p.products_date_available, p.manufacturers_id, p.products_quantity,
p.products_weight, p.products_priced_by_attribute, p.product_is_free,
p.products_qty_box_status,
p.products_quantity_order_max,
p.products_discount_type, p.products_discount_type_from, p.products_sort_order, p.products_price_sorter,
p.ink_ml
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_status = '1'
and p.products_id = '" . (int)$_GET['products_id'] . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

29 Aug 2017, 12:35 AM
#258
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Not thick. It's just clear that the construct of a select statement is unfamiliar.

Technically it doesn't matter which way; however, when the next upgrade is performed and if you use comparison software, it would be clearer what the change/difference is/was if all new information is on the same line rather than split among two of them. Meaning, I would suggest your first representation:
, p.ink_ml

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

29 Aug 2017, 12:49 AM
#259
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

MC yet again a great help, doing the change has stopped the error, final part is this, I have placed the final code here in step 7 but the data is not showing.

<!--bof Product details list --> <?php if ( (($flag_show_product_info_model == 1 and $products_model != '') or ($flag_show_product_info_weight == 1 and $products_weight !=0) or ($flag_show_product_info_quantity == 1) or ($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name))) ) { ?> <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 $product_info->fields['ink_ml']; ?> ** <?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> <br class="clearBoth" /> <?php } ?>

Have I placed it in the correct area or is it something more sinister ?

29 Aug 2017, 12:57 AM
#260
mcs_computers avatar

mcs_computers

Zen Follower

Join Date:
Aug 2013
Location:
Bridlington
Posts:
151
Plugin Contributions:
0

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

Yet the field is there in admin when I edit a product