ProductTab.php in Commerce Migrate 8.2
File
modules/csv_example/src/Plugin/migrate/source/ProductTab.php
View source
<?php
namespace Drupal\commerce_migrate_csv_example\Plugin\migrate\source;
use Drupal\migrate_source_csv\Plugin\migrate\source\CSV;
class ProductTab extends CSV {
public function initializeIterator() {
$file = parent::initializeIterator();
return $this
->getYield($file);
}
public function getYield(\Generator $file) {
foreach ($file as $row) {
for ($i = 1; $i < 3; $i++) {
if (!empty($row["tab_title{$i}"]) || !empty($row["tab_content{$i}"]) || !empty($row["tab_content{$i}"])) {
$new_row = $row;
$new_row['tab_title'] = trim($row["tab_title{$i}"]);
$new_row['tab_content'] = trim($row["tab_content{$i}"]);
$new_row['tab_cta'] = trim($row["tab_cta{$i}"]);
(yield $new_row);
}
}
}
}
}
Classes
Name |
Description |
ProductTab |
Yields values for each product tab paragraph. |