Answer the question
In order to leave comments, you need to log in
Add to the cart products that are scraped from the supplier's website?
An online store has its own products (added to the product catalog via the admin panel), and there is a connected web pricing from suppliers (when a person searches for a product by article, he is first offered to buy from the warehouse, and then order options through the supplier's API). When adding a product to the cart, the session records the product ID and quantity. And in the basket itself, respectively, according to the ID of this product, there is a selection of other characteristics (product name, manufacturer, country, etc.).
Question for connoisseurs:
How to competently implement the ability to purchase goods received through the supplier's API?
So far, only in my head:
By clicking on the "Buy" button (of a product received through the API), INSERT this product into the database, assign an ID to it, record the quantity and ID of this product in the session, and send it to the cart. In the basket, respectively, a selection of the name, manufacturer, etc.
But here it is already necessary to check for shit code ...
In general, I'm in a stupor.
Answer the question
In order to leave comments, you need to log in
In general, a logical decision. But I would improve a little.
In the cart entry class (CartItem) add the "storage" field (or something like that). If 'local' is a product from the current store database, we add some identifier for suppliers. The selection should be carried out, taking into account storage, our repository / manager / etc.
While adding to the cart, I would not add an entry to the database. Based on our "storage" you can pull the goods from the supplier. But it's not very efficient to make a request every time. Therefore, the results of requests to the api providers are cached (cache file, radish, memcache, etc.). And when placing an order, you already need to insert the goods of an external supplier. Moreover, you can revise the structure of the "Order Products" table, something like this:
storage, order_id, product_id, quantity, price_unit...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question