Support forum login

©2006-2008 IAAI Software

Contact Us

Indexed Fields

Submitted by nikomou on Sat, 2006-06-10 13:26.

Hey,

I'd like to index more fields (without using the extras option)..
Currently the fields that are indexed are:

Product Name
Product Description
Image URL
Buy URL
Price

(optional fields)
Category
Brand

I would like to index the following fields:

Product Name

Product Description
Large Image URL
Small Image URL
Monthly Line Rental
Tariff
Contract Length
Handset Cost

(optional fields)
Category
Product Make
Free Gift
Free Txts
Free Mins

I would like all the fields to be shown in the table to easily compare all the deals...

Is this possible? Thanks in advance.

Submitted by dmorison on Sun, 2006-06-11 08:22.

Hi,

Ultimately, what you are trying to do is quite a way outside the scope of the Price Tapestry script i'm afraid.

You could use Price Tapestry as a starting point, and then extend the database to include any new fields that you want to display; and then create associated support code in order to register and import the new fields. Modifications would be required in:

* database
- products table, add any new fields (eg `foo`), I would suggest VARCHAR(255)
- feeds table, add the registration field (eg `field_foo`) for each new field

* includes/admin.php
- modify admin_register() to register the new fields
- modify admin__importRecordHandler to import the new fields

* admin/feeds_register.php
- modify script to allow registration of new fields

In all of these cases, the stategy would be to copy the existing code in place for, as an example, the "Image URL" field.

Then, having completed the admin side of things you would need to create new front end scripts to display all the items you wish to provide comparison on side by side having selected from the products table.

Hope this helps - but please don't underestimate the work involved - it really is quite a long way from what Price Tapestry was designed to do.

Cheers!
David.

Submitted by nikomou on Sun, 2006-06-25 20:51.

Thanks David..

I've added 3 new fields to the mySQL table:
(products)
tariff
linerental
contractlength

(feed)
field_tariff
field_linerental
field_contractlength

Dont think i've edited the includes/admin.php or the admin/feeds_register.php pages correctly, could you please send me the appropriate amendments?

Also, how would i go about to show the content in the table?

Submitted by dmorison on Mon, 2006-06-26 10:29.

To add the field "Tariff"...

Changes required in admin/feeds_register_step2.php:

Approx line 63 (to call the register function with the new field):

<?php
admin_register
($filename,$format,$_POST["merchant"],$_POST["fieldName"], (isset($_POST["fieldDescription"])?$_POST["fieldDescription"]:"")  , (isset($_POST["fieldImageURL"])?$_POST["fieldImageURL"]:"") ,$_POST["fieldBuyURL"],$_POST["fieldPrice"],$_POST["fieldCategory"],$_POST["userCategory"],$_POST["fieldBrand"],$_POST["userBrand"],$_POST["fieldTariff"]);
?>

Approx line 163 (to create the field on the form):

<?php
  field
("Tariff","fieldTariff");
?>

Changes required in includes/admin.php:

Approx line 3 (to add the new field to the parameter list of the register function):

<?php
function admin_register($filename,$format,$merchant,$fieldName,$fieldDescription,$fieldImageURL,$fieldBuyURL,$fieldPrice,$fieldCategory,$userCategory,$fieldBrand,$userBrand,$fieldTariff)
?>

...and then lower down in admin_register() modify the SQL:

<?php
    $sql 
sprintf("INSERT INTO `".$config_databaseTablePrefix."feeds` SET
                    filename='%s',
                    registered='%s',
                    format='%s',
                    merchant='%s',
                    field_name='%s',
                    field_description='%s',
                    field_image_url='%s',
                    field_buy_url='%s',
                    field_price='%s',
                    field_category='%s',
                    user_category='%s',
                    field_brand='%s',
                    user_brand='%s',
                    field_tariff='%s'
                    "
,
                    
database_safe($filename),
                    
time(),
                    
database_safe($format),
                    
database_safe(tapestry_normalise(ucwords($merchant),'\.')),
                    
database_safe($fieldName),
                    
database_safe($fieldDescription),
                    
database_safe($fieldImageURL),
                    
database_safe($fieldBuyURL),
                    
database_safe($fieldPrice),
                    
database_safe($fieldCategory),
                    
database_safe(tapestry_normalise($userCategory)),
                    
database_safe($fieldBrand),
                    
database_safe(tapestry_normalise($userBrand)),
                    
database_safe($fieldTariff)
                    );
