Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such entity with customerId = 2 #115

Open
irnjunior opened this issue Dec 3, 2020 · 6 comments
Open

No such entity with customerId = 2 #115

irnjunior opened this issue Dec 3, 2020 · 6 comments
Labels
Priority: Critical breaking issue or urgent requirement Status: In Progress Working on the issue Type: Bug Something isn't working

Comments

@irnjunior
Copy link

I did the installation and the application works normally. I registered a user through the application normally.

However, when I try to add a product to the cart, the following message appears: "The consumer isn't authorized to access resource."

When I click on the cart icon, the following message is displayed: "No such entity with customerId = 2"

I'm using Magento 2.4

@irnjunior irnjunior added the Type: Bug Something isn't working label Dec 3, 2020
@sanjeevyadavIT
Copy link
Owner

Hello @irnjunior sorry for replying bit late, but can we discuss about the issue, if it's possible

@irnjunior
Copy link
Author

Hi.
It's all right. I would like, if possible.
Thanks.

@sanjeevyadavIT
Copy link
Owner

Regarding customer isn't authorized to access the resources, did you follow all the instructions explained here in wiki

especially these two

  1. Set available APIs, to All, while setting up integration (Point no 4. in wiki)

  2. Set expiry time for customer token very big, as explained here

4. Increase customer session expiry time

By default, customer token generated when user login is valid for 1 hour. You can change these values from Admin by selecting Stores > Settings > Configuration > Services > OAuth > Access Token Expiration.

Set it to 168 hours(7 days)

@irnjunior
Copy link
Author

I followed all the procedures correctly.

I can create and login with the client normally through the application. I add a product to the shopping cart and at that moment the message "Current Customer Does Not Have An Active Cart" is displayed. Then, when you click on the cart icon a red message is displayed "No such entity with customerId = 2"

If I create a client account directly through the browser, these errors will not appear. These errors appear only when I create an account through the app.

Any idea how to fix this?

@sanjeevyadavIT
Copy link
Owner

sanjeevyadavIT commented Feb 8, 2021

Ok, I understand, let me test tomorrow with my own local magento setup. Will let you know

@sanjeevyadavIT
Copy link
Owner

hi @irnjunior I tested it with my local magento 2.4 setup, and created new account, at my end, I am able to add products to cart.

See, one you log in, customer cart is fetched, but since, a new user, doesn't have customer cart, an error is thrown, so in app, it is handled to request quote cart, which create a cart for customer, and again customer cart is fetched.

cartSagas.js

// wroker saga: Add description
function* getCustomerCart() {
  try {
    yield put({ type: MAGENTO.CUSTOMER_CART_LOADING });
    const cart = yield call({
      content: magento,
      fn: magento.customer.getCustomerCart,
    });
    yield put({ type: MAGENTO.CUSTOMER_CART_SUCCESS, payload: { cart } });
  } catch (error) {
    yield put({
      type: MAGENTO.CUSTOMER_CART_FAILURE,
      payload: { errorMessage: error.message },
    });
    if (error.message.startsWith('No such entity with')) {
      yield put({ type: MAGENTO.CREATE_QUOTE_ID_REQUEST }); // <============== look here
    }
  }
}

This is like a hack, and possibly the problem is occurring here.

Follow these steps

  1. Open app in debug mode, you will be able to see logs in developer console of chrome
  2. Create a new account from app
  3. It will take you to login screen
  4. Clear the console of previous log
  5. Enter login credentials, and hit login button
  6. In console, you will see "MAGENTO_CUSTOMER_CART_FAILURE" action, see if ""MAGENTO_CREATE_QUOTE_ID_REQUEST" action is dispatched or not

Your console should look something like this, in this order for new account first time login

Screenshot from 2021-02-10 09-43-27

@sanjeevyadavIT sanjeevyadavIT moved this from To do to In progress in MageCart Roadmap Feb 10, 2021
@sanjeevyadavIT sanjeevyadavIT added Priority: Critical breaking issue or urgent requirement Status: In Progress Working on the issue labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Critical breaking issue or urgent requirement Status: In Progress Working on the issue Type: Bug Something isn't working
Projects
MageCart Roadmap
  
In progress
Development

No branches or pull requests

2 participants