public function ProfileBilling::prepareRow in Commerce Migrate 3.1.x
Same name and namespace in other branches
- 8.2 modules/ubercart/src/Plugin/migrate/source/ProfileBilling.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\ProfileBilling::prepareRow()
- 3.0.x modules/ubercart/src/Plugin/migrate/source/ProfileBilling.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\ProfileBilling::prepareRow()
Adds additional data to the row.
Parameters
\Drupal\migrate\Row $row: The row object.
Return value
bool FALSE if this row needs to be skipped.
Overrides SourcePluginBase::prepareRow
File
- modules/
ubercart/ src/ Plugin/ migrate/ source/ ProfileBilling.php, line 89
Class
- ProfileBilling
- Ubercart billing profile source.
Namespace
Drupal\commerce_migrate_ubercart\Plugin\migrate\sourceCode
public function prepareRow(Row $row) {
$row
->setSourceProperty('data', unserialize($row
->getSourceProperty('data')));
// Determine if this is the last revision.
$modified = (int) $row
->getSourceProperty('modified');
$uid = (int) $row
->getSourceProperty('uid');
$query = $this
->select('uc_orders', 'uo')
->condition('uid', $uid)
->condition('modified', $modified, '>');
$query
->addExpression('COUNT(uo.uid)', 'count');
$results = $query
->execute()
->fetchField();
// If there are no more revisions then mark as active and as default.
if ($results === '0') {
$row
->setSourceProperty('status', 1);
$row
->setSourceProperty('is_default', TRUE);
}
else {
$row
->setSourceProperty('status', 0);
$row
->setSourceProperty('is_default', NULL);
}
return parent::prepareRow($row);
}