craftcms / shopify

Synchronize and extend product data from your Shopify storefront.
MIT License
44 stars 25 forks source link

Only Pulls 1st Page Products #8

Closed truecolintracy closed 4 years ago

truecolintracy commented 4 years ago

If you have more products than the 50 displayed on the first page of the query then only the first page will show up.

I was able to add a limit=250 to the query, but this is a bit of a hack fix and seems to only allow that value as the top limit.

nmaier95 commented 4 years ago

Hi @truecolintray is it possible you PM me your shopify credentials of the API you use for the plugin? Or maybe create a separate app inside of shopify-ui with less authorizations. Because I do not have an account to test/reproduce this with. mail: maier-niklas@t-online.de

abswdsmn commented 4 years ago

Would just like to add that I have the same issue.

It looks like the API now returns results in paginated form with links to the next (and prev) pages in the response header (the key is 'Link'). You also need to switch to the latest version of the API to get the links returned in the header.

Not sure why the functionality changed in the older version of the API as well as the new version?

I have a really hacky temporary fix - it is not advisable to use this in production but it demonstrates the issue at least. It's just proof of concept. It would be wise to either use a while loop with a reliable break function or maybe run another query to get max results and then use that to control the expected number of loops in order to avoid it looping too long. At the moment it's got a hard coded cap of 10... not pretty.

`/**

namespace shopify\services;

use yii\base\Component;

class ShopifyService extends Component {

/**

ryanpcmcquen commented 4 years ago

@nmaier95, any progress on this? I love the plugin but we have lots of products and only getting the first page is not enough.

ryanpcmcquen commented 4 years ago

@nmaier95, @truecolintracy, and @abswdsmn, take a look at my PR here: https://github.com/nmaier95/craft-shopify-product-fetcher/pull/9