Skip to content
This repository was archived by the owner on Oct 6, 2026. It is now read-only.
This repository was archived by the owner on Oct 6, 2026. It is now read-only.

Return created/updated objects #175

Description

@MagicLegend

Overview

The API itself will already return the full object if you do a create/update operation. However, the library swallows this response here:
https://github.com/Shopify/shopify-php-api/blob/0556edf274ceb83346533bd22b662d7622e58c66/src/Rest/Base.php#L60-L74

Solution

Adding return $response->getDecodedBody(); at the end of the function should suffice. Note that the saveAndUpdate function would also need to be updated, with return $this->save(true);. Implementation can be found in my fork: MagicLegend@d43bc94

Type

  • New feature
  • Changes to existing features

Motivation

What inspired this feature request? What problems were you facing?

I would like to verify the saved object myself, without needing to query the API again for data that was already returned in the first place. This also allows immediate access to the ID of the newly created object.

Activity

  1. shota commented on May 29, 2022

    @shota

    +1
    I don't know why this has NOT been implemented yet.

  2. shota commented on May 29, 2022

    @shota

    I have created PR for this. This is what should be (save return response, saveAndUpdate update object itself)
    #185

  3. Zelfapp commented on Jul 28, 2022

    @Zelfapp

    This is a pretty serious issues that the Base.php save() method returns void. E.g. the rest api order docs incorrectly state there will be a response. Getting the response with the new order's id is mission critical for our use case, but I don't see a way to access the updated object.

    image

    Any contributors able to post a workaround until this is resolved?

  4. MagicLegend commented on Jul 29, 2022

    @MagicLegend
    Author

    @Zelfapp Yeah, as stated in the original message, I have fixed this (along with other improvements to the library) in my fork: MagicLegend@d43bc94

  5. Zelfapp commented on Jul 29, 2022

    @Zelfapp

    @MagicLegend I saw your PR. This library has too many issues for a private app at this point and feels too hacky. It has great potential though.

    For the sake of anyone else battling this alpha lib for a private app, likely you're better off simply using guzzle to make REST api endpoint requests. E.g. in just few lines of code you can dynamically pass in any endpoint and payload.

    Again, this is a great lib, but I would not classify as ready for production.

    use GuzzleHttp\Client;
    use GuzzleHttp\Psr7\Request;
    
    /// Guzzle client
    $client = new Client();
    $request = new Request(
        'GET',
        "https://$this->shop/admin/api/2022-07/$endpoint",
        [
            'X-Shopify-Access-Token' => $this->permanentAccessToken,
        ],
        $endpointParams['payload'] ?? null,
    );
    $response = $client->sendAsync($request)->wait();
    $response = $response->getBody();
  6. MagicLegend commented on Jul 29, 2022

    @MagicLegend
    Author

    I respectfully disagree, and we have my fork running in production right now. It works fine, it just has some quirks that Shopify is not allocating resources to to solve. I prefer using a library that's providing typing over doing it manually in Guzzle, but both will of course work fine.

  7. github-actions commented on Sep 28, 2022

    @github-actions

    This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

  8. MagicLegend commented on Sep 28, 2022

    @MagicLegend
    Author

    Still waiting on Shopify...

  9. github-actions commented on Nov 29, 2022

    @github-actions

    This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

  10. MagicLegend commented on Nov 29, 2022

    @MagicLegend
    Author

    Still waiting on Shopify...

  11. github-actions commented on Jan 30, 2023

    @github-actions

    This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

  12. 31 remaining items

  13. github-actions commented on Apr 14, 2024

    @github-actions

    This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

  14. MagicLegend commented on Apr 15, 2024

    @MagicLegend
    Author

    Yeah, and why is it stale bot? Because Shopify doesn't reply ;)

  15. github-actions commented on Jun 15, 2024

    @github-actions

    This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.

  16. MagicLegend commented on Jun 17, 2024

    @MagicLegend
    Author

    Yeah, and why is it stale bot? Because Shopify doesn't reply ;)

  17. paulomarg commented on Aug 13, 2024

    @paulomarg
    Contributor

    Hey folks, thanks for your patience here. We've removed the stalebot from this repo, and I'm going to add this issue to our tracking.

    Once again, thank you for your patience!

  18. MagicLegend commented on Aug 15, 2024

    @MagicLegend
    Author

    No worries. You can find an implementation of this issue in my fork: MagicLegend@d43bc94

  19. removed their assignment
    on Dec 16, 2024
  20. Suleimanlatrsh commented on Oct 6, 2026

    @Suleimanlatrsh
    Contributor

    Thanks for contributing! This package is deprecated and we're archiving this repo, so we're closing all open issues and PRs. Please use shopify-app-php instead, and open new issues there. More context: Rethinking support for PHP/Python packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions