Product Variations - Addon Update Issue


I am using product variations and everything works fine.

I have developed a small addon to add an extra field for storing the product barcode for each product variation.

The problem is that every time I update the product barcode for a specific variation all other variations updated also with parent product barcode.

Inside the cscart_products table all variations has a separate record with unique product_id.

I am using the update_product_post php hook to update the barcode for the specific product_id.


function fn_my_addon_update_product_post($product_data, $product_id, $lang_code, $create){
        $update_data = array("product_barcode"=>$_REQUEST["product_data"]["product_barcode"]);
        $barcode_update = db_query("UPDATE ?:products SET ?u WHERE product_id = ?i",$update_data,$product_id);

It seems that something else executed after update_product_post and changes the barcode to all other variations.

Does anyone know how to avoid this ?

Thank you.


Maybe some other add-on you have installed in your store interferes with process?

Try to turn off all other add-ons from external companies and check if issue still persists.

If that won't help, you can also try to not store product_barcode under product_data index. Content from this index is used for a lot of operations, and at some point it may cause incorrect behaviour.

For example, you can store the barcode in variable $_REQUEST["your_addon_id_here"]["product_barcode"].

Best regards,


Hello Robert,

Thank you for your reply.

The addon is on a clean cscart installation for testing purposes.

I've tried with different index but the same result happened !

The only way that is working ok is to store the barcodes to a separate table but is an overkill for something so simple.

I am using the TPL hook update_product_code from update.tpl file inside design/backend/templates/views/products/ and i have noticed that there is a component statement before each field:

                            {component name="configurable_page.field" entity="products" tab="detailed" section="pricing_inventory" field="product_code"}

That describes the field in some way. Does anyone know what exactly the component description do ?


Please set input name in template on product_barcode NOT product_data[product_barcode]

And in function also change code appropriately

Best regards


Hello Robert ,

This is a sample code from the product_code field . I have already used the correct input names inside smarty templates .

Do you know what the components tags do ?

Thank you .


Please show your code from you template with field product_barcode

Best regards


Robert's solution should work. Cs-cart does post-processing on fields related to variations. However, you should be able to do it via he schema. I don't remember the exact schema file, but you can add the 'product_barcode' element to the accepted fields (or remove it from the excluded fields).

Thank you all for your replies,

The solution is to extend the schema from the product_variations addon inside the folder app/addons/product_variations/schemas/product_variations/product_types.php

Everything works ok without the need to detach the data from the normal product_data array.

I hope you actually made the change in the my_changes addon so your change will survive a future upgrade.