One of the handiest features of Miva Merchant 5+ is the inclusion of built in custom product fields. These fields can be used for an enormous variety of purposes, from adding product specific data (author, manufacturer, dimensions, materials, etc) to acting as a boolean-style test variable for setting up conditional displays of information.
Unfortunately, custom product fields are not quite as intuitive as they are handy. So here are some tips for working with them.
First, how to set them up?
- In the Miva Merchant admin, in the left hand menu, click Utilities (the word, not the plus sign). Check the box beside Custom Fields and click Update.
- You will now see some new tabs across the top of the configuration settings. Click Custom Product Fields.
- Click Add. Enter a Code (see Tips & Tricks below) and a Name and click Update.
Second, you have custom product fields, now what?
To add custom field data to your products, there are two methods you can use.
- In Quick Find, select Products. In the search box, type a search term for your product and click Go.
- In the row for your chosen product, click Edit.
- In the tabs above the input boxes, you’ll see Custom Fields. Click that tab, and you’ll see your new custom field displayed, with a text box beside it.
- Enter your text (see Tips & Tricks below) and click Update.
If you have a lot of products for which you need to add custom fields, the above method isn’t very practical. Instead, you may wish to use the built in import functionality. The easiest way to do this is to start by setting up a single product with some content for your custom fields.
- Start by following the steps above for a single product.
- Then, expand Utilities (this time click on the plus sign).
- Expand Export Data and click Export Products to Flat File.
- In the custom field sections, check the box(es) beside your new custom field(s).
- Select your other settings, and click Export.
- Your export file will be in your mivadata directory, typically above the root on your server. Contact your host if you are not certain how to locate this file.
- Import the file into Excel or another suitable program, and enter the data for your custom field(s).
- Save the file as tab delimited (this has its own issues, which I’ll address in another blog post) and import to Miva Merchant.
Third, you’ve got data…now how to get it to show up on the site?
So, you have your content saved in your new custom product fields, and now you’d like to display it somewhere on a product page. Here’s where the tricky part comes in.
Custom product fields are available by default on the PROD (Product), CTGY (Category), SRCH (Search) and PLST (Product List) pages. Other pages may require the Tool Kit from Emporium Plus to access custom fields.
In order to display a custom product field on your product page, you must enable it.
- To start, go to Pages> PROD and click Edit.
- Click the Tab for Product Display Layout.
- If you are in Advanced Mode, you will need to switch to Point and Click mode. Look for the link near the bottom of the screen.
- In Point and Click mode, you will see a section for Custom Fields, with your new custom field, and a checkbox to activate it.
- Check the box, and click Update.
Important: If you’ve made any modifications to your template, activating the custom fields will reset the template back to its original state.
- In order to both recall your changes and insert your new custom fields, you will need to switch to Advanced Mode by clicking the link at the bottom of the screen.
- From the version history, select your most recent version prior to this update, and click recall. Then click update.
- Now to insert your custom product field, you will need to paste the code below into your template where you would like it to appear. You may of course modify the code as needed to suit your purposes, and do be sure to replace YourCode with your actual custom field code.
<mvt:if expr="NOT ISNULL l.settings:product:customfield_values:customfields:YourCode"> &mvt:customfield_names:customfields:YourCode;: <b>&mvt:product:customfield_values:customfields:YourCode;</b><br> </mvt:if>
Finally, the Promised Tips and Tricks
There are some sneaky things about custom product fields that I’ve found out the hard way. If you’ve followed the steps above, and the custom fields still aren’t showing as intended, here are some things to check.
- Make sure the custom product field has data. Check that the product on the page you’re looking at actually has some content in its custom field.
- Make sure you enabled the custom field properly in the relevant template using the steps above (I know…but humor me and double check anyway).
- If you edited the page template to restore your customizations, make sure you correctly entered your custom field code in the store morph tokens.
- Check the length of the custom field code. It has been my experience (completely unverified and anecdotal though it may be) that custom field codes that are longer than 10 or so characters do not work as expected. The code seems to get truncated, which means that the store morph token doesn’t match it, and therefore it doesn’t display.
- Check for hyphens in your custom field code. Sometimes they work ok, but other times they create problems. If at all possible, keep your custom field codes short, and use alpha and numerical characters only.
One final word on custom fields. They have a character limit, set in the database, of 254 characters. If you’re using MySQL, you can edit the s01_CFM_ProdValues table and set the type for the Value field to tinytext or tinyblob depending on your needs. If you’re not experienced in working with MySQL, ask your host for help, or hire a professional to do this for you.