?>

And finally within admin__importRecordHandler($record):

<?php
  $tariff 
$record[$admin_importFeed["field_tariff"]];
  
$sql sprintf("INSERT INTO `".$config_databaseTablePrefix."products` SET
                    merchant='%s',
                    name='%s',
                    description='%s',
                    image_url='%s',
                    buy_url='%s',
                    price='%s',
                    search_name='%s',
                    category='%s',
                    brand='%s',
                    dupe_hash='%s',
                    tariff='%s'
                    "
,
                    
database_safe($admin_importFeed["merchant"]),
                    
database_safe($record[$admin_importFeed["field_name"]]),
                    
database_safe(isset($record[$admin_importFeed["field_description"]])?$record[$admin_importFeed["field_description"]]:""),
                    
database_safe(isset($record[$admin_importFeed["field_image_url"]])?$record[$admin_importFeed["field_image_url"]]:""),
                    
database_safe($record[$admin_importFeed["field_buy_url"]]),
                    
database_safe($record[$admin_importFeed["field_price"]]),
                    
database_safe($searchName),
                    
database_safe($category),
                    
database_safe($brand),
                    
$dupe_hash,
                    
database_safe($tariff)
                    );
?>

That should get the new field into the database. To use it; whenever the script has selected products the new field will be in the $product array with the key "tariff", for example:

<?php
  
print $product["tariff"];
?>

For example, within html/product.php:

  <?php if ($mainProduct["description"]): ?>
    <p><?php print $mainProduct["description"]; ?></p>
  <?php endif; ?>
  <?php if ($mainProduct["tariff"]): ?>
    <p>Tariff: <?php print $mainProduct["tariff"]; ?></p>
  <?php endif; ?>

Hope this helps!

Submitted by nikomou on Tue, 2006-06-27 17:19.

Cheers for that David.

But for some reason, it shows the field name (Field8) on the products page instead of what is actually in field 8.

Submitted by dmorison on Tue, 2006-06-27 18:07.

That could be down to some missing apostrophes somewhere down the line. To start with, can you post the lines that you have modified within the products HTML page and we'll take it from there...

Cheers,
David.

Submitted by nikomou on Tue, 2006-06-27 19:48.

I am pretty sure its not the product.php page, as i checked the mySQL table and FIELD8 is written in all of the products under the tariff field.

I fixed the problem.. i used:

<?php
 database_safe
($record[$admin_importFeed["field_tariff"]])
?>

instead of:

<?php
 database_safe
($tariff)
?>

Cheers David...

Submitted by nikomou on Sun, 2006-07-09 09:43.

Hi,

How would i go about using the filters on the new fields i now have?

Cheers,
Nick

Submitted by dmorison on Sun, 2006-07-09 11:52.

Hi,

You'll need to make changes in:

admin/feeds_filters.php
admin/feeds_filters_configure.php

Each of those scripts has a section that populates an array that is used to construct the field select box; where each line looks like this:

if ($feed["field_name"]) $fields[$feed["field_name"]] = "Product Name (".$feed["field_name"].")";

You would need to add a line like this for each of your new fields; for example:

if ($feed["field_tariff"]) $fields[$feed["field_tariff"]] = "Tariff (".$feed["field_tariff"].")";

Then you should see you new field in the drop down list.

Cheers,
David.

Submitted by crounauer on Thu, 2006-09-21 21:43.

There was an error earlier where

$record

