Contributions
Extra Product Fields 1.0
Our store has happily used the Product Extra Fields 2.0j contribution until someone asked why a search wasn't working when looking for two values, each contained in a different extra field for the product. Upon examining the search code I suddenly realized that it would be impossible to do a simple search on more than one field since only one field at a time could be linked to a product. Searching more than one extra field would require code that is much more complicated than I wanted to attempt writing. I thus decided that writing a completely new contribution would be easier.
Extra Product Fields creates its new fields in the products_descriptions database file which makes searching multiple fields easier, especially when searching using multiple terms that may be divided among several fields.
This contribution is completely multi-language compatible. Unlike Product Extra Fields which allowed a field to only be either for one language or for all languages and used the same field label for all languages, Extra Product Fields allows a field to apply to any number of languages and stores a separate label for each language so you can translate the label as appropriate.
Field entry during product maintenance can be either as standard text, or selected from a list of drop down values that you define after creating the field, and can be different for each field. The drop down values are set separately for each language so they can be appropriate to the language. You can set the maximum size for each standard text field individually anywhere from 1 character up to 255 and change the size later if needed. As with Product Extra Fields, fields that are left blank during product entry are not displayed in the catalog.
Other features include:
A Sort Order to determine the order in which fields are displayed.
Advanced Search control to determine whether or not the catalog user can search on a field individually when using Avanced Search. This search control applies to each field separately so you can make some fields searchable and some not.
Product Listing control to determine whether or not the contents of a field get displayed in the product listings underneath the product name. Again this applies to each field individually so this is not an all fields or none choice as it is with Product Extra Fields.
META Keyword control to determine whether or not the value of a field will be used in a META Keyword tag on the product information page.
Options for for fields that are defined to use a list of values are:
Restrict Product Listings which allows users to restrict the results of a product listing in index.php. It operates similar to the way osCommerce works when you view a category containing products from multiple manufacturers, or a manufacturer with products in multiple categories.
Show Chain of Parent Values: Much as categories can contain other categories, this contribution allows values in the drop down lists to contain other values. For instance, if you created a drop down list field for Product Type and one of the values for that field was Movies then you could create values under Movies of VHS, DVD and BluRay. If a product then had the value set to DVD, with Show Chain enabled the value would display as Movies | DVD. Otherwise the value would display as just DVD.
Expand All / Collapse All
I had to make some small changes to install instrution 11A for product_info.php so that extra fields with an image that are displayed as an image with caption will be displayed properly in the browser.
The complete package is attached but only install instruction 11A has changed.
Extra Product Fields has been updated to allow a new permanent Product Type field to select which extra fields are available for entry during product editing. Types can have nested sub-types and extra fields can be restricted to any or all product types and will automatically be available for any sub-type for the types to which they are available.
New configuration variables control how (or if) the Product Type is displayed in the catalog and whether it can be directly searched (it will appear in the new Advanced Quick Search box if it can) or used to filter the product listing.
The extra field listing filter code has been rewritten to be intelligent so that, just as with the existing osCommerce Category/Manufacturer filter, the filters will only display if more than one value for the filtering field exists in the product listing being browsed and only the values that are used in that listing will be shown in the drop down menu.
Minor bug fix to the upgrade_pef_to_epf.php file. If you are not converting or if you have already converted you do NOT need this version. Please note that this is a complete install for osCommerce RC2a or earlier. The version developed by Mr. Toth for osCommerce 2.3 has been moved to http://addons.oscommerce.com/info/7810 and that is open for anyone to make changes.
I will be working on an updated version for this version of the contribution to use a new Product Type field to limit extra fields that can be used for certain products in place of the current category limited fields. This is being done to accomodate an upgrade to osCommerce 3 where new products do not have an initial category to start with but are assigned to categories during product editing.
Gergely Tóth provided me with a version of Extra Product Fields adapted for the new version 2.3 osCommerce core which I am passing along here. Since I don't use the 2.3 core myself I'm afraid I can't answer any questions about this version of the contribution so you would need to contact Mr. Toth about any problems with this version. I'm just posting it here since I know others will find it useful.
Small bugfix in the SQL in the full install file.
Complete installation enclosed
Just added a note to the update instructions for those who want to completely hide fields from product listings of categories to which they don't apply when they are set to display in the product listings and one or more products in the not applicable category has data for that field.
Complete install is attached.
I had someone point out that I had forgotten to include code to hide the restricting field dropdown at the top of the product listing if it did not apply to the category being browsed in index.php when using a list type extra field that is set to be used to restrict the product listing.
The complete contribution is enclosed. If you have already installed version 2.3 then you only need to follow the new instruction 4 in the upgrade 2.24 to 2.3 instruction file.
Since I had a request for the feature and noticed that it is used by Product Extra Fields 2.1 I have upgraded this contribution to allow an extra product field to be available only for products that exist in certain categories. Since products can exist in multiple categories the contribution checks all categories containing the product being edited to see if it is one of the categories for which the extra field is available. If none match then the field is hidden from view so that data can't be entered into the field for the product. By default extra fields apply to all categories. If the extra field is available for a category it is also automatically available for every subcategory found underneath that category no matter have far down it is nested.
The complete contribution is enclosed. For new installations the install instructions have been updated for the new feature. Upgrade instructions are included for those upgrading from an earlier version of Extra Product Fields. For those converting from the Product Extra Fields contribution the conversion program has been updated to accomodate the version 2.1 feature that applies fields to specific categories. Extra fields created from older versions of Product Extra Fields will be set as available to all categories.
No change to the contribution itself but after I had someone comment about data getting truncated when converting from the Product Extra Fields contribution I decided that I needed to rework the conversion program.
Now as the program converts each Product Extra Field to the new Extra Product Field it will check to see what is the maximum length of any data stored for that field. If it is more than 255 characters then it will create a textarea type extra field otherwise it will create a standard text field (varchar) that is just long enough to hold the longest data currently stored with a minimum length of 15 characters. This will prevent data loss for anyone converting over who had changed the Product Extra Field value field from the orignal type of varchar(64).
No added functionality, all I have done is correct the <script language="javascript"> tags to the proper <script type="text/javascript"> in the admin extra_fields.php and extra_values.php files.
Complete install is enclosed.
This is a bug fix for advanced search that corrects the inability to search for quoted phrases caused by slash characters that are automatically added to quote characters in $HTTP_GET_VARS.
The complete contribution is enclosed. The main instruction file has been updated with the fix and a bugfix instruction file is included for those who already have the contribution installed and just need to update. Note that this fixes a bug in osCommerce as well as with this contribution.
Bug fix on extra_fields.php where it was requiring an entry relating only to text fields when a list type field was being created.
Added an install instruction for the admin/languages.php file to handle cases where a language is added or deleted after extra fields have been defined.
Complete contribution is enclosed.
I discovered that I failed to include code to copy product extra field values when doing a product duplicate copy (Copy Method: Duplicate Product) when using Copy To in categories.php. I've updated the instruction files to account for this now. The complete install package is enclosed.
For those who have already installed version 2.21 all you need to do to fix the problem with product duplication is the following:
In admin/categories.php find somewhere around line 460 under case 'copy_to_confirm' in the part underneath elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') the following section of code:
$description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
while ($description = tep_db_fetch_array($description_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
}
and REPLACE it with the following:
// description copy modified to work with Extra Product Fields
$description_query = tep_db_query("select * from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
while ($description = tep_db_fetch_array($description_query)) {
$description['products_id'] = $dup_products_id;
$description['products_viewed'] = 0;
tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $description);
}
// end Extra Product Fields
The only change here is a correction to the install instructions for a first time install. If you already have version 2.x running correctly you do not need this update. I'd accidentally left display code for version 1 in part of install instruction 11a and have corrected it now with the proper 2.x code.
The complete contribution is attached.
When I updated our admin side version of the tep_image function to make use of the Calculate Image Size configuration variable as is done on the catalog side I suddenly discovered a problem with the PHP getimagesize function not being able to get the size of the image which creates a problem if you have the Image Required configuration variable set to false like we do. The extra field images suddenly did not display on the admin side.
If you are currently using version 2.0-2.2 the fix is simple, replace your current admin/extra_values.php with the corrected file here and then open your admin side general.php file and find where you have defined the function tep_get_extra_field_list_value. In both places inside the function where you see:
tep_image(DIR_WS_CATALOG_IMAGES
change it to:
tep_image(HTTP_CATALOG_SERVER . DIR_WS_CATALOG_IMAGES
Adding the name of the web server where the image is found allows the PHP getimagesize function to find the file and calculate the image size.
The complete install with instructions updated to counter this problem is included here.
I had a request to allow fields to be hidden from the catalog but shown during product entry. This capability made too much sense to not add it.
The complete contribution is enclosed with extremely simple upgrade instructions for those updating from 2.0 or 2.1.
This is a bugfix version. I changed the method of doing linked fields in the middle of writing the contribution and failed to adjust the code in the extra_fields.php administration file to the new method. You will get an error if you attempt to unlink fields or if you try to delete a field that is linked to another field. This version fixes the problem.
A complete version of the contribution is attached. If you have already installed version 2.0 you only need to replace the admin/extra_fields.php file with the corrected version contained here.
I've had requests for several additional features and this is the result. All of the features of 1.3 are included plus the following new features:
Value list fields can now have optional attached thumbnail images (note that this is not intended to replace any of the extra product image contributions).
You can choose to select from value lists using either radio buttons or a drop down.
You can create value list fields that allow you to select multiple values for a product using checkboxes.
You can create text area type text fields.
That takes care of the requests. To complement these requests I added the following features:
Since you can have thumbnail images in the value lists you can select to display the values on the product_info page as text only, image only or as image with a text caption underneath.
To go with the multiple select value lists you can set exclusions that prevent some values from being selected if another value is selected. You can also link a multiple select list field to a single select list field and then create values in the multiple select list that require a certain value to be selected from the single select list before they can be selected.
To go with the text area fields I have included a commented out line so that if you have installed the TinyMCE HTML editor for use with the Product Description field you can uncomment the line and make TinyMCE available for any text area field that you create.
With version 1.3 you can now search list type fields for keywords when using advanced search on product descriptions. Thanks to Hernan Bartoletti for figuring out the key to adding this to the search. If you have installed an earlier version then you only need to perform step 9b of the install instructions.
The complete install is attached but you only need to perform instruction 9b if you are upgrading from version 1.2.
Had a person point our an error in instruction 10a) of the install where you are installing into catalog/product_info.php.
Where it read
if (tep_not_null($product_info[$e['field']])) { // only display if information is set for product
it should actually read
$mt = ($e['uses_list'] ? ($product_info[$e['field']] == 0) : !tep_not_null($product_info[$e['field']]));
if (!$mt) { // only display if information is set for product
A different check for emptiness is required for list type extra fields versus text type fields. If you have already installed this contribution you need to make this change.
Complete contribution is attached but only step 10a) of the instructions has been changed.
Added Extra Product Field search functionality to the osCommerce Quick Search info box. Only drop down type extra fields marked as searchable will be listed. If you set the Quick Search In Descriptions to true then text type extra fields can be searched as well.
Complete package is enclosed.
To upgrade from 1.12 simply copy the search.php file to the appropriate place and (if you don't already use the Quick Search In Descriptions contribution) execute the following SQL query using a tool such as phpMyAdmin:
INSERT INTO `configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `date_added`, `set_function`) VALUES ('QuickSearch searches in description', 'QUICKSEARCH_IN_DESCRIPTION', 'true', 'If set to TRUE the customer can quick search in descriptions otherwise the search is limited to the product name', 1, 113, now(), 'tep_cfg_select_option(array('true', 'false'),');
I discovered a problem in advanced search with extra text fields. When using advanced search on any extra field while leaving any extra text field entry empty the search would fail to find anything even though at least one product should match. The problem was that the generated sql search contained code like (extra_value1 like %%) for each empty extra text field when it should have had nothing written in it at all.
To fix the problem if you already have the contribution installed open advanced_search_result.php and find around line 333 the line that reads
if (isset($epf_value_keywords) && (sizeof($epf_value_keywords) > 0)) {
Change it to read as follows:
if (($value != '') && isset($epf_value_keywords) && (sizeof($epf_value_keywords) > 0)) {
The complete package is attached with corrected installation instructions for those who haven't used this contribution before.
Bugfix for editing extra fields. When editing information for a drop down field the field was getting converted to a varchar(64) in the products_description database file. Also had a person say new fields were showing up blank in catalog when they shouldn't have been displayed at all so added 'default null' when creating a new text field to try and solve the problem. Complete package is attached but only the admin/extra_fields.php file has changed.
This is a simple bug fix for an error in the extra_values.php file. The complete package is attached but only the admin/extra_values.php file has changed. If you have already installed version 1.1 you only need to replace the one file.
After some questions from other users who were having problems with version 1.0 I discovered that the method I had used for some of the buttons was incompatible with Internet Explorer (or at least version 8). Clicking on the buttons wouldn't do anything. After some checking I discovered that I had to create submit buttons inside a small form (containing only the button) to get them to work in Internet Explorer. All such buttons have been corrected in this version and now they work properly with Internet Explorer as well as the Safari and Firefox browsers I had previously used for testing.
The complete packge is enclosed but those who have already installed the earlier version of the contribution need only replace the admin/extra_fields.php and admin/extra_values.php files.
I had someone ask about an error generated by this contribution and found that I had accidentally mixed my MSRP contribution into the instructions for this contribution. The complete package is attached here but only the install instructions have changed. The only change is that a request for p.products_msrp has been removed from three SQL queries to avoid problems for those who copy and paste from the instructions. Those who have already installed the MSRP contribution may be better off using the instructions as previously posted.
Our store has happily used the Product Extra Fields 2.0j contribution until someone asked why a search wasn't working when looking for two values, each contained in a different extra field for the product. Upon examining the search code I suddenly realized that it would be impossible to do a simple search on more than one field since only one field at a time could be linked to a product. Searching more than one extra field would require code that is much more complicated than I wanted to attempt writing. I thus decided that writing a completely new contribution would be easier.
Extra Product Fields creates its new fields in the products_descriptions database file which makes searching multiple fields easier, especially when searching using multiple terms that may be divided among several fields.
This contribution is completely multi-language compatible. Unlike Product Extra Fields which allowed a field to only be either for one language or for all languages and used the same field label for all languages, Extra Product Fields allows a field to apply to any number of languages and stores a separate label for each language so you can translate the label as appropriate.
Field entry during product maintenance can be either as standard text, or selected from a list of drop down values that you define after creating the field, and can be different for each field. The drop down values are set separately for each language so they can be appropriate to the language. You can set the maximum size for each standard text field individually anywhere from 1 character up to 255 and change the size later if needed. As with Product Extra Fields, fields that are left blank during product entry are not displayed in the catalog.
Other features include:
A Sort Order to determine the order in which fields are displayed.
Advanced Search control to determine whether or not the catalog user can search on a field individually when using Avanced Search. This search control applies to each field separately so you can make some fields searchable and some not.
Product Listing control to determine whether or not the contents of a field get displayed in the product listings underneath the product name. Again this applies to each field individually so this is not an all fields or none choice as it is with Product Extra Fields.
META Keyword control to determine whether or not the value of a field will be used in a META Keyword tag on the product information page.
Options for for fields that are defined to use a list of values are:
Restrict Product Listings which allows users to restrict the results of a product listing in index.php. It operates similar to the way osCommerce works when you view a category containing products from multiple manufacturers, or a manufacturer with products in multiple categories.
Show Chain of Parent Values: Much as categories can contain other categories, this contribution allows values in the drop down lists to contain other values. For instance, if you created a drop down list field for Product Type and one of the values for that field was Movies then you could create values under Movies of VHS, DVD and BluRay. If a product then had the value set to DVD, with Show Chain enabled the value would display as Movies | DVD. Otherwise the value would display as just DVD.
Note: Contributions are used at own risk.