You are here:  » 1 feed - multi merchants


1 feed - multi merchants

Submitted by searley on Tue, 2006-04-04 12:28 in

Is there a way to deal with i feed containing multiple merchants?

the feed contain a field Merchant name, but can not think of the best way to deal with this

Submitted by PaulH on Fri, 2006-04-14 09:30

This would be a good feature, Commission Junction put all thier feeds in to single file. My 5 large merchants = 250mb xml file. Something to split the large file into sperate files for each merchant would be ideal, i don't wish to import all of them.

Submitted by support on Fri, 2006-04-14 09:34

Hi Paul,

Thanks for the info - I wasn't aware that CJ bundled all the merchants that you subscribe to into a single feed.

Creating a feed split utility should be reasonably straight forward providing that you have shell access to the server; and can setup a directory with write access to the PHP process.

This would have to be run as a script executed from the command line as it may take several minutes for Magic Parser to autodetect on a 250MB XML file; and then to process all records and write out the split files will take another few minutes.

I'll get thinking about the best way to do it...

Submitted by searley on Fri, 2006-04-14 10:38

I managed a little work around, which works fine, except the merchant do not show on the merchant index

i made the 'extras' mod here: http://www.pricetapestry.com/node/175

Import the feed into a single merchant say CJ and put the merchant name in extras field

i modified the product page so it shows merchant 'CJ MerchantName' i geuss it would be possible using code to strip the 'CJ' and show just the merchant name

as i say that was just a temp solution whilst i tested feeds from someone, worked fine for me

i would have looked at splitting the xml fiole somehow, but the feed contained an undefined number of merchants and it was not possible to select by merchant, so i could have ended up with thousands of merchants to register

Submitted by support on Fri, 2006-04-14 11:25

Here's something that might work in the mean time...

250MB is a big feed; but if you're able to register the feed with a known format string (so that auto-detection is not required), one option would be to add a new filter that does the opposite of "Drop Record"; i.e. include the record only if the selected field equals a certain value.

Then, you simply make copy the feed (or make symbolic links on a Linux server) once for each merchant, then register the copies and configure the filter differently for each one.

Here's the code for an opposite to the "Drop Record" filter - just paste into includes/filters.php:

<?php
  
/*************************************************/
  /* dropRecordIfNot                               */
  /*************************************************/
  
$filter_names["dropRecordIfNot"] = "Drop Record (If Not)";
  function 
filter_dropRecordIfNotConfigure($filter_data)
  {
    print 
"Drop record if field DOES NOT contain text:<br />";
    print 
"<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
    
widget_errorGet("text");
  }
  function 
filter_dropRecordIfNotValidate($filter_data)
  {
  }
  function 
filter_dropRecordIfNotExec($filter_data,$text)
  {
    global 
$filter_dropRecordFlag;
    if(
$filter_dropRecordFlag)
    {
      return 
$text;
    }
    else
    {
      
$filter_dropRecordFlag = ($filter_data["text"] !== $text);
    }
    return 
$text;
  }
?>

To create symbolic links on Linux rather than a copy; use the "ln -s" command, something like this:

$cd feeds
$ln -s original.xml merchanta.xml
$ln -s original.xml merchantb.xml

In this example, if you had the multi-merchant file "original.xml", you would then have 2 symbolic links to the same file but with the "virutal" filenames "merchanta.xml" and "merchantb.xml", which you can then register separately and use the new Drop Record (If Not) filter to only import products for the required merchant.

Submitted by PriceSpin on Mon, 2006-04-17 18:17

I get this when adding the code to filters.php

Parse error: parse error, unexpected '}' in /home/pricespi/public_html/includes/filter.php on line 178

Submitted by support on Mon, 2006-04-17 18:19

ooops... there was a missing semi-colon on this line:

$filter_dropRecordFlag = ($filter_data["text"] !== $text);

I've fixed it in the code above - that should help...

Submitted by PriceSpin on Mon, 2006-04-17 19:01

Thanks David,
one question, how can I tell it to drop if not merchant name?

Filter only gives me the following choices:
Product Name
Product Description
Image URL
Buy URL

but none of these has any relation to the merchant...

Robert

Submitted by support on Mon, 2006-04-17 19:24

Yes - you're absolutely right. I'm not having a good weekend here! I'll figure out a way to pull in the merchant name in this scenario so that this technique will work. It isn't one of the registered fields so it isn't currently possible to register a filter against it... Sorry about that...

