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.
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!
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.
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..
Hi,
How would i go about using the filters on the new fields i now have?
Cheers,
Nick
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.
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?
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.
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.
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
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.
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.
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.
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.
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
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.
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
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.
its in it, and it gives no error with the code
Cheers Henk
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.
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
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.
#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
Hi Henk,
What data type is the column "fulltext"?
Cheers,
David.
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.
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.
I'm trying to add 6 Optional Index Fields (Asin, Delivery, Availability, Condition, Publisher, Paperbackorhardback) to my site and have folowed the directions above but the feeds are not importing into either the feed database or the product database.
These are the bits i've changed:
From feeds_register_step2
<?php
if (!widget_errorCount())
{
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["fieldAsin"],$_POST["userAsin"],$_POST["fieldDelivery"],$_POST["userDelivery"],$_POST["fieldAvailability"],$_POST["userAvailability"],$_POST["fieldCondition"],$_POST["userCondition"],$_POST["fieldPublisher"],$_POST["userPublisher"],$_POST["fieldPaperbackorhardback"],$_POST["userPaperbackorhardback"]);
?>
<?php
print "<strong>Optional Index Fields:</strong><br />";
print "<table class='feeds'>";
$userCategoryDefault = (isset($_POST["userCategory"]) ? widget_safe(widget_posted($_POST["userCategory"])) : "");
$prefixHTML = "<input type='text' name='userCategory' value='".$userCategoryDefault."' /> or use field ";
field("Category","fieldCategory",$prefixHTML);
$userBrandDefault = (isset($_POST["userBrand"]) ? widget_safe(widget_posted($_POST["userBrand"])) : "");
$prefixHTML = "<input type='text' name='userBrand' value='".$userBrandDefault."' /> or use field ";
field("Brand","fieldBrand",$prefixHTML);
$userAsinDefault = (isset($_POST["userAsin"]) ? widget_safe(widget_posted($_POST["userAsin"])) : "");
$prefixHTML = "<input type='text' name='userAsin' value='".$userAsinDefault."' /> or use field ";
field("Asin","fieldAsin",$prefixHTML);
$userDeliveryDefault = (isset($_POST["userDelivery"]) ? widget_safe(widget_posted($_POST["userDelivery"])) : "");
$prefixHTML = "<input type='text' name='userDelivery' value='".$userDeliveryDefault."' /> or use field ";
field("Delivery","fieldDelivery",$prefixHTML);
$userAvailabilityDefault = (isset($_POST["userAvailability"]) ? widget_safe(widget_posted($_POST["userAvailability"])) : "");
$prefixHTML = "<input type='text' name='userAvailability' value='".$userAvailabilityDefault."' /> or use field ";
field("Availability","fieldAvailability",$prefixHTML);
$userConditionDefault = (isset($_POST["userCondition"]) ? widget_safe(widget_posted($_POST["userCondition"])) : "");
$prefixHTML = "<input type='text' name='userCondition' value='".$userConditionDefault."' /> or use field ";
field("Condition","fieldCondition",$prefixHTML);
$userPublisherDefault = (isset($_POST["userPublisher"]) ? widget_safe(widget_posted($_POST["usePublisher"])) : "");
$prefixHTML = "<input type='text' name='userPublisher' value='".$userPublisherDefault."' /> or use field ";
field("Publisher","fieldPublisher",$prefixHTML);
$userPaperbackorhardbackDefault = (isset($_POST["userPaperbackorhardback"]) ? widget_safe(widget_posted($_POST["usePaperbackorhardback"])) : "");
$prefixHTML = "<input type='text' name='userPaperbackorhardback' value='".$userPaperbackorhardbackDefault."' /> or use field ";
field("Paperbackorhardback","fieldPaperbackorhardback",$prefixHTML);
?>
From includes/admin.php
<?php
function admin_register($filename,$format,$merchant,$fieldName,$fieldDescription,$fieldImageURL,$fieldBuyURL,$fieldPrice,$fieldCategory,$userCategory,$fieldBrand,$userBrand,$fieldAsin,$userAsin,$fieldDelivery,$userDelivery,$fieldAvailability,$userAvailability,$fieldCondition,$userCondition,$fieldPublisher,$userPublisher,$fieldPaperbackorhardback,$userPaperbackorhardback)
?>
Further down....
<?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_asin='%s',
user_asin='%s',
field_delivery='%s',
user_delivery='%s',
field_availabiliy='%s',
user_availabiliy='%s',
field_condition='%s',
user_condition='%s',
field_publisher='%s',
user_publisher='%s',
field_paperbackorhardback='%s',
user_paperbackorhardback='%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($fieldAsin),
database_safe(tapestry_normalise($userAsin)),
database_safe($fieldDelivery),
database_safe(tapestry_normalise($userDelivery)),
database_safe($fieldAvailability),
database_safe(tapestry_normalise($userAvailability)),
database_safe($fieldCondition),
database_safe(tapestry_normalise($userCondition)),
database_safe($fieldPublisher),
database_safe(tapestry_normalise($userPublisher)),
database_safe($fieldPaperbackorhardback),
database_safe(tapestry_normalise($userPaperbackorhardback))
);
?>
<?php
/* 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',
asin='%s',
delivery='%s',
availability='%s',
condition='%s',
publisher='%s',
paperbackorhardback='%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($asin),
database_safe($delivery),
database_safe($availability),
database_safe($condition),
database_safe($publisher),
database_safe($paperbackorhardback)
);
?>
Hi Phil,
I'll email you the select and modify debug version of includes/database.php - this
should print out any database errors that occur during registration and should
indicate the problem for you!
Cheers,
David.
could you email me this the debug database.php too? Im having the same problem as phil
david,
if i am going to introduce this to a new PT site, Is it posible to integrate this by default on my setup package? So that the sql will be configured automatically with the setup.php and setup.sql.
do i need to add something to setup.php and setup.sql?
I would like to have 2 added fields by default
one is the hidden image on this thread http://www.pricetapestry.com/node/2656
and another custom field.
thanks in advance.
Hi Alex,
Sure - it's easy to add the required fields for this mod to setup.sql (no changes are required to setup.php). The modifications are needed to the feeds and products table. Taking the existing setup.sql, to add the fields to the feeds table, look for example for the following line (line 50):
field_description varchar(255) NOT NULL default '',
...and simply copy that line and paste into the next line for each of the extra fields, for example:
field_tariff varchar(255) NOT NULL default '',
And then similarly, within the SQL for the products table, look for example for the following on line 84:
name varchar(255) NOT NULL default '',
...and again simply copy that line and paste into the next line for each of the extra fields, for example:
tariff varchar(255) NOT NULL default '',
Cheers,
David.
I want to import 1 extra field: subcategory. So I created a row in the products table 'subcategory' and a row named 'field_subcategory' in the feeds table.
Also made changes to the code. After importing the feeds, the row in the feeds tabel is OK, but field_subcategory is empty.
Maybe I've done something wrong in the code? Here's what I changed:
includes/admin.php
Line 3:
function admin_register($filename,$format,$merchant,$fieldName,$fieldDescription,$fieldImageURL,$fieldBuyURL,$fieldPrice,$fieldCategory,$fieldSubcategory,$userCategory,$fieldBrand,$userBrand)<code>
Line 58:
<code>$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_subcategory='%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($fieldSubcategory)
);
Line 62:
$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',
subcategory='%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($subcategory)
);
admin/feeds_register_step2.php
Line 63:
admin_register($filename,$format,$_POST["merchant"],$_POST["fieldName"], (isset($_POST["fieldDescription"])?$_POST["fieldDescription"]:"") , (isset($_POST["fieldImageURL"])?$_POST["fieldImageURL"]:"") , $_POST["fieldBuyURL"],$_POST["fieldPrice"],$_POST["fieldSubcategory"],$_POST["fieldCategory"],$_POST["userCategory"],$_POST["fieldBrand"],$_POST["userBrand"]);
Line 162:
field("Subcategory","fieldSubcategory");
Hello Pieter,
There are just 2 small errors, I think that will be all it is.
admin/feeds_register_step2.php line 63 it looks like you have the category and subcategory
fields the wrong way round compared to includes/admin.php - I think it should be:
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["fieldSubcategory"],$_POST["userCategory"],$_POST["fieldBrand"],$_POST["userBrand"]);
...and in includes/admin.php, in the block of SQL to insert the product record, instead of:
database_safe($subcategory)
...use:
database_safe($record[$admin_importFeed["field_subcategory"]])
Hope this helps!
Cheers,
David.
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.