private function Product::getVariations in Commerce Migrate 8.2
Same name and namespace in other branches
- 3.1.x modules/magento/src/Plugin/migrate/source/m2/Product.php \Drupal\commerce_migrate_magento\Plugin\migrate\source\m2\Product::getVariations()
- 3.0.x modules/magento/src/Plugin/migrate/source/m2/Product.php \Drupal\commerce_migrate_magento\Plugin\migrate\source\m2\Product::getVariations()
Returns an array of product SKUs for the variations of this product.
If this product is a variation the return array contains the SKUs for all product variations of the product.
Parameters
array $row: The current row.
Return value
array An array of variation SKUs.
1 call to Product::getVariations()
- Product::getYield in modules/
magento/ src/ Plugin/ migrate/ source/ m2/ Product.php - Prepare one row of product data.
File
- modules/
magento/ src/ Plugin/ migrate/ source/ m2/ Product.php, line 96
Class
- Product
- Gets the product rows.
Namespace
Drupal\commerce_migrate_magento\Plugin\migrate\source\m2Code
private function getVariations(array $row) {
static $searched = [];
$search_sku = strstr($row['sku'], '-', TRUE);
if (!$search_sku) {
$search_sku = $row['sku'];
}
if (isset($searched[$search_sku])) {
$variations = $searched[$search_sku];
}
else {
if (ctype_alpha($search_sku[0])) {
$pattern = "/" . $search_sku . ".*/";
$subject = $this->fileData['all_sku'];
$variations = preg_grep($pattern, $subject);
// Exclude the search pattern, it is likely the 'configurable' product
// SKU.
$variations = array_diff($variations, [
$search_sku,
]);
$searched[$search_sku] = $variations;
}
else {
$variations = [
$row['sku'],
];
}
}
return $variations;
}