Tag: shopify

未初始化的常量ShopifyAPI :: CustomerGroup :: Customers错误

毫无疑问,我在这里做错了什么,但我从这里开始遵循新提交的指示。 我收到以下错误 uninitialized constant ShopifyAPI::CustomerGroup::Customers 00:33:56 web.1 | /Users/matt/.rvm/gems/ruby-1.9.3-p0/gems/shopify_api-3.0.3/lib/shopify_api/resources/customer_group.rb:4:in `customers” 运行此代码时 group = ShopifyAPI::CustomerGroup.find(5614012) customers = group.customers 这是上面提到的gem文件

如何使用ShopifyAPI(Ruby on Rails)有效地更新许多ShopifyAPI :: Product实例?

我正在编写一个应用程序,它将位于供应商专有库存管理系统和Shopify商店之间。 该应用程序将定期从库存管理系统生成的新数据更新Shopify。 它还将为Shopify webhooks提供终点。 我目前正在做这样的事情(伪ruby省略了很多东西): def update_product_with_proxy(product_proxy) product_proxy.variant_proxies.dirty.each do |variant_proxy| update_variant_with_proxy(variant_proxy) end if product_proxy.dirty_proxy shopify_product = ShopifyAPI::Product.find(product_proxy.shopify_id) shopify_product.update_attributes({some attributes here}) end end 别处: def update_variant_with_proxy(variant_proxy) shopify_variant = ShopifyAPI::Variant.find(variant_proxy.shopify_id) shopify_variant.update_attributes({some attributes here}) end 这似乎非常低效,因为我必须在更新它们之前获取每个更新的ShopifyAPI :: Product和ShopifyAPI :: Variant(我在本地缓存了它们的id)。 更新周期大约需要25分钟,更新24个产品,每个产品有16个变种。 Rails花费不到2秒的时间来更新我的产品/变体代理。 另外99%的时间用于与Shopify交谈。 我一定做错了什么。 鉴于我知道远程对象的id是否可以直接更新它而无需先获取它? 欢呼,-tomek

在Rails shopify应用程序中的Webhooks和delayed_job

嗨,我正在尝试将webhooks添加到使用shopify gem创建的shopify应用程序中。 到现在为止一切正常。 在我的webhook_controller中,我有一个连接到商店的beforefilter:before_filter:connect_to_store def product_new data = ActiveSupport::JSON.decode(request.body.read) shopify_id = data[“id”] Product.new_from_shopify(@s, shopify_id) head :ok end private def connect_to_store shop_url = request.headers[‘HTTP_X_SHOPIFY_SHOP_DOMAIN’] shop_url = (“http://” + shop_url) @s = Shop.find_by_url(shop_url) session = ShopifyAPI::Session.new(@s.url, @s.access_token) session.valid? ShopifyAPI::Base.activate_session(session) end 通过这种方式,我可以轻松访问Product模型中的Shopify API: def self.new_from_shopify(shop, shopify_id) shopify_p = ShopifyAPI::Product.find(shopify_id) # creates the local product local_p = Product.new local_p.shopify_id […]

如何通过Shopify API删除Shopify Webhooks?

我无法删除通过Shopify API创建的Webhooks。 为了创建webhook,我在RoR中使用了这段代码: webhook = ShopifyAPI::Webhook.create(format: “json”, topic: “orders/create”, address: “some address”) 我能够发送GET请求并检索所有创建的webhook。 但是当我发送带有相应ID的DELETE请求时,响应是“404 Not Found – errors:Not found”。 我正在使用Firefox的RESTClient发送DELETE请求,格式如下: DELETE https://api_key:shared-secret@hostname/admin/webhooks/1855159.json 也许它不起作用,因为webhooks是通过API创建的。 有没有其他方法可以删除webhooks? 提前致谢!

使用外部服务Shopify定制搜索

我的情况:我们有一个Shopify商店,我们还有一个在AWS上实施和托管的搜索引擎。 我们需要在Shopify商店中使用该搜索引擎而不是默认/搜索。 理想情况下,当用户尝试搜索某些内容时,他们的查询(以及可能的其他一些内容,如前端的属性选择器/复选框)将传递给我们的搜索引擎。 然后在结果返回后,它们将在前端渲染。 我的问题:我该怎么做? 选项1:修改主题代码,注入一些javascript来调用搜索引擎(可能,但很乱) 选项2:编写应用程序,将我的搜索引擎包装在应用程序中,并以某种方式将其插入商店(我不知道如何执行此操作) 选项3:类似于选项1,但编写应用程序,使用应用程序向主题注入一些代码,并以某种方式处理工作。 (我不知道怎么做) 我在这里找到了类似的post: 在shopify中编写自定义搜索应用程序,但下面的答案更多是关于过滤/修改默认shopify引擎返回的搜索结果,我想改为使用我自己的搜索引擎。

如何捕获Shopify Webhook发送的HTTP POST请求

我有点像菜鸟,并且不敢承认,我正在研究这个项目作为学习经验,以便通过php和服务器端脚本/处理来改善。 我正试图想出一种方法来使用Shopify,并在每次从我的Shopify购物车完成订单时同时更新关闭服务器数据库。 例如,有人从我的在线商店购买了一些东西,我希望它能够更新我的家庭数据库库存,以显示它现在只有一个项目。 我得出的结论是,最好的方法是设置一个webhook通知 ,将HTTP POST请求发送到我的服务器,然后我让我的服务器捕获POST并将其解析为XML。 然后,我将通过将更新我的数据库的php脚本读取XML。 我没有问题的PHP,但我似乎无法弄清楚是如何抓住我的服务器上的webhook。 Webhook要求我提供一个发送POST请求的URL,我的问题是你; 什么是url? 我做了一些研究,发现你可以通过html,php,Access-Control-Allow-Origin等多种方式捕获POST请求。但是,由于我还是新手,我不知道真的明白如何做到这些。 我尝试过使用HTML隐藏的动作表单,但似乎无法捕获XML。 我想做的就是让webhook发送它的POST请求,并将其作为.xml捕获。 这样我就可以在每天结束时读取xml,并相应地更新数据库。 如果您能想到更好或更简单的方法,请务必向我提出您的建议。 我希望这是安全的,所以像Access-Control-Allow-Origin这样的方法是不可能的。 tl;博士:我在服务器上需要做什么来捕获webhook通知? 我应该在服务器上使用什么脚本来提供给webhook? 如何编写回调脚本?

validationShopify webhook

我认为要让Shopify webhook与Rails应用程序集成,Rails应用程序需要禁用默认的verify_authenticity_token方法 ,并使用X_SHOPIFY_HMAC_SHA256标头实现自己的身份validation。 Shopify文档说只使用request.body.read 。 所以,我做到了: def create verify_webhook(request) # Send back a 200 OK response head :ok end def verify_webhook(request) header_hmac = request.headers[“HTTP_X_SHOPIFY_HMAC_SHA256”] digest = OpenSSL::Digest.new(“sha256”) request.body.rewind calculated_hmac = Base64.encode64(OpenSSL::HMAC.digest(digest, SHARED_SECRET, request.body.read)).strip puts “header hmac: #{header_hmac}” puts “calculated hmac: #{calculated_hmac}” puts “Verified:#{ActiveSupport::SecurityUtils.secure_compare(calculated_hmac, header_hmac)}” end Shopify webhook指向正确的URL,路由将其提供给上面显示的控制器方法。 但是当我发送测试通知时,输出不正确。 两个HMAC不相等,因此未经validation。 我很确定问题是Shopify使用整个请求作为身份validation哈希,而不仅仅是POST内容。 所以,我需要原始的,未触及的HTTP请求,除非我弄错了。 在至少一个小时的搜索之后, 这个问题似乎是互联网上唯一有希望的事情。 这正是我所要求的,它有30个upvotes接受的答案。 但他的回答……很荒谬。 […]

上传具有多种变体选项的新产品

我正在尝试通过ruby上传产品(不使用rails)。 我已经通过API上传了100多个产品,但我无法上传具有多个选项值的产品。 即使我分配了三个选项值,也不会填充另外两个选项值。 这是脚本: require ‘shopify_api’ require ‘open-uri’ require ‘json’ begin_time = Time.now shop_url = “*https*(yes I know the * are their)://-YouWish-:-I’dShareNakedPics-@dev-tactical.myshopify.com/admin/products.json” include ShopifyAPI ShopifyAPI::Base.site =”*https*://-YouWish-:-I’dShareNakedPics-@dev-tactical.myshopify.com/admin/” raw_product_data = JSON.parse(open(‘omg.json’) {|f| f.read }.force_encoding(‘UTF-8’)) raw_product_data_size = raw_product_data.size puts ‘=========================================================================’ puts “#{raw_product_data_size} seconds till explosion. assistance needed…” puts ‘————————————————————————-‘ single_product_begin_time = Time.now # Create new product new_product = […]

使用rubygem访问Shopify API时出现SSL_connect错误

我使用shopify_api gem访问Shopify API时遇到问题。 这是发生的事情: >> require “shopify_api” #=> false >> ShopifyAPI::Base.site = “https://username:secret@mysite.myshopify.com/admin” => “https://username:secret@mysite.myshopify.com/admin” >> products = ShopifyAPI::Product.find(:all) Errno::ECONNRESET: Connection reset by peer – SSL_connect from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `block in connect’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:54:in `timeout’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:99:in `timeout’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:755:in `do_start’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:744:in `start’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1284:in `request’ from /Users/zubin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1026:in `get’ […]