Hi
Is there a simple way to combine two colums
some feeds have brand names and product code in two different colum
eg brand = samsung
eg model = LE26R41BDX
i want the output to be samsung LE26R41BDX
is there a simple way to do this?
thanks
phil
I know this is something I'd love to see implemented too!
Hi Dave
yeah you got it in one, a filter to do that would be excellent - would bring more products into less pages helping the site be used for its main purpose - comparisons - and many of them
looking forward to seeing the code
ta
phil
Hi Phil / Jean-Christophe,
I think I have come up with a neat solution to this; and I have now checked it into the current distribution. The only files that have changed are as follows, so you do not need to re-install every file:
includes/admin.php
includes/filters.php
This change affects the "Text Before" and "Text After" filters. For each of these filters, you can now specify the contents of other fields in the feed by using placeholders such as %MODEL% or %FIELD4% in the text applied by the filter.
For example, if you want to create a product name from the 2 fields "BRAND" and "MODEL", you would register "BRAND" as the Product Name field, and then create a "Text After" filter, with the following as the text to apply (without the quotes, but notice the SPACE character infront of the placeholder):
" %MODEL%"
You can use as many placeholders as you like in the string. In the case of a CSV feed without a header row; the placeholders would be %FIELD1%, %FIELD2% etc. etc.
Hope this helps!
Cheers,
David.
Hi dave
Before i upload this file
remember a while ago i made ammendments to the filters
ref; http://www.pricetapestry.com/node/184
will this file being uploaded ruin other filters?
P Stone
Hi Phil,
Yes, unfortunately you will need to add the new Split filter again, and make the same modifications to admin.php as described in order to handle that situation.
I think the best way forward is to copy in the new scripts; then work through the modifications described in the other thread and apply them to the new script (it doens't look like too much).
You won't need to change any of your existing filter configurations.
Cheers,
David.
Hi Dave,
Very very good, it's working nice, I didn't find for my case a good "word" to add after the name, for that I use the productID to have something unique, and now I have all my product
Thx a lot ;)
Jean-Christophe
Hi,
I tried to combine two fields, brand + productname, with the 'text after' filter. The exact name of the (productname) field is 'Product Name' so I use %Product Name%.
The result is, for example: 'Sony %product Name%' on the website.
Do you know what could be the solution?
Thanks!
Hi Wouter,
The field replacement placeholders are case sensitive - you mentioned the field name as being "Product Name" and your example shows "product Name" (lowercase "p" in product) so that may be all it is - let me know if you're still not sure of course...
Cheers,
David.
--
PriceTapestry.com
Hello David,
Yes, I mentioned the case. I'm sure I imported it in the right way, like " %Product Name%" (without the quotes).
Thanks
Hello Wouter,
Ah, it's possible that the space is a control or other character rather than an actual space. Once solution would be to make the placeholders all lower case and only apply to letters. To try this, in your includes/filters.php look for the following code at line 10:
$text = str_replace("%".$k."%",$v,$text);
...and REPLACE with:
$k = strtolower(preg_replace('/[^A-Za-z]/e','',$k));
$text = str_replace("%".$k."%",$v,$text);
And then as your placeholder, use:
%productname%
Cheers,
David.
--
PriceTapestry.com
Hi,
Now the result is 'Htc %productname%' on the site. I'm afraid I miss a step/something. I do not have to download anything am I right? I've a recent version of PT. Would you like to take a look?
Thanks!
Hi Wouter,
That is strange, the %fieldname% placeholder support for Text Before and Text After filters has been in the distribution for a very long time but it sounds like the filter_recordPlaceholders() function is not being called.
If you like I will double check if you would like to email me your includes/filter.php and also a copy of your backup .xml file for "Filters" (go to Database Tool from /admin/, select only Filters and click backup) and I'll check it all out for you...
Cheers,
David.
--
PriceTapestry.com
Hi David,
I have found that I made a mistake. The script and the filters are working more than fine! In my case the field 'pruductname' is 'model' as I imported the feeds in this way.
Thanks anyway!
Wouter
Hi Phil,
Would a filter that lets you append another field to the current field help?
This would mean you would need to register the brand field as the "Product Name", and then use a filter to append (with a space) the contents of the field "model"?
Let me know if that would do the trick and i'll post the code for a new filter to do that. I think it would be useful in other situations also..
Cheers,
David.