BillingProfile.php in Commerce Migrate 3.0.x
File
modules/commerce/src/Plugin/migrate/source/commerce1/BillingProfile.php
View source
<?php
namespace Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
class BillingProfile extends FieldableEntity {
const JOIN = 'cp.revision_id = cpr.revision_id';
public function fields() {
return [
'profile_id' => $this
->t('Profile ID'),
'revision_id' => $this
->t('Revision ID'),
'type' => $this
->t('Type'),
'uid' => $this
->t('Owner'),
'status' => $this
->t('Status'),
'created' => $this
->t('Created timestamp'),
'changed' => $this
->t('Modified timestamp'),
'data' => $this
->t('Data blob'),
'cadtype' => $this
->t('Type, if matching entry in defaults table'),
];
}
public function getIds() {
$ids['profile_id']['type'] = 'integer';
$ids['profile_id']['alias'] = 'cp';
return $ids;
}
public function query() {
$query = $this
->select('commerce_customer_profile', 'cp')
->fields('cp')
->condition('cp.type', 'billing');
if ($this
->getDatabase()
->schema()
->tableExists('commerce_addressbook_defaults')) {
$query
->leftJoin('commerce_addressbook_defaults', 'cad', 'cp.profile_id = cad.profile_id AND cp.uid = cad.uid AND cp.type = cad.type');
$query
->addField('cad', 'type', 'cad_type');
}
return $query;
}
public function prepareRow(Row $row) {
$profile_id = $row
->getSourceProperty('profile_id');
$revision_id = $row
->getSourceProperty('revision_id');
foreach (array_keys($this
->getFields('commerce_customer_profile', $row
->getSourceProperty('type'))) as $field) {
$row
->setSourceProperty($field, $this
->getFieldValues('commerce_customer_profile', $field, $profile_id, $revision_id));
}
return parent::prepareRow($row);
}
}
Classes
Name |
Description |
BillingProfile |
Gets Commerce 1 commerce_customer_profile source from database. |