I'm trying to create an atom as part of a migration but can't seem to get it to create scald_atom. Any ideas?

Comments

jcisio’s picture

I haven't tested, but it should work with Migrate Extras (so that you can use arbitrary entity in the destination). Could you share your code?

khyam’s picture

Have run into a similar issue, trying to create an entity but to no avail.

$entity_type = 'scald_atom';    
$entity = entity_create($entity_type, array('type' => 'image'));
$wrapper = entity_metadata_wrapper($entity_type, $entity);
$wrapper->title = 'Test';
$wrapper->save();

When using dpm() around $entity it is returning empty so it is not creating the actual entity. Have also tried removing the 'entity_metadata_wrapper' and attempted to create my image that way. Is there any way to use entity_create() or is Migrate Extras the only way to go?

gifad’s picture

You can have a look at

function scald_dailymotion_direct_import()

for a straightforward working sample code

jcisio’s picture

Title: How to create an atom programatically » Better support for Entity API to create atom
Status: Active » Fixed

Committed 8a1c1ce for better Entity API integration. Now you can use something like this (don't forget the "provider" property):

$entity = entity_create('scald_atom', array('type' => 'image', 'provider' => 'scald_image'));
$wrapper = entity_metadata_wrapper('scald_atom', $entity);
$wrapper->title = 'Test';
$wrapper->scald_thumbnail->set((array) file_load(3));
$wrapper->save();
khyam’s picture

Status: Fixed » Active

Will check out the dailymotion sample code and will see if i can get it working from that.

jcisio, the entity_create code that you have pasted above returns an error as follows. Have also tried changing some of the other settings but am receiving the same results.

Invalid data value given. Be sure it matches the required data type and format.

**Nevermind had to change the value of the file load id to match files already uploaded. Works, thanks.

khyam’s picture

Status: Active » Fixed

Nevermind had to change the value of the file load id to match files already uploaded. Works, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

anagp’s picture

Issue summary: View changes

I am in the same situation as bjalford was. I am trying to migrate create an atom as part of a migration. I am using migrate_extras as explained in Migration from other solutions. Both solutions (the one explained here and the one in migrate_extras. Use the Entity API method entity_create, however this method is not returning a new entity, it is returning false. Any idea what could be the cause?

This is the code I am using to call it.

<?php
$entity = entity_create('scald_atom', array('type' => 'image', 'provider' => 'scald_image'));
?>

And this is the code of the entity_create method in the Entity API (entity.module)

<?php
function entity_create($entity_type, array $values) {
  $info = entity_get_info($entity_type);
  if (isset($info['creation callback'])) {
    return $info['creation callback']($values, $entity_type);
  }
  elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
    return entity_get_controller($entity_type)->create($values);
  }
  return FALSE;
}
?>
anagp’s picture

The problem in #8 was solved by updating to the last dev version.