Mass action filters

  • Posts: 60
  • Thank you received: 6
  • Hikaserial Standard Hikashop Essential
8 months 1 week ago #359804

-- HikaShop version -- : 5.0.3
-- Joomla version -- : 4.4.3
-- PHP version -- : 8.1.27

Hi,
I want to create a massaction to change products category when the product_sale_end is over.
For testing purpose, I've 3 products.
Product 1 is in category 17 and has no sale end (product_sale_end = 0)
Product 2 is in category 13 and has a sale end at 2024-06-02 15:00 (product_sale_end = 1717333200)
Product 3 is in category 13 and has a sale end at 2024-01-01 04:00 (product_sale_end = 1704078000)

I want to change category of products to category 21 (archive)
- if product_sale_end exists (>0)
- if product_sale_end is over (<= to the current date and time)
- if the product's category is not 17 or 21

Given my filter:
Only Product 3 should be affected

Problem:
the 3 products are affected and their category is changed to 21

Why?
Thanks

Attachments:
Last edit: 8 months 1 week ago by marcmarc.

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

  • Posts: 82823
  • Thank you received: 13370
  • MODERATOR
8 months 1 week ago #359810

Hi,

I've tried the same filters on my end and it works fine. However, I would recommend using != instead of "not like" for your category filters, although it didn't change anything on my end.

What I would recommend is to first only is a "display the results" action and select the columns product_name, product_sale_end and category_id and category_name.
That way, when you process the mass action you can see what products the system finds and if the values match with your filters.
And if they do, then you can change it to another action to update the category.
If you find an issue, I would recommend you to build your mass action like I do usually:
- first, I only have a "display the results" action with the columns I want to see. I process the mass action without any filter, in order to check that it can display what I want.
- Then, I add the first filter. I process again the mass action, in order to make sure that it properly filters the products based on what I think the filter should do.
- I then add another filter, process the mass action, check the results, etc until I added all the filters.
- Once I have all the filters I need and the results I want, I can add the real action I want (I even usually add a temporary extra filter on the product_id being equal to one product on the list so that I only process one product when testing the action. That way, if I make a mistake in the action, or there is a bug, it only affects one product which I can easily revert).
This avoids processing many elements at once, only to find out that I've messed up somewhere. And also, if there is a bug somewhere, I'm not impacted, or only marginally, and best of all, I know when the problem happened. So I can narrow down the issue, and it will be easier to understand what's going wrong.

The following user(s) said Thank You: marcmarc

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

  • Posts: 60
  • Thank you received: 6
  • Hikaserial Standard Hikashop Essential
8 months 1 week ago #359813

Ok, it works now, thanks.
I haven't seen the "display the results" action, it helps!

Since we're at it: Is there a page, somewhere in the doc, which lists all the tags, i.e.{time} in the massaction or {automatic_code} in the configuration, and so on?

And another question: how to trigger a massaction with a cron?

Last edit: 8 months 1 week ago by marcmarc.

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

  • Posts: 60
  • Thank you received: 6
  • Hikaserial Standard Hikashop Essential
8 months 1 week ago #359814

I've just seen why my massaction didn't work: when triggered with the action button in the product listing the filters are not filtering! So it's the action itself which is triggered, not the massaction plugin as a whole.

Last edit: 8 months 1 week ago by marcmarc.

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

  • Posts: 82823
  • Thank you received: 13370
  • MODERATOR
8 months 6 days ago #359815

Hi,

1. There is not a page which recaps all the tags everywhere.
We have some documentation about the Mass action tags on the mass actions documentation page:
www.hikashop.com/support/documentation/1...n-form.html#detailed
For the email tags, you have the "list of tags" button when you edit an email with HikaShop Business.
For the tags in the "order number format" and "invoice number format", you have information about them on the configuration page documentation:
www.hikashop.com/support/documentation/5...nfig.html#main_order

2. To trigger a mass action with the cron you first need to make sure your HikaShop cron is running:
www.hikashop.com/support/documentation/5...ashop-cron-task.html
Once you're ok with the HikaShop cron, you can add a trigger "every minutes" or "every hour" or "every "week" or "every month" in your mass action and publish the mass action.
The next time the cron task of HikaShop runs, it will look as the mass actions which need to be triggered, and if it finds any it will trigger them. After triggering them, it will change a flag in the database so that regardless of how many times the HikaShop cron task is triggered, the mass action won't be triggered before they need to be triggered.
For example, if you configure a mass action with "every one" and you have a cron task configured to be triggered every 15 minutes, then the mass action will be triggered the first time the cron runs, then it will skip 4 cron tasks and it will the be triggered on the 5th.

3. When you activate the "actions as a button" option of a mass action, it will add a button with the name of the mass action on the listing. However, as the name of the option implies, only the actions of the mass action will be triggered on the selected elements. The filters will be ignored. So that is not a good way of testing the filters of a mass action. For that, you want to use the "process" button of your mass action as I was recommending in my previous message.

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

  • Posts: 60
  • Thank you received: 6
  • Hikaserial Standard Hikashop Essential
8 months 6 days ago #359819

nicolas wrote: 2. To trigger a mass action with the cron you first need to make sure your HikaShop cron is running

So the massactions are activated when one hit the url https://…/index.php?option=com_hikashop&ctrl=cron and they obey to the trigger parameter for the minimum interval between triggerings. Ok.

3. …So that is not a good way of testing the filters of a mass action. For that, you want to use the "process" button of your mass action as I was recommending in my previous message.

I've understood, it was what I did before your explanation. I was only explaining why it didn't work for me and the same settings worked for you.

Thanks

The following user(s) said Thank You: nicolas

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

Time to create page: 0.066 seconds
Powered by Kunena Forum