Created
September 19, 2014 10:09
-
-
Save claudiu-cristea/d87db7d38002dda60127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->map = new MigrateSQLMap($this->machineName, | |
array( | |
'sku' => array( | |
'type' => 'varchar', | |
'length' => 32, | |
'not null' => TRUE, | |
), | |
'delta' => array( | |
'type' = 'int', | |
'unsigned' => TRUE, | |
'not null' => TRUE, | |
'description' => 'Type of ticket', | |
), | |
), | |
MigrateDestinationEntityAPI::getKeySchema('commerce_product') | |
); | |
... | |
public function prepareRow($row) { | |
... | |
$row->delta = 0; | |
... | |
} | |
... | |
public function prepare($entity, stdClass $row) { | |
for ($delta = 1; $delta <= 7, $delta++) { | |
$variant = entity_create('commerce_product', array( | |
'sku' => $row->wathever, | |
... | |
'property' => $row->foo, | |
... | |
)); | |
commerce_product_save($variant); | |
$source = clone $row; | |
$source->delta = $delta; | |
$this->map->saveIDMapping($source, array($variant->sku)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment