Hi David,
I would like to add filter on fields that are not currently in the standard mapping.
For CJ feed I would like to filter out product where there in-stock=no and take the lower between the sale price and price (if sale price exists).
Additional one would be based on date field not to load product that were change just before last import date.
Any idea how to ad these filters?
Thanks
Danny
Thanks David,
It worked with no problem. much simpler solution than I thought.
The date filter is no loanger relevant.
Thanks again
Danny
Hi David,
Thank you for the wonderful price comparison script. I am starting to build my website now.
Regarding the sale price, As i see this code "$record[$admin_importFeed["field_price"]]" in many places of admin.php, do i need to replace all with the new code?
Thanks,
Syed
Hi Syed,
No - you shouldn't need to as the code I provided for you above overwrites this variable with the sale price (if applicable), intentionally so that you do not need to change so much code...
Cheers,
David.
Hi David,
Unfortunately, Sale price Vs Price is not working for me.The steps i followed are as given below
Q1. Sale price Vs Price
1. Installed PT.
2. In admin.php added the below code
if (
($record["SALE-PRICE"])
&&
($record["SALE-PRICE"] < $record[$admin_importFeed["field_price"]])
)
{
$record[$admin_importFeed["field_price"]] = $record["SALE-PRICE"];
}
....after $record[$admin_importFeed["field_price"]] = tapestry_decimalise($record[$admin_importFeed["field_price"]]);
3. Registered the feed with "price" as column value for price.
4. Imported the feed.
Please give me steps.
Q2. How do i put 3 random items in a box cetered in the index page.
I would need to display picture, title and price.
Q3.I receive error Internet explorer cannot display webpage after few minutes when i click register and import or only import.(the feed file is xml and big). I have hosted with Yahoo and have only ftp account with which i am uploading the feeds. I am not able to connect using putty/telnet to the server to run import.php.
When i refresh i am able to view but the products count mismatch.
How to resolve these issues?
Thanks
Syed
Hi Syed,
1/
The field name SALE-PRICE is very specific to the feed that the above user has in their feeds. Does this definitely match the field name in the feeds that you are using? For example, check that it is not "SALEPRICE" or "SALE_PRICE" that you need to be using instead...
2/
Lots of users convert the featured products code on the home page to display random products instead. All you need to do is replace the featured products SQL on line 32 of index.php from:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY sequence";
to:
$sql = "SELECT *,1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 3";
Now, if you have a very large site there may be performance issues, in which case let me know and i'll suggest some other ways of doing it (such as selecting a random merchant and then 3 random products from that merchant for example) - but give this a go first. Also, if you would like to continue using the featured products as well as random products i'll explain how to copy the featured products code in order to do this.
3/
For the import timeout, some users have found (where they are not able to Telnet or SSH in) that using an alternative version of feeds_import.php that generates a continuous output helps, as this stops the web server or proxy server from assuming that nothing is happening. I'll email you this file in just a moment...
Cheers,
David.
Hi David,
Q1. The field name is saleprice. I modified the field name and it takes the lower value but there are many feeds which has sale price either 0.00 or null. Now many products are having 0.00 as price but when we clicked to store it shows the price. So it looks like we need to modify the if condition to exclude the lower values 0.00 for sale price. Is it possible?
Q2. Yes, I am getting the random products but due to long product name, the data shown are unordered. Is it possible to trim the title to specific characters length in the random display. eg: "Sony Ericsson HBH PV708 Bluetooth Headset" and "Hotpoint TCL770G Graphite Tumble Dryer inc DelConn"
Q3. Thank you for the script Unfortunately, still i am receiving the same error - Internet Explorer cannot display the webpage.
Thanks,
Syed
Hi,
Sure - you can condition the code to only use a sale price if its value is greater than zero, simply modify the code as follows:
if (
($record["SALE-PRICE"] > 0.00)
&&
($record["SALE-PRICE"] < $record[$admin_importFeed["field_price"]])
)
{
$record[$admin_importFeed["field_price"]] = $record["SALE-PRICE"];
}
Trimming the product name is straight forward; simply look for the following code (line 9 in the distribution) of html/featured.php:
<h4><a href='<?php print $product["productHREF"]; ?>'><?php print $product["name"]; ?></a></h4>
...and change this to:
<h4><a href='<?php print $product["productHREF"]; ?>'><?php print substr($product["name"],0,20); ?></a></h4>
...changing the "20" to the number of characters you wish to limit the displayed name to.
Regarding the import timeout; do you being to see the output generated before Internet Explorer displays the "Page cannot be displayed" message, or does it just show the page loading icon with nothing being displayed?
Cheers,
David.
Hi David,
The random image works fine but the performance is very slow. Please suggest the other way to implement( 1 merchant 3 items).
When i click register and import in the admin page,the page just remains for few minutes and then gives an error message http 500. IE cannot display webpage. Few products got imported but not all. This happens for large files.
Thanks,
Syed
Hello Syed,
To change the random images from all products to products from a random merchant, change the modification from:
$sql = "SELECT *,1 AS sequence FROM `".$config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 3";
to:
$sql = "SELECT merchant FROM feeds ORDER BY RAND() LIMIT 1";
database_querySelect($sql,$rows);
$merchant = $rows[0]["merchant"];
$sql = "SELECT *,1 AS sequence FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($merchant)."' ORDER BY RAND() LIMIT 3";
Regarding the import timeout; when you try a smaller feed that works; do you see the output that the modified version of the import script is generating come out as it imports; or do you not see it until the import has completed? If there is no output displayed, could you double check that the alternative version of admin/feeds_import.php was uploaded to the correct location (the /admin/ directory)...
Cheers,
David.
Hi David,
1. I changed the above code in index.php but unable to see any output.
2. I do not see it until the import has completed. i have renamed old feeds_import.php to feeds_import_bkp.php and uploaded the new file into admin directory. (/admin/feeds_import.php ).
Thanks,
Syed
Hi Danny,
Complex filtering requirements, in which you want to set a value based on a comparison, are better off performed in PHP within the import record handler; at which point you have access to the entire record, including fields that haven't actually been registered.
The place to add the code is within the admin__importRecordHandler() function, beginning on line 124 of includes/admin.php. Scroll down until after the global variable declarations, and then to filter out records where the in stock field is "no" simply add the following code:
if ($record["IN-STOCK"] == "no") return;
(in this case, IN-STOCK would be whatever the field name is that contains the stock data, as viewed in the same record on the feed registration step 2 page)
Regarding the price; the variable that is inserted into the database is:
$record[$admin_importFeed["field_price"]]
...so what you would need to do is add something like this:
if (
($record["SALE-PRICE"])
&&
($record["SALE-PRICE"] < $record[$admin_importFeed["field_price"]])
)
{
$record[$admin_importFeed["field_price"]] = $record["SALE-PRICE"];
}
Could you expand on your requirement to block the import based on a date field, perhaps with an example? The date of last import is available at this point in the code through the variable:
$admin_importFeed["imported"]
...stored as a PHP time() value (seconds since 1/1/1970) but i'll need a little more information about the date field in your feed in order to show you how to selectively import based on that field...
Cheers,
David.