had to be inserted... I am sure having had a look at the script that it should be in this line of code and not the one previously stated.

$tarrif = $record[$admin_importFeed["field_tarrif"]];

David, perhaps you could clarify this for us please?

Computer Hardware

Submitted by dmorison on Fri, 2006-09-22 06:34.

Hi,

Either way should work. The line you mention would be an addition that goes in prior to the SQL construction; which will have the same effect as loading the value $record[...] for the field registered as tarrif.

Cheers,
David.

Submitted by clare on Sun, 2006-12-10 03:24.

Hi,

I havent been able to import feeds since adding a new field and think I have got confused at this point about where to put the $record, in admin.php.

There were a few changes mentioned after the original code and I tried to implement them but am notable to import. This is the code I used for my new field "compare" in the admin_register section..

<?php
$sql 
sprintf("INSERT INTO `".$config_databaseTablePrefix."feeds` SET
                    filename='%s',
                    registered='%s',
                    format='%s',
                    merchant='%s',
                    field_name='%s',
                    field_description='%s',
                    field_image_url='%s',
                    field_buy_url='%s',
                    field_price='%s',
                    field_category='%s',
                    user_category='%s',
                    field_brand='%s',
                    user_brand='%s'
                    field_compare='%s'
                    "
,
                    
database_safe($filename),
                    
time(),
                    
database_safe($format),
                    
database_safe(tapestry_normalise(ucwords($merchant),'\.')),
                    
database_safe($fieldName),
                    
database_safe($fieldDescription),
                    
database_safe($fieldImageURL),
                    
database_safe($fieldBuyURL),
                    
database_safe($fieldPrice),
                    
database_safe($fieldCategory),
                    
database_safe(tapestry_normalise($userCategory)),
                    
database_safe($fieldBrand),
                    
database_safe(tapestry_normalise($userBrand)),
                    
database_safe($fieldCompare)
                    );
?>

and then in admin__importRecordHandler

<?php
 
/* added compare field */
    
$compare $record[$admin_importFeed["field_compare"]];
     
/* create product record */
    
$sql sprintf("INSERT INTO `".$config_databaseTablePrefix."products` SET
                    merchant='%s',
                    name='%s',
                    description='%s',
                    image_url='%s',
                    buy_url='%s',
                    price='%s',
                    search_name='%s',
                    category='%s',
                    brand='%s',
                    dupe_hash='%s'
                    compare='%s'
                    "
,
                    
database_safe($admin_importFeed["merchant"]),
                    
database_safe($record[$admin_importFeed["field_name"]]),
                    
database_safe(isset($record[$admin_importFeed["field_description"]])?$record[$admin_importFeed["field_description"]]:""),
                    
database_safe(isset($record[$admin_importFeed["field_image_url"]])?$record[$admin_importFeed["field_image_url"]]:""),
                    
database_safe($record[$admin_importFeed["field_buy_url"]]),
                    
database_safe($record[$admin_importFeed["field_price"]]),
                    
database_safe($searchName),
                    
database_safe($category),
                    
database_safe($brand),
                    
$dupe_hash,
                    
database_safe($record[$admin_importFeed["field_compare"]])
                    );
?>

Can you see which bit I have messed up, I have tried a few variations and checked it several times unsuccessfully.

Submitted by clare on Sun, 2006-12-10 03:36.

Hi, sorry, I just had another go and just totally copied exactly your code David, instead of trying to make the changes suggested after and it has worked!

Thanks
Clare

Submitted by clare on Sun, 2006-12-10 04:23.

Actually on second look, this time the feed did seem to be import, but there are no records in the database, so maybe I do need to do something with the $record part.

I am just unclear from the two posts about where to change the original code you wrote.

Submitted by dmorison on Sun, 2006-12-10 08:39.

Hi Clare,

There is an error in your SQL (assuming that it is still the same
as posted above) which will result in the query failing and no
records being imported.

You need to add a comma after $dupe_hash before where you have
added your new field:

