Hi.

i want to alter the values in some of my product custom fields in every cron run.

I created a rule using react on event "Cron maintainance tasks" but i cant find any way to access commerce product entity.

Any ideas??

Thank you

Comments

rszrama’s picture

Status: Active » Fixed

You have to load them first using the "Fetch an entity" action, but I'd recommend against using Rules to build something like this in favor of a custom cron hook in a site-specific module. You'll be able to target your load query much more specifically so you aren't having to load every product on the site each cron.

frixos12’s picture

Hi and thank you for your post.

My problem is when using the "Fetch an entity action" the property value of the entity to be fetched doesn't have my entity's fields as an option.

How can i load my entity's fields since i cannot use conditions like entitys has field or entity exists by property?

frixos12’s picture

Status: Fixed » Postponed (maintainer needs more info)
rszrama’s picture

Status: Postponed (maintainer needs more info) » Fixed

You have to loop over the return value from the "Fetch an entity" action and pass them entities one by one to a Rules component that includes the necessary conditions and the actions for processing the entity. That's the only way to get the "Entity has field" conditions in the "action" part of the Rule.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.