Can't Fetch all products?

Legz444
Visitor
2 0 0

I am fetching from the Storefront API and at first my products were coming through. But since adding new products, only some are showing. I am positive they are all set to Active on the dashboard. Just can't figure out why some show and others do not. I am using js in react. No errors are showing. Any ideas?

 

 

class Store extends Component {
      // create a constructor for the component
  constructor(){
    super();
  //set initial state of the application
    this.state ={
      isCartOpen: false,
      checkout: { lineItems: [] },
      products: [],
      collection: [],
      shop: {}
    };
  // set each of the functions to this state with bind()

  this.handleCartClose = this.handleCartClose.bind(this);
  this.addItemToCart = this.addItemToCart.bind(this);
  this.updateQuantityInCart = this.updateQuantityInCart.bind(this);
  this.removeLineItemInCart = this.removeLineItemInCart.bind(this); 
}

  // create functions

    componentWillMount() {
        this.props.client.checkout.create().then((res) => {
            this.setState({
                checkout: res
            });
        });
        this.props.client.product.fetchAll().then((res) => {
            this.setState({
                products: res
            });
            console.log(this.state.products);
        });
        this. props.client.shop.fetchInfo().then((res) => {
            this.setState({
                shop: res
            });
        });
    }

 

 

Reply 1 (1)

PaulNewton
Shopify Partner
6274 573 1318

@Legz444 wrote:

 I am positive they are all set to Active on the dashboard.


Are they active AND published to the relevant sale channel like for online-sale, buy buttons, private?

 

In case of sales channels 

https://community.shopify.com/c/shopify-apis-and-sdks/private-app-admin-and-storefront-api-no-produc... 

https://community.shopify.com/c/shopify-apis-and-sdks/shopify-storefront-api-graphql-doesn-t-return-... 

https://shopify.dev/api/admin-rest/2021-10/resources/productlisting#top 

 

If building test suites you'll want to have a check and logging for that situation.

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org