The plugin "Variants quantity synchronization" has an error

  • Posts: 57
  • Thank you received: 6
  • Hikashop Business
1 year 4 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: 73880
  • Thank you received: 11330
  • MODERATOR
1 year 4 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: 57
  • Thank you received: 6
  • Hikashop Business
1 year 4 months ago #320134

Super! Merci ;)

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

  • Posts: 233
  • Thank you received: 2
  • Hikashop Business
4 weeks 23 hours 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: 73880
  • Thank you received: 11330
  • MODERATOR
4 weeks 7 hours 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: 233
  • Thank you received: 2
  • Hikashop Business
2 weeks 6 days 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: 2 weeks 6 days ago by dvddvd.

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

  • Posts: 73880
  • Thank you received: 11330
  • MODERATOR
2 weeks 5 days 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.

Time to create page: 0.081 seconds
Powered by Kunena Forum