TransWikia.com

Migrating categories from Entry to Asset

Craft CMS Asked by evvvvritt on October 29, 2020

Is it possible to migrate content like categories from an entry to an asset easily?

Each entry has an image asset and I’d like to move all the categories on the entry to the asset.

Would this require a SQL operation or is there any easier way?

One Answer

I would probably do this in two steps:

  1. Create a twig file formatted as a CSV that outputs the category and asset id's, i.e.
AssetId, Category<br>
{% for entry in entries %}
{{ entry.asset.one().id }}, {% for category in categories %}{{ category.id }}{% if not loop.last %}-|-{% endif %}{% endfor %}<br>
{% endfor %}
  1. Use feed me to re-import the categories onto the assets using the CSV.

Correct answer by dmatthams on October 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP