Get item references - podio

Using get item references returns just a few fields of the app item. If I then use Get item by app_item_id to drill down to all of the fields.
Is there a more efficient way of doing this so that I can just use one call instead of multiple calls to get the details of a referenced object? At the moment, the plan is to repeat the same calls for each of the referenced items.
Use case is that I have an 'Invoice' item in Podio, with one or more referenced 'Inventory' items. I am using this data to push those items through to Xero as seperate line items.
Thanks

Please bundle responses (that's super powerful technique to reduce number of requests). You can read more about bundling responses here: https://developers.podio.com/index/api (scroll page down)
Ruby example
item_id = <some item id>
item = Podio::Item.find(item_id, {'fields' => 'refs'})
puts item['refs']

Related

How to store system-created to-do list items?

In a to-do list where users have both system-created items and their own items, how would you store the items?
A to-do list can have a mix of items. The system-created items can be modified and deleted just like user-created items. There difference is the titles and description text for the system-created items are initially pulled from a configuration. Many users can have the same system-created items. E.g. if two users want to paint rooms in their houses, they'd both get "buy paint" items.
Option 1
Save the full system-created items (including the title & text) with the user-created items.
Pros: Flexibility for user modifications since the items belong to the user and are not dependent on a central item configuration.
Cons: Lots of redundancy because there will be many users all with the same items.
Option 2
Save references to a configuration for system-created items with the user-created items.
Pros: Flexibility for system modifications since if we want to say "buy X-brand paint" instead of "buy paint", the change is easily reflected for all users with this item.
Cons: System-created items have to persist forever in the configuration even if the item is no longer relevant for new to-do lists because otherwise the user's reference will be broken.
Other options?
Thank you!
My initial thought is - what is your requirement? Your user-flows and project road-map might contain information to inform your design.
From your question "system-created items can be modified and deleted just like user-created items":
This indicates that you are going to have to have a way to track modifications to your 'system-created' templates per user or convert them to 'user-created' messages when they are edited.
This is more complexity than you seem to need
It seems much simpler to create messages from system templates, then have them be regular messages.
A bit of extra storage is not going to break the bank
You have not mentioned any case where you would need to operate over only system-created to-do's. But in this case, you could include created-by metadata.
I think the key here is whether you need to be able to modify a "system todo", and that change to be reflected in all the "user todos"...
If that's a requirement (it sounds sensible to me), your only option is Option 2 - the real con of Option 1 is once you copied the "system todo" as a "user todo", you cannot tell anymore whether they're related...
I'd go for a model similar to this, with 2 entities/tables:
ToDoTemplate
Integer id
String name
String description
ToDoItem
Integer id
ToDoTemplate template
Boolean completed = false
?String name = null
?String description = null
When you create a ToDoItem, you create it based on a ToDoTemplate (it may be a blank template), and you set the name and description as null, reusing the template name/description... Only if the user modifies their own ToDoItem is when you store that value... i.e.
String getName() {
return this.name != null ? this.name : this.template.name;
}
This is the most flexible of the approaches, and the only valid in many situations... Note the con you mention:
Cons: System-created items have to persist forever in the configuration even if the item is no longer relevant for new to-do lists because otherwise the user's reference will be broken.
This is not a con really - as long as there's one ToDoItem that uses a given ToDoTemplate, the template is still relevant, and of course there's no reason to remove it...

Sitecore REST API search By Navigation Category

I am working on building a REST API based connector to a marketplace which uses sitecore. I have found the documentation for using the search API command here:
https://sdn.sitecore.net/upload/sitecore6/65/sitecore_search_and_indexing_sc60-65-a4.pdf
I have been unable to figure out how to use it to search for content that is grouped into a navigation category, and was unsure if there was a good way to do this. I did not design the site, and the designers were contractors who are no longer working with us.
I would like to be able to find a list of items based on a specific navigation category that has been assigned to them. I have tried getting the children of the category ID itself, but that did not work. Here is a picture of the navigation category associated with a given object in case it adds clarification:
enter image description here
Is there an easy way to search for items like this?
Going with the assumption that you are on 7.2 or above, you just need to search for items that have the ID of the Navigation Categorization field (in your index as navigation_categorization) that are set to the ID of the item you wish to filter on. In your image, it would be the ID of "connectivity services" item.
var context = ContentSearchManager.GetIndex("master").CreateSearchContext();
var computedLanguage = Sitecore.Context.Language.CultureInfo.Name;
// get the iBuild items
var results = context.GetQueryable<SearchResultItem>()
.Where(i => i["navigation_categorization"].Contains([connectivity services ID])
&& i.Language == computedLanguage)
.GetResults()
.Hits.Select(x => x.Document.GetItem(
));

How to get the relist history for a given item id?

That is. When a listing has ended, but it was relisted (and hence, a new item id exists), you get the message...
This listing has ended. The seller has relisted this item or one like this.
...at the top of the page, with a link to the new listing.
So, starting from the original listing, one could get the whole chain of item id's just by following those links.
My question is, is there a way to programmatically get this history of relists? If not the full history, a way to get the ancestor/parent or descendant/child listing for a given item would be enough.
Thanks for your help. :)
you'll want to use the Item.ListingDetails.RelistedItemID property of the parent item that has ended. See http://developer.ebay.com/devzone/xml/docs/reference/ebay/getitem.html#Response.Item.ListingDetails.RelistedItemID for details and https://ebay-sdk.intradesys.com/s/d9d4f495e875a2e075a1a4a6e1b9770f for an example.
HTH, --Andreas

