如何使用Ruby覆盖Shopify现有产品图像位置?

时间:2017-07-07 22:37:29

标签: ruby-on-rails ruby api shopify

我正在使用Shopify API和Ruby,我正在尝试了解将新产品图像发布到现有产品到位置1并覆盖\重新排列当前图像到位置2的位置的流程。

products = ShopifyAPI::Product.find(123456789)
products.images[0].position = 2
products.images << ShopifyAPI::Image.new(:src=> "http://website/CF01.jpg", :position=> 1)
products.save

当将当前图像位置设置为2时,它会更改位置属性,但不会更改图像在商店中的实际位置,即使将位置设置为nil也不起作用。我是否需要完全删除并重新上传当前图像以使新图像处于第一个位置?我应该尝试访问ShopifyAPI :: Image端点吗?

const routes: Routes = [
  {
    path: ''
    },
    children: [
      { path: '', component: AdminComponent },
      { path: 'users', component: AdminUsersComponent },
      { path: 'games', component: AdminGamesComponent },
      { path: '**', redirectTo: '' }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AdminRoutingModule { }

1 个答案:

答案 0 :(得分:0)

将图像上传到产品并保存,然后更改第一张图像上的位置,然后新图像再次保存似乎有效。

<Window x:Class="Text_Box_with_Buttons.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Text_Box_with_Buttons"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Border BorderBrush="Black" BorderThickness="0 0 2 0">
        <StackPanel Grid.Column="0" Margin="10">
            <Button Margin="10" Height="20" Content="Remove selected entry"/>
            <Border BorderBrush="Red" BorderThickness="2">

                <TextBlock
               HorizontalAlignment="Center"
               Margin="10"
               >
               Instance of text 1<LineBreak/>
               Instance of text 2<LineBreak/>
               Instance of text 1<LineBreak/>
               Instance of text 2<LineBreak/>
               Instance of text 1<LineBreak/>
                </TextBlock>
            </Border>

        </StackPanel>
    </Border>

    <StackPanel
        Grid.Column="1" 
            Margin="10"
            VerticalAlignment="Center"
                >

        <Button
            x:Name="Button1"
            Margin="0 0 0 5"
            Content="Add instance of text"
            Height="70"
            Width="120"
            Click="Button1Click"
            />

        <Button
            x:Name="Button2"
            Margin="0 5 0 0"
            Height="70"
            Width="120"
            Content="Add different instance"
            Click="Button2Click"
            />

    </StackPanel>
</Grid>
</Window>