This SQL script is used to duplicate existing products from a base unit category (e.g., standard "Washing") into a new unit category (e.g., "Washing Urgent").
What the script does automatically:
sale_price and rsp_with_tax for the new items.You must change the following three variables at the top of the script before executing it:
| Variable | Description | Example |
|---|---|---|
| @a | The current maximum barcode number. The script will add +1 to this number for every new product. | 889994 |
| @where_unit | The Source Unit ID. This is the unit you are copying data from. | 2 (e.g., Normal Washing) |
| @new_unit | The Destination Unit ID. This is the unit you are copying data to. | 7 (e.g., Urgent Washing) |
Copy and paste the code below into your database manager. Always ensure you have updated the variables for your specific task.
-- 1. Set your variables here
SET @a:=889994;
SET @where_unit:=2;
SET @new_unit:=7;
-- 2. Execute the duplication
INSERT INTO aip_product_unit (product_id, barcode, unit_id, eq_to_base, sale_price, minimum_sale_rate, mrp, multi_unit_qty, multi_base_unit_qty, unit_item_description, unit_item_description_short, packing_description, rsp_with_tax, price_change, modified_user, status)
SELECT
product_id,
@a:=@a+1,
@new_unit,
eq_to_base,
sale_price + sale_price,
minimum_sale_rate,
mrp,
multi_unit_qty,
multi_base_unit_qty,
unit_item_description,
unit_item_description_short,
packing_description,
rsp_with_tax + rsp_with_tax,
price_change,
modified_user,
status
FROM aip_product_unit
WHERE unit_id = @where_unit;
sale_price + sale_price. If you need a different markup (e.g., a 50% increase), you will need to adjust those specific lines in the SELECT statement to something like sale_price * 1.5.