You are here:  » Can I pull agregated data to display using a search query?

Support Forum



Can I pull agregated data to display using a search query?

Submitted by Paul1107 on Mon, 2012-04-02 10:23 in

Hey David.

I know my PT is heavily customised already but wondered if there was a way to incorporate a couple of menu items?

1. "New In" items but just for particular type of garment i.e "dresses" which can be gathered from all the different datafeeds?
2. "On Sale/in Sale" item on the same basis as above?

just would really be handy to have those?

Regards

Paul

Submitted by support on Mon, 2012-04-02 12:32

Hi Paul,

> 1. "New In" items but just for particular type of garment
> i.e "dresses" which can be gathered from all the
> different datafeeds?

The way that Price Tapesty keeps the database up to date during an import process is that when you import a feed, all products from that feed are first deleted, and then the feed imported again which ensures that your database always matches the feed.

A number of users have made changes to enable identification of new products by adding `deleteme` and `timestamp` fields to the products table, and then modifying the import process as follows:

1) Initiate import process but instead of deleting all products for the feed instead update the `deleteme` flag to '1'.

2) Modify the import record handler to check for an existing record for the product. If exists, then the record is updated, deleteme is set to 0 and timestamp updated to NOW(). Otherwise, record is inserted, with deleteme set to 0 and timestamp set to NOW() by default.

3) After import, expired products are removed using DELETE FROM .... WHERE `deleteme` = '0'.

This modification is documented in this thread which I think applies to the distribution that you will be running; if not let me know and if you could email me a copy of your includes/admin.php I'll apply the changes for your verison.

Please note that this wouldn't be compatible with using import.php @ALL as this method TURNCATEs the `products` table for efficiency.

With that in place, latest products can be included by adding a sort handler based on the timestamp field. To do this, search for the following line in search.php:

    $orderByDefault["rating"] = "rating DESC";

...and REPLACE with:

    $orderByDefault["rating"] = "rating DESC";
    $orderByDefault["new"] = "timestamp DESC";

And then the following code:

    $orderByFullText["rating"] = "rating DESC";

...and REPLACE with:

    $orderByFullText["rating"] = "rating DESC";
    $orderByFullText["new"] = "timestamp DESC";

With that in place, a search could be constructed as follows:

search.php?q=category:Dresses:&sort=new

> 2. "On Sale/in Sale" item on the same basis as above?

This would involve adding a new field and search handler. Instructions for the latest version can be found in this thread where a field "sale" could be added. The easiest method would be to arrange that this field either contains something (sale item) or nothing (non-sale item), so with a feed that contains "YES" or "NO" for sale/non-sale a Search and Replace filter could be used to replace "NO" with an empty value. The string value can then be used as a sort field as MySQL returns an empty string first, so with that in place, extend the modification described above by adding

    $orderByDefault["sale"] = "sale DESC";

and

    $orderByFullText["sale"] = "sale DESC";

...enabling a query such as

search.php?q=category:Dresses:&sort=sale

Both the above would require similar modifications to the search code in your external* scripts which I know you are using - if you're not sure of any of the changes of course forward the relevant files and I'll modify accordingly...

Cheers,
David.
--
PriceTapestry.com

Submitted by Paul1107 on Mon, 2012-04-02 14:14

Hi David,

thanks again.... I should have explained that for the both questions Most of my feeds actually have "New In" or "New" "Onsale" "sale" categories already, so I was looking to aggregate those feeds that have that category, and then display the item required, so in the instance "dress" so I should have explained myself a little better.

That may change the method you explain above

cheers

Paul

Submitted by support on Tue, 2012-04-03 08:02

Hi Paul,

I presume you're already importing a main category field anyway e.g. "Dresses" so have you added anything yet to import the New / Sale field, for example as a new field in the database?

Cheers,
David.
--
PriceTapestry.com