You are here:  » Create new, pre-populated field for every product


Create new, pre-populated field for every product

Submitted by ccgale on Fri, 2017-05-12 13:19 in

Hi

Wondering it would be possible to create an extra field for every product which I could use a fixed variable to populate it? I have set up custom extra fields and I have them mapping using the scan and set, so, for example, if the product name contains 'red' it will add red as a value to my custom field. All is good there.

What I'm trying to do, in addition, is add the value of 'store' to every product - by store I don't mean the merchant selling it, I literally mean the word store. I can create an extra custom field easily enough, however, I cannot find a way to set it so that all imported items would then have the word store as an attribute value. I thought I would be able to do it via the mapping but it seems you can only choose a drop down populator for each field, rather than be able to enter fixed text.

If this even makes sense, is it possible to do what I'm attempting?

many thanks

Submitted by support on Sat, 2017-05-13 10:42

Hi,

It would be no problem at all to add a custom field to the products table with a database configured default value, for example to add the field `custom1` with the default value "Store", use the following dbmod.php script instead of the usual script for adding custom fields (and no need for `custom1` to be defined in $config_fieldSet)

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            ADD `custom1` VARCHAR(255) NOT NULL default 'Store'"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ccgale on Mon, 2017-05-15 11:05

Perfect. Thank you