On Mon, Nov 2, 2009 at 9:18 PM, Bob Waycott <[email protected]> wrote: > Maybe I'm missing something here, but why would subclassing Product require > modifying Cart & Order classes? > > On Mon, Nov 2, 2009 at 12:32 PM, Arek <[email protected]> wrote: >> >> On Mon, Nov 2, 2009 at 2:18 PM, anentropic <[email protected]> wrote: >> > >> > I've gone back to doing it the way the docs suggest. >> > >> > I'm having troubles though. I'm trying to set up clothing products, >> > with a single option group for 'size'. I created the main Product and >> > the ConfigurableProduct and then the Variations as per the tutorial >> > docs. I want to manage stock levels individually for each variation >> > so I have left the Product stock at 0... then from the Products list >> > screen I can go and edit each Variation as if it was a Product, where >> > I've added specific stock level for one of the variations. >> > >> > When I go to the public product page... the 'size' selector seems to >> > have the opposite logic - when I select the variation that has stock >> > the 'add to cart' is greyed out, and when I select variations that >> > have no stock it's enabled. >> > >> > Looking in the javascript validation I can see entries like: >> > "6": {"PRICE": {"1": "\u00a350.00"}, "SLUG": "nike947_6", "QTY": >> > "10000"} >> > for all the variations except the one where I added some stock. >> > >> > The qty:10000 appears to be because I have the NO_STOCK_CHECKOUT >> > option in config, since I will be needing the ability to pre-order >> > certain products (though I need this to be a per-product option not a >> > global setting...) >> > >> > The js validation info comes via a lookup against the >> > product_productpricelookup table... I have rows in there for each >> > Product and each Variation - except the one that I edited as a >> > Product. >> > >> > If I go in and edit that Variation as a product again, this time >> > specifying a price, then a row is created in >> > product_productpricelookup. I don't want to have to specify the price >> > on each Variation though, it should just inherit the Product price >> > (which it does, as long as I don't edit the stock level). If I'm not >> > supposed to edit the Variation as a Product, why does it show up in >> > the Products list view as a Product in the admin? >> > >> > I'm getting a bit confused about how I'm supposed to use this system. >> > Can someone advise? I think I may be best to go the Satchmo Diaries >> > route and just sub-class Product directly and hack whatever bits of >> > Satchmo need to co-operate. >> > >> > >> > >> > On Nov 2, 11:25 am, anentropic <[email protected]> wrote: >> >> Thanks, at the moment I am torn between doing things the way described >> >> in the docs, or just directly sub-classing the Product model. I think >> >> either way I will have to do a fair bit of work later on to tidy up >> >> the admin so the client can use it. >> >> >> >> Did you sub-class one of the secondary product models like I'm trying, >> >> or Product itself? >> >> >> >> I think what I found above was a bug, I will post as an issue on >> >> BitBucket so the devs can take a look. >> >> >> >> On Oct 30, 7:00 pm, Trent Jurewicz <[email protected]> wrote: >> >> >> >> >> >> >> >> > I've done something similar to what you are attempting using >> >> > instructions in >> >> > this blog >> >> > post:http://juanjoalvarez.net/es/detail/2009/jul/27/why-bad-idea-tm-overri.... >> >> > We then make our additional data an inline on the Product in the >> >> > admin. >> >> >> >> > ~Trent >> >> >> >> > On Fri, Oct 30, 2009 at 1:20 PM, anentropic <[email protected]> wrote: >> >> >> >> > > has anyone tried sub-classing ConfigurableProduct? >> >> >> >> > > it seems like the logical thing to do - I want a product type that >> >> > > has >> >> > > the features of a Configurable along with some of my own fields. >> >> > > basically all the products in my store would be this type. >> >> >> >> > > everything worked fine when it was a non-sub-classed model, but the >> >> > > downside is that to create a new product you have to first create a >> >> > > Satchmo product, then add a ConfigurableProduct to it, then add my >> >> > > custom sub-type as well. I can't imagine asking the client to do >> >> > > all >> >> > > that! >> >> >> >> > > when I sub-class and go to create/edit a new (satchmo) Product I >> >> > > get: >> >> >> >> > > TemplateSyntaxError at /admin/product/product/7/ >> >> > > ... >> >> > > AttributeError: 'Product' object has no attribute 'ctproduct' >> >> >> >> > > The problem seems to be in the 'get_subtypes' method of the Product >> >> > > model: >> >> >> >> > > try: >> >> > > subclass = getattr(self, subtype.lower()) >> >> > > gettype = getattr(subclass, '_get_subtype') >> >> > > subtype = gettype() >> >> > > if not subtype in types: >> >> > > types.append(subtype) >> >> > > except models.ObjectDoesNotExist: >> >> > > pass >> >> >> >> > > At first glance it seems to me that the code as-it-is is catching >> >> > > the >> >> > > wrong exception (one that would never occur) and my attempt at >> >> > > extending a model has tested the code for the first time. But I >> >> > > could >> >> > > be completely wrong of course! >> >> >> >> > > (I changed it to except AttributeError and the form loads and shows >> >> > > my >> >> > > 'add' link in the subtypes... could it be that simple?) >> > > >> > >> >> I have sub-classed product on http://weadmire.net to get color and >> size fields, and other things. Had to modify cart and order classes >> later on plus some satchmo signals. But admin area is so much easier >> for my customer I think it was worth it. Good luck >> >> -- >> At no time is freedom of speech more precious than when a man hits his >> thumb with a hammer. >> >> > > > > > I need to access properties like this cartitem.color orderitem.size. in views and templates
-- At no time is freedom of speech more precious than when a man hits his thumb with a hammer. -- Marshall Lumsden --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
