I have gone through the code and webparts but couldn't figure out how rating works.
All I know is the rating control provided.
I want to show rating history through an API.
I also need to allow users to rate using API.
I can get rating value of a document with the query:
select DocumentRatings, DocumentRatingValue from CMS_Document WHERE [DocumentNodeID] = 123
But how to see rating history?
How rating is calculated internally?
Which are the other tables involved?
In Kentico, there are two different types of content ratings, both count towards the document's content rating:
Ratings without message
increments the rating value and count directly in the Document table.
Ratings with message (uses Message Board functionality)
adds a message with rating to [Board_Message] table, grouped together by a board representing the page stored in [Board_Board]
also increments the rating value and count directly in the Document table.
If you're wanting to have full rating history, and be able to expose it via an API, you're probably best looking at using Message Board functionality. To do this, you can check the API documentation here or investigate how Kentico's Message Board webparts work, try checking:
CMS\CMSModules\MessageBoards\Controls\MessageBoard.ascx.cs
CMS\CMSModules\MessageBoards\Controls\Messages\MessageEdit.ascx.cs (btnOk_Click event)
Related
I would like to change the price of a product based on the customer's selection. For example, I'm trying to build a small PDP widget to make customers able to choose the number of candles on a cake or write text on cakes and update the price accordingly. The docs only cover how to change the price by overwriting the cart's collector/processor but I don't want to use this method because of other plugins potentially overwriting the same service. So, is there are any other methods of changing the price of the products by subscribing to an event?
There are a few things you will need to consider in this one.
Firstly, you will need to save the user input data somewhere (amount of candles, text).
Possibly a separate database table that has a OneToMany relationship on cart line items. See this article. Und ya, this is also the part where you will hook into the onLineItemAdd event & save your user input to that table. You may as well also subscribe to the onLineItemUpdate for the same saving logic. You could do the same when removing the item from the cart, although that may not be necessary if you use database's "CASCADE on delete" when implementing your DB table. Meaning once the line item gets removed by the customer (deleted in the DB), your database entry gets deleted as well.
Afterwards, you can then use the extensions or otherwise called associations to pull this data on the cart page & the order pages. You can be a little more fancy here, if you look at all the frontend router calls, you will notice that Shopware sometimes passes "Criteria" class you can hook into.
public static function getSubscribedEvents(): array
{
return [
OrderRouteRequestEvent::class => 'alterCriteria',
DocumentOrderCriteriaEvent::class => 'alterCriteria',
];
}
public function alterCriteria(Event $event): void
{
if (method_exists($event, 'getCriteria')) {
$event->getCriteria()->addAssociation('lineItems.myExtension'); // check syntax, could be lineItem.
}
}
Now you can extend the twig templates to show your candles or text in the order page, cart page, document (invoice) pages.
Secondly, you will have to handle the price. This part will be easier now that you have data saved & being automatically pulled via criteria subscribers. If it's not possible to hook into those events all the time, you will still have an option to manually load your data.
I do not recommend modifying the price itself, but maybe you could look into adding a surcharge instead. Maybe this article will be helpful to understand the price flow. You could also see if there are any other plugins out there that implement surcharge logic to see it in action.
I have a timeline feed for my website. The feeds are currently displaying in the order where latest feeds are displayed first. I would like to change the order of feed listing. Is it possible to list the activities in the feed based on the latest commented activity? That is latest comment reacted activity should be displayed first.
Yes, you can definitely support this but you need to decide a field to rank on and update that field according to comments. A ranking function implements this idea:
{"score": "last_commented == 0 ? time : last_commented","defaults": {"last_commented": 0}}
It assumes you maintain comment timestamp in custom last_commented field on the activities.
Trying to figure out how to set the location of a multi-location Netsuite so that on the web store it only will display the quantity of that location only. Currently it displays ALL locations (sums).
I would like js in the header possibly that will set the location to one location and then when using locationquantityavailable it will grab that locations quantity and displays it.
Anyone been able to display just a locations quantity?
You can mark your locations as making their inventory available in the web store. Then the standard sitebuilder tags quantityavailable and quantityonhand will pull from those.
If that doesn't work you could manage this by various forms of scripting.
Script your inventory affecting transactions so that inventory changes from the desired locations update custom item fields.
Create a Suitelet that takes a page's item ids as a query string and returns current inventory for those items.
create a non-stored custsom item field that populates with the results of a saved search. I doubt this option will work in the context of the web store but it's very low effort to check. Search for "Creating Custom Fields with Values Derived from Summary Search Results" in the Netsuite online help for details.
I've used the first two of these in production to achieve the result you're looking for.
each of these has advantages and disadvantages so there's a trade off between how busy your back-end is vs how busy the site is.
We are planning to use foursquare api to get venue in a particular city. I want data of all the food outlets in a particular city. I have managed to get the categories list but not sure how to get venues from that particular category in a particular city or area.
Please share some tutorials or document which i can check out.
One way of doing what you want will be using the Venues Platform for browsing according to a category ID.
Look at venue search API reference.
Example of using it:
I know that 4bf58dd8d48988d11f941735 is nightlife (just picked the first one I saw)
So I will call the API (the ll is someplace in New York):
https://api.foursquare.com/v2/venues/search?ll=40.7268,-73.9972&categoryId=4bf58dd8d48988d11f941735&limit=50&intent=browse&radius=1500&your ids/oauth
Or use the explorer to see results right away.
Important, read the search API and the parameters used here to alter behavior to your needs.
Another very important thing, the API parameters are case sensitive!! (so if they want categoryId, categoryid will not work :) )
I have a view that pulls in feed items (from various "Owner feeds" to use the feeds module lingo), then sorts them by date (very important). The owner feed has a CCK field for the type of feed (Twitter, Blog, etc.) and a CCK field theoretically to limit the number of feed items displayed in the view. (The reason for the limit is that Twitter dominates, but we want some blogs, etc., so I don't want to have to show 100 tweets before displaying my first blog.)
I'm guessing some sort of Views hook code is in order, but I'm not sure which one. Perhaps the hook that allows direct modification of the query...
Note that the Owner feed nid is being pulled into the view via a Relationship.
Thanks in advance!
Using the Arguments field in the view, you could first select the node type, then node post date.
In this way you could give priority to the blog type, before sorting by date.
You could also consider building two Views, for instance the top 5 blog items and the top 20 Twitter feeds...