You are here:  » Drop record if 2 database fields are equal

Support Forum



Drop record if 2 database fields are equal

Submitted by redspark on Thu, 2009-05-07 21:29 in

Hi David,

For a discount site i have add an extra field in the database called old_price. So now i have 2 prices. The old and the current. With those prices i can also show people how much they can save, by subtracting the new price from the old.

You can see an example on http://www.productkorting.nl

The problem is that i have a lot of products which do not have a discount. I want to drop those records. I have tried it with the filter Drop Record If Not RegExp -> if old_price equals price. Do you know if it is possible?

ps. is there also a way to get the savings in the database itself? if that would be possible i could do some filtering with it.

regards,

B.

Submitted by support on Fri, 2009-05-08 08:13

Hi,

This could be easily done in the import record handler in includes/admin.php. Look for the following code starting at line 152:

    /* copy record into global space for use by filters */
    $filter_record = $record;

...and on the next line, add the following code:

    if ($record[$admin_importFeed["field_old_price"]] == $record[$admin_importFeed["field_price"]]) return;

...and that will ignore the product if the prices are the same...

Cheers,
David.

Submitted by redspark on Sat, 2009-05-09 12:04

Thanks David,

I have changed price in field_price and then it worked

regards,

B.

Submitted by support on Sat, 2009-05-09 12:29

Ta! I correct the code above for future reference...

Cheers,
David.