|
|
@@ -35,8 +35,14 @@ def create_product(price=None, title=u"Dummy title",
|
|
35
|
35
|
Helper method for creating products that are used in tests.
|
|
36
|
36
|
"""
|
|
37
|
37
|
ic, __ = ProductClass._default_manager.get_or_create(name=product_class)
|
|
38
|
|
- item = Product._default_manager.create(title=title, product_class=ic,
|
|
39
|
|
- upc=upc, **kwargs)
|
|
|
38
|
+ item = Product(title=title, product_class=ic, upc=upc, **kwargs)
|
|
|
39
|
+
|
|
|
40
|
+ if attributes:
|
|
|
41
|
+ for key, value in attributes.items():
|
|
|
42
|
+ setattr(item.attr, key, value)
|
|
|
43
|
+
|
|
|
44
|
+ item.save()
|
|
|
45
|
+
|
|
40
|
46
|
if price is not None or partner_sku or num_in_stock is not None:
|
|
41
|
47
|
if not partner_sku:
|
|
42
|
48
|
partner_sku = 'sku_%d_%d' % (item.id, random.randint(0, 10000))
|
|
|
@@ -48,13 +54,6 @@ def create_product(price=None, title=u"Dummy title",
|
|
48
|
54
|
partner_sku=partner_sku,
|
|
49
|
55
|
price_excl_tax=price,
|
|
50
|
56
|
num_in_stock=num_in_stock)
|
|
51
|
|
- if attributes:
|
|
52
|
|
- for key, value in attributes.items():
|
|
53
|
|
- attr, __ = ProductAttribute.objects.get_or_create(
|
|
54
|
|
- name=key, code=key)
|
|
55
|
|
- ProductAttributeValue.objects.create(
|
|
56
|
|
- product=item, attribute=attr, value=value)
|
|
57
|
|
-
|
|
58
|
57
|
return item
|
|
59
|
58
|
|
|
60
|
59
|
|