How to add image for brand

images
brands

#1

Hi! How i can add the image for brand?


#2

Hey Sooqa,

Flows could be a good to do this. I am in the process of writing up how it would work. I will get back to you tomorrow with more detail. In the meantime check out flows in the dashboard and try adding a flow for a brand, with an image string field

-George


#3

Hey Sooqa,

Sorry for the delay. Here is a rough outline of what you could do. I used postman to work with the api.
First you will need to create a Flow. Flow can be used to extended moltin objects (example; brands, products, categories).
The slug will be the object you are extending

https://api.moltin.com/v2/flows
 {
  "data": {
    "type": "flow",
    "name": "Brands",
    "slug": "brands",
    "description": "Extends the default brand object",
    "enabled": true
  }
 }

You then can create a field. This will be the key for the things you are adding to the object (slug). You can also put in a default value here.

https://api.moltin.com/v2/fields
{
    "data": {
    "type": "field",
    "name": "Brand image",
    "slug": "brand-image",
    "field_type": "string",
    "description": "Image for the brand",
    "required": false,
    "unique": false,
    "default": "https://s3-eu-west-1.amazonaws.com/bkt-svc-files-cmty-api-moltin-com/e8c53cb0-120d-4ea5-8941-ce74dec06038/61118f21-14a2-466c-a84b-c30b1f900cf9.png",
    "enabled": true,
    "order": 1,
    "relationships": {
        "flow": {
            "data": {
                "type": "flow",
                "id": "f3f052f0-cdb3-4e69-a61d-6e99786895ab"
            }
        }
    }
  }
}

Now when you call brands you will see the object has been extended to include brand-image.

    "data": {
        "id": "0d28e5b6-f615-4e1c-b038-275cfde97927",
        "type": "brand",
        "status": "live",
        "name": "Cool Clothing",
        "slug": "cool-clothing",
        "description": "Cool clothing make cool clothes!",
        "meta": {
            "timestamps": {
                "created_at": "2018-05-24T13:55:51+00:00",
                "updated_at": "2018-05-31T18:31:02+00:00"
            }
        },
        "relationships": {
            "products": {
                "data": [
                    {
                        "type": "product",
                        "id": "5fcdcc0d-ef18-4067-aa3f-0ab4f03b4119"
                    },
                    {
                        "type": "product",
                        "id": "541d505c-0ff4-47d1-8786-b8585466d9ac"
                    }
                ]
            }
        },
        "brand-image": "https://s3-eu-west-1.amazonaws.com/bkt-svc-files-cmty-api-moltin-com/e8c53cb0-120d-4ea5-8941-ce74dec06038/61118f21-14a2-466c-a84b-c30b1f900cf9.png"
    }
}

Now you can update brands to included the images you want for the specific brand

## Update Brand x
curl -X "PUT" "https://api.moltin.com/v2/brands/BRAND X ID" \
     -H 'Content-Type: application/json' \
     -H 'Authorization: bearer' \
     -d $'{
  "data": {
    "status": "live",
    "id": "BRAND X ID",
    "type": "brand",
    "image": "image Y"
  }
}'

Let me know if you have any issues. Also would love to hear more about what you are working on.

-George


#4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.