If I already have existing product attributes and then use the function below, it removes existing attributes from the product and replaces them with this one attribute.
I only want to update this one attribute value with a new value programmatically.
Do I have to read the existing attributes array with get_post_meta first and update it? I am just trying to find out if there is an alternative method.
function update_internalSKU() {
$product_id = 850;
$product_attributes = array();
$product_attributes['internalSKU'] = array(
'name' => 'internalSKU',
'value' => 'b8de7569042',
'position' => 1,
'is_visible' => 0,
'is_variation' => 0,
'is_taxonomy' => 0
);
update_post_meta( $product_id ,'_product_attributes', $product_attributes);
}
update_internalSKU();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…