class TagTerm in Commerce Migrate 3.1.x
Same name and namespace in other branches
- 8.2 modules/woocommerce/src/Plugin/migrate/source/woo3/TagTerm.php \Drupal\commerce_migrate_woocommerce\Plugin\migrate\source\woo3\TagTerm
- 3.0.x modules/woocommerce/src/Plugin/migrate/source/woo3/TagTerm.php \Drupal\commerce_migrate_woocommerce\Plugin\migrate\source\woo3\TagTerm
Yields each taxonomy term and vocabulary pair.
The cell containing the WooCommerce 3 Tags is a comma separated list of the tags assigned to the product variation in this row.
Example:
Fleece, Organic cotton
In this case, the terms 'Fleece' and 'Organic Cotton' will be added to the Tags vocabulary.
Plugin annotation
@MigrateSource(
id = "woo3_tag_term_csv"
)
Hierarchy
- class \Drupal\commerce_migrate_woocommerce\Plugin\migrate\source\woo3\TagTerm extends \Drupal\migrate_source_csv\Plugin\migrate\source\CSV
Expanded class hierarchy of TagTerm
File
- modules/
woocommerce/ src/ Plugin/ migrate/ source/ woo3/ TagTerm.php, line 24
Namespace
Drupal\commerce_migrate_woocommerce\Plugin\migrate\source\woo3View source
class TagTerm extends CSV {
/**
* {@inheritdoc}
*/
public function initializeIterator() {
$file = parent::initializeIterator();
return $this
->getYield($file);
}
/**
* Prepare one row per taxonomy term field in the source.
*
* @param \Generator $file
* The source CSV file object.
*
* @codingStandardsIgnoreStart
*
* @return \Generator
* A new row with one taxonomy term.
*
* @codingStandardsIgnoreEnd
*/
public function getYield(\Generator $file) {
foreach ($file as $row) {
$new_row = $row;
$tags = explode(',', $row['Tags']);
foreach ($tags as $tag) {
$new_row['name'] = trim($tag);
(yield $new_row);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TagTerm:: |
public | function | Prepare one row per taxonomy term field in the source. | |
TagTerm:: |
public | function |