Submitted by PriceSpin on Tue, 2006-04-18 16:38

Just wondering if you had any luck with this so far? Got about 20 feeds in one csv file so would be handy...

Cheers

Robert
www.pricespin.co.uk

Submitted by support on Wed, 2006-04-19 04:53

Hi Robert,

As it is a CSV feed that you need to split there is a reasonably easy way to do this from the command line using the "grep" command, and by piping the output to a new file.

The basic syntax would be:

grep "MerchantName" <filename> > MerchantName.csv

For example:

grep "John Lewis" bigfeed.csv > JohnLewis.csv

To test it out first without doing the redirection into a new file; just experiment with grep on its own:

grep "John Lewis" bigfeed.csv

The quotes around MerchantName are essential if the merchant name contains spaces. I don't know why I didn't think of mentioning this the other day; but it should work fine...!
Cheers,
David.

Submitted by PriceSpin on Thu, 2006-04-20 18:01

Hello David,
I can download them individually but when I need to download 25-30 feeds or one large one it would be handy to be able to import one large feed and have it distinguise it via a field 'Merchant' if you know what I mean...

Robert
www.pricespin.co.uk

Submitted by jmrwv on Mon, 2006-09-18 05:57

Does dropRecordIfNot only drop the record if the field is not *exactly* equal to the one entered? In other words, if my product categories look like this:

/Products/webstore/house/bed_bath/bathroom/towels/sets
/Products/webstore/women/accessories/small_goods/wallets

can I get it to drop all records where "house" is not contained anywhere within the category field?

When I attempt to apply this filter in this way, I just get a blank screen on the trial import.

Submitted by jmrwv on Mon, 2006-09-18 06:59

I actually ended up using your selectiveImport function and reversed the arguments for strpos.

I changed this:
$filter_dropRecordFlag = (strpos($filter_data["text"],$text) === FALSE);

to this:
$filter_dropRecordFlag = (strpos($text,$filter_data["text"]) === FALSE);

I kept trying to use the function as it was written, but after looking at the strpos function on php.net, I decided I needed to switch the arguments. I'm not sure I understand how it worked before, but this seems to do ok for me.

Problem solved!

Submitted by xlot on Thu, 2007-01-18 08:09

Hi guys,

Just curious, most feeds have a "Merchant" column within them.
Would'nt it be easier to change the process of importing feeds so that when you register a feed you have a "Merchant" and "user_Merchant" as you do category and brand? Then you could name some feeds and select from the dropdown on others...... I know that would help me out quite a bit....

Mark Bellavanc

Submitted by multiz on Thu, 2007-01-18 18:58

Hello Mark,

I haven't done what you're talking about, but you'd probably have to start by modifying "admin/feeds_register_step2.php" & "includes/admin.php" to get that to work.

Michael

ZZPrices - Electronics Price Comparison Shopping

Submitted by wdekreij on Sun, 2007-01-21 23:09

What if I want to have the products that have "a" or "b" in a certain field, but the rest has to be dropped?

