Hi,
A product (main or variant) must have a product code which will be unique.
So you can't read it from the main product if not specified because it will be specified.
You have to use a similar product code in the variants so while searching the main product code, it will found the variants too.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.