Customer Creation from backend with store_id using magento REST api - java

I was creating a magento customer using REST api. But the customer is being created with some default store_id = 0 .
As a result when I try to login to the magento store I am getting error saying I
Invalid login or password.
In the magento customer creation they haven't mentioned anything about this. How Can I do this? Any kind of heads up will be appreciated.
If I create a customer from front-end page then its getting *store_id=1* and for back-end its *store_id=0*. Both of them have same *website_id=1* So, when trying to login to magento I think we are trying to login different store.

If you set the website ID instead it should take care of this for you.
For your reference
Global: This refers to the entire installation.
Website: Websites are ‘parents’ of stores. A website consists of one or more stores. Websites can be set up to share customer data, or not to share any data
Store (or store view group): Stores are ‘children’ of websites. Products and Categories are managed on the store level. A root category is configured for each store view group, allowing multiple stores under the same website to have totally different catalog structures.
Store View: A store needs one or more store views to be browse-able in the front-end. The catalog structure per store view will always be the same, it simply allows for multiple presentations of the data in the front. 90% of implementations will likely use store views to allow customers to switch between 2 or more languages.

Related

How to store UUIDs client side

For my app I have a server-side database in which I store users and their data. I am wondering how to keep track of which user has which UUID. I want to make sure that only the same user with their own unique UUID can access their data in the database.
What would be the best way to do this?
In your database, create a table where each row represents one particular user. That table would have their permanently assigned UUID, along with name, email, etc.
Some databases such as Postgres and H2 support UUID as a built-in data type. Some databases proved a feature, perhaps as a plug-in, to generate a UUID value. For example, the uuid-ossp plug-in for Postgres. If not, you can generate a UUID in Java.
When creating an account for a user, create a row in that table. When a user logs in, look up their credentials in this table, retrieving their previously assigned UUID.
During the execution of your app, keep that retrieved UUID in memory as a java.util.UUID object. In a web app built on Jakarta Servlet, a good place to keep their UUID would be as an attribute on the Session. See Binding Attributes into a Session in the spec. See HttpSession#setAttribute and getAttribute.
When you write rows in other tables that belong to a particular user, include a column for their UUID. Include their UUID as a criteria in your queries.
You might want to look into multitenancy as a topic.
After authenticating the user (via your favorite authentication process), add a set-cookie response header with the user id (or any other data you deem appropriate) as the value.
Don't forget to set the cookie properties httponly, secure, and samesite.

Obtain image via an API call to then save and serve up from local for repeated viewings

I'm working on a webapp at the moment that will display a list of items. The list is dynamic and can change between users. A great analogy is to think of the objects as books, with the db backing it as the library.
My database for Book will contain a list of all books in the library.
-A user can add a book to their collection.
-If a user wants to add a new book to their collection they will also add it to the library.
-If a user wants to add a new book to their collection and it exists in the library, nothing will be added to the Book database.
Currently my table is incredibly simple: Book(id, name). I am able to access a plethora of information about these books via an API call, such as a front cover, number of pages etc etc. I would like to store a subset of this information, especially the image url.
I think a sensible approach would be to alter my Book table so that it looks like: Book(id, name, imageUrl, otherValue, idOfThisBookInApiCallTable) the idOfThisBookInApiCallTable value will allow me to get other attributes as I need them, however I've two issues with this that I'm not sure on how to proceed.
Firstly is that this Table can easily get out of date with the APITable. I don't expect there to be much change, if any, but the risk is there.
Secondly, the image being stored is my main concern, on a page where there might be 50 books, I'll making a call to the url of the image each time. I think a sensible solution would be download the image locally and then serve it from then on repeated visits but I'm not sure if this is the correct approach.
Might I ask if anyone can see any issues with this approach and/or suggest a better one please? I have limited experience with db/web/app design so a little out of my depth here.
If saving the image locally is the correct approach, is there a 'best' way of doing this?
Thanks in advance for any help/suggestions/advice.
I can share my 2 cents of a plausible design but I think the question is too broad and is mostly opinion-based. Let's address it by taking one thing at a time.
First regarding your Book table. Why not a Library table where you maintain the current state of your library with all the books that the library has at the moment.
Each user can hold a collection (a table etc with a one to many relation like user_id to list of book_ids or whatever) and then each user sort of owns a subset of bookIDs.
When adding a new book via user or via library (library can also add more books even if no particular user brought it in) then always add it to the library and if the user_id is known for the 'owner' of this book, add a relation for this user as well in the collection table
More details of a book can be stored separately in a BookDetails table.
Storage of images on your side is always a nice option and you don't want to get blocked by the API for over-usage when requesting over and over again. You can use some cloud storage like s3 where you can keep the images and then not bother the external api. S3 supports compression and caching so you can save lots of time and not have speed problems.
All the above points are just my opinion based on the information you gave on the question. The situation can of course be different for your use-case.

