Frankly, I don't expect this is possible, but you've come up with some pretty amazing solutions, so I'll ask anyway.
In the datafeeds there are two columns, one for regular price and one for sale price. Most merchants are correctly completing both columns. If there is no sale price, they still insert the regular price in that column. This makes importing pretty straight forward, you simply import the sale price column as the product price.
Of course, there are some that don't. They have the regular price column filled in and only if the product is on sale, do they enter a price for the sale price column. This means I have to import the regular price column.
My question becomes, is there some php code I can add to cross reference these two columns? Something like:
if (saleprice!=" ")
{price=saleprice}
else (price=regularprice)
And where or how would I implement this?
Unfortunately, the column name varies, as the datafeeds are from different networks. The columns are the same within each network.
After posting, I started thinking the problem might be that I'm looking at it from the import side rather than the result side.
If I add a field to the db and the import routines, as I've done with the product id, then I could import both columns, one as price and one as sale price, I would just need to add some code to the product.php and maybe search.php to check if the column in mysql for sale price is empty, if it is then show the price field.
This would eliminate the issue of different column names for 'sale price' in the datafeeds.
But any suggestions you can come up are greatly appreciated!!
Hi,
Adding another field (I presume that you have found the instructions) is the more round-a-bout way of going about it. Once you have done that, it would be possible to add code within the import record handler to fix-up the main price field as per your code, but equally possible is to do what you suggest and add Price / Sale price columns to the prices table...
Cheers,
David.
I'm all for keeping it simple. If you think adding a price / sale price column to the prices table wouldn't be too difficult, I'd be interested in that. I think it would look cool to show the regular price and then a sale price right next to it if available.
This would give more information to the visitor as they would know there is a sale going on and encourage a quicker purchase to get the lower sale price.
Hi,
If you have added the field to the database, it is not much work to add some simple code to the import record handler to set the main price to the sale price if one exists. Otherwise, the cheapest merchant may not be the first in the list if their regular price is higher than other merchant's regular price.
If you have added the field to the database, let me know what field name you have used, and i'll post the code for the prices table and, if you want to do it, the price setting during import...
Cheers,
David.
David,
I just added the field and named it saleprice.
Thanks for any help you can give with displaying this price/saleprice combo.
Hi,
With "saleprice" in the database, the easiest thing to do is to make the saleprice the main price if set, exactly as per your example code in the first post.
To do this, in includes/admin.php, look for the following code (line 168), within the admin__importRecordHandler() function:
$record[$admin_importFeed["field_price"]] = tapestry_decimalise($record[$admin_importFeed["field_price"]]);
...and add the following new code immediately afterwards:
$saleprice = tapestry_decimalise($record[$admin_importFeed["field_saleprice"]]);
if ($saleprice)
{
$record[$admin_importFeed["field_price"]] = $saleprice;
}
Hope this helps!
Cheers,
David.
After adding the new field will I have to go back and registar all the feeds again?
Hi,
Basically yes - the fields are only configured during registration...
However, if: a) You have lots of feeds; and b) They're all the same format (i.e. from the same affiliate network); then I can help you work out the SQL statement that will update the feeds table in one go. You could then execute this SQL using phpMyAdmin or similar MySQL admin tool.
For example, it might be something like:
UPDATE feeds SET field_saleprice = 'SALEPRICE';
Cheers,
David.
One network used SalePrice and the other uses PRICE/SALE
Hi there,
If you can identify the network via the value of another registered field, then you could do it with queries like this:
UPDATE feeds SET field_saleprice = 'SalePrice' WHERE field_price='Price';
UPDATE feeds SET field_saleprice = 'PRICE/SALE' WHERE field_price='PRICE/RRP';
Cheers,
David.
I just noticed that 0.00 is used if there is a SalePrice. For example Signature Wool Gabardine Pleated Trouser they are on sale for 99.50
http://www.megashoppingonline.com/products.php?q=Signature+Wool+Gabardine+Pleated+Trouser
Signature Wool Gabardine Pleated Trouser
Price 195.0
SalePrice 99.5
Hi Adrian,
Can you send me your latest includes/admin.php so that I can see the latest mods - it sounds like something is wrong in the import function if 0.00 is getting imported if there is a SalePrice value - i'll need to see the code to work out what that might be...
Cheers,
David.
Hi,
There's potentially quite a quick solution to this; but if this is not the case then it will take a bit more work.
Firstly, it sounds as if all of these feeds are of the same format. If this is the case, is the field name (that you would see on the Feed Registration (Step 2) page) for "Regular Price" always the same, and if so, can you post the name of that field and i'll roll a quick hack to put into the import record handler to do almost exactly as you suggest in your post...
Cheers,
David.