You are here:  » RegExp Product Mapping - Custom Description


RegExp Product Mapping - Custom Description

Submitted by ChrisNBC on Mon, 2016-07-04 15:27 in

Hi David,

Hope you had a good weekend..

I wondered if you could possibly suggest a way I could add a 'custom description' field to RegExp Product Mappings? I searched the forum but couldn't spot anything on the subject.

Thanks in advance.

Best regards
Chris

Submitted by support on Mon, 2016-07-04 15:50

Hello Chris,

I didn't include custom description override in Product Mapping by RegExp since it can be used to map multiple products in a range within a single rule which would not necessarily have the same description but if required it can be added easily.

Firstly, run the following dbmod.php script to create the new `description` field on the productsmap_regexp table;

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."productsmap_regexp`
            ADD `description` TEXT NOT NULL"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

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

  `category` = '".database_safe($_POST["category"])."',

...and REPLACE with;

  `category` = '".database_safe($_POST["category"])."',
  `description` = '".database_safe($_POST["description"])."',

(I've described this mod as following the `category` field since I recall documenting changes here following the `brand` field with regards to additional triggers, but essentially, the `description` field just needs adding to the $sql construction, watch out for commas...)

Then look for the following code around line 276:

  widget_textBox("Custom Brand","brand",FALSE,$productmap["brand"],"",12);

...and REPLACE with:

  widget_textBox("Custom Brand","brand",FALSE,$productmap["brand"],"",12);
  widget_textArea("Custom Description","description",FALSE,$productmap["description"],100,12);

Then in includes/admin.php, look for the following code at line 342:

if ($admin_importProductMappingsRegExpOverrides[$v["name"]]["brand"]) $importRecord["brand"] = $admin_importProductMappingsRegExpOverrides[$v["name"]]["brand"];

...and REPLACE with:

  if ($admin_importProductMappingsRegExpOverrides[$v["name"]]["brand"]) $importRecord["brand"] = $admin_importProductMappingsRegExpOverrides[$v["name"]]["brand"];
  if ($admin_importProductMappingsRegExpOverrides[$v["name"]]["description"]) $importRecord["description"] = $admin_importProductMappingsRegExpOverrides[$v["name"]]["description"];

And finally the following code at line 662:

  $admin_importProductMappingsRegExpOverrides[$productsmap_regexp["name"]]["brand"] = (($productsmap_regexp["brand"])?$productsmap_regexp["brand"]:"");

...and REPLACE with:

  $admin_importProductMappingsRegExpOverrides[$productsmap_regexp["name"]]["brand"] = (($productsmap_regexp["brand"])?$productsmap_regexp["brand"]:"");
  $admin_importProductMappingsRegExpOverrides[$productsmap_regexp["name"]]["description"] = (($productsmap_regexp["description"])?$productsmap_regexp["description"]:"");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Mon, 2016-07-04 16:21

Hi David,

Thanks for the quick response. I think there is something missing from the last instruction re line 662? Would be grateful if you could clarify if it's a replacement or just addition.

Thanks in advance.

Best regards
Chris

Submitted by support on Mon, 2016-07-04 16:42

Ooops - corrected above...!

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Mon, 2016-07-04 17:02

Thanks David,

I've made all the changes above (and double checked everything) but no custom description box is visible? I wonder if you could suggest a possible cause?

Best regards
Chris

Submitted by support on Mon, 2016-07-04 17:17

Hi Chris,

The text box to enter the custom description should appear by virtue of this line added to admin/productsmap_regexp_configure.php

   widget_textArea("Custom Description","description",FALSE,$productmap["description"],100,12);

...but I know you've been making a number of changes over the last couple of weeks so if you'd like to email me the modified admin/productsmap_regexp_configure.php I'll check it out for you..

Cheers,
David.
--
PriceTapestry.com

Submitted by smartprice24 on Fri, 2017-12-15 14:38

Hi David.

I have this new file.

{code saved}

After Save setting, the values not save in DBtable

{code saved}

I forget something

Thanks for support

Giuseppe

Submitted by support on Fri, 2017-12-15 14:51

Hello Giuseppe,

Try your modified script with database debug mode enabled by changing line 6 in config.advanced.php as follows;

  $config_databaseDebugMode = TRUE;

If that doesn't reveal anything, in the case of admin scripts depending on server configuration you may not be able to capture any error as the page reloads, so in this case edit includes/database.php and look for the following code at line 56:

      print "[".$sql."][".mysqli_error($link)."]";

...and REPLACE with:

      print "[".$sql."][".mysqli_error($link)."]";exit();

The script will then exit should any database error occur. If you're not sure from what is displayed where the problem lies, or if there is no difference of course, post the debug output and I'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by smartprice24 on Fri, 2017-12-15 15:43

Thank David. Solved!

I have omitted comma in the end line...

`regexp` = '".database_safe($_POST["regexp"])."',
`product_name` = '".database_safe($_POST["product_name"])."',
`description` = '".database_safe($_POST["description"])."',
`category` = '".database_safe($_POST["category"])."' < , omitted etc
`brand` = '".database_safe($_POST["brand"])."' < , omitted etc
`meta_title` = '".database_safe($_POST["meta_title"])."',
`meta_description` = '".database_safe($_POST["meta_description"])."'

Many thanks David!

Ciao. Giuseppe