"unit_price" is the simplest case _calculated_ from db values, not
stored. You can have a price for 1 piece and a better price valid for
5 pieces and more and other better price valid only until tomorrow and
you can have a complicated configurable product with adjustments for
different options like the computer. :)

You can do something more general like

    for product in products:
        for subproduct in product.get_subtype_with_attr('unit_price'):
           for priceobj in subproduct.price_set.all():
               priceobj.price = priceobj.price * CONST


or for the easiest case you want, do simply

    for priceobj in Price.objects.all():
        priceobj.price = priceobj.price * CONST

eventually
python manage.py satchmo_rebuild_pricing for variants etc.

-- Hyn

On 27 bře, 21:31, Ángel Velásquez <[email protected]> wrote:
> Hello people,
>
> I was facing an issue increasing the unit_price of all products of the db.
>
> I need to do this because all the products got increased by 5% .. so I
> wrote the following django command.
>
> [code]
>
> from django.core.management.base import BaseCommand, CommandError
> from django.conf import settings
> from django.core.exceptions import ValidationError
>
> from product.models import Product
>
> from decimal import Decimal
>
> INCREMENT_RATE = Decimal('0.10')
>
> class Command(BaseCommand):
>     args = ''
>     help = 'Increase products in 10%'
>
>     def handle(self, *args, **options):
>         products = Product.objects.all()
>
>         for product in products:
>             new_val = product.unit_price * CONVERSION_RATE
>             product.unit_price = new_val
>             product.save()
> [/code]
>
> But I get this error:
>
> AttributeError: can't set attribute
>
> Could somebody give me a light?. I can't do this using the form because I
> have to increase the value of all the products on the DB, and doing one by
> one i'd by painful.
>
> Thanks in advance.
>
> --
> github: angvp
> Ángel Velásquez

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to