Ad

Get Shopify Categories Collection For A Specific Store Via API In Shopify App - OhMyBrew App

- 1 answer

I have multiple stores in my Shopify Account. I am trying to get all custom categories collection.

I have developed an App by extending Laravel's OhMyBrew package, which is installed on all stores, but that app is returning only last store's categories collection.

I want that app to return categories by its store specific.

Ad

Answer

I think This Package will allow you to query only logged-In Shop's data via API.And you wanted to access store's data regardless session. Might be in back-end CRONS.

use below function to achieve this.

 function getShopApi( $shop_id ){
      $shop = \OhMyBrew\ShopifyApp\Models\Shop::where([
                ['id' , '=', $shop_id]
            ])->first();
            $shop = $shop->toArray();
            $api = new \OhMyBrew\BasicShopifyAPI();
            $api->setShop($shop['shopify_domain']);
            $api->setAccessToken($shop['shopify_token']);

            return $api;
    }

    $api = getShopApi( 1 );
    $collections = $api->rest('GET', '/admin/collections.json');
Ad
source: stackoverflow.com
Ad