You have:

                    dupe_hash='%s'
                    compare='%s'

Should be:

                    dupe_hash='%s',
                    compare='%s'

Cheers,
David.

Submitted by multiz on Tue, 2007-01-09 06:05.

Hello David,

I have gotten everything to work by adding a sku to my products, but I'm having a problem with the filter.

With one of my merchants, they supply "FIELD1" which equals the sku.
The problem is that I also need to use "FIELD1" in the tracking URL. So, I put a URL before "FIELD1", but that URL now also gets in the sku I want use later.

Is there anyway I can use the sku in 2 different places?

Thanks,
Michael.

ZZPrices - Electronics Price Comparison Shopping

Submitted by dmorison on Tue, 2007-01-09 08:37.

Hi Michael,

If there is a blank field in the feed, you can also register that as your "Buy URL", and then add a filter to append the SKU from the other field using a "Text After" filter with "%FIELD1%" as the text. That placeholder will bring in the value of FIELD1 for the current record - so as long as you make it the first filter you can use it to make a copy of another field.

If the feed is XML there is always a blank field that you can register - normally the first in the list, which has been derived from the record element in the source XML.

Hope this helps,
Cheers,
David.

Submitted by henk on Tue, 2008-01-29 13:27.

Hi,

Is there something wrong with this code????

<?php
 
/* create dupe_hash value */
    
$dupe_key $admin_importFeed["merchant"];
    
// uncomment any additional fields that you wish to filter duplicates on (description not recommended)
    
$dupe_key .= $record[$admin_importFeed["field_name"]];
    
// $dupe_key .= $record[$admin_importFeed["field_description"]];
    // $dupe_key .= $record[$admin_importFeed["field_image_url"]];
    // $dupe_key .= $record[$admin_importFeed["field_buy_url"]];
    // $dupe_key .= $record[$admin_importFeed["field_price"]];
    
$dupe_hash md5($dupe_key);
    
/* create product record */
    
$title $record[$admin_importFeed["field_title"]];
    
$title_alias $record[$admin_importFeed["field_title_alias"]];
    
$introtext $record[$admin_importFeed["field_introtext"]];
    
$fulltext $record[$admin_importFeed["field_fulltext"]];
    
$sql sprintf("INSERT INTO `".$config_databaseTablePrefix."jos_content` SET
                    merchant='%s',
                    name='%s',
                    description='%s',
                    image_url='%s',
                    buy_url='%s',
                    price='%s',
                    search_name='%s',
                    category='%s',
                    brand='%s',
                    dupe_hash='%s',
                    title='%s',
                    title_alias='%s',
                    introtext='%s',
                    fulltext='%s'
                    "
,
                    
database_safe($admin_importFeed["merchant"]),
                    
database_safe($record[$admin_importFeed["field_name"]]),
                    
database_safe(isset($record[$admin_importFeed["field_description"]])?$record[$admin_importFeed["field_description"]]:""),
                    
database_safe(isset($record[$admin_importFeed["field_image_url"]])?$record[$admin_importFeed["field_image_url"]]:""),
                    
database_safe($record[$admin_importFeed["field_buy_url"]]),
                    
database_safe($record[$admin_importFeed["field_price"]]),
                    
database_safe($searchName),
                    
database_safe($category),
                    
database_safe($brand),
                    
$dupe_hash,
                    
database_safe($title),
                    
database_safe($title_alias),
                    
database_safe($introtext),
                    
database_safe($fulltext)
                    );
?>

The feeds registering in the database is ok but not the products???

Cheers HEnk

Submitted by dmorison on Tue, 2008-01-29 15:06.

Hi Henk,

It looks OK as far as the PHP is concerned, but your modifications could fail if the SQL does not match the database table structure. What I normally do in this sort of situation is to print the SQL out, and then run it manually using phpMyAdmin, so you would add the following code after that above:

  print $sql;exit();

