Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Getting "Error: Your app doesn't have a publication for this shop." when publishing a product.

Getting "Error: Your app doesn't have a publication for this shop." when publishing a product.

Wakil_eFoli
Shopify Partner
47 2 6

When publishing a product to the online store I get the following error:

Error: Your app doesn't have a publication for this shop.

How can I solve this error? 
Replies 3 (3)

Liam
Community Manager
3108 344 899

Hi Wakil,

 

Are you using the storefront API?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Wakil_eFoli
Shopify Partner
47 2 6

At 1st I was using the admin API but now I'm using the storefront API and still no luck.

 

This following code is getting executed in the action:

 

  const { admin } = await authenticate.admin(request);

  const { storefront } = await unauthenticated.storefront( 'test-app.myshopify.com' );

  // Publish the product.
  // const publishProductRequest = await admin.graphql(
  const publishProductRequest = await storefront.graphql(
    `#graphql
    mutation publishProduct($id: ID!, $input: [PublicationInput!]!) {
      publishablePublish(id: $id, input: $input) {
        userErrors {
          field
          message
        }
        publishable {
          availablePublicationCount
          publicationCount
          publishedOnCurrentPublication
        }
        shop {
          id
          name
          publicationCount
        }
      }
    }`,
    {
      variables: {
        id: productId,
        input: {
          publicationId: onlineStorePublicationId,
        },
      },
    }
  );

  
  const publishProductResponse = await publishProductRequest.json();

  return json(publishProductResponse);

 

 

Wakil_eFoli
Shopify Partner
47 2 6

@Liam Can you please tell me why and where should I use the storefront Api?