Create a PODIO item with relationship with podio api for PHP - podio

How can we create an item and relate it to other items (setting the values on a relationship field)? I found no examples regarding those fields.

Just found how to do it.
1) Get the 'item_id' value for the app item you want to relate to in the parent application.
$item_id = $item->item_id;
2) Use the item_id on the child application relationship field.
new PodioAppItemField(array("external_id" => "my_rel_field", "values" => array( 'item_id' => $item_id)))

Related

Podio App Create not respecting Field external_id

I'm running into an issue with the Podio App Create API call:
https://developers.podio.com/doc/applications/add-new-app-22351
It does not appear to respect external_id for fields.
For example, given:
...
[fields] => Array
(
[0] => Array
(
[type] => text
[external_id] => title
[config] => Array
(
[label] => Name
...
The resulting field will have an external id of "name" and not "title".
This is a rather big issue as when trying to make exact copies of apps (into places that clone won't go), the change in field ids causes GF flows to break.
Any way around this?
Per the API documentation there is no "external_id" input in this call. The external IDs are always a standardized version of the field label though. (e.g. if you have 2 Name fields the first will be "name" and the second will be "name-2").
Alternatively, you could just run "get app" https://developers.podio.com/doc/applications/get-app-22349 to see what the external IDs ended up being.

Create product with assign collection in shopify

I have tried to create product in myshopify with help of below parameter.Product is creating in myshopify admin but the collection is not assign so kindly let met know how can I assign collection with this.
"product"=> array(
"title"=> $product->getName(),
"body_html"=> $product->getDescription(),
"vendor"=> "Troupe",
"product_type"=>"",
"collection_ids" => array('31231','231312'),
"published"=> true ,
"variants"=> array(
array(
"price"=> ($product->getPrice()),
"sku"=> $product->getsku()
)
),
"images"=> $images
)
);
You can't create a product and assign it to a collection in a single REST API call.
The best you can do is create the product first and upon its success, create a "collect", which is a mapping between a collection and a product.
See this API page for info on how to do that, Custom collection update.

Get multiple items of multiple apps in podio api

Can i retrieve all the items in my filter which is under multiple apps which has same app name in podio api.
Example scenario:
I have two work space. Both work space have Deliverable app. I want to get all items in Deliverable from both work space, and i want to filter through it.
I can get items in an app by :
PodioItem::filter( $app_id, $attributes = array(), $options = array() );
is there a way like:
PodioItems::filter(array($multiple_app_id), $attributes = array(), $options = array() );
No. The API filter operation doesn't support passing multiple app ids. You'll have to make a separate call for each app that you'd like to retrieve items, regardless of the workspace.

How to get n records from a Yii data provider?

I have a model which has the following relationship declared:
'messages' => array(self::HAS_MANY, 'WallMessages', 'liga_id',
'condition'=>'specific_post.parent_message_id IS NULL',
'order'=>'specific_post.date DESC',
'alias'=>'specific_post'),
Im trying to use this collection within a CListView with a custom pagination. However, if for example my pages are of size 5, i need to get from elements 5 through 10 to populate the view.. How can i get n elements from a defined relationship?
you can use model's serach() or custom CDbCriteria yourself.
CDbCriteria

Mapping a child collection without indexing based on database primary key or using bag

I have a existing parent-child relationship I am trying to map in Fluent Nhibernate:
[RatingCollection] --> [Rating]
Rating Collection has:
ID (database generated ID)
Code
Name
Rating has:
ID (database generated id)
Rating Collection ID
Code
Name
I have been trying to figure out which permutation of HasMany makes sense here. What I have right now:
HasMany<Rating>(x => x.Ratings)
.WithTableName("Rating")
.KeyColumnNames.Add("RatingCollectionId")
.Component(c => { c.Map(x => x.Code);
c.Map(x => x.Name); );
It works from a CRUD perspective but because it's a bag it ends up deleting the rating contents any time I try to do a simple update / insert to the Ratings property. What I want is an indexed collection but not using the database generated ID (which is in the six digit range right now).
Any thoughts on how I could get a zero-based indexed collection (so I can go entity.Ratings[0].Name = "foo") which would allow me to modify the collection without deleting/reinserting it all when persisting?
First of all, you're using an old version of Fluent NHibernate; WithTableName has been deprecated in favor of Table.
An IList can be accessed by index so a Bag should work. I'm not sure why you have mapped Rating as a Component or what the effect of that is. This is a standard collection mapping:
HasMany(x => x.Ratings).KeyColumn("RatingCollectionId")
.Cascade.AllDeleteOrphan().Inverse()
.AsBag().LazyLoad();