This will exist having dumped the SQL to the screen. Then you can run the SQL manually and study the error message, which will probably describe the problem...

Cheers,
David.

Submitted by henk on Tue, 2008-01-29 15:22.

i tried it (line after line) first with de title field that works ok, but then the title_alias field it goes wrong.

Thx
Henk

Submitted by dmorison on Tue, 2008-01-29 15:27.

Hi Henk,

That probably indicates that title_alias does not exist in the products table in the database - that's the first thing to check...

Cheers,
David.

Submitted by henk on Tue, 2008-01-29 15:42.

its in it, and it gives no error with the code

Cheers Henk

Submitted by dmorison on Tue, 2008-01-29 15:47.

Hi Henk,

I presume that when you run the code manually, there is still nothing inserted into the table? This must imply, if the fields are all correct; that there is a unique index on one of the new fields that is preventing any more records from being inserted.

What output do you get from phpMyAdmin when you run the query?

Cheers,
David.

Submitted by henk on Tue, 2008-01-29 16:09.

INSERT INTO `jos_content` SET merchant='Henk', name='De Kolonisten van Catan', description='Waan je in het tijdperk van de ontdekkingsreizen je schepen hebben na een lange tocht vol ontberingen de kust van een onbekend eiland ontdekt. Het eiland wordt Catan genoemd! Je bent echter niet de enige ontdekkingsreiziger. Ook andere onverschrokken zeelieden zijn op de kust van Catan geland de wedstrijd om de kolonisatie is begonnen! De vrouwen en mannen van je expeditie stichten de eerste twee nederzettingen. Het land is gelukkig vruchtbaar en rijk aan grondstoffen.Je bouwt straten en nieuwe dorpen, die tot steden uitgroeien. Gaat het je lukken, om op Catan de belangrijkste macht te worden. Ruilhandel beheerst het leven op Catan. Van sommige grondstoffen heb je genoeg, andere zijn schaars. Je ruilt erts tegen wol, en baksteen tegen hout al naar gelang hetgeen dat je nodig hebt voor je volgend bouwwerk! Ga omzichtig te werk! Sticht je nederzettingen op de juiste plaats en ruil slim. Dan heb je meer kans om te winnen. Ook je medespelers zijn niet op hun ...', image_url='http://www.gamesandtoys.nl/thumbs/999KOL01.jpg', buy_url='http://www.coolmove.nl/ttcm/?campaignID=355&materialID=0&affiliateID=4586&redirectURL=http%3A%2F%2Fwww.gamesandtoys.nl%2Fpages%2Fdetails.php%3Fproduct_id%3D2077', price='32.95', search_name='DeKolonistenvanCatan', category='', brand='', dupe_hash='bf3d5632545dc4dd6c49544a167a51eb', title='De Kolonisten van Catan', title_alias='', introtext='Waan je in het tijdperk van de ontdekkingsreizen je schepen hebben na een lange tocht vol ontberingen de kust van een onbekend eiland ontdekt. Het eiland wordt Catan genoemd! Je bent echter niet de enige ontdekkingsreiziger. Ook andere onverschrokken zeelieden zijn op de kust van Catan geland de wedstrijd om de kolonisatie is begonnen! De vrouwen en mannen van je expeditie stichten de eerste twee nederzettingen. Het land is gelukkig vruchtbaar en rijk aan grondstoffen.Je bouwt straten en nieuwe dorpen, die tot steden uitgroeien. Gaat het je lukken, om op Catan de belangrijkste macht te worden. Ruilhandel beheerst het leven op Catan. Van sommige grondstoffen heb je genoeg, andere zijn schaars. Je ruilt erts tegen wol, en baksteen tegen hout al naar gelang hetgeen dat je nodig hebt voor je volgend bouwwerk! Ga omzichtig te werk! Sticht je nederzettingen op de juiste plaats en ruil slim. Dan heb je meer kans om te winnen. Ook je medespelers zijn niet op hun ...', fulltext='Waan je in het tijdperk van de ontdekkingsreizen je schepen hebben na een lange tocht vol ontberingen de kust van een onbekend eiland ontdekt. Het eiland wordt Catan genoemd! Je bent echter niet de enige ontdekkingsreiziger. Ook andere onverschrokken zeelieden zijn op de kust van Catan geland de wedstrijd om de kolonisatie is begonnen! De vrouwen en mannen van je expeditie stichten de eerste twee nederzettingen. Het land is gelukkig vruchtbaar en rijk aan grondstoffen.Je bouwt straten en nieuwe dorpen, die tot steden uitgroeien. Gaat het je lukken, om op Catan de belangrijkste macht te worden. Ruilhandel beheerst het leven op Catan. Van sommige grondstoffen heb je genoeg, andere zijn schaars. Je ruilt erts tegen wol, en baksteen tegen hout al naar gelang hetgeen dat je nodig hebt voor je volgend bouwwerk! Ga omzichtig te werk! Sticht je nederzettingen op de juiste plaats en ruil slim. Dan heb je meer kans om te winnen. Ook je medespelers zijn niet op hun ...'

