You are here:  » update the fields in import

Support Forum



update the fields in import

Submitted by konpapdo on Thu, 2011-03-31 10:34 in

Hey david,

so my problem is the following.
i added a field called Sub category in registration, i imput the Sub category field manually in the database for every product.. i want that imput of that field to stay the same after importing the same product, is that possible?
the thing is that the product id changes every time i import products so apparently with every import the old products are deleted and the new are added ...how can i just update the products that already exist in the db...
if its not complicated can you help me?

cheers,
kostas

Submitted by support on Thu, 2011-03-31 10:47

Hello kostas,

Seeing as you have to enter the information somewhere, rather than having to keep editing the database directly, why not maintain a subcategory.php file, which can be read during the import script and will set the subcategory field for you.

I assume you have called the field "subcategory". If not, just change as required.

First, create a new file called

includes/subcategory.php

<?php
  $subcategory 
= array();
  
$subcategory["Product Name 1"] = "Green Widgets";
  
$subcategory["Product Name 2"] = "Blue Widgets";
  
$subcategory["Product Name 3"] = "Red Widgets";
  
// etc.
?>

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

    if (!$importRecord["merchant"]) return;

...and REPLACE with:

    if (!$importRecord["merchant"]) return;
    if (!is_array($subcategory)) require_once("../includes/subcategory.php");
    $importRecord["subcategory"] = $subcategory[$importRecord["name"];

This will set subcategory from the file at every import.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by konpapdo on Thu, 2011-03-31 11:32

thnx david i will do that..