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

Add ability to associate products with categories #10

Open
roelvan opened this issue Dec 12, 2016 · 6 comments
Open

Add ability to associate products with categories #10

roelvan opened this issue Dec 12, 2016 · 6 comments

Comments

@roelvan
Copy link

roelvan commented Dec 12, 2016

How would the api call look like?

@BrandesEric
Copy link
Contributor

Hi @roelvan,

No need for a separate call to get categories for a product or services for specific stores. By default, any product or store call will return the associated categories or services.

For example, if you make the following product call:
http://localhost:3030/products?id=43900

You'll see as part of the JSON response a categories property that contains a list of all categories that product is associated with

{
  "total": 1,
  "limit": 10,
  "skip": 0,
  "data": [
    {
      "id": 43900,
      "name": "Duracell - AAA Batteries (4-Pack)",
      "type": "HardGood",
      "price": 5.49,
      "upc": "041333424019",
      "shipping": 0,
      "description": "Compatible with select electronic devices; AAA size; DURALOCK Power Preserve technology; 4-pack",
      "manufacturer": "Duracell",
      "model": "MN2400B4Z",
      "url": "http://www.bestbuy.com/site/duracell-aaa-batteries-4-pack/43900.p?id=1051384074145&skuId=43900&cmp=RMXCC",
      "image": "http://img.bbystatic.com/BestBuy_US/images/products/4390/43900_sa.jpg",
      "createdAt": "2016-11-17T17:58:03.298Z",
      "updatedAt": "2016-11-17T17:58:03.298Z",
      "categories": [
        {
          "id": "abcat0208002",
          "name": "Alkaline Batteries",
          "createdAt": "2016-11-17T17:57:04.285Z",
          "updatedAt": "2016-11-17T17:57:04.285Z"
        },
        {
          "id": "pcmcat248700050021",
          "name": "Housewares",
          "createdAt": "2016-11-17T17:57:05.399Z",
          "updatedAt": "2016-11-17T17:57:05.399Z"
        },
        {
          "id": "pcmcat303600050001",
          "name": "Household Batteries",
          "createdAt": "2016-11-17T17:57:04.285Z",
          "updatedAt": "2016-11-17T17:57:04.285Z"
        },
        {
          "id": "pcmcat312300050015",
          "name": "Connected Home & Housewares",
          "createdAt": "2016-11-17T17:57:04.285Z",
          "updatedAt": "2016-11-17T17:57:04.285Z"
        }
      ]
    }
  ]
}

The same applies for store queries. Any query will return the services associated with that store under the services property.

For example, if you go to http://localhost:3030/stores

You'll get a response that contains a list of stores, and for each store the list of services at that store:

  "total": 1561,
  "limit": 10,
  "skip": 0,
  "data": [
    {
      "id": 4,
      "name": "Minnetonka",
      "type": "BigBox",
      "address": "13513 Ridgedale Dr",
      "address2": "",
      "city": "Hopkins",
      "state": "MN",
      "zip": "55305",
      "lat": 44.969658,
      "lng": -93.449539,
      "hours": "Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-9; Sat: 10-9; Sun: 10-8",
      "createdAt": "2016-11-17T17:57:05.708Z",
      "updatedAt": "2016-11-17T17:57:05.708Z",
      "services": [
        {
          "id": 1,
          "name": "Geek Squad Services",
          "createdAt": "2016-11-17T17:56:35.881Z",
          "updatedAt": "2016-11-17T17:56:35.881Z",
          "storeservices": {
            "createdAt": "2016-11-17T17:57:09.213Z",
            "updatedAt": "2016-11-17T17:57:09.213Z",
            "storeId": 4,
            "serviceId": 1
          }
        },
        {
          "id": 2,
          "name": "Best Buy Mobile",
          "createdAt": "2016-11-17T17:56:35.881Z",
          "updatedAt": "2016-11-17T17:56:35.881Z",
          "storeservices": {
            "createdAt": "2016-11-17T17:57:09.213Z",
            "updatedAt": "2016-11-17T17:57:09.213Z",
            "storeId": 4,
            "serviceId": 2
          }
        },
// truncated

Does that sort of answer what you were looking for?

@roelvan
Copy link
Author

roelvan commented Dec 12, 2016

Hi @BrandesEric thanks for the quick reply. Sorry next time I should explain my question in detail, my mistake.
What I meant was, now all associations are already in the database. What if I want to do a call to link a new category to a product? There are calls to create standalone products, services, categories,... but how could I create a new connection between two entities. Eg. I want to add the category "Apple Devices" to the product "iMac" because that category hasn't been linked yet to that specific product.
I am very curious how that could be implemented in Restful way.
Btw, I really love this repo. I am learning a lot from it!

@BrandesEric
Copy link
Contributor

Ah yes! I see what you mean :) Unfortunately there is nothing exposed today that will link them for you. While you can currently create categories and products, there aren't any calls that modify the productcategory table in the database at this time. I'll talk to the team about it and see if that's something that we're planning on exposing!

@roelvan
Copy link
Author

roelvan commented Dec 12, 2016

Would love to see that :) Thanks for your time and effort!

@roelvan roelvan closed this as completed Dec 12, 2016
@Flet
Copy link
Contributor

Flet commented Dec 12, 2016

@roelvan - I think its a great idea to add this functionality; do you mind if we keep this issue open for tracking?

@Flet Flet reopened this Dec 12, 2016
@Flet Flet changed the title What would be the best way to link categories with a product? Or services with a store? Add ability to associate products with categories Dec 12, 2016
@roelvan
Copy link
Author

roelvan commented Dec 13, 2016 via email

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

No branches or pull requests

3 participants