Hi @ricardogrune,
Thanks for your post and for using ATUM.
The plugin stores all the ATUM fields in custom tables for performance reasons. That implies you can’t access the EAN field by accessing the products’ post meta fields.
To access ATUM properties, you’d need some custom code like:$product = \Atum\Inc\Helpers::get_atum_product( $product_id );
$ean = $product->get_barcode();
$purchase_price = $product->get_purchase_price(); ...
SKU is a WooCommerce’s field and you can access it by default.
Hope this helps,
Best Regards,
José Andrés
Hi Jose,
I already fixed it with this:
function update_product_meta_data() {
global $wpdb;
// Selecteer alle producten met een barcode en supplier_sku
$query = "SELECT product_id, barcode, supplier_sku FROM wp_atum_product_data WHERE barcode IS NOT NULL OR supplier_sku IS NOT NULL";
$products_with_meta = $wpdb->get_results($query);
foreach ($products_with_meta as $product) {
// Update of voeg barcode meta toe
if (!empty($product->barcode)) {
$current_barcode = get_post_meta($product->product_id, 'barcode', true);
if ($current_barcode !== $product->barcode) {
update_post_meta($product->product_id, 'barcode', $product->barcode);
}
}
// Update of voeg supplier_sku meta toe
if (!empty($product->supplier_sku)) {
$current_sku = get_post_meta($product->product_id, 'supplier_sku', true);
if ($current_sku !== $product->supplier_sku) {
update_post_meta($product->product_id, 'supplier_sku', $product->supplier_sku);
}
}
}
}
add_action(‘woocommerce_update_product’, ‘update_product_meta_data’);