Skip to content

How to create multiple shopify objects to access multiple stores #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vuivenao opened this issue Jan 18, 2019 · 5 comments
Open

How to create multiple shopify objects to access multiple stores #61

vuivenao opened this issue Jan 18, 2019 · 5 comments
Assignees

Comments

@vuivenao
Copy link

Hi everybody,
I want to update data to my two Shopify stores. But if I changed a config of Shopify SDK, it's not working. Object 1 of store 1 is same to Object 2 of store 2.

Here 's my code:

PHPShopify\ShopifySDK::config($config_store_1);
$shopify_1 = new PHPShopify\ShopifySDK;

PHPShopify\ShopifySDK::config($config_store_2);
$shopify_2 = new PHPShopify\ShopifySDK;
    
$locations_1 = $shopify_1->Location->get();
echo json_encode($locations_1)."<br/><br/><br/>==========================<br/><br/><br/>";

$locations_2 = $shopify_2->Location->get();
echo json_encode($locations_2);

===> $locations_1 is same to $locations_2

Please help me. Thanks!

@vicn1222
Copy link

vicn1222 commented Feb 17, 2019

I have exactly the same issue. It appears PHPShopify\ShopifySDK is a singleton.

I need to clone/copy from one store to another. But the 2nd shopify store object overrides the 1st one. I have limited knowledge on using php object, but it appears to be the same as using "static" in C/C++.

Can someone please look into this issue?

Thank you!

@vicn1222
Copy link

After looking at the code, I see “static” is used throughout the class. That is the bug,

@vicn1222
Copy link

I made the changes to support multiple instances of ShopifySDK

How can I submit the changes for review? Can someone check in for me?

Thanks!

fixBug.tar.gz

shawnhind added a commit to SchemaApp/php-shopify that referenced this issue Mar 7, 2019
Using static properties for configs means that you can never initialize
more than one SDK object at a time.

closes phpclassic#72 and phpclassic#61
@tareqtms tareqtms self-assigned this May 22, 2019
@vicn1222
Copy link

vicn1222 commented May 1, 2021

The static for config is never fixed. It is still there.

@adviewmx
Copy link

adviewmx commented Aug 26, 2022

you need change the 3 files in the issue #61 (comment)

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

No branches or pull requests

4 participants