How to design micro-services in the below scenario :-

I have to design an application using micro services architecture using Java-Spring boot which has the below use cases :-
The user should be able create account in the portal.
User should be able to view / browse the online educational courses and add the courses to shopping cart.
The user should be able to buy the courses by doing an online payment.
The user should be able to view / play the courses which he/she has purchased.
Queries :-
How many micro services should be created and what will be those?
How do we relate the data so that we can map which user has purchased which courses? ( In RDBMS we usually we use a foreign key constraint ) . How is data usually related in such scenarios using micro services architecture?
Which database will be suitable for such architecture and how many data stores will be there?
Request you all to be as specific as possible in the solution.
Answer1:
As per your Requirement you can create following micro services
Registration
Login
Education Courses
Shopping Cart
User Courses
Answer2:
In User Courses table you can store User info as well as course info(both Id's)
Answer 3:
You can use mysql or mongodb or combination of this depends on your requirement.
If you will create 5 schema or will take 5 different database it would be good.

Is it possible to collect data from links and send that information to a database?

I need to build a recommendation system and I want to build it from scratch to practice and get more involved with coding and learning languages. I want to be able to collect user data from a website when user click on links and send that information into a table in the database that would return a set of suggestions according to the links chosen during a given session. Is it even possible to do such thing? For example, say I have a E-store that sells all type of different bikes and gear:
Bikes
Mountain Bikes
BMX Bikes
Triathlon bicycles
Etc...
Gear
Mountain helmets
BMX Helmets
Triathlon Helmets
Etc...
Now let's give those categories some ID'S 1,2,3,4,5 & 6 then create a table named recommendation_system that would be connected to the category_table.
According to the input inserted into recommendation_system the Servlet will call the appropriate category from the category_table and return a set of products.
The system would make precise guesses with user input.
For instance, there are very good probabilities that a user that picks id(2) BMX Bikes as first category will be interested to see suggestions from id(4) BMX Helmets and so on. Its all about directing the user up to the next same product's "family".
So is it possible to collect those given id's, send them to a database and then display suggestions according to the id that was previously pick? Do I need to use some kind of a form or only handle HTTP requests?
First you cannot know if a user has clicked on one link. All you know is that during a session, a client has sent a request for a URL, possibly through a link but maybe from its history, directly on address bar, or even through another window of same browser. IMHO a filter could perform that task, or depending of the technology, interceptors (for Spring MVC or Struts2), or aspects on relevant controllers (for any MVC2 solution).

Dynamic application form free flow

I am building a product in which customers can create dynamic form depending upon their requirements. For example one customer can create a form having fields like first name, last name, others can have one extra field like middle name.
I want to store each and every customers settings and finally i want to merge these two settings into one form at the time of display to our end users. I am finding right way to implement it.
Finding a way to store individual customers settings either in Database or XML or anything.
Finding a way to merge customers settings into one form, once our end user select both customers to apply (i want to give only one form which contains both customer form fields).
Please remember that i am providing a tool where customer can create new label like Gender, which is not defined in the system. We are giving generin data type to create such fields using text box, text-area, table, check-box, radio and many more.
Please assist me to design the architecture of above problem set.
You can do this by modelling your database as Entity–attribute–value model. See this :
Using Database Metadata and its Semantics to Generate Automatic and Dynamic Web Entry Forms
Planning and Implementing a Metadata-Driven Digital Repository
You can also find useful threads here in SO in the tag: eav

Categories