You are here:  » Created new field that can be mapped like EAN

Support Forum



Created new field that can be mapped like EAN

Submitted by koen on Sat, 2013-04-20 13:58 in

Hello,

I'm using EAN code now for 80% of my feeds, which works great. Problem is that the products of the other feeds still have to be mapped manually.
I've figured out a solution which (I think) can help, but I don't know where to start implementing it..
My product table look like this, two records for same product:

Merchant: Merchant ABC
Name: 6177 lego basic stenen (650 stuks)
Brand: Lego
EAN: 5702014518032

AND:
Merchant: Merchant DEF
Name: LEGO basisstenen deluxe 6177
Brand: LEGO
EAN:

I've created a new field, "kbkey", which I would like to be filled on importing. When Importing I've got some steps to undertake:
1. Extract the number (min 4 digits) from the productname (using "preg_match_all" I guess) ("6177")
2. Convert the brandname to lowercase ("lego)
3. Combine brand & number to an key ("lego6177")
4. Save key in field "kbkey" ("lego6177").

The last step will be running a copy of eanmap.php, doing the same type of mapping like ean, but than on the kbkey field.

Questions I have:
Is it possible to implement this option? What will happen to products that (also) have been mapped on EAN? And, when positive, can you give me directions on where how to implement this?

Thanks in advance, cheers,

Koen

Submitted by support on Mon, 2013-04-22 08:53

Hi Koen,

The extraction should be relatively straight forward, and then what about having creating the kbkey field, IF ean is empty, then set ean=kbkey. Then, following a full import you only need run the uidmap.php script to auto-product map by ean.

To try this, in includes/admin.php, look for the following comment at line 315:

  /* niche mode */

...and then insert the following code above that line (it just makes a convenient marker for adding new code that isn't specifically a modification of existing code).

  preg_match('/([0-9]{4,})/',$importRecord["name"],$matches);
  if (isset($matches[0]) && $matches[0])
  {
    $importRecord["kbkey"] = strtolower($importRecord["brand"]).$matches[0];
    if (!$importRecord["ean"])
    {
      $importRecord["ean"] = $importRecord["kbkey"];
    }
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com