cheers henk

Submitted by dmorison on Tue, 2008-01-29 16:11.

Hi Henk,

The SQL looks fine, but the problem will be to do with the table structure not matching the SQL.

phpMyAdmin should tell you what that problem is when you try to run the query....

What error do you get?

Cheers,
David.

Submitted by henk on Tue, 2008-01-29 16:23.

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext='Waan je in het tijdperk van de ontdekkingsreizen je schepen hebben na ' at line 1

HEnk

Submitted by dmorison on Tue, 2008-01-29 16:28.

Hi Henk,

What data type is the column "fulltext"?

Cheers,
David.

Submitted by henk on Tue, 2008-01-29 16:31.

text

HEnk

Submitted by dmorison on Tue, 2008-01-29 16:33.

Hi Henk,

Can you construct a test query, using the SQL above as a starting point; and try a simpler text field.

In other words, keep removing fields from the above SQL until it works - that should help point to what is wrong...

Cheers,
David.

Submitted by henk on Tue, 2008-01-29 16:36.

thx till now

HEnk

Submitted by henk on Tue, 2008-01-29 18:20.

Maybee, is fulltext a command ?

HEnk

Submitted by dmorison on Tue, 2008-01-29 18:35.

Hi Henk,

Sorry - I should have spotted that - It think you're correct...

Where you have a field that is the same as a reserved word, you need to enclose it in back-ticks.

To do this, change your SQL statement construction as follows:

<?php
$sql 
sprintf("INSERT INTO `".$config_databaseTablePrefix."jos_content` SET
                    merchant='%s',
                    name='%s',
                    description='%s',
                    image_url='%s',
                    buy_url='%s',
                    price='%s',
                    search_name='%s',
                    category='%s',
                    brand='%s',
                    dupe_hash='%s',
                    title='%s',
                    title_alias='%s',
                    introtext='%s',
                    `fulltext`='%s'
                    "
,
                    
database_safe($admin_importFeed["merchant"]),
                    
database_safe($record[$admin_importFeed["field_name"]]),
                    
database_safe(isset($record[$admin_importFeed["field_description"]])?$record[$admin_importFeed["field_description"]]:""),
                    
database_safe(isset($record[$admin_importFeed["field_image_url"]])?$record[$admin_importFeed["field_image_url"]]:""),
                    
database_safe($record[$admin_importFeed["field_buy_url"]]),
                    
database_safe($record[$admin_importFeed["field_price"]]),
                    
database_safe($searchName),
                    
database_safe($category),
                    
database_safe($brand),
                    
$dupe_hash,
                    
database_safe($title),
                    
database_safe($title_alias),
                    
database_safe($introtext),
                    
database_safe($fulltext)
                    );
?>

Cheers,
David.

Submitted by henk on Tue, 2008-01-29 19:35.

Yes thx

HENK