Mass-action filter with todays date value possible?

  • Posts: 88
  • Thank you received: 19
1 year 9 months ago #342099

-- HikaShop version -- : 4.6.0
-- Joomla version -- : 4.1.4
-- PHP version -- : 8.0

Hi

I have a custom date field on my products. Is it possible to use that field and compare it agains todays date in a mass-action filter?
What I'm looking to do is to move all products from one category to another, if date in custom field is less than "today".

Kind regards
Daniel

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

  • Posts: 81361
  • Thank you received: 13036
  • MODERATOR
1 year 9 months ago #342104

Hi,

It might be possible.
You say you have a custom date field, do you mean a custom field of the table "advanced date picker" ?
Is it a mass action you'll run only once and be done with it, or a mass action you want to run every day automatically ?

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

  • Posts: 88
  • Thank you received: 19
1 year 9 months ago #342110

Yes it's an "advanced date picker" field. I need it to run on a regular schedule.
All seems possible if we could just use e.g. MySQL NOW() or PHP date() as a filter parameter?

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

  • Posts: 81361
  • Thank you received: 13036
  • MODERATOR
1 year 9 months ago #342111

Hi,

In that case you can use a filter on the product column with the operator < and the value:

{year}{month}{day}000000
I would recommend to first try with an action "display the results" to check that the filter works as expected.

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

  • Posts: 88
  • Thank you received: 19
1 year 9 months ago #342133

Thank you. I have tried using your code but I don't get any results. If I manually enter todays date in the same way, I get 5 results. So it seems not to be accepting the tags?

Attachments:

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

  • Posts: 81361
  • Thank you received: 13036
  • MODERATOR
1 year 9 months ago #342142

Hi,

Indeed, there is a bug with these tags. I was able to reproduce the problem on my end and added a patch for it.
Download again the install package of HikaShop on our website and install it on yours and it will work.

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

  • Posts: 88
  • Thank you received: 19
1 year 9 months ago #342279

Thanks
That fixed the issue with the tags indeed. However, I might have found another :-)
If you look at my attached screenshot, you can se I have a filter on Dato(date field) to only display if not null. However, I do get 3 results with no date. So it seems that "IF NOT NULL" is not working?

Attachments:

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

  • Posts: 81361
  • Thank you received: 13036
  • MODERATOR
1 year 9 months ago #342280

Hi,

In MySQL not null is different from empty.
So the column might be empty but not null.
And thus, you'll want a third filter with "different from empty". You can do so with the operator "!=" and leaving the value field empty.

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

  • Posts: 88
  • Thank you received: 19
1 year 9 months ago #342291

I've tried that also, but I still get items with no date.

Attachments:

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

  • Posts: 88
  • Thank you received: 19
1 year 9 months ago #342292

Another thing. I think there is a javascript issue with the filter. When first creating a filter (before save), adding multiple filters is no problem. All works as expected. Then I save. After that, when I try to e.g. add a filter, my tags or values to check for gets deleted, < is changed to = and I can't set up the new filter. I can only select the type but not setup what field or values to check for.

Tested in both Safari and Chrome on MacOS.

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

  • Posts: 81361
  • Thank you received: 13036
  • MODERATOR
1 year 9 months ago #342300

Hi,

Then it means that you have another value in that field for these products. Check the column dato in your table hikashop_product for the 3 products you see with an empty "dato" via your PHPMyAdmin. Maybe they have a value like 00000000 or something ?

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

Time to create page: 0.070 seconds
Powered by Kunena Forum