Shopify / mobile-buy-sdk-android

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.
MIT License
216 stars 136 forks source link

How to get subcollections or sub categories #477

Closed Midhilaj closed 6 years ago

Midhilaj commented 6 years ago

How to get subcollections or sub categories I use this code for get Collections but ,result is mixed with categories and subcategories ,there is no option for separate it

  GraphClient graphClient =      GraphClient.builder(this)
                .shopDomain("myshop.myshopify.com")
                .accessToken("**89f5**********2111")

                .httpCache(new File(getApplicationContext().getCacheDir(), "/http"), 10 * 1024 * 1024) // 10mb for http cache
                .defaultHttpCachePolicy(HttpCachePolicy.CACHE_FIRST.expireAfter(5, TimeUnit.MINUTES)) // cached response valid by default for 5 minutes
                .build();
        Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery
                .shop(shopQuery -> shopQuery
                        .collections(arg -> arg.first(3), collectionConnectionQuery -> collectionConnectionQuery
                                .edges(collectionEdgeQuery -> collectionEdgeQuery
                                        .node(collectionQuery -> collectionQuery
                                                .title()

                                                .image(imageConnectionQuery -> imageConnectionQuery.src())

                                        )
                                )
                        )
                )
        );

        graphClient.queryGraph(query).enqueue(new GraphCall.Callback<Storefront.QueryRoot>() {

            @Override public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response) {
                List<Storefront.Collection> collections = new ArrayList<>();
                for (Storefront.CollectionEdge collectionEdge : response.data().getShop().getCollections().getEdges()) {
                    collections.add(collectionEdge.getNode());

/*                    List<Storefront.Product> products = new ArrayList<>();
                    for (Storefront.ProductEdge productEdge : collectionEdge.getNode().getProducts().getEdges()) {
                        products.add(productEdge.getNode());
                    }
                    */
                }
                Log.i("milla_c",new Gson().toJson(collections));
            }

            @Override
            public void onFailure(@NonNull GraphError error) {

            }

        });
henrytao-me commented 6 years ago

Hi @Midhilaj,

I am not aware of subcollections or sub categories that you are mentioning. There are collections and products. Product is belong to collection.

Can you give more explanation about your question?

Midhilaj commented 6 years ago

i mean Collections -> Fruits
Subcollections ->apple,orange,grap,etc.. or Menu items and links check our website , in menu (main categories)and on click item it show all product related to that menu(sub categories)

henrytao-me commented 6 years ago

Hi @Midhilaj I don't think subcollection is existed. However, you can use advance query with field matching https://github.com/Shopify/mobile-buy-sdk-android#field-matching-.

Hopefully it will help.

Midhilaj commented 6 years ago

Hi @henrytao-me is there any code for get Navigation Main menu list and it related collection details

henrytao-me commented 6 years ago

@Midhilaj No, there isn't. Sorry. You can set tag for product, build collection and menu based on tag and use tag as filter on mobile app.

Midhilaj commented 6 years ago

Would you please write code for fetch main menu data

Midhilaj commented 6 years ago

@henrytao-me please help me , How to make menu and sub menu in android app ? by fetching only collections , there is no relation to identify

henrytao-me commented 6 years ago

I am not aware of API for fetching menu data but without it, you can still be able to define menu and submenu dynamically using your own naming convention on collection's name and use collection API to fetch data that you need.

Midhilaj commented 6 years ago

How to get "Revoluction slider" image url list using android buy sdk ?

henrytao-me commented 6 years ago

For slider, it is belong to Online Store channel. There is no API to get it on BuySDK.

Midhilaj commented 6 years ago

To add this feature in android buy sdk , whom should i contact? 1 . Revoluction slider image url list 2 . Main menu data and link

sav007 commented 6 years ago

The idea of Buy SDK is to provide you a way to build customer facing apps, that includes only core features like browsing products, collection, create checkouts, etc.. Everything else is out of scope of Buy SDK and should be built on your end.