[英]How do I override Shopify existing product image position with Ruby?
我正在将Shopify API与Ruby结合使用,并且试图理解将新产品图像发布到现有产品中的位置1并覆盖/重新布置当前图像位置到位置2的流程。
products = ShopifyAPI::Product.find(123456789)
products.images << ShopifyAPI::Image.new(:src=> "http://website/CF01.jpg", :position=> 1)
products.save
将当前图像位置设置为2时,它会更改位置属性,但不会更改图像在商店中的实际位置,即使将位置设置为nil也不起作用。 我是否需要完全删除并重新上传当前图像以使新图像位于第一个位置? 我是否应该尝试访问ShopifyAPI :: Image端点?
products = ShopifyAPI::Product.find(123456789)
products.images[0].position = 2
products.images << ShopifyAPI::Image.new(:src=> "http://website/CF01.jpg", :position=> 1)
products.save
将图像上载到产品并保存,然后更改第一个图像上的位置,然后更改新图像并再次保存似乎已奏效。
#this is based on a product with 1 image
products = ShopifyAPI::Product.find(id)
products.images << ShopifyAPI::Image.new(:src=> "http://website.com/image.jpg")
products.save
products.images[0].position = 2
products.images[1].position = 1
products.save
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.