I prefer to serve the product images from my own server rather than the merchants. I have downloaded the merchant images and placed them in a directory named after the merchant.
Then I use the search and replace filter to change the merchants file path to the images in the datafeed to my own file path to the images.
This works fine for merchants who keep all the product images in a single directory.
However, some merchants keep these images in several different directories like this:
http://www.isubscribe.co.uk/images/covers/uk/403/11460/large/ArtWorld2730822261.jpg
http://www.isubscribe.co.uk/images/covers/uk/266/1877/large/DigitalPhotographer17407212328.jpg
http://www.isubscribe.co.uk/images/covers/uk/27/1918/large/Icon63082310.jpg
http://www.isubscribe.co.uk/images/covers/uk/27/1977/large/GrandDesignsandIcon5120618541.jpg
Is there a filter I can apply? I tried putting this into the search part:
http://www.isubscribe.co.uk/images/covers/uk/../../large/
but it did not work.
What should I do?
Hi Tony,
This could be done with another new filter that just performs a strtolower(); but if you are not using this filter for anything else, you could simply combine it so that Explode returns a string that has been converted to lower case.
In the above code, you will see the following code near the end of the block:
return $parts[$index];
...simply change this to:
return strtolower($parts[$index]);
That should do the trick!
Cheers,
David.
Hi David,
Still looking for a solution to this John Lewis feed using explode filter. Most urls are as follows,
{link saved}
As you can see the size is at the end, if I choose "-" as the Explode Character or String: and then the Return Index: should be "-1" to extract the size? However after I import it, there seems to be no change to the feed?
Regards
Paul
Hi Paul,
It's just occurred to me that the instructions I gave in my earlier email wouldn't work by Explode'ing on a comma, as the comma is stripped from the product name by the normalise function (original version of Price Tapestry as this installation is running).
To fix this, in includes/admin.php, look for the following code at around line 158:
/* apply standard filters */
$record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]]);
...and REPLACE with:
/* apply standard filters */
$record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]],",");
The Explode filter with , as the Explode Character or String and then 0 as the Return Index should then do the trick...
Cheers,
David.
Hi David,
the mod worked, but for those with the url as below with a different separator character another solution is needed, I tried to put an additional explode filter on using "-" as the explode character and "-1" as the return index, but does that require anther mod to the admin file as that didn't work.
{link saved}
Thanks
Paul
Hi Paul,
What's the original product name in the feed from your example URL before import?
The "-" character is only being added in place of spaces in real time for the clean URL, - it's actually a SPACE in the script...
Cheers,
David.
Hi david,
can't find that specific example in the xml feed befor import, but the description is the following
141DI6219006 NVY DRPE DRS 10, so it is a space rather than a dash, can we use a space as the character and -1 as the index?
Follow this to see the product and related products page which are 3 of the same but different sizes
Cheers
Paul
Hi Paul,
Is this a different feed to John Lewis?
If you could email me your includes/filter.php from that site I'll add something that will split out all BEFORE the last space - unfortunately Explode won't do it i'm afraid as that will split the value up into each separate word...
Cheers,
David.
Hi Tony,
Here is the code for a new filter that will help you with this (taken from this thread). Add the code below to includes/filters.php.
This will give you a new filter called "Explode", which splits the input value up into sections by splitting it up on the character or string entered on the configuration page. The return value parameter then sets which of the "exploded" strings is the one returned. It is zero based, so 0 will return the first string, 1 the second and so on.
However, you can also enter a negative number to return the n'th string from the end, so in your case if you set the Explode Character or String to "/" (without the quotes), and then a return index value of "-1", the return value will be the image filename on its own!
Then, simply add "Text Before" filter (after the explode filter) to prefix this with your own image path...
/*************************************************/
/* explode */
/*************************************************/
$filter_names["explode"] = "Explode";
function filter_explodeConfigure($filter_data)
{
print "Explode Character or String:<br />";
print "<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
widget_errorGet("text");
print "<br />";
print "Return Index: (zero based)<br />";
print "<input type='text' size='3' name='index' value='".widget_safe($filter_data["index"])."' />";
widget_errorGet("index");
}
function filter_explodeValidate($filter_data)
{
if (!$filter_data["text"])
{
widget_errorSet("text","required field");
}
}
function filter_explodeExec($filter_data,$text)
{
$parts = explode($filter_data["text"],$text);
$index = intval($filter_data["index"]);
if ($index < 0)
{
$index = count($parts) + $index;
}
return $parts[$index];
}
Cheers,
David.