当前位置: 首页>>代码示例>>Python>>正文


Python Product.sku方法代码示例

本文整理汇总了Python中products.models.Product.sku方法的典型用法代码示例。如果您正苦于以下问题:Python Product.sku方法的具体用法?Python Product.sku怎么用?Python Product.sku使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在products.models.Product的用法示例。


在下文中一共展示了Product.sku方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _product

# 需要导入模块: from products.models import Product [as 别名]
# 或者: from products.models.Product import sku [as 别名]
    def _product(self, item):
        try:
            product = Product.objects.get(wholesale_legacy_id=int(item['id']), is_visible=True)
        except Product.DoesNotExist:
            product = Product()
        except Product.MultipleObjectsReturned:
            print item['id']
            for p in Product.objects.filter(wholesale_legacy_id=int(item['id'])):
                print p.id, p.title, p.code, p.sku
            print '-----'
            raise

        quantity = int(item.get('qtyi', 0))
        if quantity < 0:
            quantity = 0

        weight = int(item.get('weight', 0))
        if weight < 0:
            weight = 0

        product.sku = item['article']
        product.weight = weight
        product.quantity = quantity
        product.code = item['link']
        product.title = item['name']
        product.description = item['descr']
        product.is_visible = bool(int(item['pub']))
        product.wholesale_legacy_id = item['id']
        product.created = TIMEZONE.localize(datetime.datetime.fromtimestamp(int(item['dt'])))

        size = None
        try:
            size = SIZE_RE.findall(u' '.join([item['name'], item.get('alt', ''), item['descr']]))[0]
        except IndexError:
            try:
                size = SIZE2_RE.findall(u' '.join([item['name'], item.get('alt', ''), item['descr']]))[0]
            except IndexError:
                pass

        if size:
            product.size = u'×'.join([str(x) for x in size])

        return product
开发者ID:Lisaveta-K,项目名称:lisaveta-k.github.io,代码行数:45,代码来源:products_wholesale_import.py

示例2: get_or_create_product

# 需要导入模块: from products.models import Product [as 别名]
# 或者: from products.models.Product import sku [as 别名]
def get_or_create_product(asin):
    """
    Checks the database for an existing ASIN. If not found, try to fetch it
    using the Amazon Product API.

    :return:
        An instance of `products.models.Product`
    """
    try:
        product = Product.objects.get(asin=asin)
    except:
        amazon = AmazonAPI(settings.AWS_ACCESS_KEY_ID,
                           settings.AWS_SECRET_ACCESS_KEY,
                           settings.AWS_ASSOCIATE_TAG)                                       
        az = amazon.lookup(ItemId=asin)
        product = Product(asin=asin, upc=az.upc, ean=az.ean, 
                          description=az.title, image_url=az.large_image_url,
                          amazon_url=az.offer_url)
        
        product.save()
        generate_thumb.delay(product, '600x400')
        generate_thumb.delay(product, '125x125')
    
        product.manufacturer = az.get_attribute('Manufacturer')
        product.brand = az.get_attribute('Brand')
        product.model_number = az.get_attribute('Model')
        product.mpn = az.mpn
        product.part_number = az.part_number
        product.sku = az.sku
        product.isbn = az.isbn
        product.length = az.get_attribute('ItemDimensions.Length')
        product.width = az.get_attribute('ItemDimensions.Width')
        product.height = az.get_attribute('ItemDimensions.Height')
        product.weight = az.get_attribute('ItemDimensions.Weight')
        product.save()
        

        
    return product
开发者ID:phrac,项目名称:onemgin,代码行数:41,代码来源:amazon_utils.py

示例3: _product

# 需要导入模块: from products.models import Product [as 别名]
# 或者: from products.models.Product import sku [as 别名]
    def _product(self, item):
        try:
            product = Product.objects.get(id=int(item['id']))
        except Product.DoesNotExist:
            product = Product(id=int(item['id']))

        quantity = int(item.get('qtyi', 0))
        if quantity < 0:
            quantity = 0

        weight = int(item.get('weight', 0))
        if weight < 0:
            weight = 0

        product.sku = item['article']
        product.weight = weight
        product.quantity = quantity
        product.code = item['link']
        product.title = item['name']
        product.description = item['descr']
        product.is_visible = bool(int(item['pub']))
        product.is_wholesale = False
        product.created = TIMEZONE.localize(datetime.datetime.fromtimestamp(int(item['dt'])))

        size = None
        try:
            size = SIZE_RE.findall(u' '.join([item['name'], item.get('alt', ''), item['descr']]))[0]
        except IndexError:
            try:
                size = SIZE2_RE.findall(u' '.join([item['name'], item.get('alt', ''), item['descr']]))[0]
            except IndexError:
                pass

        if size:
            product.size = u'×'.join([str(x) for x in size])

        return product
开发者ID:Lisaveta-K,项目名称:lisaveta-k.github.io,代码行数:39,代码来源:products_import.py


注:本文中的products.models.Product.sku方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。