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

Cost data for product and variant? #1091

Open
dooferorg opened this issue Aug 18, 2024 · 3 comments
Open

Cost data for product and variant? #1091

dooferorg opened this issue Aug 18, 2024 · 3 comments

Comments

@dooferorg
Copy link

dooferorg commented Aug 18, 2024

In gathering data from the Shopify API via ShopifySharp, there seems to be nowhere where the cost for the product or variant is returned. I would like this data since I am writing something to monitor product cost, shipping, margins and adjust prices accordingly.

Am I missing where that might be? I am looking at the ProductVariant object and not seeing it, nor have I found any other way to get that information.

So this might not be an 'issue' with ShopifySharp, maybe just what is available via the API and that I don't know where to look.

Help appreciated, thank you.

ETA: right AFTER I posted this, I found that what I'm looking for may be in the 'InventoryItem' object. Curiously on the Wiki there is no mention of InventoryItem and how to query it via ShopifySharp

@nozzlegear
Copy link
Owner

Hey! I see you found the InventoryItem info. Quick question, are you querying using the GraphQL API or with the rest API? I believe the price info has indeed moved for the graph API, but at the moment it's still available on the ProductVariant class via the rest api: link. Your query the product using ShopifySharp's ProductServive, and then loop through each of the variants on the product to check the price.

Note the product API is deprecated for rest though, so eventually you'll have to use graphql.

@dooferorg
Copy link
Author

dooferorg commented Aug 18, 2024

To be honest, I am not certain what ShopifySharp uses (I'm using the latest nuget project). I did not see any reference to inventory under the ProductVariant class I have in the solution here. I started tinkering with GraphQL but since this project seems cool I thought I'd give it a go today and it's helping me make progress.

For completeness, I was able to determine what I needed via this:

var filter = new InventoryItemListFilter();
filter.Ids = shopifyProd.Variants.Select(x => (long)x.InventoryItemId).ToList();
var inventoryList = inventoryService.ListAsync(filter).Result;

Noting that the list of ids is from the ProductVariant InventoryItemId , then the list of items was returned and can be matched up with what I gathered previously. Worked fine.

Edited: Actually yes, using the GraphQL URL. Since I was tinkering with that way, that was the URL that is being passed to ShopifySharp. I had overlooked changing it.

@nozzlegear
Copy link
Owner

Awesome! Glad you got it working. I'm in the middle of some maintenance PRs to improve performance of the current GraphService in ShopifySharp and fix up some bugs, but after that I'm planning on doing some major work around making graphql a first-class citizen. It's pretty difficult to use right now (partly because I don't have much documentation for it), but improvements are definitely planned.

If you have any feedback for graphql improvements, or any other questions/problems just let me know!

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

2 participants