When I input two filters, one for "a" and one for "b", there will be (logically) no products (because the fields do not contain an "A" and a "B", only 1 letter.

How can I fix this, so that I can input A and B, and that PT keeps all the products witn an A or B, and drops the rest?

Submitted by support on Mon, 2007-01-22 08:59

Hi,

What you need is a new filter that drops the record if the value is not in given list. Here's a new "Drop Record Unless" filter that should fit the bill:

<?php
  
/*************************************************/
  /* dropRecordUnless                              */
  /*************************************************/
  
$filter_names["dropRecordUnless"] = "Drop Record Unless";
  function 
filter_dropRecordUnlessConfigure($filter_data)
  {
    print 
"Drop record unless field contains text: (comma separated list)<br />";
    print 
"<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
    
widget_errorGet("text");
  }
  function 
filter_dropRecordUnlessValidate($filter_data)
  {
  }
  function 
filter_dropRecordUnlessExec($filter_data,$text)
  {
    global 
$filter_dropRecordFlag;
    if(
$filter_dropRecordFlag)
    {
      return 
$text;
    }
    
$parts explode(",",$filter_data["text"]);
    
$filter_dropRecordFlag = (!isset($parts[$text]));
    return 
$text;
  }
?>

To use it, enter the items that you want to allow in a comma separated list, for example "A,B". The filter will then drop any record where the selected field is not A or B.

Hope this helps,
Cheers,
David.

Submitted by wdekreij on Mon, 2007-01-22 14:58

Hmm.. No matter what I put into the field, when I import the feed there will be 0 products imported, so something's wrong here?

Does the script work at your PT install?

Submitted by support on Mon, 2007-01-22 15:16

Hi,

Sorry - the $parts variable needs to be converted into an associative array rather than the numeric array returned by explode(). Here's the corrected version:

<?php
  
/*************************************************/
  /* dropRecordUnless                              */
  /*************************************************/
  
$filter_names["dropRecordUnless"] = "Drop Record Unless";
  function 
filter_dropRecordUnlessConfigure($filter_data)
  {
    print 
"Drop record unless field contains text: (comma separated list)<br />";
    print 
"<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
    
widget_errorGet("text");
  }
  function 
filter_dropRecordUnlessValidate($filter_data)
  {
  }
  function 
filter_dropRecordUnlessExec($filter_data,$text)
  {
    global 
$filter_dropRecordFlag;
    if(
$filter_dropRecordFlag)
    {
      return 
$text;
    }
    
$parts explode(",",$filter_data["text"]);
    foreach(
$parts as $k=>$v$parts2[$v] = 1;
    
$filter_dropRecordFlag = (!isset($parts2[$text]));
    return 
$text;
  }
?>

This works for an exact match on the selected field, just tested on my development server....

Cheers,
David.

Submitted by Alastair on Tue, 2008-03-11 17:42

Mark said:

Hi guys,

Just curious, most feeds have a "Merchant" column within them.
Would'nt it be easier to change the process of importing feeds so that when you register a feed you have a "Merchant" and "user_Merchant" as you do category and brand? Then you could name some feeds and select from the dropdown on others...... I know that would help me out quite a bit....

Mark Bellavanc
_____________________________________-

Hello Mark (and any others)

The method described in Mark Bellavanc's post sounds like a nice straightforward way to read in a single file containing data from multiple merchants (identified in the file). Has anyone done it? (i.e has anyone got any code I could crib?!) Thanks

Alastair

Submitted by support on Tue, 2008-03-11 17:44

Hi Alastair,

I have made this mod before for another user; but it's quite a complex change.

I have, however, thought of a slightly easier way to do the same thing, so I'll check this out and then document the changes through the forum...

Cheers,
David.

Submitted by Alastair on Tue, 2008-03-11 17:48

That's great David

I'm sure lots of people will benefit.

Submitted by Alastair on Sun, 2008-03-23 20:09

Hey David

Forgot to wish you Happy Easter!

Submitted by support on Sun, 2008-03-23 20:11

Thanks - Happy Easter to all too!

Cheers,
David.

Submitted by Alastair on Thu, 2008-04-17 18:07

Hello David

I wondered if you had had any further thoughts on how to load in a single feed containing data from multiple merchants? I would find this particularly useful as I find I have to manipulate data quite a lot to "normalise" the product name. I do this in Excel and I find that I have to repeat the process for each merchant's feed. For those merchants in a network such as Affiliate Window, it would be really useful to be able to just manipulate a single file in Excel and then upload with PT taking the Merchant names from a data filed in the feed.

Submitted by support on Fri, 2008-04-18 08:49

Hi Alastair,

I'll drop you an email with the multi-merchant patch...

Cheers,
David.

Submitted by paul30 on Thu, 2008-09-11 19:38

Hey David, just got and installed the script, but I am having the same problem described in this thread: CJ feed containing multiple merchants in a single TXT file...

Will the "multi-merchant patch" help with this issue? and if so could I also receive it?

Thanks a lot.

Submitted by support on Fri, 2008-09-12 08:25

Hi,

Multi Merchant patched sent by email as requested...

Cheers,
David.

Submitted by marklapsley on Thu, 2009-04-02 09:23

hi would it be posible to have the Multi Merchant patch as well

Many thnaks

Mark

Submitted by RattyDAVE on Thu, 2009-05-14 10:20

Could I have this patch too for http://www.360voice.co.uk

Thank you.

Submitted by support on Thu, 2009-05-14 10:33

On it's way...

Cheers,
David.

Submitted by mediadream on Thu, 2009-05-14 17:53

I would also like to have it!

Thanks David!

Internetsidorna Hitta företag

Submitted by support on Thu, 2009-05-14 17:57

On way...

Cheers,
David.

Submitted by webie on Thu, 2009-05-28 20:06

Hi Dave,

Would it be possible if can also have this patch to deal with CJ Feeds

Kind Regards

Darren