I am having a list of products. I have added to the google appengine search API index with each product being each document. User can search for products. So far everything is good.
Now I want the user to be able to sort by price of the product ascending or descending. If i have fixed price for each product, I could simply build separate indexes and put the documents inside them. But unfortunately, the prices are dynamic. The product price can change 3-4 times a day. I have more than 200,000 products.
Since rewriting the document each time the price changes is bad, I have a ndb datastore model which has the documentID and price as the entity attributes.
Is there any way to sort the search api results, based on the price in the ndb model. Alternate design solutions are also welcome.
Related
I'm creating a flutter app which needs shopping basket functionality. I'm using Firestore to save the contents of user's shopping baskets but do not know how best to do this.
At the moment, I have a collection called 'baskets' which contains documents (with the users id as the reference).
Within these documents, should I have a field which is a dictionary/map with key = productID and value = quantity, or should I just create a field for every product that the user adds to their basket?
Or is there a better way altogether (still using Firestore).
You are on the right track. Creating a root collection called baskets, under which each user has its own document based on the user's unique UID is good. Now, inside each of the user's documents, you can add a sub-collection called cartItems, where you will hold a document per product.
For each product then you can add its name, price, and amount and other descriptive product fields. That way instead of having multiple documents of the same product, just add a document per product, and a field called amount which you increment as users add more items of that same product.
You will be able to calculate how much is the total cost of their cart by pulling all documents, adding up all the amount fields of products times their individual prices, etc.
You can increment / decrement the amount of products, or altogether remove the product from their basket by removing the product document.
The main collection baskets should look like this:
While your cartItems subcollection could look like this:
Good luck!
I have a multitenant site, whose products are indexed in Solr, so visitors can search by product name, or any other product property.
Now, I would like to filter by product price.
There are two problems:
Not all tentants have the same products on their website.
The product price can differ from one customer to another, as each tenant can change the price of each of the product it uses.
So given a tenantId, I'd like to search for all products that tenant has, which are in a given price range.
I don't think I can store a Map<CustomerId, Price> for each product and somehow query that, so I'm a bit stuck on how to design the schema. At the moment, I just have, for each product, a multivalued property called customer, so I can just filter by all products of a given tentant.
Any help appreciated, thanks!
I have a document in a lucene which, say, models a shop.
The document has a number of terms which specify the items the shop has. Now I want to associate a price with every item in the document without having to create extra fields for each item. I want to be able to sort on these prices and filter on these prices.
How can I achieve this functionality? I had thought of payloads for sorting, but not sure how to do the filtering part?
I have a very interesting problem in relation to CakePHP. I have a client that is currently selling products on eBay, and wants to start selling products on their own website as well. There would, then, be two separate sales avenues: (1) eBay, and (2) website.
However, they do want to have a seamless website experience for their customers. Basically, they want their current eBay sites to be categories within their current website, and their current eBay auction items to be searchable on their website.
A simple CakePHP website would have two tables: products and categories, with the simple table relation of "products belongsTo categories" and "categories hasMany products". How would I then add in the eBay categories and products? Basically, I want the http://site/products/index to return a list of ALL products, both in the products table and on eBay. I want http://site/categories/index to return a list of all defined categories in the categories table plus the categories items are listed in on eBay.
eBay has a very good pretty much real-time request query API, so I've been thinking about an option to do this, but am wondering if there is a better way... I don't think this option would work very well with PaginatorComponent...
Method:
(1) In beforeFind, capture the request parameters and save to a persistent variable
(2) In afterFind, make a request to the eBay API based on the request parameters, then manually add the results to the $results array.
Again, I think this would work for basic find operations, but I'm not sure this would work with pagination because I'm not sure how to deal with, say, a 20 item page limit (i.e. How do I deal with a page 2 when only 18 items from the database were on page 1, and now on page 2 I need to start at 19 instead of 21 from the database?)
Is there a CakePHP syntax that I'm overlooking here, or do I just start working on coding for all of these eventualities?
I'm coding on a CakePHP 2.6.0 platform.
Thanks so much for your help!
One possible approach would be to read all the products from each datasource, sort them in memory and paginate from there. The number of products would of course play a major role here.
A second one, if the number of products does not change too often, would involve a background process to retrieve their ID, and the most essential data, from eBay and write them in the common Product table, flagging the rows created.
Then Paginator can then show your results, but other fast-changing data can be retrieved on-the-fly from eBay for the flagged products while composing the page.
I have a strange requirement in Solr.
The business model is like for each store in state (say victoria), we have different sales catalog (like Richmond, Brunswick etc) which in turn act as fulfillment centers on their own.
so my url of storeId- vic and catalogId-Richmond will retrieve me catalogues with richmond's store.
Now the requirement is I need to filter out the products based on the inventory for each of these sales catalogues.
I constructed a TI table which has the following structure
catentry_id -------- QUANTITY_RICFUL-------------QUANTITY_BrunFUL
1234-------------------0------------------------------------20
I had incorporate the changes in solr query to add these columns in the final result too.
But I do not know how to filter out the products in the front end during catalogue navigation or during search.
Any help would be much appreciated!!!
So basically you want to tie the returned catalog entries in a list with inventory? For instance, when they click on a category you do not want to display products with no inventory?
This would be a customization you can either do at the Solr Level or at the JSP level. You should probably track inventory in commerce (import it) into a field Solr can key off of and then only return items with the flag set to greater than zero. I am not sure if you need actual inventory or just a boolean. Are you using a single fulfillment center or multiple ones? Multiple gets a bit trickier and it would require them to log in most likely but then fulfillment would be addressed by the ship to address.
If the store is set up with ATP inventory then you should just get this for free, as products not in stock will simply not be displayed. Check out this page in the infocenter - http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=%2Fcom.ibm.commerce.user.doc%2Fconcepts%2Fcosatpatpandnonatp.htm
I am not sure what you are trying to ask here but it seems you are trying to display a Quantity dropdown or display an Quantity field under each product on a search page which to me makes no sense from a UI perspective. Also keep in mind if you have integrated with a 3rd party inventory model that runs every few mins/hours etc. How often do you plan to run indexing etc?
I would rather leave such complexity to a Prodcut Detail page. If you do require to show an Quantity field on the search page I would rather prefer displaying a QuickView popup/modal that displays the color/size attributes with the quantity dropdown etc and enable a user to add an item to his/her shopping cart.