Autommatically random price and image for variants

  • Posts: 224
  • Thank you received: 26
  • Hikashop Business
2 years 3 months ago #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:

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
2 years 3 months ago #338846

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>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 or Create an account to join the conversation.

  • Posts: 224
  • Thank you received: 26
  • Hikashop Business
2 years 3 months ago #338861

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: 2 years 3 months ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
2 years 3 months ago #338864

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:

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 or Create an account to join the conversation.

  • Posts: 224
  • Thank you received: 26
  • Hikashop Business
2 years 3 months ago #338898

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

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 or Create an account to join the conversation.

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
2 years 3 months ago #338914

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

Please Log in or Create an account to join the conversation.

Time to create page: 0.063 seconds
Powered by Kunena Forum