Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

How to display the current store and the products of that shore? #15

Closed
online217 opened this issue Feb 27, 2018 · 6 comments
Closed

How to display the current store and the products of that shore? #15

online217 opened this issue Feb 27, 2018 · 6 comments

Comments

@online217
Copy link

Hello, Thank you for this app. I successfully installed in my local.

But I can't find how to display the current store logged and the products of it.

Can you provide a sample?

Thank you,

Best Regards,

Ronard

@brianakidd
Copy link

Hi Ronard,

Once the store installs your app, the shop domain and an API token will be stored in the shops database table. You can use this token to access the shop's data using the Shopify Admin API. Here's a link: https://help.shopify.com/api/reference

This package does all of the heavy lifting and now you can focus on your app requirements. Hope this helps.

@mabrodeur
Copy link

mabrodeur commented Feb 27, 2018

In your controller you can go like this:

$shop = ShopifyApp::shop();

// If you want to know what is the current store url
echo($shop->shopify_domain);

// If you want to get all the products
$response = $shop->api()->request('GET', '/admin/products.json');
$products = $response->body;

@online217
Copy link
Author

Hello @brianakidd @mabrodeur,

Thank you for the response it helps a lot.

@online217
Copy link
Author

Done. Thank you.

@pasartap
Copy link

Hi guys, appreciate your help please.

I am trying to do the same thing but my $shop object is null. I followed exactly the statements provided by @mabrodeur.

I also added the line:
use \OhMyBrew\ShopifyApp\Facades\ShopifyApp;
at the top.

Do I need to somehow initialize the $shop object myself or am I missing something here?

@gnikyt
Copy link
Owner

gnikyt commented Mar 27, 2018

@pasartap Did your shop pass through the auth route? (try clicking on the app again in admin and make sure the auth path in Shopify App settings points to /authenticate)

$shop = ShopifyApp::shop(); after including the facade should load the shop.

Can you spit out what session('shopify_domain') value is? See if its filled or empty?

Also, is this route you're accessing using the auth.shop middleware?

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

No branches or pull requests

5 participants