You are here:  » Additional custom fields in Product Mapping


Additional custom fields in Product Mapping

Submitted by support on Tue, 2015-10-06 11:45 in

Hi everyone,

If you have added custom fields to your site, overrides by Product Mapping can be included in the same way as Custom Category, Brand etc. as follows. Continuing the example of a custom `keywords` field first use a dbmod.php script to create an entry for the new field on the `productsmap` table:

dbmod.php

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

Next, edit admin/productsmap_configure.php and look for the following code at line 62:

  image_url = '".database_safe($_POST["image_url"])."'

...and REPLACE with:

  image_url = '".database_safe($_POST["image_url"])."',
  keywords = '".database_safe($_POST["keywords"])."'

And then look for the following code at line 95:

  widget_textBox("Custom Image URL","image_url",FALSE,$productmap["image_url"],"",6);

...and REPLACE with:

  widget_textBox("Custom Image URL","image_url",FALSE,$productmap["image_url"],"",6);
  widget_textBox("Custom Keywords","keywords",FALSE,$productmap["keywords"],"",6);

And to apply the custom values at import time, edit includes/admin.php look for the following code at line 305:

  if ($admin_importProductMappingsOverrides[$importRecord["name"]]["image_url"]) $importRecord["image_url"] = $admin_importProductMappingsOverrides[$importRecord["name"]]["image_url"];

...and REPLACE with:

  if ($admin_importProductMappingsOverrides[$importRecord["name"]]["image_url"]) $importRecord["image_url"] = $admin_importProductMappingsOverrides[$importRecord["name"]]["image_url"];
  if ($admin_importProductMappingsOverrides[$importRecord["name"]]["keywords"]) $importRecord["keywords"] = $admin_importProductMappingsOverrides[$importRecord["name"]]["keywords"];

And then the following code at line 642:

  $admin_importProductMappingsOverrides[$productsmap["name"]]["image_url"] = (($productsmap["image_url"])?$productsmap["image_url"]:"");

...and REPLACE with:

  $admin_importProductMappingsOverrides[$productsmap["name"]]["image_url"] = (($productsmap["image_url"])?$productsmap["image_url"]:"");
  $admin_importProductMappingsOverrides[$productsmap["name"]]["keywords"] = (($productsmap["keywords"])?$productsmap["keywords"]:"");

Cheers!
David
--
PriceTapestry.com