Publish on all my sales channels GRAPHQL Admin API (publishablePublish mutation)

I try to activate products for sales channels with publishablePublish - GraphQL Admin

Previously you could activate all sales channels for a product with “global” when publishing. Does this no longer work with GraphQL? What is the solution here to avoid having to check all sales channel IDs?

1 Like

Hi,

From looking into this, there doesn’t seem to be a direct way to indicate that a product should be activated for all available sales channels so you will need to use the shop query to retrieve the list of available sales channels and their IDs. Then you can use these as input values for the publishablePublish mutation. You could explore storing these values separately to avoid needing to query every time.

I also am struggling the documents have a lot of depreciation and little useful knowledge in how to achieve the basics of publishing your product on the “online Store” Channel. Re-coding my API connection for product additions is like playing a game of whack a mole, need this and that and this mutator after querying that or this.

Let me know if you figure this out as I am also currently looking at the solution, think I’m close using as Liam mentioned “publishablePublish” Which at first need you to query “publications”:

function fetchPublications() {
    // GraphQL query to fetch publications
    $query = '
    query {
        publications(first: 8) {
            edges {
                node {
                    id
                    name
                }
            }
        }
    }';

    // Execute the query using the existing curlReqGraphQL function
    $response = curlReqGraphQL($query);

    // Check for errors in the response
    if (isset($response['errors'])) {
        // Handle errors as needed
        return null;
    }

    // Extract publication data
    $publications = [];
    foreach ($response['data']['publications']['edges'] as $edge) {
        $publications[] = [
            'id' => $edge['node']['id'],
            'name' => $edge['node']['name']
        ];
    }

    return $publications;
}