Load entity is not working when using eca commerce

Created on 22 January 2024, 11 months ago
Updated 11 February 2024, 11 months ago

Problem/Motivation

I like the ECA module and have started to use it more and more in my educational projects, but I've run into an issue and could use your assistance. My problem is that I need to create an ECA so that if a user adds a product to their cart but doesn't complete the order, they receive an email reminder. I've configured the event as 'Cart: Add order item to cart,' but I'm facing a challenge due to the absence of an entity load. I require this function to load user orders and verify if the order state is in the draft state.

Steps to reproduce

create model eca
add event 'Cart: Add order item to cart'
add task 'Entity: load'

πŸ’¬ Support request
Status

Fixed

Version

2.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡¦Ukraine patricion

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @patricion
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Are you probably looking for the Entity: load action?

  • πŸ‡ΊπŸ‡¦Ukraine patricion

    Yes, I use Entity: load, but for some reason I get an error in the eca debug log that Access denied to Entity: load even if it is made from admin

  • πŸ‡ΊπŸ‡¦Ukraine patricion

    Yes, I use Entity: load, but for some reason I get an error in the eca debug log that Access denied to Entity: load even if it is made from admin.
    admin 15:41:46 Access denied to Entity: load (Activity_0rviqx6) from ECA noname (process_l5ny2hh) for event Drupal\eca_queue\Event\ProcessingTaskEvent: No entity available.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Yes, from the configuration I can see that the action is configured to load an entity, but it doesn't tell which one. You probably want to load the entity by its entity ID? Then you need to configure the load action accordingly.

  • πŸ‡ΊπŸ‡¦Ukraine patricion

    Yes, thanks for the help, I set up entity:load by id and it worked for me. The only problem is that I don't know how to configure Entity: load to load the order of the user whose token I loaded into user1. I have attached a screenshot of how I configured entity load, and it does not work as it should because it takes the user's id as the order's id. I tried to add the user id not in the entity id but in the entity, then it gives an error and does not load. I would be very grateful if you could help me with the correct configuration of Entity: load

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    You want to load an order entity, then you have to provide the ID of the order entity in the field "Entity ID".

  • πŸ‡ΊπŸ‡¦Ukraine patricion

    I'm sorry, maybe I didn't quite understand what you're talking about, I tried to use your method by specifying the [commerce_order:order_id] token, but I get the same error. And I can't specify a plain text id

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    That token is not available by itself, that's why it won't provide you any value.

    To learn how to make tokens available, maybe the Tokens chapter in the ECA Guide may be helpful.

  • πŸ‡ΊπŸ‡¦Ukraine patricion

    Thank You .It helped me in solving my problem

  • Status changed to Fixed 11 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    That's good to know, thanks for your feedback.

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    I might be able to add something here, as I am making a new model that reacts to "order is paid" and I noticed that the "[entity]" token does not work. Tokens like "[commerce-order:]" do work. So when I create an action, "Entity: load", and I specify "[entity:order_id"] it will not work, but when I use [commerce-order:order_id] it does load the order entity.

    The documentation states that:

    When an entity related event gets triggered, e.g. Presave content entity, then ECA automatically puts the related entity onto the token stack with the name entity and also under the name of the entity type, e.g. node, user, etc.

    ...so perhaps we do have a bug here.

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    I made another discovery here, I could not get the action "Get field value" to work, to build a list of order_items until I specified "commerce_order" as the entity to act on. Leaving that field empty made the action not execute.

    Hence it really seems that the "entity" token is empty, and that causes problems with certain actions, including "Entity:load".

    I am on 1.x dev so apologies if this is fixed in the 2.x branch.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @AlfTheCat this really sounds like a bug, but not really related to this issue. So, it would be great to open a new issue as a bug report for that.

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    Hi Jurgen,

    Thank you, and done: πŸ› "entity" token is not set Active .

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

Production build 0.71.5 2024