public function ProductAttributeValue::getYield in Commerce Migrate 3.1.x
Same name and namespace in other branches
- 8.2 modules/magento/src/Plugin/migrate/source/magento2/ProductAttributeValue.php \Drupal\commerce_migrate_magento\Plugin\migrate\source\magento2\ProductAttributeValue::getYield()
- 3.0.x modules/magento/src/Plugin/migrate/source/magento2/ProductAttributeValue.php \Drupal\commerce_migrate_magento\Plugin\migrate\source\magento2\ProductAttributeValue::getYield()
Prepare one row per attribute and option.
@codingStandardsIgnoreStart
@codingStandardsIgnoreEnd
Parameters
\Generator $file: The source CSV file object.
Return value
\Generator A new row, one for each attribute and option pair.
1 call to ProductAttributeValue::getYield()
- ProductAttributeValue::initializeIterator in modules/
magento/ src/ Plugin/ migrate/ source/ magento2/ ProductAttributeValue.php
File
- modules/
magento/ src/ Plugin/ migrate/ source/ magento2/ ProductAttributeValue.php, line 49
Class
- ProductAttributeValue
- Yields each product attribute and one option..
Namespace
Drupal\commerce_migrate_magento\Plugin\migrate\source\magento2Code
public function getYield(\Generator $file) {
foreach ($file as $row) {
$new_row = [];
$attributeSet = explode(',', $row['additional_attributes']);
foreach ($attributeSet as $set) {
$tmp = explode('=', $set);
if (isset($tmp[1])) {
$new_row['attribute'] = $tmp[0];
$options = preg_split("/[\"|\"\\|\"]/", $tmp[1], NULL, PREG_SPLIT_NO_EMPTY);
foreach ($options as $option) {
$new_row['name'] = $option;
if ($this
->rowUnique($new_row)) {
(yield $new_row);
}
}
}
}
}
}