Shopify Api 使用 PHP 更新产品详细信息
Shopify Api for products details updating using PHP
我正在使用 Shopify 应用程序通过 PHP 在 Shopify 中更新产品详细信息,所以任何人都可以帮助我 API 用于在 Shopify 中更新产品详细信息。
以下是我需要更新的详细信息:
1) 产品价格
2) 库存
3) 产品 SKU
4) 产品变体
我从https://help.shopify.com/api/reference/product#index找到了方法
低于
更新产品,重新订购产品款式
PUT /admin/products/#{id}.json
{
"product": {
"id": 632910392,
"variants": [
{
"id": 457924702
},
{
"id": 39072856
},
{
"id": 49148385
},
{
"id": 808950810
}
]
}
}
但是如何在我的以下函数中使用上面的代码:
public function post_one($arrData){
return $this->call('POST', '/admin/products.json', $arrData);
}
每当您在 Shopify 中更新 product/variant/anything 时,您都需要执行 PUT 调用而不是 POST 调用。 POST 用来重新创造一些东西。
用以下内容替换您的函数。这里,URL 是 PUT /admin/products/#{id}.json
格式。还要注意,最终 URL 必须像下面这样 - https://{shopify-store}.myshopify.com/admin/....
public function put_one($arrData){
return $this->call('PUT', '/admin/products/632910392.json', $arrData);
}
如果您一次只修改一个变体,我强烈建议您使用 ProductVariant 端点:
https://help.shopify.com/api/reference/product_variant#update
如果您使用 Product 端点更新单个变体,一不小心可能会无意中破坏其余变体。
我正在使用 Shopify 应用程序通过 PHP 在 Shopify 中更新产品详细信息,所以任何人都可以帮助我 API 用于在 Shopify 中更新产品详细信息。
以下是我需要更新的详细信息:
1) 产品价格
2) 库存
3) 产品 SKU
4) 产品变体
我从https://help.shopify.com/api/reference/product#index找到了方法 低于
更新产品,重新订购产品款式
PUT /admin/products/#{id}.json
{
"product": {
"id": 632910392,
"variants": [
{
"id": 457924702
},
{
"id": 39072856
},
{
"id": 49148385
},
{
"id": 808950810
}
]
}
}
但是如何在我的以下函数中使用上面的代码:
public function post_one($arrData){
return $this->call('POST', '/admin/products.json', $arrData);
}
每当您在 Shopify 中更新 product/variant/anything 时,您都需要执行 PUT 调用而不是 POST 调用。 POST 用来重新创造一些东西。
用以下内容替换您的函数。这里,URL 是 PUT /admin/products/#{id}.json
格式。还要注意,最终 URL 必须像下面这样 - https://{shopify-store}.myshopify.com/admin/....
public function put_one($arrData){
return $this->call('PUT', '/admin/products/632910392.json', $arrData);
}
如果您一次只修改一个变体,我强烈建议您使用 ProductVariant 端点:
https://help.shopify.com/api/reference/product_variant#update
如果您使用 Product 端点更新单个变体,一不小心可能会无意中破坏其余变体。