# Merge objectcontainer (oc)

**URL:** <https://forums.plex.tv/t/merge-objectcontainer-oc/57871>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [February 19, 2014, 11:15am UTC](https://forums.plex.tv/t/merge-objectcontainer-oc/57871 "2014-02-19T11:15:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![realriot](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@realriot](https://forums.plex.tv/u/realriot)\
**Post date:** [February 19, 2014, 11:15am UTC](https://forums.plex.tv/t/merge-objectcontainer-oc/57871/1 "2014-02-19T11:15:52Z")

</div>

Hi,

&nbsp;

I got 2 different oc (objectcontainer) from 2 functions. To display the content (mainmenu) I have to merge these 2 container.&nbsp;

&nbsp;

Is there any easy way to merge them into one? Trying to iterate with them didn't work. Any hints?

Greets

Sascha

---

<div class="post-metadata">

**Author:** ![greeeny101](https://avatars.discourse-cdn.com/v4/letter/g/e274bd/32.png) [@greeeny101](https://forums.plex.tv/u/greeeny101)\
**Post date:** [February 19, 2014, 11:50am UTC](https://forums.plex.tv/t/merge-objectcontainer-oc/57871/2 "2014-02-19T11:50:58Z")

</div>

Could you do something like   
  
  
oca.items = oca.items.extend(ocb.items)  
  
That will append one on to the other, assuming my syntax is correct that is 🙂  
  
  
Sent from my HTC One using Tapatalk

---

<div class="post-metadata">

**Author:** ![realriot](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@realriot](https://forums.plex.tv/u/realriot)\
**Post date:** [February 19, 2014, 12:23pm UTC](https://forums.plex.tv/t/merge-objectcontainer-oc/57871/3 "2014-02-19T12:23:06Z")

</div>

Nope, does not work....

> AttributeError: 'MediaContainer' object has no attribute 'items'

---

<div class="post-metadata">

**Author:** ![Gerk](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/gerk/32/81980_2.png) [@Gerk](https://forums.plex.tv/u/Gerk)\
**Post date:** [February 21, 2014, 3:41pm UTC](https://forums.plex.tv/t/merge-objectcontainer-oc/57871/4 "2014-02-21T15:41:20Z")

</div>

I would personally probably change up the way you are doing things, I've never had the need to merge multiple object containers for one menu item .. it sounds like you're doing something a bit funky there to be honest ...

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [February 21, 2014, 5:39pm UTC](https://forums.plex.tv/t/merge-objectcontainer-oc/57871/5 "2014-02-21T17:39:35Z")

</div>

It is possible if you do it like this:

```
def SomeFunction:
	oc = ObjectContainer()

```
oc.extend(OtherFunction())
oc.extend(YetAnotherFunction())

return oc

```

def OtherFunction():  
oc = ObjectContainer()  
oc.add(…)  
return oc

def YetAnotherFunction():  
oc = ObjectContainer()  
oc.add(…)  
return oc
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 21, 2019, 1:21am UTC](https://forums.plex.tv/t/merge-objectcontainer-oc/57871/6 "2019-12-21T01:21:03Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
