public function CategoriesTerm::getYield in Commerce Migrate 3.0.x
Same name and namespace in other branches
- 8.2 modules/woocommerce/src/Plugin/migrate/source/woo3/CategoriesTerm.php \Drupal\commerce_migrate_woocommerce\Plugin\migrate\source\woo3\CategoriesTerm::getYield()
- 3.1.x modules/woocommerce/src/Plugin/migrate/source/woo3/CategoriesTerm.php \Drupal\commerce_migrate_woocommerce\Plugin\migrate\source\woo3\CategoriesTerm::getYield()
Prepare one row per taxonomy term field in the source.
@codingStandardsIgnoreStart
@codingStandardsIgnoreEnd
Parameters
\Generator $file: The source CSV file object.
Return value
\Generator A new row with a taxonomy term and it's parent.
1 call to CategoriesTerm::getYield()
- CategoriesTerm::initializeIterator in modules/
woocommerce/ src/ Plugin/ migrate/ source/ woo3/ CategoriesTerm.php
File
- modules/
woocommerce/ src/ Plugin/ migrate/ source/ woo3/ CategoriesTerm.php, line 50
Class
- CategoriesTerm
- Yields each taxonomy term in the Categories column.
Namespace
Drupal\commerce_migrate_woocommerce\Plugin\migrate\source\woo3Code
public function getYield(\Generator $file) {
foreach ($file as $row) {
$new_row = $row;
$categorySet = explode(',', $row['Categories']);
foreach ($categorySet as $category) {
$names = explode('>', $category);
$previous_name = 0;
// Build a row for each term name.
foreach ($names as $name) {
$new_row['parent'] = $previous_name;
$previous_name = trim($name);
$new_row['name'] = trim($name);
(yield $new_row);
}
}
}
}