[Skip to main content](#vessel-content)

#   Variant code not updating?

##

- **[dc10555](/forum/user/8580-dc10555 "View dc10555's Profile")**
- [![dc10555's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8580-dc10555 "View dc10555's Profile") Topic Author
- [ Offline](/forum/user/8580-dc10555)

Less More

- Posts: 10
- Thank you received: 0
-
-

11 years 9 months ago [\#189070](#189070) by [dc10555](/forum/user/8580-dc10555 "View dc10555's Profile")  *[Variant code not updating?](/forum/3-bug-report/874692-variant-code-not-updating#189070 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Hey guys I have a strange one, I've noticed that when I create a NEW product and save it, then change the product code my variants codes update correctly, However when I copy a product and change the product code the variant code does not update for some reason.  Is there anyway I could fix this as I have a tonne of products I'd like to add which all have the same price and variants, just different images etc so the copy feature is perfect for me.")* was created by *[dc10555](/forum/user/8580-dc10555 "View dc10555's Profile")*

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6

Hey guys I have a strange one, I've noticed that when I create a NEW product and save it, then change the product code my variants codes update correctly, However when I copy a product and change the product code the variant code does not update for some reason.

Is there anyway I could fix this as I have a tonne of products I'd like to add which all have the same price and variants, just different images etc so the copy feature is perfect for me.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzQ2OTItdmFyaWFudC1jb2RlLW5vdC11cGRhdGluZz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

11 years 9 months ago [\#189081](#189081) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Variant code not updating?](/forum/3-bug-report/874692-variant-code-not-updating#189081 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Hey guys I have a strange one, I've noticed that when I create a NEW product and save it, then change the product code my variants codes update correctly, However when I copy a product and change the product code the variant code does not update for some reason.  Is there anyway I could fix this as I have a tonne of products I'd like to add which all have the same price and variants, just different images etc so the copy feature is perfect for me.")*

Hi,

It's because the system which updates the variants code bases itself on the fact that the variants code have a specific format. When you copy a product, it's variants have a _copyXXXX text appended to the variants code which makes it impossible for the system to updates the variants code to do its magic.
Change the line:
$copy-&gt;product_code = $copy-&gt;product_code.'_copy'.rand();
to:
$copy-&gt;product_code = str_replace($this-&gt;template-&gt;product_code,$newProduct-&gt;product_code,$copy-&gt;product_code);
in the file administrator/components/com_hikashop/helpers/import.php and that should avoid the issue for new products you copy after the change.

The following user(s) said Thank You: [dc10555](/forum/user/8580-dc10555 "View dc10555's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzQ2OTItdmFyaWFudC1jb2RlLW5vdC11cGRhdGluZz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[dc10555](/forum/user/8580-dc10555 "View dc10555's Profile")**
- [![dc10555's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8580-dc10555 "View dc10555's Profile") Topic Author
- [ Offline](/forum/user/8580-dc10555)

Less More

- Posts: 10
- Thank you received: 0
-
-

11 years 9 months ago -  11 years 9 months ago [\#189140](#189140) by [dc10555](/forum/user/8580-dc10555 "View dc10555's Profile")  Replied by *[dc10555](/forum/user/8580-dc10555 "View dc10555's Profile")* on topic *[Variant code not updating?](/forum/3-bug-report/874692-variant-code-not-updating#189140 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Hey guys I have a strange one, I've noticed that when I create a NEW product and save it, then change the product code my variants codes update correctly, However when I copy a product and change the product code the variant code does not update for some reason.  Is there anyway I could fix this as I have a tonne of products I'd like to add which all have the same price and variants, just different images etc so the copy feature is perfect for me.")*

> nicolas wrote: Hi,
>
> It's because the system which updates the variants code bases itself on the fact that the variants code have a specific format. When you copy a product, it's variants have a \_copyXXXX text appended to the variants code which makes it impossible for the system to updates the variants code to do its magic.
> Change the line:
> $copy-&gt;product\_code = $copy-&gt;product\_code.'\_copy'.rand();
> to:
> $copy-&gt;product\_code = str\_replace($this-&gt;template-&gt;product\_code,$newProduct-&gt;product\_code,$copy-&gt;product\_code);
> in the file administrator/components/com\_hikashop/helpers/import.php and that should avoid the issue for new products you copy after the change.

Thank so much this worked perfectly! It makes more sense for the system to process stuff like this especially for copying products, might be worth putting it in the next update? ![:P](/media/kunena/emoticons/14.png ":P")

*EDIT*
Ugh, I just realized you can do a mass product import using a preset product template and a CSV, Maybe it might be good idea to highlight this feature a bit more so it stands out as I think it's a little lost down at the bottom.

Last edit: 11 years 9 months ago by [dc10555](/forum/user/8580-dc10555 "View dc10555's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzQ2OTItdmFyaWFudC1jb2RlLW5vdC11cGRhdGluZz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

11 years 9 months ago [\#189156](#189156) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Variant code not updating?](/forum/3-bug-report/874692-variant-code-not-updating#189156 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Hey guys I have a strange one, I've noticed that when I create a NEW product and save it, then change the product code my variants codes update correctly, However when I copy a product and change the product code the variant code does not update for some reason.  Is there anyway I could fix this as I have a tonne of products I'd like to add which all have the same price and variants, just different images etc so the copy feature is perfect for me.")*

It's already applied on our end for next release yes.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84NzQ2OTItdmFyaWFudC1jb2RlLW5vdC11cGRhdGluZz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.054 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
