The plugin "Variants quantity synchronization" has an error

  • Posts: 121
  • Thank you received: 10
  • Hikashop Business
4 years 5 months ago #320093

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.18

Hello,
I can't find the support for the plugin "Variants quantity synchronization" on the Market place. But it generates an error on the product submit process.

The line 63 of plugins/hikashop/variants_quanity_synch/variants_quanity_synch.php

$class = hikashop_get('class.product');
$class->saveRaw($parentSave);

The saveRaw methods doesn't exists (anymore ?)
I think the patch below would work
$class = hikashop_get('class.product');
$class->save($parentSave);

Best regards.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 5 months ago #320119

Hi,

Thanks for your feedback.
Indeed, it should be save for now.
The saveRaw function will actually be in the next release of HikaShop and I had forgotten it wasn't yet available :)
I've added a patch to the plugin on our end so that it uses saveRaw if available and if not it fallback to save.

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

  • Posts: 121
  • Thank you received: 10
  • Hikashop Business
4 years 5 months ago #320134

Super! Merci ;)

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

  • Posts: 267
  • Thank you received: 5
3 years 2 months ago #335780

Hello Nicolas,
I see that this plugin "Variants quantity synchronization" is very useful, but is it possible to activate it, in some way, so that it updates all the products (through a daily cron)?, Instead of performing the synchronization one by one. Thank you.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 2 months ago #335793

Hi,

You don't need to modify its code for that.
Just run a mass action on the main products (with a filter), with an action "update the values" and you select a column like "product_published" with the "mode" being operation and the value being product.product_published
That way, it will run update the product_published of each product with the same value and thus trigger the variants quantity synch plugin each time.

Note however that if you have thousands of products, it might take a lot of time / memory resulting in the process crashing in the middle as your server stops PHP before it can finish its job.
It won't break anything, but that means you would have to increase the values of your php.ini or have instead several mass actions and use their "limitations" section to run the synchronization on different groups of products (one for products from 0 to 500, one for products from 500 to 1000, etc).

The following user(s) said Thank You: dvddvd

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

  • Posts: 267
  • Thank you received: 5
3 years 1 month ago #335932

Hello Nicolas,

Thanks for your answer, I have performed the following massaction.



But the quantities of the main product, which should be converted into the sum of the stock of the variants, remains at zero.
I do not understand what is the mistake I am making.
You can help?

Thanks

Attachments:
Last edit: 3 years 1 month ago by dvddvd.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 1 month ago #335939

Hi,

That's my bad. I thought that the save of class.product was called when an action was called, but looking at the code that's actually not the case for mass actions on products, due to performance issues.

So instead, you need to use a mass action with a action "Run PHP code" and use that code:

$class = hikashop_get('class.product');
$product = new stdClass();
$product->product_id = {product_id};
$class->saveRaw($product);

The following user(s) said Thank You: dvddvd

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

  • Posts: 267
  • Thank you received: 5
2 years 7 months ago #340812

Hi Nicolas,
I have published a massaction that when a variant has zero stock, it is deleted directly.
It is the case that main products are left without any variant, but in this case the stock of the main product remains with the previous value in which it did have variants.
Is there a way for Hikashop Variants Quantity Synch Plugin to assign a zero stock value to a main product with a characteristic assigned, but no variants on that characteristic?

A cordial greeting.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 7 months ago #340814

Hi,

That's a good point. The plugin so far only handled the update of the stock of the main product when a variant was created or modified, but not when a variant was deleted.
I've made a patch to the plugin to support that. Redownload the plugin on our website and install it on your website and you'll get the patch.
Note that for this to work, the deletion of the variant needs to trigger the onBeforeProductDelete and onAfterProductDelete. If you delete a variant through the interface or with a "delete element" action, then it will work. But if you delete a variant with a MySQL query directly (with a "Run a MySQL query" action for example), then it won't be taken into account as these events won't be called for you.

The following user(s) said Thank You: dvddvd

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

  • Posts: 267
  • Thank you received: 5
2 years 7 months ago #340848

Hi Nicolas,

I have installed and tested "Variants quantity synchronization" with the new patch.
My case is the following:
1.- Through CSVI, through a csv file, generate two imports:
a) Main products, it only loads the new products, those that are already on the web, it skips them.
b) Variants always update them
2. - When loading a new main product, it assigns through a massaction the only characteristic that exists, in my case there are 48 variants, but since it is cumbersome that there are so many...
3.- Through another massaction it eliminates all the variants with stock 0 of the variants

So what happens is that when you have "Variants quantity synchronization" activated with the new patch and update the variants again through the import of the csv, the massaction of point 3 that deletes the variants with zero stock gives an error 1064, due , I believe, because variants that have been removed and reloaded have a different product_id.

Also from the administration it does not allow me to delete variants manually.

Thank you very much and receive a cordial greeting.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 7 months ago #340852

Hi,

I've made a new version of the plugin with extra checks which I think would help. As always, you can download it on our website and install it via the joomla installer to get the patch.
If you still have the issue with that new version of the plugin, please activate the "debug system" setting of the Joomla configuration and try again. It should display an error page with more information on the situation which will help me properly fix the issue.

Last edit: 2 years 7 months ago by nicolas.
The following user(s) said Thank You: dvddvd

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

Time to create page: 0.097 seconds
Powered by Kunena Forum