<p><a href="https://github.com/craftcms/cms/pull/4404" rel="nofollow noreferrer">https://github.com/craftcms/cms/pull/4404</a></p>

<p>You can now delete objects that implement ElementInterface using this method:</p>

<pre><code>craft\services\Elements::mergeElements()
</code></pre>

CC BY-SA 4.0
2019-08-16T09:02:19.327Z
2019-08-16T09:02:19.327Z
tim-pixeldeluxe
<p>Is there any way to merge trashed elements with an existing element? I'm creating a custom restore action so you can merge a trashed (commerce) Product with an existing one. The mergeElementsByIds function is failing because it uses the getElementById function which ignores trashed elements. Is there any work around?</p>

<p>Thanks in advance!</p>

<plugin-development><plugin-craftcommerce2><merge><element>
Merge trashed element with existing one
# Merge trashed element with existing one

(Asked by: username_0 on 2019-05-27)

Is there any way to merge trashed elements with an existing element? I'm creating a custom restore action so you can merge a trashed (commerce) Product with an existing one. The mergeElementsByIds function is failing because it uses the getElementById function which ignores trashed elements. Is there any work around?

Thanks in advance!

**Tags:** plugin-development, plugin-craftcommerce2, merge, element


---

## 1 answers

### Answer by username_0 on 2019-08-16. Score: 1

https://github.com/craftcms/cms/pull/4404
You can now delete objects that implement ElementInterface using this method:
craft\services\Elements::mergeElements()


---

