You are here:  » RSS Data feed with no price field.


RSS Data feed with no price field.

Submitted by dealstockpile on Tue, 2012-07-03 03:16 in

I have been trying to automate a data feed that has the price listed in the title field mixed with other content such as screen size or model number. I tried to put title field in price field. The screen size or other values become part of the price. The price seems to always be at end. I was thinking maybe something could be done using a filter. Here is some examples:

BenQ MX511 XGA DLP Projector - $643.49

$511643.49
More Information(This is the result in price listing)

Epson EX3210 Portable Business 3LCD Projector - $399.99

$32103399.99
More Information

Please help.

Thanks, Brandon

Submitted by support on Tue, 2012-07-03 08:17

Hi Brandon,

Provided that the price is _always_ the last "word" in the title then yes, you can extract it easily using an Explode filter, with -1 as the Return Index.

Register the field as you have been experimenting with using the feed's product name field as the Price field. After registration and trial import, click Filters alongside the feed, and add a new Explode filter to the Price field, with -1 as the Return Index, which returns the last value in the exploded array - e.g. $643.49 - which will then be converted into decimal as normal by the import record handler and should do the trick...

Cheers,
David.
--
PriceTapestry.com

Submitted by dealstockpile on Tue, 2012-07-03 08:37

Hello,

Thank you very much, everything is starting to work.

Best wishes, Brandon Coakley

Submitted by Mark Hennessy on Wed, 2013-07-31 09:43

Afternoon David,

I am also having this issue. The price is stuck inside the description field, which is then coming up as $0 when imported.

The feed is;

{link saved}

The price I'm looking to import it always the value after "Special Price: $"

Any help would be greatly appreciated!

Submitted by support on Wed, 2013-07-31 12:15

Hi Mark,

This would be best done with a new filter to extract the required data using a regular expression and PHP's preg_match() function. Add the following code to your includes/filter.php:

  /*************************************************/
  /* pregMatch */
  /*************************************************/
  $filter_names["pregMatch"] = "preg Match";
  function filter_pregMatchConfigure($filter_data)
  {
    print "RegExp:<br />";
    print "<input type='text' size='40' name='regexp' value='".widget_safe($filter_data["regexp"])."' />";
    widget_errorGet("regexp");
    print "<br />";
    print "Return Index:<br />";
    print "<input type='text' size='40' name='index' value='".widget_safe($filter_data["index"])."' />";
    widget_errorGet("index");
  }
  function filter_pregMatchValidate($filter_data)
  {
    if (!$filter_data["regexp"])
    {
      widget_errorSet("regexp","required field");
    }
    if (!$filter_data["index"])
    {
      widget_errorSet("index","required field");
    }
  }
  function filter_pregMatchExec($filter_data,$text)
  {
    preg_match("/".$filter_data["regexp"]."/",$text,$matches);
    return (isset($matches[intval($filter_data["index"])])?$matches[intval($filter_data["index"])]:"");
  }

Register the feed using DESCRIPTION as the Price field, and then add a new preg Match filter to the Price field. On the configuration page for the filter, in the Regular Expression box enter:

<span(.*)product\-price(.*)£(.*)<\/span>

...and a Return Index of 3 (because you want the value of the third bracketed sub-expression)

Cheers,
David.
--
PriceTapestry.com

Submitted by Mark Hennessy on Mon, 2013-08-05 08:59

Hi David, I unfortunately could not get this working. I added the filter and Return Index as suggested however it simply imports 0 products.

I also changed the £ sign to $ in the filter as this is what the feed was displaying products prices in.

Any fresh ideas?!

Submitted by support on Mon, 2013-08-05 09:40

Hi Mark,

Please could you let me know the feed URL again and I'll re-check the filter configuration - it's possible that the $ is entity encoded for example so that would be to be included in the expression...

Thanks,
David.
--
PriceTapestry.com

Submitted by Mark Hennessy on Mon, 2013-08-05 10:08

Thanks again!

{link saved}

Submitted by support on Mon, 2013-08-05 11:16

Hi Mark,

Seems to be using an unencoded euro character now, so expression would be:

<span(.*)product\-price(.*)€(.*)<\/span>

...I believe your installation has currency conversion in place so that would have to be applied to this feed if showing prices in dollars...

Cheers,
David.
--
PriceTapestry.com

Submitted by senaite on Thu, 2014-03-20 23:26

Hi David,
How can I import the price from this RSS feed?

{link saved}

Is there any way to import both Normally $Price and Now $Price? I have both retailprice and price fields in my database.

If too complicated, just using the price in the title is good enough.

Thank you

Submitted by support on Fri, 2014-03-21 09:29

Hello senaite,

After adding the above "preg Match" filter code to your includes/filter.php, register this feed as normal and on Feed Registration Step 2, map the DESCRIPTION field to your Price and Retail Price fields.

Then, from the /admin/ home page, click Filters alongside the feed, and add a new "preg Match" filter to the Price field. On the configuration page for the filter, enter a RegExp value of:

Now ([0-9\.]*)\b

...and a Return Index value of 1.

Do the same for the Retail Price field, using a RegExp value of:

Normally ([0-9\.]*)\b

...and again a Return Index value of 1.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by senaite on Fri, 2014-03-21 14:07

Hi David,
It works perfectly.

Thank you.