You are here

Product.php in Commerce Migrate 8.2

File

modules/ubercart/src/Plugin/migrate/source/uc6/Product.php
View source
<?php

namespace Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc6;

use Drupal\migrate\Row;
use Drupal\node\Plugin\migrate\source\d6\Node;

/**
 * Ubercart 6 product source.
 *
 * @MigrateSource(
 *   id = "uc6_product",
 *   source_module = "uc_product"
 * )
 */
class Product extends Node {

  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = parent::query();
    $query
      ->innerJoin('uc_products', 'ucp', 'n.nid = ucp.nid AND n.vid = ucp.vid');
    $query
      ->fields('ucp', [
      'model',
      'sell_price',
    ]);
    if (isset($this->configuration['node_type'])) {
      $query
        ->condition('n.type', $this->configuration['node_type']);
    }
    return $query;
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    $fields = [
      'model' => $this
        ->t('Product model'),
      'sell_price' => $this
        ->t('Sell price of the product'),
      'name' => $this
        ->t('Node type'),
      'stores' => $this
        ->t('Stores'),
    ];
    return parent::fields() + $fields;
  }

  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    $row
      ->setSourceProperty('stores', 1);
    return parent::prepareRow($row);
  }

}

Classes

Namesort descending Description
Product Ubercart 6 product source.