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

#   Autommatically random price and image for variants

##

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

Less More

- Posts: 285
- Thank you received: 42
-
-

4 years 10 months ago [\#338830](#338830) by [oxido](/forum/user/29793-oxido "View oxido's Profile")  *[Autommatically random price and image for variants](/forum/32-content-creation/903855-autommatically-random-price-and-image-for-variants#338830 "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 3.10.5 -- PHP version -- : 7.4  Hi,  I have this situation, when I create a variant for any product, the price set by default for the variant is not the price that I have on the main product. The price it is randomly set, and also it is set an image picked from another random product. Is this the natural behavior of the component?  Thank you, and happy new year guys :silly:")* was created by *[oxido](/forum/user/29793-oxido "View oxido's Profile")*

-- HikaShop version -- : 4.4.5
-- Joomla version -- : 3.10.5
-- PHP version -- : 7.4

Hi,

I have this situation, when I create a variant for any product, the price set by default for the variant is not the price that I have on the main product.
The price it is randomly set, and also it is set an image picked from another random product.
Is this the natural behavior of the component?

Thank you, and happy new year guys :silly:

- [ ![hika&#95;random&#95;price&#95;image&#95;variants&#95;oxido.jpg](/forum/attachment/54250) ](/forum/attachment/54250 "...ants&#95;oxido.jpg") [ ](/forum/attachment/54250?download=1 "...ants&#95;oxido.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzODU1LWF1dG9tbWF0aWNhbGx5LXJhbmRvbS1wcmljZS1hbmQtaW1hZ2UtZm9yLXZhcmlhbnRzP3RtcGw9bWFya2Rvd24=) 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: 86584
- Thank you received: 14325
-
-

4 years 10 months ago [\#338846](#338846) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Autommatically random price and image for variants](/forum/32-content-creation/903855-autommatically-random-price-and-image-for-variants#338846 "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 3.10.5 -- PHP version -- : 7.4  Hi,  I have this situation, when I create a variant for any product, the price set by default for the variant is not the price that I have on the main product. The price it is randomly set, and also it is set an image picked from another random product. Is this the natural behavior of the component?  Thank you, and happy new year guys :silly:")*

Hi,

By default, when a variant is generated by HikaShop, no price is assigned to the variant.
And when no price is set for a variant, it will automatically use the price of the main product when using it on the frontend. But on the backend, you'll see it as no price set.
If you see a price set automatically in the variant in the backend after the variant is generated, then it means that you probably have a mass action setting that price. So I would recommend checking your mass actions in the menu System&gt;Mass actions.
If it's not a mass action, then it could be a custom plugin, or some other code customization at play here.

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

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

Less More

- Posts: 285
- Thank you received: 42
-
-

4 years 10 months ago -  4 years 10 months ago [\#338861](#338861) by [oxido](/forum/user/29793-oxido "View oxido's Profile")  Replied by *[oxido](/forum/user/29793-oxido "View oxido's Profile")* on topic *[Autommatically random price and image for variants](/forum/32-content-creation/903855-autommatically-random-price-and-image-for-variants#338861 "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 3.10.5 -- PHP version -- : 7.4  Hi,  I have this situation, when I create a variant for any product, the price set by default for the variant is not the price that I have on the main product. The price it is randomly set, and also it is set an image picked from another random product. Is this the natural behavior of the component?  Thank you, and happy new year guys :silly:")*

I have deactivate all my custom plugins and deleted all the massAcctions, it behave the same, random price and image.
If you want nicolas, you can check it here:
This message contains confidential information

Thank you!

Last edit: 4 years 10 months ago by [Philip](/forum/user/34318-philip "View Philip's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzODU1LWF1dG9tbWF0aWNhbGx5LXJhbmRvbS1wcmljZS1hbmQtaW1hZ2UtZm9yLXZhcmlhbnRzP3RtcGw9bWFya2Rvd24=) 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: 86584
- Thank you received: 14325
-
-

4 years 10 months ago [\#338864](#338864) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Autommatically random price and image for variants](/forum/32-content-creation/903855-autommatically-random-price-and-image-for-variants#338864 "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 3.10.5 -- PHP version -- : 7.4  Hi,  I have this situation, when I create a variant for any product, the price set by default for the variant is not the price that I have on the main product. The price it is randomly set, and also it is set an image picked from another random product. Is this the natural behavior of the component?  Thank you, and happy new year guys :silly:")*

Hi,

Then, it just means that you deleted entries of the table hikashop_product without deleting the corresponding entries in the tables hikashop_price and hikashop_file.
So when a variant is created, if there are already entries in hikashop_price / hikashop_file you see them.
The best is to clean your tables with a MySQL query.
For example: Code:

DELETE a FROM #__hikashop_price as a LEFT JOIN #__hikashop_product AS b ON a.price_product_id = b.product_id WHERE b.product_id IS NULL;

That will remove all the price entries that aren't attached to a variant or a product.

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

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

Less More

- Posts: 285
- Thank you received: 42
-
-

4 years 10 months ago [\#338898](#338898) by [oxido](/forum/user/29793-oxido "View oxido's Profile")  Replied by *[oxido](/forum/user/29793-oxido "View oxido's Profile")* on topic *[Autommatically random price and image for variants](/forum/32-content-creation/903855-autommatically-random-price-and-image-for-variants#338898 "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 3.10.5 -- PHP version -- : 7.4  Hi,  I have this situation, when I create a variant for any product, the price set by default for the variant is not the price that I have on the main product. The price it is randomly set, and also it is set an image picked from another random product. Is this the natural behavior of the component?  Thank you, and happy new year guys :silly:")*

Thank you nicolas, that query fixed my problem with the price.
so now for the image, that should work, right? Code:

DELETE a FROM #__hikashop_file as a LEFT JOIN #__hikashop_product AS b ON a.file_ref_id = b.product_id WHERE b.product_id IS NULL;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTAzODU1LWF1dG9tbWF0aWNhbGx5LXJhbmRvbS1wcmljZS1hbmQtaW1hZ2UtZm9yLXZhcmlhbnRzP3RtcGw9bWFya2Rvd24=) 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: 86584
- Thank you received: 14325
-
-

4 years 10 months ago [\#338914](#338914) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Autommatically random price and image for variants](/forum/32-content-creation/903855-autommatically-random-price-and-image-for-variants#338914 "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 3.10.5 -- PHP version -- : 7.4  Hi,  I have this situation, when I create a variant for any product, the price set by default for the variant is not the price that I have on the main product. The price it is randomly set, and also it is set an image picked from another random product. Is this the natural behavior of the component?  Thank you, and happy new year guys :silly:")*

Yes, exactly.
You can also do it on hikashop_product_category for the link between products and categories, and on hikashop_product_related for related products, options and bundled products.

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

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