【问题标题】:shopify Title instead of product id. API Pythonshopify 标题而不是产品 ID。 API Python
【发布时间】:2018-01-31 17:07:11
【问题描述】:

我想在我的 shopify 商店中查找所有商品。我找到了这段代码,它给了我产品 ID。

xxx = shopify.Product.find(limit=50, page=1)

我要找的是标题…………

我试过了

xxx = shopify.Product.title(limit=50, page=1)
xxx = shopify.Product.title(limit=50, page=1).title()
xxx = shopify.title(limit=50, page=1)
xxx = title(limit=50, page=1)

我想在输出窗口上看到什么。

'This is the title of the product' <- this is what I want to extract

我现在得到的是

product(322940174383) <- bad I want the title not product id

【问题讨论】:

    标签: python api shopify


    【解决方案1】:

    我编辑了我的答案,因为我误解了你的问题。 您必须遍历整个产品列表,您可以执行以下操作:

    p_count = shopify.Product.count()
    p_max_pages = int(p_count / 250) + 1
    titles = []
    for page in range(1, p_max_pages + 1):
        products = shopify.Product.find(page=page, limit=250)
        for product in products:
            titles.append(product.title)
    

    在循环中的产品对象中,您可以找到Shopify Documentation 中列出的所有属性

    老答案

    如果你想按标题获取产品,你应该使用

    shopify.Product.find(title="My Product")
    

    这将返回包含字符串“我的产品”的产品列表

    【讨论】:

    • 我希望 api 找到库存中的所有标题。不止一个。此外,这仍然只是给了我产品 ID 号,这不是我想要的我想要的产品标题
    • @benolsen 我编辑了我的答案,我误解了你想要达到的目标。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-20
    • 1970-01-01
    • 1970-01-01
    • 2013-01-17
    • 1970-01-01
    • 2016-08-13
    • 1970-01-01
    相关资源
    最近更新 更多