如何获取在我的commercetools项目中创建的所有ProductType?

时间:2017-11-28 12:06:17

标签: java commercetools sphere.io

我需要获取在我的commercetools项目中定义的所有ProductType,因为我必须使用" name"的本地化值。在文件系统中执行搜索。 基本上我需要使用JVM SDK来提取ProductTypes列表并遍历它。

有人能给我一些线索如何实现它吗?

提前致谢。

2 个答案:

答案 0 :(得分:2)

是的,使用jvm sdk非常可行,这里有一个如何操作的代码片段

from __future__ import print_function
from matplotlib.widgets import RectangleSelector
import numpy as np
import matplotlib.pyplot as plt


def line_select_callback(eclick, erelease):
    x1, y1 = eclick.xdata, eclick.ydata
    x2, y2 = erelease.xdata, erelease.ydata
    print("(%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2))

fig, current_ax = plt.subplots()
N = 100000 
x = np.linspace(0.0, 10.0, N) 

plt.plot(x, +np.sin(.2*np.pi*x), lw=3.5, c='b', alpha=.7)  # plot something
plt.plot(x, +np.cos(.2*np.pi*x), lw=3.5, c='r', alpha=.5)
plt.plot(x, -np.sin(.2*np.pi*x), lw=3.5, c='g', alpha=.3)


# drawtype is 'box' or 'line' or 'none'
RS = RectangleSelector(current_ax, line_select_callback,
                                       drawtype='box', useblit=True,
                                       button=[1, 3],  # don't use middle button
                                       minspanx=5, minspany=5,
                                       spancoords='pixels',
                                       interactive=True)
fig.canvas.draw()
bg = fig.canvas.copy_from_bbox(RS.ax.bbox)
RS.set_visible(True)

ext = (0,4,0,1)
RS.draw_shape(ext)
# Update displayed handles
RS._corner_handles.set_data(*RS.corners)
RS._edge_handles.set_data(*RS.edge_centers)
RS._center_handle.set_data(*RS.center)
for artist in RS.artists:
    RS.ax.draw_artist(artist)
    artist.set_animated(False)
fig.canvas.draw()

def initclick(evt):
    RS.background = bg
    RS.update()
    for artist in RS.artists:
        artist.set_animated(True)
    fig.canvas.mpl_disconnect(cid)

cid = fig.canvas.mpl_connect("button_press_event",initclick)

plt.show()

我希望这能回答你的问题。

答案 1 :(得分:1)

您可以使用课程QueryExecutionUtils

from skimage import io, color
import matplotlib.pyplot as plt

image = io.imread('/tmp/colors.png')
lab = color.rgb2lab(image)
rgb = color.lab2rgb(lab)

plt.imshow(rgb)
plt.show()