I have in Drupal Commerce products the price of which needs to calculated based on a value that is updated daily. (For the curious: the prices that are stored are worked into a formula that includes current copper sell prices and a copper price to total price ratio). I have used the Entity Construction Kit to create a small entity type to store copper prices - basically just date and price.

I'm having trouble selecting the most recently added copper price entity though.
Right now I'm looking at action "Fetch entity by property" (out of Entity Rules) and selecting by the current date. This would mean though that each day the customer would need to think to add a new price for tomorrow - which would definitely cause trouble.
Is there a module that offers to sort a list and select the last/first item in Rules?

1 Answer 1


If one 'price entity' is created based on the daily prices per day, you could use the 'after saving new content' action, restricted to your price entity type (provided you entity can be seen as a node.) Then, calculate the values for your products at that time, using the values within the newly created price entity.

Otherwise, you could put a 'last entry' field on you entity and use another rule to set this field to 'true' on a newly created entity and 'false' on all other entities. Then, set a condition on the original rule that filters entities based on this field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.