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

#   Change / customize how product cloning works

##

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

10 years 11 months ago [\#222438](#222438) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#222438 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")* was created by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")*

-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.45

When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.

Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.

Also I would like to change which fields get copied and which don't.

where can I change this settings?

Thank you.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgwNzk0LWNoYW5nZS1jdXN0b21pemUtaG93LXByb2R1Y3QtY2xvbmluZy13b3Jrcz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

10 years 11 months ago [\#222469](#222469) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#222469 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

Hi,

There are no such settings.
It is handled by the function copyProduct of the file administrator/components/com_hikashop/helpers/import.php
So if you wanted to change its behavior, you would have to change the code of that function.

The following user(s) said Thank You: [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")

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

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

10 years 11 months ago [\#222564](#222564) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#222564 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

I will go for it.

Thank you!

Could be a good idea for future releases to create some extra control in the fields (similar to the custom fields interface) where you could checkbox this as if you want it to be cloned or not.

Best regards,

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgwNzk0LWNoYW5nZS1jdXN0b21pemUtaG93LXByb2R1Y3QtY2xvbmluZy13b3Jrcz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

10 years 11 months ago [\#222670](#222670) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#222670 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

Hi,

Well, you could potentially use the import system using the "product template" system. It actually goes through roughly the same code and thanks to the product template and the CSV, you can choose what you want to get from the template product and what you want to get from the CSV by just specifying what you want from the CSV in the CSV. The rest will come from the product template.
[ www.hikashop.com/support/support/documen...hikashop-import.html](https://www.hikashop.com/support/support/documentation/73-hikashop-import.html)

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

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

10 years 11 months ago [\#222696](#222696) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#222696 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

Thank you for the idea, I will analyze this method

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

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

10 years 4 months ago [\#245410](#245410) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#245410 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

Please, can you give advice as how to write some code tweak? I then would extend to my need following your example

I want the product clonation button in hikaMarket product list not to copy **all fields,** and I want to selectively clone some only, for example:

**to clone**

product_name

**but not**

product_alias
product custom field 'MyCustom_Field_1'

**and then** empty images for the new cloned product

**and last force**

product_published always False

I understand I should do this against this code inside **administrator/components/com\_hikashop/helpers/import.php**
Code:

function copyProduct($product_id){ $this-&gt;addTemplate($product_id); $newProduct = new stdClass(); $newProduct-&gt;product_code = $this-&gt;template-&gt;product_code.'_copy'.rand(); $this-&gt;_checkData($newProduct); if(!empty($newProduct-&gt;product_code)){ $products = array($newProduct); if(!empty($this-&gt;template-&gt;variants)){ foreach($this-&gt;template-&gt;variants as $variant){ $copy = (!HIKASHOP_PHP5) ? $variant : clone($variant); $copy-&gt;product_parent_id = $newProduct-&gt;product_code; $copy-&gt;product_code = str_replace($this-&gt;template-&gt;product_code,$newProduct-&gt;product_code,$copy-&gt;product_code); unset($copy-&gt;product_id); $products[]=$copy; } } JPluginHelper::importPlugin( 'hikashop' ); $dispatcher = JDispatcher::getInstance(); $do = true; $dispatcher-&gt;trigger( 'onBeforeProductCopy', array( &amp; $this-&gt;template, &amp; $products[0], &amp; $do) ); if(!$do){ return false; } $this-&gt;_insertProducts($products); $dispatcher-&gt;trigger( 'onAfterProductCopy', array( &amp; $this-&gt;template, &amp; $products[0]) ); } return true; }

Hope you can dedicate some small time to write down example lines.

Thanks in advance.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgwNzk0LWNoYW5nZS1jdXN0b21pemUtaG93LXByb2R1Y3QtY2xvbmluZy13b3Jrcz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

10 years 4 months ago [\#245425](#245425) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#245425 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

Hi,

You could add there such lines:
unset($this-&gt;template-&gt;product_alias);
so the product_alias wouldn't be copied to the copy product.
But that's a hack.
A cleaner solution would be developping a small hikashop plugin implementing the onBeforeProductCopy and unsetting the attribute $template:
[ www.hikashop.com/support/documentation/6...#onBeforeProductCopy](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onBeforeProductCopy)
That way, you wouldn't loose your change each time you update Hikashop.

The following user(s) said Thank You: [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")

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

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

10 years 4 months ago -  10 years 4 months ago [\#245458](#245458) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#245458 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

Thank you Nicolas!

I used it now as a hack for a quick release of some client request. It works fine for core fields and custom fields.

But, how can I remove the images?

I need cloned products to be empty of images.

I'm not sure a simple unset of something is enough. Can you guide me?

Thanks

\##################################
SOLVED
\##################################

OK, no need for help, is as simple as this:
Code:

unset($this-&gt;template-&gt;images);

Last edit: 10 years 4 months ago by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile"). Reason: found solution

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

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

10 years 4 months ago [\#245502](#245502) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#245502 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

product_page_title does not get copied (sure for obvious reasons) to the new clone.

How could I force it? even if it was adding this part of random text to warn the user about duplicated titles
Code:

.'_copy'.rand();

I tries many ways without success, looks like another function should be involved somewhere....

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgwNzk0LWNoYW5nZS1jdXN0b21pemUtaG93LXByb2R1Y3QtY2xvbmluZy13b3Jrcz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

10 years 4 months ago [\#245540](#245540) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Change / customize how product cloning works](/forum/32-content-creation/880794-change-customize-how-product-cloning-works#245540 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.45  When I clone a product from the product list in frontend using the + button I get a copy with the same pictures and with no data in the SEO fields.  Some fields get cloned, others not, sure there is a logical pattern for this, but I would like to change it so for example the clone comes empty of pictures.  Also I would like to change which fields get copied and which don't.  where can I change this settings?  Thank you.")*

Hi,

You would have to add the column name to the array: Code:

$this-&gt;fields = array('product_weight','product_description','product_meta_description','product_tax_id','product_vendor_id','product_manufacturer_id','product_url','product_keywords','product_weight_unit','product_dimension_unit','product_width','product_length','product_height','product_max_per_order','product_min_per_order','product_warehouse_id');

in the file administrator/components/com_hikashop/helpers/import.php

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgwNzk0LWNoYW5nZS1jdXN0b21pemUtaG93LXByb2R1Y3QtY2xvbmluZy13b3Jrcz90bXBsPW1hcmtkb3du) 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.077 seconds

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