-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wp_all_import_parsed_product_attributes #58
Comments
Here's an example of how to use it: add_filter("wp_all_import_parsed_product_attributes", "wpai_wp_all_import_parsed_product_attributes", 10, 3);
/**
* Filter product attributes.
* @param array $attributes - Parsed product attributes
* [
* 'name' => string, 'value' => string, 'in_taxonomy' => bool, 'is_create_taxonomy_terms' => bool, 'is_visible' => bool, 'in_variation' => bool
* ]
* @param int $pid - Product ID
* @param int $import_id
*/
function wpai_wp_all_import_parsed_product_attributes($attributes, $pid, $import_id) {
// Here's the example attribute layout https://d.pr/i/bcVI5v
// hold new attributes
$new_attributes = array();
// process each attribute row one by one
foreach($attributes as $attribute ){
// split the individual names and values
$names = explode('|', $attribute['name']);
$values = explode('|', $attribute['value']);
foreach( $names as $key => $name ){
$temp = array();
$temp['name'] = $name;
$temp['value'] = isset($values[$key]) ? $values[$key] : '';
$temp['in_taxonomy'] = $attribute['in_taxonomy'];
$temp['is_create_taxonomy_terms'] = $attribute['is_create_taxonomy_terms'];
$temp['in_variation'] = $attribute['in_variation'];
$temp['is_visible'] = $attribute['is_visible'];
$new_attributes[] = $temp;
}
}
return $new_attributes;
} |
Hello guys. Please note that the above code has a bug. The visible field is missing.
|
Hi @dimmisel, Thanks for pointing that out! ( This was generalized from some project code where the visibility was set elsewhere and I missed adding it back in ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WooCo Add-On 3.0.7+
This allows for the use of delimited Attribute names and values, but you must write the custom code to process those values and return them to WP All Import.
The text was updated successfully, but these errors were encountered: