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

Video-50-Create-Seller-Page #52

Merged
merged 1 commit into from Nov 18, 2020
Merged

Video-50-Create-Seller-Page #52

merged 1 commit into from Nov 18, 2020

Conversation

basir
Copy link
Owner

@basir basir commented Nov 18, 2020

No description provided.

Copy link

@jorgeariasacevedo jorgeariasacevedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<div className="price">${product.price}</div>
<div>
<Link to={`/seller/${product.seller._id}`}>
{product.seller.seller.name}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me only works if I use {product.seller.name}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also happened to me

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well actually name will not display with {product.seller.name}, but original code wont run neither

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea how to solve it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are stuck in this part maybe you need to delete mongodb database and recreate it, that solved my problem.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anvoluther @Royal6969 I have the same error: "TypeError: Cannot read property '_id' of undefined". I tried following what you said but I do not understand. Can you please explain what changes I needed to make exactly in productModel.js and orderModel.js?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi gannau, in product model and order model - seller is added with below line:
seller: { type: mongoose.Schema.Types.ObjectId, ref: "User" },

It's hard to tell what went wrong on your part since I don't have your codes but this error started showing up with the change to multi-vendor but if you assigned each of the product with a seller id which in this case is Admin, there shouldn't be a problem. The other option is to delete old products and create a new one either in frontend or with /seed in backend but make sure to update the seller name and it doesn't have to be just admin this time.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gannau
you have to delete all your products and create again IN THE PAGE throw admin view and seller view for example
use delete and create product button that you had done before

In my case, one day, doing this lesson,
I found my users deleted and had to create it with login screen and admin view for privileges (seller or admin) and I checked the data in Moongose too

After that, I delete and create again all product
For the admin, his product first
and for sellers their products too
for separate
both are new user , remember??

And later with the Basir's code, all began to work perfectly

PD: In some cases, ObjectId in MongoDB gave me issues and it got me crazy but with moongose view (compass) is easy manage the data but it's mmmmm ...
Also, check your ObjectId in sellers!!
you have to be same ObjectId for group of product in common
Also if you experiment the same issue you are showing me in past email,
but instead with ._id , you have the same issue with name
it mean that you would had previously filled the fields for each seller in their seller views in the page

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gannau
you have to delete all your products and create again IN THE PAGE throw admin view and seller view for example
use delete and create product button that you had done before

In my case, one day, doing this lesson,
I found my users deleted and had to create it with login screen and admin view for privileges (seller or admin) and I checked the data in Moongose too

After that, I delete and create again all product
For the admin, his product first
and for sellers their products too
for separate
both are new user , remember??

And later with the Basir's code, all began to work perfectly

PD: In some cases, ObjectId in MongoDB gave me issues and it got me crazy but with moongose view (compass) is easy manage the data but it's mmmmm ...
Also, check your ObjectId in sellers!!
you have to be same ObjectId for group of product in common
Also if you experiment the same issue you are showing me in past email,
but instead with ._id , you have the same issue with name
it mean that you would had previously filled the fields for each seller in their seller views in the page

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that at models the ObjectId was written like this: ObjectID... and it should be ObjectId. When I changed that, it worked perfect :)

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont delete the entire database..just delete the new product you created from database.. you can delete that specific product from np sqlbooster...or you code go to localhost3000/profile and create a seller name..that is the issue all u have to do is delete the new product u created..and go to profile and add the seller name..it worked for me

<div className="price">${product.price}</div>
<div>
<Link to={`/seller/${product.seller._id}`}>
{product.seller.seller.name}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how make make the database

<div className="price">${product.price}</div>
<div>
<Link to={`/seller/${product.seller._id}`}>
{product.seller.seller.name}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make like the normal way

@anvoluther
Copy link

dont delete the entire database..just delete the new product you created from database.. you can delete that specific product from np sqlbooster...or you code go to localhost3000/profile and create a seller name..that is the issue all u have to do is delete the new product u created..and go to profile and add the seller name..it worked for me

@anvoluther
Copy link

Thank you Jomin I appreciate your prompt response but I already deleted everything from mongodb atlas :( I just wonder why my website would crash if you don't assign a seller to all products. To my recall, Basir only assigned one product with a seller id and the website seems to be working still. Did you manage to finish the end of this course?

@ghost
Copy link

ghost commented May 9, 2021

Yea..but some modules didnot respond quite well due to node js version..otherwise all went well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet