0

すべての画像とバリエーションを含む既存の Shopify 製品を複製したいと考えています。

Shopify gem を使用してこれを行うにはどうすればよいですか?

Rails 3.2.2 と Shopify gem 3.0.1 を実行しています。

ありがとう、アウグスト

更新#1:

次のコードを試しました:

問題は、元の商品と同じ shopifyid で新しい商品を作成しようとしていることにあると思います。よくわかりませんが、他にも問題があるのではないかと思います。

original_p = ShopifyAPI::Product.find(xxx)
new_p = ShopifyAPI::Product.new(original_p.attributes)
new_p.save

ActiveResource::ResourceNotFound: Failed.  Response code = 404.  Response message = Not Found.
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/connection.rb:136:in `handle_response'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/shopify_api-3.0.1/lib/active_resource/connection_ext.rb:9:in `handle_response_with_response_capture'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/connection.rb:115:in `request'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/shopify_api-3.0.1/lib/active_resource/connection_ext.rb:13:in `request_with_detailed_log_subscriber'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/connection.rb:92:in `block in put'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/connection.rb:218:in `with_auth'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/connection.rb:92:in `put'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/base.rb:1354:in `update'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/observing.rb:19:in `update_with_notifications'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/base.rb:1156:in `save'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/validations.rb:79:in `save_with_validation'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeresource-3.2.2/lib/active_resource/observing.rb:19:in `save_with_notifications'
from (irb):26
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
from /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'1.9.2p290 :027 > np.errors
4

1 に答える 1