You are here:  » regex allow only digits and characters brands import

Support Forum



regex allow only digits and characters brands import

Submitted by webie on Sat, 2009-07-18 14:14 in

Hi Dave,

I wonder if you can help with this one checking product database the brands field is very poor due to merchant feeds not following the same feed layout can we not create regex to only allow combintion of digits and letters.

so my idea is the reject any brand name which contains only digits?

Kind Regards

Darren

Submitted by support on Mon, 2009-07-20 08:05

Hi Darren,

It would be straight forward to plumb this into the import record handler. The brand field is currently "normalised" (made safe) by the following code beginning at line 175 of includes/admin.php:

    if ($admin_importFeed["field_brand"])
    {
      $record[$admin_importFeed["field_brand"]] = tapestry_normalise($record[$admin_importFeed["field_brand"]]);
    }

...so you could REPLACE that with;

    if ($admin_importFeed["field_brand"])
    {
      $record[$admin_importFeed["field_brand"]] = tapestry_normalise($record[$admin_importFeed["field_brand"]]);
      if (is_numeric($record[$admin_importFeed["field_brand"]]))
      {
        $record[$admin_importFeed["field_brand"]] = "";
      }
    }

Cheers,
David.