![](/img/trans.png)
[英]End of file error while updating product order in smart collection using shopify_api gem
[英]Product creation using shopify gem returns 404 error
我正在嘗試使用shopify_api gem將產品添加到商店。 這是我正在嘗試使用的代碼:
ShopifyAPI::Base.authenticate
variant_shopify = ShopifyAPI::Variant.create(
:compare_at_price => @variant.compare_at_price,
:created_at => @variant.created_at,
:fulfillment_service => @variant.product.vendor.fulfillment_service.name,
:grams => @variant.grams,
:id => @variant.id,
:inventory_management => @variant.inventory_management,
:inventory_policy => @variant.inventory_policy,
:inventory_quantity => @variant.inventory_quantity,
:price => @variant.price,
:requires_shipping => @variant.requires_shipping,
:sku => @variant.sku,
:taxable => @variant.taxable,
:title => @variant.title,
:updated_at => @variant.updated_at)
product_shopify = ShopifyAPI::Product.create(
:body_html => @product.body_html,
:created_at => @product.created_at,
:id => @product.id,
:images => [{ :src => @product.image.url }],
:product_type => @product.product_type,
:published_at => @product.published_at,
:template_suffix => @product.template_suffix,
:title => @product.title,
:updated_at => @product.updated_at,
:variant => variant_shopify,
:vendor => @product.vendor.business_name)
但是,此代碼會導致來自shopify的404響應。 關於我能做什么的任何想法? 感謝您的幫助
您的代碼毫無意義。 讓我們以您的產品create語句開始。 您正在嘗試使用哈希創建產品。 精細。 為什么您的哈希參數是產品實例變量? 好吧..撇開它,當您創建產品時,您會從API獲得ID。 此外,它提供了created_at日期的時間戳。 創建不是更新,因此您不提供更新。
假設您為@product抓住了一個現有產品,那么您不僅需要提供與此相關的參數,還需要提供唯一的句柄。 首先將其剝離,然后再進行其他修復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.