Magento API Rest filters

So I have this piece of code below which will sucessfully pull a product and give the XML data for my magento store...
http://mywebsite.com/api/rest/products?type=rest&filter[1][attribute]=name&filter[1][in]=test%20product%20name
However, it will ONLY pull up the product info if I make the product name perfect. If I try to just put in
http://mywebsite.com/api/rest/products?type=rest&filter[1][attribute]=name&filter[1][in]=test
It will not bring ANY products. It was my understanding that if I used the "[in]" filter that it should bring up all products containing the "test" word but it doesnt...
in - "equals any of" - returns items that are equal to the item(s) with the specified attribute(s)
Try to use 'like' ...
http://mywebsite.com/api/rest/products?type=rest&filter[1][attribute]=name&filter[1][like]=%test%

Kentico Ecommerce: getting top selling categories

I am using Kentico 7.0, ecommerce version.
I would like to create a sidebar menu that shows the eshop's top selling product categories. I am a kentico newbie so I am looking around for the correct terminology/guidance so that I can dig deeper.
The ideal approach in my opinion would be to be able to add a field on categories, which is used to filter categories for the menu. This way I can either have some kind of job that updates the fields automatically based on sales, OR provide a manual override for an admin to specify whether a category will show up on the menu. Of course some kind of weight would also be needed to specify menu item ordering.
Which way should I look?
HAve you tried using the "Top N products by sales" web part that is available? you can configure from which part of the content tree (products) it should pull the data - in the Path property you can use also a path expression or macro that is resolved dynamically so the web part can display different products in different sections.
There are many ways to code for Kentico. I personally find the API is a bit clunky and on quite a few occasions I was surprised that a method didn't exist requiring extra calls to get the required results. I do use the Kentico API more when putting data in to Kentico. Pulling it out I use the following.
STORED PROC
Write a SQL stored procedure to get the top X categories - GetTop5Categories.
Look at the COM_* tables, specifically COM_OrderItem, linking OrderItemSKUID back to COM_SKU (or View_COM_SKU_Joined if you need to get to the IA).
This will get you the top selling products with a group by, a count, a top X and an order by.
Then you can link to other tables such as CMS_Category or CMS_Document (depending on how you setup your categories). The bonus of this is that procs are compiled, you do all your data manipulation there (it's what MSSQL specialises in!) and you only send back what you need to in the result set.
DOMAIN (leveraging EF)
I usually create a separate class library project myproject.domain and put an Entity Framework edmx in there mapped back to the Kentico DB. Add the proc to the EDMX, then create a Function Import MyProject_GetTop5Categories from your newly imported proc.
WEB
add a reference to the domain project from your web project, and a 'using at the top of the codebehind of the control.
using myproject.domain;
then in Page_Load for the control:
...
if(!IsPostBack)
{
var entities = new MyProjectModelContainer();
var list = entities.MyProject_GetTop5Categories().ToList();
StringBuilder sb = new StringBuilder("<ul>");
foreach(var category in list)
{
sb.Append("<li><a href='"+category.Link+"'>" + category.Name + "</a></li>");
}
sb.Append("<ul>");
listPlaceHolder = sb.ToString();
}
handwritten so probably a typo or two in there :)
HTH